Commit Graph

308 Commits

Author SHA1 Message Date
Spottedleaf
a9a885ad00 Resolve concurrent access to ticket state
The concurrent access occurred in the region merge/split logic,
as it did not own the ticket lock. To resolve this, we simply
make the ticket add/remove acquire the read lock of
the region lock.
2023-03-12 15:00:38 -07:00
Spottedleaf
518b2d5dec Fix zero radius tasks being recognized as infinite
Fixes parallelism loss from spawn entity chunk status
2023-03-12 00:51:43 -08:00
Spottedleaf
0a11f6aa1f Do not execute infinite radius task in parallel when pushing tasks
By definition, it should not execute in parallel with anything.
2023-03-12 00:17:44 -08:00
Spottedleaf
3bc5341531 Make specialCaseUnload global state
With region state, it may be modified concurrently while
only holding the region lock. Need to figure out a solution
for the ticket state as well.
2023-03-11 23:28:34 -08:00
Spottedleaf
9561a53e7a Log exceptions in ThreadedRegioniser explicitly
I suspect something called these methods, they threw and then
the error was hidden by some completablefuture somewhere.
2023-03-11 12:56:43 -08:00
Spottedleaf
a80cdafae9 Make uncaught exceptions in tick thread shut down the server 2023-03-11 12:36:37 -08:00
Spottedleaf
3f2b83c35a Make SaplingBlock.treeType a thread-local
Now it is accessed concurrently
2023-03-11 06:27:35 -08:00
Spottedleaf
9e835221b9 Update new bee position before adding to beehive
This will ensure the thread check from discard does not fail
2023-03-11 06:14:05 -08:00
Spottedleaf
760de0a276 Move region center calculation into try-catch
Sometimes a region is empty, but only when the threaded regioniser
crashes. So, it should not prevent shutdown.

Additionally, only remove pending teleports after setting the
current region.
2023-03-11 05:46:20 -08:00
Spottedleaf
0fa5f339f2 Do not allow players to interact with entities outside the current region 2023-03-11 05:38:11 -08:00
Spottedleaf
d2a5acba4a Do not allow players to interact with blocks outside of their region 2023-03-11 05:16:10 -08:00
Spottedleaf
4af9f6c889 Do not allow players to destroy blocks that are not owned 2023-03-11 05:10:34 -08:00
Spottedleaf
4cffea6652 Read cancelled field while holding region lock
This will prevent a race condition where the region is cancelled
and immediately re-scheduled, and where this all happens while
the tick thread is blocking on tryMarkTicking.
2023-03-10 20:46:58 -08:00
Spottedleaf
f6d776697b Fix kicking player when they die on a vehicle with instant respawn
The respawn logic apparently can fire before the death is broadcasted
2023-03-10 20:11:08 -08:00
Spottedleaf
e1ad1b1d91 No longer give everyone access to /tps
Everyone had access to /tps for the private tests, but we cannot
trust everyone to use it responsibly for the public test
(i.e revealing coordinates of all logged in players).
2023-03-10 00:19:40 -08:00
Spottedleaf
d258d32393 Add chunk system throughput counters to /tps 2023-03-10 00:18:12 -08:00
Spottedleaf
8625606b3d Fix crash if player disconnects during login stage 2023-03-09 21:17:18 -08:00
Spottedleaf
a9d01f9b4f Max pending logins
Should help hold the floodgates on launch
2023-03-09 21:04:10 -08:00
Spottedleaf
bbee4310fe Fix fishing rods throwing exceptions
Need to move setOwner after the position update, as the thread-check
will fall back to position
2023-03-09 20:45:32 -08:00
Spottedleaf
5cbf898ca1 Stream mode
Disable chat and /msg and /me for non-ops so that the server is
safe to stream
2023-03-09 20:45:32 -08:00
Spottedleaf
950216171d Do not let projectiles travel into chunks not owned by current region
Otherwise, the thread checks for moving the entity into the new
entity chunk section would throw and cause the projectile to
be deleted.
2023-03-08 20:15:22 -08:00
Spottedleaf
ef515cc6f5 Consider non-owned chunks in entity movement as unloaded
This should prevent entities from moving into areas not owned
by the current region.
2023-03-08 19:44:01 -08:00
Spottedleaf
afd678cab6 Fall back to position check if the entity has a null entity callback
In the case that the entity has a null callback, it means the
entity has not been added to the world - so, we should treat
it the same as entity#isRemoved.
2023-03-08 19:38:50 -08:00
Spottedleaf
deae156e59 Make Level#getBlockEntity return null immediately if not tickthread
Otherwise, the world data will be null and we will NPE. The
function is supposed to return null for off-thread access,
anyways.
2023-03-08 17:40:28 -08:00
Spottedleaf
74f665b6f5 Fix compilation 2023-03-07 20:06:08 -08:00
Spottedleaf
b00a16a66d Fix command label placeholder in usage for /tps
Only <command> gets replaced with the provided label
2023-03-07 17:34:45 -08:00
Spottedleaf
68b20e0acc Add API for checking ownership of region by position/entity
This may be useful for plugins which want to perform operations
over large areas outside of the buffer zone provided by the
regionaliser, as it is not guaranteed that anything outside
of the buffer zone is owned. Then, the plugins may use
the schedulers depending on the result of the ownership
check.
2023-03-07 14:44:37 -08:00
Spottedleaf
386bcd1094 Make ServerLevel#areChunksLoadedForMove also check region ownership
We do not want players to move into chunks that are not owned
by the current region
2023-03-07 13:31:59 -08:00
Spottedleaf
0e4358fb7e Make Player#kickPlayer function asynchronously
We have made disconnect() mt-safe, so there is no need for
this check anymore.
2023-03-07 13:22:53 -08:00
Spottedleaf
7af86e656d Do not schedule keepalive fail kick to main
There is no main thread to schedule to, and I've already
make disconnect() handle off-region kicks safely.
2023-03-07 13:19:29 -08:00
Spottedleaf
99429cee37 Make plugin tickets no longer sync load the chunk
This is to prevent any thread-check from failing. Note that
ticket additions are mt-safe.

