Commit Graph

2655 Commits

Author SHA1 Message Date
Aikar 78ee3b4e88
Restore a condition I accidently removed in last build 2020-05-25 12:53:40 -04:00
Aikar 88a6882930
Fix unloading inaccessible chunks too fast regressing gen speed
A chunk was loaded but not yet finished in use and was unloaded too early.

This caused it to be reloaded again or caused crashes.

Now also check if the chunk pops out of the unload queue that it also
doesn't now have a ticket either.
2020-05-25 12:36:19 -04:00
Aikar 210a32f26f
Unload leaked Cached Chunks
Due to some complexity in mojangs complicated chain of juggling
whether or not a chunk should be unloaded when the last ticket is
removed, many chunks are remaining around in the cache.

These chunks are never being targetted for unload because they are
vastly out of view distance range and have no reason to be looked at.

This is a huge issue for performance because we have to iterate these
chunks EVERY TICK... This is what's been leading to high SELF time in
Ticking Chunks timings/profiler results.

We will now detect these chunks in that iteration, and automatically
add it to the unload queue when the chunk is found without any tickets.
2020-05-25 11:12:22 -04:00
Aikar c9795e9221
Fix Spigot bug with chunk unloading
Spigot inserted their Slack Activity Accountant in the wrong location
resulting in a chunk being removed from the unload queue, inserted into
the unload map, but never calling the function to finish the removal....

This caused the chunk to become stuck in the unload map if ever hit, because
the unload map was meant to be a TEMPORARY location while it was saving.

Fix this by abort iteration AFTER the current chunk is finisehd processing

Also, improve how aggressive we are at unloading chunks, targetting 10% per tick instead.
These saves are asynchronous so there should be less of a hit here.
2020-05-25 11:09:44 -04:00
Aikar b6cf80ee66
Preload important classes such as Logger and JLine
This is for 2 reasons:
1) Ensuring our log4j is mostly loaded at OUR version.
   I've seen stack traces with line numbers that do not match our version. This means that some
   plugin has shaded in log4j and their loaded version is mixing with ours....
   So by at least trying to load a bunch of log4j classes before we load plugins, we can be
   more sure mixed versions are not loading.

2) If the jar file is replaced while the server is runnimg class not found errors galore
   This will preloaod a bunch of classes commonly seen to error during shutdown due to this.

   The goal here is to help let the server shutdown gracefully as possible. Some plugins will
   still blow up here if they access a class that hadn't been loaded yet, but goal is to at least
   stop freezing the shutdown process as it does with JLine and Log4j errors requiring an external kill.

   Ideally you should not replace jars while the server is running, but it is something that happens in
   development for testing.

Updated test server to do a copy though to avoid this happening in Paper development.
2020-05-24 13:19:08 -04:00
Aikar ea1a909c80
Fix netty version to 50 and restore epoll native support
Accidently used the snapshot, as well as needed to exclude the
existing old 25 build of libnetty so that we load the newer build of
epoll instead.

Thanks to 56738 for the catch.
2020-05-24 13:07:53 -04:00
Aikar 10502558e9
Workaround for some hacky environments that mess up things
2 people had issues where some plugin is doing some reallly insane NMS hackery
that created invalid worlds, which caused some errors...

Really don't understand what in the world they did, but putting in a dumb guard that
shouldn't even be necessary to just not send the sound effect rather than erroring.
2020-05-23 22:27:37 -04:00
Aikar 8b2a437b9e
Fix plugins calling getChunkAtAsync asynchronously
While this method has async in it's name, it's not actually meant
to be called asynchronously.... It just means IT will load the chunk
asynchronously without blocking main.

So fix this so that if a plugin calls it async, it forces the request back to main thread.
2020-05-23 18:38:29 -04:00
Aikar c8055836e8
Update Netty to 4.1.51
Minecraft's Netty version was severely out of date. There has been
numerous security fixes, bug fixes, and likely performance fixes
since the version Minecraft uses (4.1.25).

This fixes some known issues with "Closed Channel" spam.

Fixes #3388
2020-05-23 17:58:45 -04:00
Aikar 64cfcf3e4b
Optimize sending packets to nearby locations (sounds/effects)
Instead of using the entire world or player list, use the distance
maps to only iterate players who are even seeing the chunk the packet
is originating from.

This will drastically cut down on packet sending cost for worlds with
lots of players in them.

Closes #3437
2020-05-23 17:17:14 -04:00
Aikar cf82dad399
Fix Non Full Status Chunk NBT Memory Leak
Any full status chunk that was requested for any status less than full
would hold onto their entire nbt tree and every variable in that function.

This was due to use of a lambda that persists on the Chunk object
until that chunk reaches FULL status.

With introduction of no tick, we greatly increased the number of non
full chunks so this was really starting to hurt.

We further improve it by making a copy of the nbt tag with only the memory
it needs, so that we dont have to hold a copy to the entire compound.
2020-05-23 01:40:27 -04:00
Aikar 5a12515a42
Update Log4J Configuration file to stop truncating stack traces
This should help greatly (as long as this change works...) in
understanding an exception when it doesn't get truncated with
"... and 14 more" at a vital point of the stack trace.
2020-05-22 23:52:56 -04:00
Aikar 7c001d64a5
More Improvements to Chunks
Fixed issues where urgent and prioritized chunks didn't actually
always get their priority boosted correctly....

Properly deprioritize non ticking chunks.
Limit recursion on watchdog prints to stop flooding as much
Remove neighbor priorities from watchdog to reduce information
reduce synchronization duration so that watch dog won't block main should main actually wake up
probably fixed a deadlock risk in watchdog printing also that was leading to crashes
fixed chunk holder enqueues not being processed correctly
added async catchers in some locations that should not be ran async

Fixed upstream bug where VITAL callbacks that must run on main actually could
sometimes run on the server thread pool causing alot of these nasty bugs we've seen lately!

This build will provide massive improvements to stability as well as even faster
sync chunk load/gens now that priority is correctly set.

Fixes #3435
2020-05-22 23:52:56 -04:00
Aikar e1c451968c
Fix high memory use of non ticking chunks
The nibble pooling for NBT Tags was 'semi' leaked from loaded chunks
as we store the NBT Tag of Tile Entities in a Chunk, but don't process
them and remove them until chunk reaches Entity Ticking status....

This caused some phantom references to persist causing high memory use
of these chunks.

So I just got rid of pooling from NBT deserialization and we'll have to
take the hit on memory allocations there because too many cascading concerns
with anyone using NBT Tag Byte Arrays.

