When moving a misplaced chunk move tile entities too. Fixes BUKKIT-4092

When a chunk is being loaded the server checks to ensure the chunk's idea
of where it is located matches where it was located in the region file. If
these two values do not match the chunk's idea of its position is updated
and the chunk is reloaded. In vanilla minecraft this loading involves the
chunk's tile entities as well. With the change to loading player chunks
asynchronously we split loading tile entities to a separate step that takes
place after this check. Because of this tile entities are loaded with
invalid locations that result in trying to fetch block data from negative
or too large positions in the chunk's internal block storage arrays.

Because loading the tile entities is not thread safe we cannot return to
vanilla behavior here. Instead when we detect a misplaced chunk we just
edit the NBT data for the chunk to relocate the tile entities. This results
in them moving correctly with the chunk without having to actually load
them first.
Validate chunk data array lengths. Fixes BUKKIT-4093

If a chunk has somehow managed to save with arrays that are not 4096
entries long when reading them again we will get exceptions. Checking the
array length and resizing if needed is cheap so we should do this to help
avoid crashing servers due to this error.
POM Changes.
mc-dev imports

 2 files changed, 160 insertions(+)
Spigot Changes

The set of changes which provide core Spigot functionality, which would otherwise be a mess to try and apply individually.
Merge tweaks and configuration

This allows the merging of Experience orbs, as well as the configuration of the merge radius of items. Additionally it refactors the merge algorithm to be a better experience for players.
LongHash Tweaks.

This commit adds a flat array based cache to the LongHash(Set/Map) classes leading to excellent efficiency for servers where most activity is centered around the origin (0,0)
Async Operation Catching

Catch and throw an exception when a potentially unsafe operation occurs on a thread other than the main server thread.
View Distance

This commit allows the user to select per world view distances, and view distances below 3. Be wary of the issues selecting a view distance of 1 or 2 may cause!
Address BUKKIT-3286 by firing the inventory close event when a secondary container is closed due to the player entity being destroyed. This covers all edge cases such as server stop / player kick / player quit.
Implement 'lightening' of NibbleArrays - only allocate buffers when non-trivial value Saving from 40-45% of memory use by chunk section data.

Finish up NibbleArray lightening work - use for Snapshots, reduce copies

Fix nibble handling with NBT - arrays aren't copied by NBTByteArray
Update versioning check to correctly resolve api version.
Optimize packet used to unload chunks for the client

At the moment telling a client to unload a chunk involves calling the entire chunk from memory, deflating it and then sending it through the pipes even though the client ignores it and based on the bitmap simply unloads the chunk, and to add the cherry on top, this is done on the main server thread.
Alternate, sync-free-but-safe chunk reference cache
Tick loop optimization - sleep for as long as possible.
Improved Timings System

Tracks nearly every point of minecraft internals and plugin events to give a good quick overview on what is causing TPS loss.
Add oreobfuscator for Spigot.
Only count entities in chunks being processed for the spawn wave. Fixes mob spawn issues.
Detect, remove and warn about null tile entities.
Entity Activation Range

This feature gives 3 new configurable ranges that if an entity of the matching type is outside of this radius of any player, will tick at 5% of its normal rate.

This will drastically cut down on tick timings for entities that are not in range of a user to actually be "used".
This change can have dramatic impact on gameplay if configured too low. Balance according to your servers desired gameplay.