Refactored 0229-Fix-this-stupid-bullshit in order to prevent merge conflicts
when spigot decides to update the timer and to provide some form of hint in the
console/log on startup.
the first 'major' change in this PR is to cache the generated event
executrs from the ASM class, by doing this we only generate a single
class for every method that we need an executor for, thus reducing the
number of classes that are needed, especially in cases where plugins
re/unregister events all the time.
The second change is to modify the generated classloader map, generated
classloaders are not held against the plugin itself but the classloader
that the event is declared in, the implication here is that we cannot
drop generated classloaders when a plugin disable, and so we use a guava
weak-key'd hashmap, downfall here is that classes won't be GC'd until
guava drops the generated classloader, however the first change should
deal with most of the grunt.
FixesPaperMC/Paper#883 same issue as MinecraftForge/MinecraftForge#4386
A more detailed anaylsis of what is probably going on, courtesy of
@bs2609 and the MCForge Issue Tracker is:
When a chunk is unloaded, the entities and tile entities it contains are
marked for removal. The actual removal (from the world) occurs later,
when the world ticks its entities.
Conversely, when a chunk is loaded, it generally adds its entities to
the world promptly, without queuing.
Here's the normal sequence of events:
Chunk unloaded
Old entities removed
Chunk loaded
New entities added
However, what can happen:
Chunk unloaded
Chunk loaded
New entities added
Old entities removed
This occurs when an unloaded chunk is reloaded before its corresponding
entities have been removed.
Fixes falling dragon eggs in lazy chunks fall to the block below the last empty block and replacing that block with them.
See also https://bugs.mojang.com/browse/MC-94186
Spigot is manipulating the Travel Agents canCreatePortal, but forgot to reset it on cancel
This causes nether portals to not be generated if the event is ever cancelled