Fixes #3431
2020-05-22 23:52:51 -04:00
Aikar ee9f0d513f
Fix another case of breaking blocks causing sync chunk loads 2020-05-22 18:57:48 -04:00
Aikar 6009ba8f44
Drop AABB limit patch until it can be tested more
Fixes #3428
2020-05-22 02:21:32 -04:00
Aikar 0e9c24e595
Fix log spam about Hanging entities bounding boxes
Nothing really "Broke" them, just a lot of log spam. This will clean that up
2020-05-22 02:04:00 -04:00
Aikar 83fadad7da
Fix conversion for deserializing raw nbt itemstacks - Fixes #3424 2020-05-22 01:08:18 -04:00
Aikar 4d38ee111f
Many fixes and improvements to chunk prioritization
I believe this brings us back to stable. A lot of complexity was
learned about juggling priorities.

We were essentially promoting more chunks to urgent than really
needed to be urgent.

So this commit adds a lot more logic to juggle neighbor priorities
and demote their priority once they meet the requirements needed of
them.

This greatly improves the performance of "urgent" chunks".

Fixes #3410
Fixes #3426
Fixes #3425
Fixes #3416
2020-05-22 01:03:42 -04:00
Aikar 281181c7c7
Use saner Entity bounding box limits
CB only protected from > 64 but there's no reason an entity should ever
be more than 2x its width or 1x height as the BB is supposed to represent
the entity size.

BB is / 2 to calculate position.
2020-05-22 00:40:56 -04:00
Aikar edd6b6a2ba
Protect the visible chunk map from plugins touching it, trim Timing Errors
Blow up if a plugin tries to mutate visibleChunks directly and prevent them
from doing so.

Also provide a safe get call if any plugins directly call get on it so
that it uses the special logic to check pending.

Also restores ABI for the visibleChunks field back to what it was too.

Additionally, remove the stack trace from Timings Stack Corruption for any
error thrown on Minecraft Timings, and tell them to get the error ABOVE this
instead, so people stop giving us useless error reports.

Also fixes a memory leak when the source map down sizes but dest map didn't,
which resulted in lingering references to old chunk holders.

Fixes #3414
2020-05-22 00:39:16 -04:00
Aikar 18c686576b
Optimize performance of object pool
synchronized arraydeque ends up still being way faster.
Kinda shocked how much that strategy was using, it wasn't really
that complicated... but oh well, this is even simpler and not
seeing blocked threads show up at all in profiling because
the lock is held for such a short amount of time.

also because most uses are on either server thread pool or chunk load pool.

Also optimize the pooling of nibbles to not register Cleaner's
for Light Engine directed usages, as we know we are properly
controlling clean up there, so we don't need to rely on GC.

This will return them to the pool manually, saving a lot of Cleaners.

Closes #3417
2020-05-20 21:45:43 -04:00
Aikar 7e1525ea2d
Many improvements to chunk prioritization and bug fixes
Fixed a few bugs, and made numerous improvements.
Fixed issue where a sync chunk load could have its ticket removed and the
priority ticket could expire...
Still not perfect there but better than before.

Also fixed few other misc issues such as watchdog cpu usage, chunk queue update
had risk of double enqueue due to it no longer being a set.

Added much more information about chunk state to watchdog prints.

I see some more room for improvement even, but this is much better than before.

Fixes #3407
Fixes #3411
Fixes #3395
Fixes #3389
2020-05-20 05:13:01 -04:00
Aikar c82b292ab0
Fix pooled buffer leak resulting in dynmap black spots - Fixes #3386
Dynmap accessed the raw bytes because it utilized NBT locally, but the
NBTTagcompound was garbage collected while the bytes were still being used.

This will return getBytes() back to being safe, and add a new PoolSafe method
that will prevent the additional allocations for general chunk loading.

Also fixed applyPatches for people with paths in their working directory
if they have mcdev sources built.
2020-05-20 00:55:30 -04:00
Aikar 614a664bd3
Implement Chunk Priority / Urgency System for Chunks
Mark chunks that are blocking main thread for world generation as urgent

Implements a general priority system so that chunks that are sorted in
the generator queues can prioritize certain chunks over another.

Urgent chunks will jump to the front of the line, ensuring that a
sync chunk load on an ungenerated chunk does not lag the server for
a long period of time if the servers generator queues are filled with
lots of chunks already.

This massively reduces the lag spikes from sync chunk gens.

Then we further prioritize loading order so nearby chunks have higher
priority than distant chunks, reducing the pressure a high no tick
view distance holds on you.

Chunks in front of the player have higher priority, to help with
fast traveling players keep up with their movement.

This commit also improves single core cpu scenarios in that we will
now automatically disable Async Chunks as well as Minecrafts thread
pool.

It is never recommended to use async chunks on a single CPU as context
switching will be slower than just running it all on main.

This also bumps the number of server worker threads by default too.
Mojang does not utilize the workers in an effecient manner, resulting
in them using barely any sustained CPU.

So give it more workers so more chunks can be processed concurrently

This change also improves urgent chunk loading, so players flying into
unloaded chunks will hurt a little bit less (but still hurt)

