Commit Graph

256 Commits

Author SHA1 Message Date
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
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
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
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
Spottedleaf
bc07c9f31f Fix radius aware executor softlock
The softlock would occur when a dependency tree finished executing
all of its task and searched for the highest dependency tree
to queue tasks from, only to have that such tree be filled
with purged tasks. Because it would select an empty
tree to pull tasks from, it would not select another
tree to execute tasks from as this logic is done after a task
is executed.
2023-03-01 22:22:24 -08:00
Spottedleaf
9443d3ad35 Only attempt to respawn/cancel ender dragon if current region owns 0,0
The only tick thread allowed to touch the dragon fight state is
the one that owns 0,0
2023-03-01 20:10:34 -08:00
Spottedleaf
ac079d0691 Use Folia repo in version checker
Want this to work after it goes public
2023-03-01 19:16:40 -08:00
Spottedleaf
093b1e5394 Fix several issues, mostly saving pending teleporting entities
The place/portal async function now track entities that have been
removed from the world but have not teleported. When the server
shuts down, these entities will have their passenger tree restored
and re-added to the entity slices at the location they were teleporting to,
or in the case of portals that did not run placeAsync yet,
the location they entered the portal on. This should ensure that
for regular teleports that the entity is placed at its correct
target location, and for portalling to ensure that either
the entity is placed at the portal entrace location (where
they entered) or the portal destination. In any case,
the entity is preserved in a location and will survive
the shutdown.

Additionally, move player saving until after the worlds save. This
is to ensure that the save logic is performed only after
all teleportations have completed.

Fix some other misc issues as well:
 - Fix double nether portal creation by checking if a portal exists again
   before creating it, fixing a race condition where two entites would portal
   and neither would see that the other created a portal.
 - Make all remove ticket add an unknown ticket.
   In general this behavior is better since it means that unloads will only
   ever occur at the next tick, rather than during the tick logic. Thus,
   there will be no cases where a chunk is unloaded unexpectedly.
 - Do not use fastFloor for calculating chunk position from block position
   It is not going to return a good value outside of [-1024, 1024]
 - Always perform mid tick update for ticking regionised player chunk loader
   If no entities were loaded, no chunks were loaded, and nothing else -
   the logic would not have otherwise ran. This fixed some rare cases of
   chunks never loading for players after logging in.
2023-03-01 19:12:31 -08:00
Spottedleaf
85c9fb622a Improve thread-safety of ownsRaid
It should null check the position and retrieve it only once.
2023-02-28 06:41:08 -08:00
Spottedleaf
30d90b4700 Make raids thread-safe
We don't need to worry about synchronisation for saving data,
as that is currently only done by the shutdown thread - after
all regions stop ticking.
2023-02-28 06:33:34 -08:00
Spottedleaf
36675a1b9f Make map data thread-safe to access
We can just synchronise on all of the map data accesses, but
this means we need to be careful about ensuring that no
sync loads occur, otherwise we could block other threads for
long periods of time.
2023-02-27 08:37:47 -08:00
Spottedleaf
19fd3efaa6 Increase parallelism for neighbour writing chunk statuses
Namely, everything after FEATURES. By creating a dependency
chain indicating what chunks are in use, we can safely
schedule completely independent tasks in parallel. This
will allow the chunk system to scale beyond 10 threads
per world.

Currently this patch needs some more testing.
2023-02-26 23:45:21 -08:00
Spottedleaf
5a4351d3b6 Improve thread-safety of combat tracker
The simple solution is that we ignore entities/positions that are not
in the current region. Making retrieval of items in inventory
thread-safe is not going to happen.
2023-02-24 00:23:10 -08:00
Spottedleaf
9b824e6406 Fix player chunk loader behaving poorly when limits are low
Need to use ceil() so that it always allows at least 1 addition
for the 50ms case.
2023-02-24 00:03:00 -08:00
Spottedleaf
b772012778 Make the StructureCheck class MT-Safe
This is so that it may be accessed concurrently
from many regions.

Additionally, make sure it does not leak memory by limiting
the number of entries it will cache.
2023-02-23 23:35:30 -08:00
Spottedleaf
6d922d4b48 Implement player sleep status / night skip
Now, all of the sleep status changes are pushed to the global
tick thread. Had to modify the wake up all players routine
to use the task scheduler to ensure the player is woken up
on the right region context.

Fix erroring while crashing on the global tick thread due to
region field being null.
2023-02-23 20:48:49 -08:00
Spottedleaf
2474482685 Remove the remains of per-player mob spawns
Now, the spawning should be running Vanilla logic; except
that it is calculated per region (which is what per player
was effectively achieving anyways).
2023-02-23 20:07:56 -08:00
Spottedleaf
256f68d149 Regionise skip hopper event fields 2023-02-23 19:34:00 -08:00
Spottedleaf
fd7901d0f1 Implement TPA system for test server
Will be removed later once this is all public.

Fixed many issues with teleporting players on vehicles
while in the same region.

Additionaly, make sure dead players are dismounted - as
this logic was previously done by remove.

Re-add regiontodo.txt
2023-02-23 18:42:20 -08:00
Spottedleaf
fa05f7830c Implement BlockEntity#updateTicks
Because game time is now on the global tick thread, we no longer
need adjustments for any block entity. But, just in case we do
updateTicks functions now.
2023-02-23 12:52:39 -08:00
Spottedleaf
5f6b82862f Make BlockEntity#IGNORE_TILE_UPDATES a thread local
Ensures regions do not step over each other
2023-02-23 12:33:43 -08:00
Spottedleaf
18cac6b26e Use Folia comments in threaded regions patch
Other patches planned to be rebased
2023-02-23 08:35:07 -08:00
Spottedleaf
62c1166ee5 Initial commit 2023-02-23 08:13:45 -08:00
Jason Penilla
b19eb28a37
Update 2022-12-13 14:27:38 -07:00
Jason Penilla
aedd5067fd
Update upstream 2022-04-21 20:36:03 -07:00
Jason Penilla
74b34eec95
Lowercase project names and exclude paper-api from paper-mojangapi 2021-12-02 20:58:35 -08:00
Jason Penilla
ad960f72e1
Update upstream 2021-12-02 00:00:38 -08:00
Jason Penilla
53dbd2bc9c
Update upstream & paperweight to 1.2.0 2021-11-16 21:27:00 -08:00
Jason Penilla
ec10cc7b81
Update upstream & paperweight to 1.1.13 2021-11-03 19:59:43 -07:00
Jason Penilla
1a5f02ce1b
Update upstream 2021-10-08 22:39:53 -07:00
Jason Penilla
fe0ed1609c
Update upstream & paperweight to 1.1.12 2021-10-02 18:58:17 -07:00
Jason Penilla
a90d11e921
Update upstream 2021-09-24 19:10:14 -07:00
Jason Penilla
5288d83ece
Update to paperweight 1.1.11 2021-08-24 21:34:59 -07:00
Kyle Wood
b683ff522e
Updates for paperweight 1.0.3 2021-06-16 01:28:10 -05:00
Kyle Wood
192618885a
Update patch for Paper 2021-06-13 15:47:02 -05:00
Kyle Wood
7a5fcc1249
Update for new paperweight 2021-06-12 23:44:00 -05:00
MiniDigger
8001a714db its working now 2021-06-12 20:04:04 +02:00