Commit graph

4745 Commits

Autor SHA1 Nachricht Datum
BillyGalbreath
b7402f11c3
Add phantom creative and insomniac controls (#3222) 2020-04-25 16:33:18 -04:00
Wesley Smith
75819fac2d
Fix Potion#toItemStack swapping the extended and upgraded constructor values (#3216) 2020-04-25 00:01:45 +01: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
Aikar
f26362afa4
Load Spawn Chunks Asynchronously and Spiral Out
Ensures absolute center is first in priority
Speeds up server startup
2020-04-19 06:01:07 -04:00
Aikar
54f762e2f7
Load Chunks for Login Asynchronously
No longer will trigger Synchronous Chunk Loads when a player logs
in to the server.

Will delay PlayerJoinEvent until the chunk has been loaded.

Should have massive performance benefits for larger servers with
lots of players logging in and out.
2020-04-19 04:35:01 -04:00
Aikar
f2d1b6e549
Clean up duplicate PlayerInitialSpawnEvent
Confused on this one, as commit history says Spigots version is older
than our version, so i'm not sure how we ended up duplicating this when
the 2 events are 100% identical.

Subclass spigots event and rely on the inheritance system, and clean up
the duplicate event fires.

Fix Spigots setPosition to use setPositionRaw to avoid chunk load prematurely.
2020-04-19 04:34:43 -04:00
Aikar
c2d022d7e7
Fix Longstanding Broken behavior of PlayerJoinEvent
For years, plugin developers have had to delay many things they do
inside of the PlayerJoinEvent by 1 tick to make it actually work.

This all boiled down to 1 reason why: The event fired before the
player was fully ready and joined to the world!

Additionally, if that player logged out on a vehicle, the event
fired before the vehicle was even loaded, so that plugins had no
access to the vehicle during this event either.

This change finally fixes this issue, fully preparing the player
into the world as a fully ready entity, vehicle included.

There should be no plugins that break because of this change, but might
improve consistency with other plugins instead.

For example, if 2 plugins listens to this event, and the first one
teleported the player in the event, then the 2nd plugin actually
would be getting a valid player!

This was very non deterministic. This change will ensure every plugin
receives a deterministic result, and should no longer require 1 tick
delays anymore.
2020-04-19 00:56:43 -04:00
AvrooVulcan
d0a348b95e
Broadcast join messages to console 2020-04-19 00:52:35 -04:00
Aikar
1ef687a4a6
Don't crash if player is attempted to be removed from untracked chunk.
I suspect it deals with teleporting as it uses players current x/y/z

Fixes #2803
2020-04-18 16:03:30 -04:00
Spottedleaf
c11668aca1
Make sure the chunk conversion task is executed immediately
Appending to the tail of the chunk tasks leaves a
window for the chunk to be moved to a
non-ticking status.

Additionally, use CB's callback executor so we
can ensure that we are not incorrectly
scheduling.
2020-04-18 13:00:17 -04:00
Aikar
26fb7cc35a
Fix Chunk Post Processing deadlock risk
See: https://gist.github.com/aikar/dd22bbd2a3d78a2fd3d92e95e9f28dc6

as part of post processing a chunk, we can call ChunkConverter.

ChunkConverter then kicks off major physics updates, and when blocks
that have connections across chunk boundries occur, a recursive risk
can occur where A updates a block that triggers a physics request.

That physics request may trigger a chunk request, that then enqueues
a task into the Mailbox ChunkTaskQueueSorter.

If anything requests that same chunk that is in the middle of conversion,
it's mailbox queue is going to be held up, so the subsequent chunk request
will be unable to proceed.

We delay post processing of Chunk.A() 1 "pass" by re stuffing it back into
the executor so that the mailbox ChunkQueue is now considered empty.

This successfully fixed a reoccurring and highly reproduceable crash
for heightmaps.
2020-04-18 04:44:35 -04:00
Shane Freeder
ffecc4e264
Revert "Optimize entity list iteration requiring entities be in"
This reverts commit bc48a3172d.
2020-04-17 18:26:57 +01:00
Aikar
0a4286cc42
Prevent Fire from loading chunks
Had my server die from this twice already as it can cause a chain reaction.
2020-04-17 00:29:53 -04:00
MiniDigger
07915ea183
Add Player Client Options API (#2883) 2020-04-17 00:10:38 -04:00
Spottedleaf
bc48a3172d
Optimize entity list iteration requiring entities be in
loaded chunks

We retain a list of loaded entities specifically for this usage
2020-04-16 23:59:15 -04:00
Spottedleaf
88092fef13
Optimize ChunkProviderServer's chunk level checking helper methods
These can be hot functions (i.e entity ticking and block ticking),
so inline where possible, and avoid the abstraction of the
Either class.
2020-04-16 23:47:15 -04:00
Aikar
01e8ce8d2d
Forced Watchdog Crash support and Improve Async Shutdown
If the request to shut down the server is received while we are in
a watchdog hang, immediately treat it as a crash and begin the shutdown
process. Shutdown process is now improved to also shutdown cleanly when
not using restart scripts either.

If a server is deadlocked, a server owner can send SIGHUP (or any other signal
the JVM understands to shut down as it currently does) and the watchdog
will no longer need to wait until the full timeout, allowing you to trigger
a close process and try to shut the server down gracefully, saving player and
world data.

Previously there was no way to trigger this outside of waiting for a full watchdog
timeout, which may be set to a really long time...

Additionally, fix everything to do with shutting the server down asynchronously.

Previously, nearly everything about the process was fragile and unsafe. Main might
not have actually been frozen, and might still be manipulating state.

Or, some reuest might ask main to do something in the shutdown but main is dead.

Or worse, other things might start closing down items such as the Console or Thread Pool
before we are fully shutdown.

This change tries to resolve all of these issues by moving everything into the stop
method and guaranteeing only one thread is stopping the server.

We then issue Thread Death to the main thread of another thread initiates the stop process.
We have to ensure Thread Death propagates correctly though to stop main completely.

This is to ensure that if main isn't truely stuck, it's not manipulating state we are trying to save.
2020-04-16 22:40:20 -04:00
Zach Brown
fdb8fe7807
Be less strict with vanilla teleport command limits
Just limit to the same valid location check as BaseBlockPosition, no
reason to restrict to the world border.

Ref: GH-3165
2020-04-16 21:19:42 -05:00
Zach Brown
0f06d38062
Restrict vanilla teleport command to within worldborder
Fixes GH-3165
2020-04-16 20:11:44 -05:00
Aikar
24d93aafa2
Fix Optional null issue - Fixes #3155
Also check class loader cache before locking to speed up cached hits to avoid the lock

wasn't gonna make a unique build just for that but can lump it in here.
2020-04-16 03:57:02 -04:00
Spottedleaf
eb71c5fa3b
Fix incorect timing of mspt
Move oversleep and all task execution back into the timed area...
2020-04-16 03:47:38 -04:00
Spottedleaf
1ca8043428
Optimise entity hard collision checking
Very few entities actually hard collide, so store them in their own
entity slices and provide a special getEntites type call just for them.
This reduces entity collision checking impact (in my testing) by 25%
for crammed entities (shove 130 cows into an 8x6 area in one chunk).
Less crammed entities are likely to show significantly less benefit.
Effectively, this patch optimises crammed entity situations.
2020-04-16 00:40:47 -04:00
Spottedleaf
b67a423768
Don't run entity collision code if not needed
Will not run if max entity craming is disabled and
the max collisions per entity is less than or equal to 0
2020-04-16 00:40:34 -04:00
Spottedleaf
bd9aa547d2
Optimise ArraySetSorted#removeIf
Remove iterator allocation and ensure the call is always O(n)
2020-04-16 00:21:32 -04:00
Gergely Sarkozi
78871d07dc
Make JavaClassLoader thread-safe (Fixes #3137) (#3144)
* Make PluginClassLoader thread-safe (fixes #3137)

* Clean up implementation of MT safe class loader

Co-authored-by: Aikar <aikar@aikar.co>
2020-04-15 03:39:39 -04:00
Aikar
81706e6268
Make the shutdown thread try to shutdown on main 2020-04-13 03:30:12 -04:00
Shane Freeder
8918245090
Prevent opening inventories when frozen 2020-04-13 07:33:46 +01:00
Spottedleaf
e6d395cc83
Port 04-Util.patch from Tuinity (#3136) 2020-04-13 01:34:18 -04:00
Aikar
59453f6675
Fix incorrectly loading chunks on a cancelled interact event
A players previous block break location is held onto permanently, and if
an interact event is cancelled, the client sends a stop breaking block packet
This then tries to update client about that old location.

This old location might then be in a now unloaded chunk, and it caused it to load.

We now also clear reference to it once abort destroy block is ran to stop trying
to send updates about the old block anyways.
2020-04-12 23:56:29 -04:00
Aikar
bdcc31caad
Let invalid positioned entities clean up previous chunk by the chunkCheck
I had did a few of the operations myself, which would have broken chunkCheck
from doing it itself, which would leave some state left in the original chunk
and thats not good....
2020-04-12 22:55:43 -04:00
Spottedleaf
92d2907d14
Multiple memory and performance optimizations (removing streams) 2020-04-12 19:34:56 -04:00
Aikar
748e6447e3
Improve the don't save entities patch per leafs feedback 2020-04-12 18:29:52 -04:00
Callahan
c096fe19fa
Port 20w15a Villager AI optimizations 2020-04-12 16:56:59 -04:00