Ping #3395 #3363 (Not marking as closed, we need to make prevent moving work)
2020-05-19 04:09:37 -04:00
Mariell c8028d1c76
Fix data version check for ItemStack serialization (#3394)
The expected version should be equal to or newer than the one stored.

Although Aikar claims he did this on accident (and NOT my ligatures!), I
claim this is all a big conspiracy by followers of the Taco cult.
2020-05-18 12:24:06 -05:00
Mariell Hoversholm 6f196fe701
Add Raw Byte ItemStack Serialization
Serializes using NBT which is safer for server data migrations than bukkits format.
2020-05-17 00:52:24 -04:00
Spottedleaf df43f82838
Allow server startup for those poor people running <1G Xmx
Clamp logic for poolsize so we dont pass zero
2020-05-17 00:32:37 -04:00
Spottedleaf 3c9b65ef9d
Fix cases where no-tick < tick view distance 2020-05-17 00:24:49 -04:00
MeFisto94 72f89a076a
Workaround for Client Lag Spikes (MC-162253)
When crossing certain chunk boundaries, the client needlessly
calculates light maps for chunk neighbours. In some specific map
configurations, these calculations cause a 500ms+ freeze on the Client.

This patch basically serves as a workaround by sending light maps
to the client, so that it doesn't attempt to calculate them.
This mitigates the frametime impact to a minimum (but it's still there).
2020-05-17 00:21:42 -04:00
Mariell Hoversholm 3f941c0cce
Add option for console having all permissions
Overrides permissions set to default false (which op does not get)
2020-05-16 23:55:54 -04:00
Mariell Hoversholm d2ae4658ec
Add permission for command blocks 2020-05-16 23:48:54 -04:00
kickash32 74466412ee
Check portal restrictions when entering end gateways 2020-05-16 23:28:59 -04:00
Josh Roy fc9cf84dc6
Fix NPE when temp ip bans expire (#3373) 2020-05-16 23:26:49 -04:00
Max Lee 16bd420db5
Add missing mob goals for API (#3367) 2020-05-16 23:19:24 -04:00
Mariell Hoversholm b5c4e2f655
Ensure no-tick view is not smaller than ticking VD
Fixes #3372.
2020-05-16 23:09:06 -04:00
MiniDigger 52564b1f89
Expand Pathfinding API with more options 2020-05-16 23:02:48 -04:00
MiniDigger dde6548136
Fix usage of vanilla goals 2020-05-16 22:59:20 -04:00
kickash32 7797aebe63
Drop Leads from nether portals - Fixes #3226 2020-05-16 22:58:11 -04:00
Spottedleaf 511b6bc278
Reduce MutableInt and Vec3d allocations, use ArrayDeque 2020-05-16 22:26:45 -04:00
Aikar 84673141a0
Optimize NibbleArray to use pooled buffers
Massively reduces memory allocation of 2048 byte buffers by using
an object pool for these.

Uses lots of advanced new capabilities of the Paper codebase :)

Targets 3072 * 8 buffers per 1GB of heap memory up to a max consideration
of 6GB of heap (any more over 6GB won't give more nibble pool)

You can control the 3072 number by setting -DPaper.nibbleBucketSize=2048

Remember this number is * 8 then * heap memory in GB

That is 98304 objects for 4GB of memory, at 2064 bytes roughly, meaning 194MB

You may also control max number of pooled objects directly instead of any
dynamic calculation using -DPaper.maxNibblePoolSize=1024000

While this will use more old generation by a tad bit, allocation rate will drop
significantly, causing less young generation GC's.

This commit has gone through extensive testing for over a day and confident
it no longer has any issues with light corruption.
2020-05-16 22:24:36 -04:00
Aikar 897dd2c840
Foundational work for Future Memory usage improvements
This commit doesn't do much on its own, but adds a new Java Cleaner API
that lets us hook into Garbage Collector events to reclaim pooled objects and
return them to the pool.

Adds framework for Network Packets to know when a packet has finished dispatching
to get an idea when a packet is done sending to players.

Rewrites PooledObjects impl to properly respect max pool size and remove
almost all risk of contention.

Bumps the Paper Async Task Queue to use 2 threads, and properly shuts it down on shutdown.
2020-05-16 21:38:19 -04:00
Spottedleaf bb4002d82e
Handle CraftPlayer#setSpectatorTarget better
Use a proper teleport for teleporting to entities in different
worlds.

Validate that the target entity is valid and deny spectate
requests from frozen players.

Also, make sure the entity is spawned to the client before
sending the camera packet. If the entity isn't spawned clientside
when it receives the camera packet, then the client will not
spectate the target entity.
2020-05-14 18:05:00 -05:00
Aikar 4ae089597b
Fix collision checks on spawning hanging entities and null on async chunk loads
getCubes will now always load chunks
getChunk with gen false will now not throw error

Fixes #3368
Fixes #3364
2020-05-14 05:05:13 -04:00
Aikar c2f8d1ef98
Protect Bedrock and End Portal/Frames from being destroyed
This fixes exploits that let players destroy bedrock by Pistons, explosions
and Mushrooom/Tree generation.

These blocks are designed to not be broken except by creative players/commands.
So protect them from a multitude of methods of destroying them.

A config is provided if you rather let players use these exploits, and let
them destroy the worlds End Portals and get on top of the nether easy.
2020-05-14 03:16:31 -04:00
Aikar 827cc63263
Updated Upstream (Bukkit/CraftBukkit/Spigot)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
ffc8e4ca SPIGOT-5716: Clarify documentation of MultipleFacing

CraftBukkit Changes:
d07a78b1 SPIGOT-5716: Clarify documentation of MultipleFacing
46a13860 SPIGOT-5718: Block.BreakBlockNaturally does not reflect tool used
214ffea9 SPIGOT-5727: GameRule doImmediateRespawn cannot be set per-world

Spigot Changes:
2f5d615f SPIGOT-5730: Modernise inventory patch
a2bdb119 SPIGOT-5679: Add config option for end portal activation sound

Closes #3352
2020-05-12 01:27:07 -04:00
Aikar 92f680ed84
Fix Pathfinding and obscure glitchy buggy 0 tick farms
I swear the crap that stuff will abuse to make stuff happen is insane.

Hash codes apparently changing behavior of stuff based on its value, so
reverting 2d401d2dfb

Fixes #3346
Fixes #3341
2020-05-11 21:18:11 -04:00
Aikar 7a7c429260
Optimize Pathfinder - Remove Streams / Optimized collections
I utilized the IDE to convert streams to non streams code, so shouldn't
be any risk of behavior change. Only did minor optimization of the
generated code set to remove unnecessary things.

I expect us to just drop this patch on next major update and re-apply
it with the IDE again and re-apply the collections optimization.

Optimize collection by creating a list instead of a set of the key and value.

This lets us get faster foreach iteration, as well as avoids map lookups on
the values when needed.
2020-05-11 04:24:38 -04:00
Aikar fc917d1687
Optimize Hoppers - Major performance improvement
Removed streams from hoppers and also fixed a mistake in the logic.
When this patch was ported to 1.14/1.15, a line of code was put in
the wrong place which disabled a significant portion of the improvement.

Replaced usages of streams in isEmpty and itemstack checks
Replaced usage of streams in pulling loop
Replaced usage of streams in Lootable Inventory isEmpty() check
Only check for refilling Lootable Inventory when accessing first slot, not all

All of these in general were pretty significant hits, so this single commit
is going to cause tacos to magically appear in front of you every day.

🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮🌮

Nom Nom Nom
If you hate taco's, you're not allowed to use this improvement.

Also ignore the renames, pulled a lot of PR's.
2020-05-11 03:42:32 -04:00
Omer Uddin 14ad77c692
Fix PotionEffect API Ignoring Icon bug
Fixes #3142
2020-05-11 00:44:27 -04:00
Omer Uddin eb3ce8a258
Fix EntityRaider picking up items when they shouldn't be able
Fixes #2205
2020-05-11 00:41:15 -04:00
Aikar 1ea9ada0da
Add a TELEPORT ticket when changing dimensions
This should fix any remaining issues around collision issues on
chunk edges when changing dimensions sending to Y 256
2020-05-11 00:19:40 -04:00
Aikar 8e9459eadc
Fix missing flag pass for isUrgent 2020-05-11 00:19:40 -04:00
Josh Roy 7befec4420
Potential bed api (#3339) 2020-05-11 00:19:04 -04:00
Spottedleaf 27945a6b1f
Optimize WorldBorder collision checks and air
Port part of leafs changes from Tuinity, will worry about rest later with larger changes coming
2020-05-10 22:52:20 -04:00
Aikar 55e17a8599
Wait for Async Tasks during shutdown
Server.reload() had this logic to give time for tasks to shutdown,
however shutdown did not...

Adds a 5 second grace period for any async tasks to finish and warns
if any are still running after that delay just as reload does.

Closes #3337
2020-05-10 22:17:55 -04:00
Aikar b59052566b
Ensure Entity AABB's are never invalid
If anything used setPositionRaw, it left potential for an AABB
to be left stale at their old location, which could cause massive
AABB boxes if movement ever then got called on the new position.

This guarantees any time we set the entities position, we also
update their AABB.
2020-05-10 22:14:47 -04:00
Aikar a054aa6f02
Properly remove Entities from current chunk
We store a reference to the chunk the entity is currently in, so use it
to more accurately unregister it in chunkCheck

Should maybe fix some entity loss issues.
2020-05-10 05:52:31 -04:00
Aikar c894ddfd38
Fix teleporting onto a chunk line
Obscure detail in that if you teleport right on a chunk line, it
adds +1 to your collision check and will check the unloaded neighbor.

but the call to load the chunk then returned null if it was pending unload, such
as the load we did in Player List

However we want gen=true for players here anyways, so use getType
2020-05-10 05:52:26 -04:00
Aikar 57d6cc0158
Send LOGIN protocol packets immediately - Fix disconnect during async prelogin 2020-05-10 03:12:05 -04:00
Aikar cd93e54df3
Don't use our modified chunk checks for collision in world gen
Fixes issues with errors in logs on generating chunks
2020-05-10 02:27:50 -04:00
Aikar b4003ef1ca
Allow loading entities current chunk if needed to fix collision checks
Having trouble reproducing this myself, but this should do it.
2020-05-10 01:04:45 -04:00
Aikar e5f6489602
Add Urgent API for Async Chunks API and use it for Async Teleport
This also cleans up the implementation of Async Chunks to get rid of most
Consumer callbacks and instead return futures.

This lets us propogate errors correctly up the future chain
(barring one isn't lost even deeper in the chain...)

So exceptions can now bubble to plugins using getChunkAtAsync
2020-05-10 00:57:03 -04:00
Aikar ad8e59dc79
Ensure chunks loaded on respawn for suffocation check 2020-05-09 21:13:30 -04:00
Aikar b1691e7b69
Remove some Streams usage in Entity Collision
While there is more down the collision system, remove some of the wrapping
Spliterator stuff as even this wrapper stream has shown up in profiling.

With other collision optimizations, we might also even avoid inner streams too.
2020-05-09 19:38:31 -04:00
JellySquid d454bbd5e1
Implement JellySquid's Entity Collision optimisations patch
This patch replaces the vanilla collision code for both block and entity collisions with faster implementations by JellySquid, used originally in her Lithium mod.

Optimizes Full Block voxel collisions, and removes streams from Entity collisions

Original code by JellySquid, licensed under GNU Lesser General Public License v3.0
you can find the original code on https://github.com/jellysquid3/lithium-fabric/tree/1.15.x/fabric (Yarn mappings)

Ported by
Co-authored-by: Zoutelande <54509836+Zoutelande@users.noreply.github.com>

Touched up by Aikar to keep previous paper optimizations
2020-05-09 19:19:18 -04:00
Aikar 8e85f841d8
Optimize Collision to not load chunks
The collision code takes an AABB and generates a cuboid of checks rather
than a cylinder, so at high velocity this can generate a lot of chunk checks.

Treat an unloaded chunk as a collision for entities, and also for players if
the "prevent moving into unloaded chunks" setting is enabled.

If that setting is not enabled, collisions will be ignored for players, since
movement will load only the chunk the player enters anyways and avoids loading
massive amounts of surrounding chunks due to large AABB lookups.

Fixes #3321
2020-05-09 19:19:08 -04:00
Aikar ceb824dbde
Fix ChunkCache .getXIfLoaded to use the local chunks in the cache
It was calling back out to world for it, we already have them.

Also use the nocache method for building the chunk cache too.
2020-05-09 14:58:08 -04:00
Aikar f6f9157bd4
Don't toString block unless actually showing the message
This is causing MASSIVE performance issues with hoppers and block states
in general.
2020-05-09 13:55:41 -04:00
Aikar ec8d7387ad
MC-183249: Don't generate Carving Masks BitSet unless needed
This was using SIGNIFICANT amounts of memory allocating many
long[]'s for BitSets for every ProtoChunk in the cache that had
been unloaded and reloaded.

This will result in a nice memory reduction.
2020-05-09 12:13:29 -04:00
Aikar 2d401d2dfb
Improve BlockPosition hashCode/equals
Actually showed up in profiling as decent time spent here...

Noticed y/z was missing its final that it use to have, when x had it. some how
must of got messed up on some update. though people suggest this shouldn't of
mattered anyways, but lets put it back for safety.

Added cache of hashcode, as well as optimized the hash code using larger primes.
Also stored the long value of the x/y/z so that for equals we can compare a single long,
as well as have that long value cached for .asLong()
2020-05-09 10:59:29 -04:00
Aikar 2572bd017c
Fix world unload toLowercase - Fixes #3326 2020-05-09 10:59:10 -04:00
virustotalop dda9680be5
Optimize brigadier child sorting performance
Use a TreeMap instead of a LinkedHashMap and then manually sorting

This will significantly reduce CPU usage on logging in and changing worlds.
2020-05-08 20:55:44 -04:00
Aikar a71a4ec215
Fix CraftServer.unloadWorld Leak
The dimension manager was still registered which leaked the entire World
2020-05-08 20:40:42 -04:00
Aikar f6fc0d4cd4
Don't create region files for chunk checks - mistake on upstream merge
Accidently handled a conflict wrong in a previous upstream merge and set wrong param.
2020-05-08 18:22:37 -04:00
Aikar cfed00cf54
Fix Light Command
This lets you run /paper fixlight <chunkRadius> (max 5) to automatically
fix all light data in the chunks.

Permission node is same "bukkit.command.paper"
2020-05-07 19:44:33 -04:00
Aikar a6ff84add7
Revert Nibble patch, causing issues still 2020-05-07 05:30:40 -04:00
Aikar f1a8eb7fda
Use a finalizer for light packet instead of onPacketDone
Sadly sharing packets is breaking the ability to do this :(

We can prob still do a little better than this but will save that
for another commit.
2020-05-07 01:58:23 -04:00
Aikar 03c9bb05c1
Optimize NibbleArray to use pooled buffers
Massively reduces memory allocation of 2048 byte buffers by using
an object pool for these.
2020-05-07 01:32:02 -04:00
Aikar d0a528b1cb
Move delayed init down later in tick, improve accuracy of startup time
Now tracks the full startup time for "Done" message at end, as apparently
Vanillas was done in a place that skipped tracking a lot of code too.

This fixes an issue with ViaVersion
2020-05-06 21:24:43 -04:00
Aikar cc477e6abb
Force Plugins that use delayed tasks for init back in their place
Will now run those tasks just before we print "Done" so that startup
time is appropriately accounted for a plugin, as well as will no longer
trip the watchdog on startup.

Any plugin that tries to bypass this is just going to then trip watchdog
on Spigot too, so don't you dare.

Stop trying to cheat the delay your plugin added to startup time.

This isn't a behavior change because the first thing the tick does....
was run these tasks....

So it's just moving it slightly a few lines to be before a watchdog tick and
to account for it in "Done" time.

Fixes #3294
2020-05-06 20:18:31 -04:00
Aikar 597263fd55
Don't skip full player connection tick when dead
Still need to send keep alives and kick for idle

Fixes #3299
2020-05-06 19:30:47 -04:00
Spottedleaf e2c23475b5
Revert loaded entity list (#3304) 2020-05-06 11:31:29 -05:00
Spottedleaf fa87db6b91
Move another NetworkManager util into the inner class (#3303)
Those poor souls running outdated ProtocolLib.
2020-05-06 10:07:51 -05:00
Spottedleaf 841c7d1879
Make loaded entity list logic more consistent (#3301)
When adding/removing to a chunk, we need to also look at
editing the loaded entity list.

Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
2020-05-06 09:57:18 -05:00
Aikar 36f34f01c0
Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
da9ef3c5 #496: Add methods to get/set ItemStacks in EquipmentSlots
3abebc9f #492: Let Tameable extend Animals rather than Entity
941111a0 #495: Expose ItemStack and hand used in PlayerShearEntityEvent
4fe19cae #494: InventoryView - Add missing Brewing FUEL_TIME

CraftBukkit Changes:
933e9094 #664: Add methods to get/set ItemStacks in EquipmentSlots
18722312 #662: Expose ItemStack and hand used in PlayerShearEntityEvent
2020-05-06 06:05:22 -04:00
Aikar 5ca5f131bb
Rebuild all patches using the new rebuild pattern 2020-05-06 05:48:49 -04:00
Mariell Hoversholm 1ccff6fabb
Add villager reputation API 2020-05-06 05:48:06 -04:00
Aikar f37381ea8a
Optimize Network Manager to not need synchronization
Removes synchronization from sending packets
Makes normal packet sends no longer need to be wrapped and queued like it use to work.
Adds more packet queue immunities on top of keep alive to let the following scenarios go out
without delay:
  - Keep Alive
  - Chat
  - Kick
  - All of the packets during the Player Joined World event

Hoping that latter one helps join timeout issues more too for slow connections.

Removes processing packet queue off of main thread
  - for the few cases where it is allowed, order is not necessary nor
    should it even be happening concurrently in first place (handshaking/login/status)

Ensures packets sent asynchronously are dispatched on main thread

This helps ensure safety for ProtocolLib as packet listeners
are commonly accessing world state. This will allow you to schedule
a packet to be sent async, but itll be dispatched sync for packet
listeners to process.

This should solve some deadlock risks

This may provide a decent performance improvement because thread synchronization incurs a cache reset
so by avoiding ever entering a synchronized block, we get to avoid that, and packet sending is a really
hot activity.
2020-05-06 05:28:47 -04:00
stonar96 8f9df2ed43
Anti Xray cleanup
Undo the accidental renaming of a method in 0aad8bf
Aikar wanted to rename DataPalette#getDataBits(T object) to getOrCreateIdFor
in 0aad8bf but he also accidentally renamed
ChunkPacketInfo#getDataBitsIndex(int chunkSectionIndex) to
getOrCreateIdForIndex.

Remove chunk-edge-mode and chunk loading entirely from Anti-Xray
The chunk-edge-mode is broken since several versions.
Loading chunk neighbors for chunk edge obfuscation isn't needed anymore.
Unlike in previous versions, these are under normal circumstances already loaded
at the time we need them (plugins for example can bypass this).

Use the modified methods and constructors everywhere
Anti-Xray provides support for the default nms methods and constructors,
which where modified by Anti-Xray to avoid breaking stuff (plugins)
which somehow uses these methods.
However, the modified versions of those methods and constructors should be used
where possible.
2020-05-06 04:35:20 -04:00
Spottedleaf 878c66f116
No-Tick view distance implementation - Closes #3196
Implements world view distance getters/setters

Per-Player is absent due to difficulty of maintaining
the diff required to make it happen.
2020-05-06 03:50:52 -04:00
Spottedleaf b87743c1e0
Stop copy-on-write operations for updating light data
Causes huge memory allocations + gc issues
2020-05-06 03:48:56 -04:00
Spottedleaf 97a9c9724a
Optimize isOutsideRange to use distance maps
Use a distance map to find the players in range quickly
2020-05-06 03:48:18 -04:00
Spottedleaf b4e629a283
Use distance map to optimise entity tracker / Misc Utils
Use the distance map to find candidate players for tracking.

This also ports a few utility changes from Tuinity
2020-05-06 03:47:24 -04:00
Spottedleaf d80d15174b
Optimize Entity Ticking to Loaded Chunks only
We retain a list of loaded entities specifically for this usage
2020-05-06 03:43:11 -04:00
MiniDigger 75e1e3b3e1 Mob Goal API 2020-05-05 18:05:27 +02:00
Aikar c7bc393a87
Revert "Don't flush packet queue off main thread"
This reverts commit 1abd2bd279.

Sadly not gonna work due to server pings
2020-05-04 04:50:08 -04:00
Aikar 1abd2bd279
Don't flush packet queue off main thread
Increases risk of deadlock if a plugin using protocollib sends a packet
async, and then a listener then reads world state, and main thread is then
blocked waiting for the queue to flush.

This will break out of the synchronized block when it jumps to the netty event loop.

See: https://gist.github.com/aikar/e7abb2ba7059149d0a91f7a226e98590
2020-05-04 03:07:04 -04:00
Aikar a4ed58a9ab
Clean up Direct Memory Region Files Fix for different Java versions
Java 9+ doesn't allow using the exposed cleanup method, but added
a new method on Unsafe to do it.

So have to detect java version and use the appropriate strategy.
2020-05-04 02:19:38 -04:00
Aikar 55e3501967
Set cap on JDK per-thread native byte buffer cache
See: https://www.evanjones.ca/java-bytebuffer-leak.html

This is potentially a source of lots of native memory usage.

We are clearly seeing native usage upwards to 1-4GB which doesn't make sense.

Region File usage fixed in previous patch should of tecnically only been somewhat
temporary until GC finally gets it some time later, but between all the various
plugins doing IO on various threads, this hidden detail of the JDK could be
keeping long lived large direct buffers in cache.

Set system properly at server startup if not set already to help protect from this.
2020-05-04 01:14:10 -04:00
Aikar b5101f4f97
Cleanup Region Files Direct Memory on close
Mojang was semi leaking native memory here by relying on finalizers
to clean up the direct memory.

Finalizers have no guarantee on when they will be ran, and since this is
old generation memory, it might be a while before its called.
2020-05-04 01:08:51 -04:00
Aikar 81e655d7fa
Optimize Voxel Shape Merging
This method shows up as super hot in profiler, and also a high "self" time.

Upon analyzing, it appears most usages of this method fall down to the final
else statement of the nasty ternary.

Upon even further analyzation, it appears then the majority of those have a
consistent list 1.... One with Infinity head and Tails.

First optimization is to detect these infinite states and immediately return that
VoxelShapeMergerList so we can avoid testing the rest for most cases.

Break the method into 2 to help the JVM promote inlining of this fast path.

Then it was also noticed that VoxelShapeMergerList constructor is also a hotspot
with a high self time...

Well, knowing that in most cases our list 1 is actualy the same value, it allows
us to know that with an infinite list1, the result on the merger is essentially
list2 as the final values.

This let us analyze the 2 potential states (Infinite with 2 sources or 4 sources)
and compute a deterministic result for the MergerList values.

Additionally, this lets us avoid even allocating new objects for this too, further
reducing memory usage.
2020-05-03 23:02:52 -04:00
Aikar ed9fc11fe3
Sync position on teleportation
We've seen many a cases where the "last good" x/y/z is desynced from
the x/y/z that is checked for moving too fast.

Theory is that when you have multiple movement packets queued up,
and the player is teleported after the first then the 2nd and 3rd come in,
it is triggering a massive movement velocity.

This will ensure that the servers position is synchronized anytime player is te

Fixes #3258
2020-05-03 15:29:53 -04:00
Aikar 9c326fceda
Nanothing to see here 2020-05-03 03:38:19 -04:00
Aikar 3e9fc24b66
Attempt to fix FastLogin maybe 2020-05-03 02:20:56 -04:00
Aikar 932e97f345
Rename to AsyncPlayerSendSuggestionsEvent to be consistent in naming
It was still technically read correctly in what it was doing, but
all our Player events begin with Player.

Nothing uses this event yet so safe to rename.

If you are some rapid adopter of this event, sorry :P
2020-05-02 15:29:03 -04:00
Aikar 0dd1907568
AsyncSendPlayerSuggestionsEvent Brigadier Event
Going to be used for ACF to be able to send Tooltips to client :)

This is after completions are calculated, to control what is sent to the client.
2020-05-02 14:17:17 -04:00
Aikar a9e20e5f62
Fix being kicked in survival for block picking - Fixes #3277 2020-05-02 13:32:03 -04:00
MiniDigger 4d20537e6e
Expose game version (#3274) 2020-05-02 04:56:08 -04:00
Aikar 85fb00152a
Validate PickItem Packet and kick for invalid - Fixes #3256 2020-05-02 03:10:26 -04:00
Aikar 5729bc716e
Special case Keep Alive packets from Anti Xray
If a server enables Anti Xray, packet sending can be delayed until the
chunk has been obfuscated, blocking the entire queue from going out.

On a busy server, considering Anti Xray can only operate on a single
thread, it is quite possible the obfuscation backlog can get quite behind
resulting in a delay of sending packets.

And logging in is a clear area where lots of chunks are going to be queued
for obfuscation....

We should probably special case a few more than this (such as chat),
but this will hopefully help the keep alive issues some people run into.
2020-05-02 01:01:50 -04:00
Spottedleaf a76b774070
Improved oversized chunk data packet handling
Now target all TE data, except for TE's that do not have
update packets.
2020-05-02 00:31:24 -04:00
Aikar a6f78170db
Use Vanilla Bed Search for non players (Villagers)
Should help #2959
2020-05-01 21:56:50 -04:00
Aikar 68fb98b50f
Fix 2 plugin specific issues with loot drop and pathfinders
Based on what that collection does, won't really cause any real issue for UC.
So let it silently be ignored.

Fixes #3269
Fixes #3255
2020-05-01 21:48:43 -04:00
Aikar 6e41f7b79a
Update Activation Range 2.0 with more villager controls
Now has separate configs to control Villager immunities a bit.

whether or not they wake up due to panic situations (raids)
and when should they wake up when work is available after being
inactive for so long, and for how long.

This work config may make the 'wake up inactive' feature for villagers
useless in most scenarios, but if there is a situation where the villager
does go without needing to work for a long period of time, it would kick
in then.

This also removes movement based immunities, so now villagers should only move
if they trigger a work immunity, panic immunity, or inactive wake up immunity.

Fixes #3263
2020-05-01 21:48:33 -04:00
Aikar 57dd397155
Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
b999860d SPIGOT-2304: Add LootGenerateEvent

CraftBukkit Changes:
77fd87e4 SPIGOT-2304: Implement LootGenerateEvent
a1a705ee SPIGOT-5566: Doused campfires & fires should call EntityChangeBlockEvent
41712edd SPIGOT-5707: PersistentDataHolder not Persistent on API dropped Item
2020-05-01 18:03:57 -04:00
MiniDigger 5ab48ad901
Fix commodore (#3264)
fixes #3262
2020-04-30 18:05:20 +01:00
Aikar 87e7ee7e79
Improve Async Login to avoid firing in middle of Entity Ticking
If a sync load was triggered, it would process pending join events,
causing them to be added to the world in the middle of the entity ticking
process.

This caused their add to be queued instead of immediate, causing
"Illegal Tracking" errors.

This schedules it to fire at the players next Connection Tick, which
is exactly where this entire process use to run anyways.

Also added missing tab complete and syntax for syncloadinfo debug command
2020-04-29 05:40:40 -04:00
Aikar 00d760a537
Fix build due to spigot changing the build timestamp process 2020-04-27 04:03:00 -04:00
Aikar 842e040c19
Updated Upstream (Bukkit/CraftBukkit/Spigot)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
220bc594 #486: Add method to get player's attack cooldown
21853d39 SPIGOT-5681: Increase max plugin channel size
5b972adc Improve build process
b55e58d9 Note which custom generator is missing required method

CraftBukkit Changes:
893ad93b #650: Add method to get player's attack cooldown
ef706b06 #655: Added support for the VM tag jansi.passthrough when processing messages sent to a ColouredConsoleSender.
e0cfb347 SPIGOT-5689: Fireball.setDirection increases velocity too much
94cb030f SPIGOT-5673: swingHand API does not show to self
b331a055 SPIGOT-5680: isChunkGenerated creates empty region files
e1335932 Improve build process
a8ec1d60 Add a couple of method null checks to CraftWorld
ce66f693 Misc checkstyle fixes
8bd0e9ab SPIGOT-5669: Fix Beehive.isSedated

Spigot Changes:
2040c4c4 SPIGOT-5677, MC-114796: Fix portals generating outside world border
ab8f6b5a Rebuild patches
e7dc2f53 Rebuild patches
2020-04-27 03:34:45 -04:00
nick c03260a280
Add getter and setter for villager's numberOfRestocksToday (#3231) 2020-04-27 02:13:41 -04:00
Aikar fe366fbe77
null check tracker for entity metadata update - Fixes #3070 2020-04-27 01:57:42 -04:00
Aikar fdf41b742d
Implement Brigadier Mojang API
This is the start of a new module for Paper to add support for API's
that interface Mojang API's directly.

This allows us to version properly by MC version incase Mojang makes any major breaking changes.

It also lets us separate Mojang API's from Paper-API so our downstream friends at Glowstone
will not have to worry about Mojang code.

Adds AsyncPlayerSendCommandsEvent
  - Allows modifying on a per command basis what command data they see.

Adds CommandRegisteredEvent
  - Allows manipulating the CommandNode to add more children/metadata for the client
2020-04-27 01:42:12 -04:00
Aikar e0ea2e0e14
Entity Activation Range 2.0! Major improvements to restoring behavior
Calling this 2.0 as it's a pretty major improvement with more knobs to twist.

This update fixes many things. The goal here is to restore vanilla behavior to some degree.
Instead of permanent inactive pools of animals, let them show some signs of life some....

Yes this may reduce performance compared to before, but I hope it is minimal. Got to find a balance.
Previous EAR logic really compromised vanilla behavior of mobs. This tries to restore it.

Changes:

1) All monsters are now classed as Monster. Mojang has an interface, we should use it.
   - This now includes Shulker, Slimes, see #2 for Phantom and Ghast
2) Villagers and Flying Monsters now have their own separate activation range configs.
   - Villagers will default to your Animals config
3) Added a bunch of more immunities
   - Brand new entities are immune for a few seconds
   - Entities that recently traveled by portal are immune for few seconds
   - Entities that are leashed to a player are immune
   - Ender Signals are immune
   - Entities that are jumping, climbing, dying (lol) are immune
   - Minecarts are now always immune to the movement restriction
4) Villagers immunity received major overhaul...
   - Now has many immunities for Villager activities to let them
     do their work then go back inactive
   - Such as interacting with doors and workstations should be more normal now
   - Raids will trigger immunities, in that villagers will run and hide when bell rings.
   - Raid should keep the entire village immune during the raid to keep gameplay mechanics
     You can disable raids by game rule if you dont want raids

Then the big one.....

Wake Up Inactive Entities:
One issue plagueing "farms" is that we no longer even let entities move now.
Entities become lifeless.

A new system has been introduced to wake up inactive entities every so often, to let
them stretch their legs, eat some food, play with each other and experience the good entity life.

Animals, Villagers, Monsters (Includes Pillagers), and Flying Monsters will now wake up every
so often after staying inactive for a very long. This grants them a temporary immunity, that
the goal is they will then find "stuff to do" by having a longer activity window.

How many to wake up, how often they wake up, and for how long they wake up are all configurable.

Current EAR Immunities really don't give some entities enough of a window to find work
to then keep them immune for the work to even start. This system should help that.

We will only wake up a few entities per tick on the first wave, restoring 1 per type per world per tick.

So say you have 10 monsters qualify for inactive wake up, all 8 will wake up on the first eligible tick,
and then the 9th will wake up on next tick, 10th on next tick.

If for 5 ticks no more inactive wake up, our buffer will have built back up to 5, and then 5 can go next needed tick.

This basically incrementally wakes them up, preventing too many from waking up in a single tick, to reduce impact to TPS.
2020-04-27 01:22:44 -04:00
Aikar 10396d28e1
Fix Tracking Range mismatch on Vehicle/Passenger checks
This was missing Entity Tracking Range support, creating different
values in this section vs normal section.

Concerned this might of caused some carnage on tracker if this code says
"Yes you should track this player 500 blocks away from you on a horse" and then
the other check uses the normal value.
2020-04-27 00:33:14 -04:00
Aikar 68994c64ec
Add a config to turn off Optimized TickList #3145
Set:

settings:
  - use-optimized-ticklist: false

If you are having issues with block updates and want to see if this fixes it.

Please report confirmations on #3145 ticket
2020-04-26 04:01:03 -04:00
Aikar d847d33684
Improve blocking players from opening inventories while sleeping
This is friendlier to plugins as far as the plugin is concerned,
the inventory did open and immediately closed.

We avoid sending the packet to client so they don't see the window
flash either.

If a plugin wants to avoid wasteful fake opens, they should check
that the player is not sleeping before opening the inventory.
2020-04-26 03:26:21 -04:00
Aikar ac4f6b5022
Clean up Timings and Async Chunk Configs
Renames a bunch of timings to be more appropriate for the new environment.

Many things dealt with sync loads which wasn't correct anymore.
adjusted timings to be a little bit more accurate here.

Also cleaned up old 1.13 async chunks configs so people won't keep
thinking they can change some of those configs when they can't.
2020-04-26 02:19:43 -04:00
Aikar fcf89e852e
Improve mid tick chunk loading, Fix Oversleep, other improvements
Process loads outside of any canSleep check. Original intent was to
only apply those restrictions to generations but realized I had some
checks higher up the call chain.

Reworked the back off strategy to just run every 1 millisecond per world,
and to apply the per tick limit to generations only.

This guarantees that your chunk will load with at most around 1ms delay.

Additionally, fire midTick processing in a few more places, notably the
oversleep section so we can keep processing loads here too which has
a large up to 50ms window...

Speaking of oversleep, we had a bug in our implementation changes for
Timings that caused oversleep to not sleep the correct amount.

Because we now moved it into the NEXT tick instead of THIS tick, the
value of nextTick had already been increased to +50ms, resulting in
the risk of sleeping more than it should, but, more importantly, this
caused every task that was trying to NOT run during oversleep to actually
run during oversleep.

This is now fixed.

Another small tweak is to the /tps command, to no longer show the star when
TPS is right at 20.

Due to ineffeciencies in the sleep precision, TPS is commonly 20.02.
This causes the star to show up almost constantly, so now only show it if
we actually hit a real "catchup".

This commit also improves the changes to the CallbackExecutor, in that
it now is also recursion safe.

It was possible that the executor could run tasks out of desired order
if the executor task scheduled more executor tasks.

We solve this by ensuring new additions do not enter the currently iterated queue.

Each depth level will have its own queue.

Fixes #3220
2020-04-26 01:14:52 -04:00
Spottedleaf ab36835ca0
Improve random ticking behaviour - Fixes #3181 2020-04-25 18:43:13 -04:00
Aikar a6ac47e502
Fix numerous item duplication issues and teleport issues
This notably fixes the newest "Donkey Dupe", but also fixes a lot
of dupe bugs in general around nether portals and entity world transfer

We also fix item duplication generically by anytime we clone an item
to drop it on the ground, destroy the source item.

This avoid an itemstack ever existing twice in the world state pre
clean up stage.

So even if something NEW comes up, it would be impossible to drop the
same item twice because the source was destroyed.

This should make us more forward proof on preventing dupes.

These dupes have been in for years at this point, they aren't new...
Everyone knows about them and are mitigating with plugins atm breaking gameplay.

so better to make it clear its fixed in the messaging.

I am submitting this to Mojang.
2020-04-25 16:38:14 -04:00
BillyGalbreath b7402f11c3
Add phantom creative and insomniac controls (#3222) 2020-04-25 16:33:18 -04:00
Aikar cb15cfa4f8
Improve Async Login so pending connections dont get exposed
We still keep vanilla process of waiting for existing session to be removed before logging in
by storing a separate map of pending.

also fire the callback using executor incase further recursion causes any trouble
2020-04-24 05:48:51 -04:00
Aikar f275e9cb9c
Optimize Hoppers - Major Boost - Got2GoFast!
* Don't check for Entities with Inventories if the block above us is also occluding (not just Inventoried)
* Remove Streams from Item Suck In and restore restore 1.12 AABB checks which is simpler and no voxel allocations (was doing TWO Item Suck ins)
* Restore missing application of previous optimization to getEntities for Inventoried Entities from CullanP
* Use getChunkIfLoadedImmediately for getting loaded entities (faster/simpler, no risk of sync loads)
2020-04-24 03:01:17 -04:00
Aikar 0106485ccb
Improvements to watchdog changes
catch a thread death, fix invalid watchdog timeouts

<= 0 seconds will now change to 5 minutes.
2020-04-24 00:27:50 -04:00
Aikar 65934b1fec
Fix build for last commit. 5am commits are great 2020-04-23 04:53:20 -04:00
Aikar 3f4360296c
Don't process watchdog until server has fully started and ticked.
I think adjusting watchdog settings may of caused instant crashes.

Fixes #3209
2020-04-23 04:49:41 -04:00
Aikar 938bd97255
Don't fire BlockFade on worldgen threads - Fixes #3208
Caused a deadlock
2020-04-23 01:37:30 -04:00
Aikar 509a828e06
Fix loading spawn chunks when async chunks is off
I feel sorry for those who need to do this, and now feel sorry more
since back to slow startups again.

There is keep-spawn-loaded-range in paper.yml to reduce the range to
mitigate this if you must keep async chunks off.
2020-04-22 05:47:35 -04:00
Aikar 8a91bfd240
Improvements to async login
Bump chunk priority to ensure chunks load fast
Handle case where client disconnects before they even fire PlayerJoinEvent
  - no longer call PlayerQuitEvent or print quit message.
  - don't save the player data file if never joined. Nothing has changed.
    CraftBukkit has a bug here that if you do save it, you will lose
    any horse that the player logged off on because the horse hasn't
    been resummoned yet.
2020-04-22 05:40:06 -04:00
Ytnoos bf698865f7
Revert "Re-track players that dismount from other players" 2020-04-22 03:16:31 -04:00
Aikar 82b984184a
Fix some issues with async login as well another source of sync loads 2020-04-22 02:52:17 -04:00
Aikar aa241d2b64
Allow multiple callbacks to schedule for Callback Executor
ChunkMapDistance polls multiple entries for pendingChunkUpdates

Each of these have the potential to move a chunk in and out of
"Loaded" state, which will result in multiple callbacks being
needed within a single tick of ChunkMapDistance

Use an ArrayDeque to store this Queue
2020-04-21 03:55:31 -04:00
nossr50 a2064a4135
Add PlayerAttackEntityCooldownResetEvent
This event is called when processing a player's attack on an entity
right before their attack strength cd is reset, there are no existing
events that fire within this period of time so it was impossible to
capture the players attack strength via API prior to this commit.

The event is cancellable, which will just skip over the normal reset of
attack strength cd
2020-04-21 02:10:43 -04:00
Mariell Hoversholm f48d429968
Allow sleeping players to float
This change lets players who are in their bed have a position which is above
ground for a longer period of time. This is because of the server not setting
their position to the ground/exit location when entering the bed, resulting in
the server believing they're still in the air.
2020-04-20 23:15:55 -04:00
Omer Uddin eeb2f67db6
Fix Bed respawn deviating too far from vanilla (#3195) 2020-04-20 23:14:28 -04:00
2277 68a7b9fec8
Move player to spawn point if spawn in unloaded world
The code following this has better support for null worlds to move
them back to the world spawn.
2020-04-20 23:12:28 -04:00
Spottedleaf f29c7ebd84
Improve async login (#3189)
Add helper functions to ChunkProviderServer to make this easier
for other uses

Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
2020-04-19 13:58:02 -04:00
Aikar 9fd36824fc
Fix Citizens Player NPC tracking issue - Fixes #3186 2020-04-19 13:41:16 -04:00
Aikar 0e72de1c18
Fix Player Tracking issue during join process.
Because we moved entity registration to occur before the PlayerJoinEvent occurs,
We started tracking the entity too early before it was registered to the client.

So delay tracking until after list packets have been sent.
2020-04-19 06:46:48 -04:00