Additionally, add more thread checks.
2023-03-07 13:13:31 -08:00
Spottedleaf
2ccfc8efc0 Add RegionisedServerInitEvent
This event allows plugins to perform synchronous operations before
any region will tick. Plugins will not have to worry about the
possibility of a region ticking in parallel while listening
to the event.
2023-03-07 13:06:11 -08:00
Spottedleaf
f86bc13d22 Make tpdeny prompt show /tpadeny instead of /tpaccept
As it should be showing
2023-03-07 13:03:20 -08:00
Spottedleaf
71a4219ab6 Make sure /tps includes global region in total util percent
While we expect the util from the global region to be around 0.0,
it doesn't mean it always will be. So, include it.
2023-03-07 12:51:23 -08:00
Spottedleaf
2802e2b360 Add paragraph explaing plugin.yml requirenments to new rules section 2023-03-06 15:33:01 -08:00
Spottedleaf
8fcf959ee3 Fix various World chunk methods
- Add thread check for loadChunk
- Make isChunkGenerated use the region task queue to schedule
  to "main"
- Don't complete async chunk future if not in the owning thread
  for the chunk
2023-03-06 14:27:02 -08:00
Spottedleaf
7ca8feff63 Log delayed world init
Nothing ticks until this is done, so it should be logged.
2023-03-06 14:04:08 -08:00
Spottedleaf
5c4d65efb8 Require plugins to be explicitly marked as Folia supported
Plugins must add "folia-supported: true" to their plugin.yml
otherwise the server will refuse to load them.

Since Folia is a major breakage for plugins, the vast majority
of plugins will not function correctly on Folia. To prevent
user confusion from this, we will refuse to load the plugin
and provide a log indicating why - which will be much
more helpful than some random error log caused by
a breakage.
2023-03-06 14:03:17 -08:00
Spottedleaf
4e7205d401 Change entity scheduler API to use Runnables
The generics pose a problem, and the parameter passed to the
Consumer is not needed in API.

Additionally, stop trying to cancel Bukkit scheduler tasks on
plugin disable as the Bukkit scheduler does not work.
2023-03-06 12:57:29 -08:00
Spottedleaf
71c4d0f41f Add license.
This project is GNU GPLv3.
2023-03-06 02:59:21 -08:00
Spottedleaf
490b8f5182 Add logo 2023-03-06 02:43:32 -08:00
Spottedleaf
e6d60da06f Halt chunk systems before saving chunks for all worlds
This is to ensure that chunks are not progressing in other worlds
while saving
2023-03-05 12:51:23 -08:00
Spottedleaf
43d0469e36 Initial README documentation
First draft
2023-03-04 20:27:36 -08:00
Spottedleaf
282ded3b44 Add some scheduling API 2023-03-04 13:13:23 -08:00
Spottedleaf
8ffa40246a Fix NPE in treeFinished()
tryPushTasks returns null when there are no tasks, not
an empty list.
2023-03-03 16:46:03 -08:00
Spottedleaf
04b28a65ca Fix mob spawning
We should only iterate over the local region's entities, not the
global entity list to set up the spawner state, as everything else
about the spawner state (player count / chunk count) is regionised.
Additionally, move the last spawner state to regionised state so that
paper mobcaps command functions as expected.
2023-03-03 15:58:43 -08:00
Spottedleaf
147df3c14c Delay scheduler improvements
It turns out, the scheduler is good enough right now - the main
bottlenecks to scaling chunk workers is actually the chunk
system locking behavior (mostly schedule lock, but ticket lock
is there too)
2023-03-03 00:21:34 -08:00
Spottedleaf
f9327302d8 Make ServerLevel#onTrackingEnd map data access thread-safe
We need to synchronise on the map data object and on the
cache, as is done everywhere else for access of such data
2023-03-02 23:39:55 -08:00
Spottedleaf
bb3f8a4aea Process player chunk loader mid tick at the start of tick
Additionally, process ticket updates as well if either
the mid tick logic did anything or whether we processed
any chunk tasks.

We process the mid tick logic at the start to be consistent
with the inbetween task execution logic (which is not implemented),
and we process ticket updates to ensure that any full status changes
are processed from chunk tasks.
2023-03-02 23:31:59 -08:00
Spottedleaf
b42537ed02 Cache whether region files do not exist
The repeated I/O of creating the directory for the regionfile
or for checking if the file exists can be heavy in
when pushing chunk generation extremely hard - as each chunk gen
request may effectively go through to the I/O thread.
2023-03-02 23:26:47 -08:00