Skip to content

Commit

Permalink
Merge branch 'PaperMC:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Chaosdave34 authored Nov 26, 2024
2 parents 3c6f17c + 5f0932b commit be36e73
Show file tree
Hide file tree
Showing 15 changed files with 112 additions and 58 deletions.
68 changes: 55 additions & 13 deletions patches/api/0394-Folia-scheduler-and-owned-region-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ the schedulers depending on the result of the ownership check.

diff --git a/src/main/java/io/papermc/paper/threadedregions/scheduler/AsyncScheduler.java b/src/main/java/io/papermc/paper/threadedregions/scheduler/AsyncScheduler.java
new file mode 100644
index 0000000000000000000000000000000000000000..d9cdd04660c5e60e494a8fed91ae437e6cb733ed
index 0000000000000000000000000000000000000000..9852e14e68d12ca56b0d57cd6e83e252f47bde72
--- /dev/null
+++ b/src/main/java/io/papermc/paper/threadedregions/scheduler/AsyncScheduler.java
@@ -0,0 +1,51 @@
Expand Down Expand Up @@ -52,7 +52,7 @@ index 0000000000000000000000000000000000000000..d9cdd04660c5e60e494a8fed91ae437e
+ * @return The {@link ScheduledTask} that represents the scheduled task.
+ */
+ @NotNull ScheduledTask runDelayed(@NotNull Plugin plugin, @NotNull Consumer<ScheduledTask> task, long delay,
+ @NotNull TimeUnit unit);
+ @NotNull TimeUnit unit);
+
+ /**
+ * Schedules the specified task to be executed asynchronously after the initial delay has passed,
Expand All @@ -65,7 +65,7 @@ index 0000000000000000000000000000000000000000..d9cdd04660c5e60e494a8fed91ae437e
+ * @return The {@link ScheduledTask} that represents the scheduled task.
+ */
+ @NotNull ScheduledTask runAtFixedRate(@NotNull Plugin plugin, @NotNull Consumer<ScheduledTask> task,
+ long initialDelay, long period, @NotNull TimeUnit unit);
+ long initialDelay, long period, @NotNull TimeUnit unit);
+
+ /**
+ * Attempts to cancel all tasks scheduled by the specified plugin.
Expand All @@ -75,7 +75,7 @@ index 0000000000000000000000000000000000000000..d9cdd04660c5e60e494a8fed91ae437e
+}
diff --git a/src/main/java/io/papermc/paper/threadedregions/scheduler/EntityScheduler.java b/src/main/java/io/papermc/paper/threadedregions/scheduler/EntityScheduler.java
new file mode 100644
index 0000000000000000000000000000000000000000..9f69e189be8202a0ab1450540f5d12187ba6c987
index 0000000000000000000000000000000000000000..99e9e20ae01f9b4b8cde585d29c57e27c53c996e
--- /dev/null
+++ b/src/main/java/io/papermc/paper/threadedregions/scheduler/EntityScheduler.java
@@ -0,0 +1,104 @@
Expand Down Expand Up @@ -142,7 +142,7 @@ index 0000000000000000000000000000000000000000..9f69e189be8202a0ab1450540f5d1218
+ * @return The {@link ScheduledTask} that represents the scheduled task, or {@code null} if the entity has been removed.
+ */
+ @Nullable ScheduledTask run(@NotNull Plugin plugin, @NotNull Consumer<ScheduledTask> task,
+ @Nullable Runnable retired);
+ @Nullable Runnable retired);
+
+ /**
+ * Schedules a task with the given delay. If the task failed to schedule because the scheduler is retired (entity
Expand All @@ -161,7 +161,7 @@ index 0000000000000000000000000000000000000000..9f69e189be8202a0ab1450540f5d1218
+ * @return The {@link ScheduledTask} that represents the scheduled task, or {@code null} if the entity has been removed.
+ */
+ @Nullable ScheduledTask runDelayed(@NotNull Plugin plugin, @NotNull Consumer<ScheduledTask> task,
+ @Nullable Runnable retired, long delayTicks);
+ @Nullable Runnable retired, long delayTicks);
+
+ /**
+ * Schedules a repeating task with the given delay and period. If the task failed to schedule because the scheduler
Expand All @@ -181,11 +181,11 @@ index 0000000000000000000000000000000000000000..9f69e189be8202a0ab1450540f5d1218
+ * @return The {@link ScheduledTask} that represents the scheduled task, or {@code null} if the entity has been removed.
+ */
+ @Nullable ScheduledTask runAtFixedRate(@NotNull Plugin plugin, @NotNull Consumer<ScheduledTask> task,
+ @Nullable Runnable retired, long initialDelayTicks, long periodTicks);
+ @Nullable Runnable retired, long initialDelayTicks, long periodTicks);
+}
diff --git a/src/main/java/io/papermc/paper/threadedregions/scheduler/GlobalRegionScheduler.java b/src/main/java/io/papermc/paper/threadedregions/scheduler/GlobalRegionScheduler.java
new file mode 100644
index 0000000000000000000000000000000000000000..365b53fea8dee09cdc11f4399dea5f00c6ee70e2
index 0000000000000000000000000000000000000000..57455aca80ecc458b96b44c086cea94ddcecae47
--- /dev/null
+++ b/src/main/java/io/papermc/paper/threadedregions/scheduler/GlobalRegionScheduler.java
@@ -0,0 +1,58 @@
Expand Down Expand Up @@ -239,7 +239,7 @@ index 0000000000000000000000000000000000000000..365b53fea8dee09cdc11f4399dea5f00
+ * @return The {@link ScheduledTask} that represents the scheduled task.
+ */
+ @NotNull ScheduledTask runAtFixedRate(@NotNull Plugin plugin, @NotNull Consumer<ScheduledTask> task,
+ long initialDelayTicks, long periodTicks);
+ long initialDelayTicks, long periodTicks);
+
+ /**
+ * Attempts to cancel all tasks scheduled by the specified plugin.
Expand Down Expand Up @@ -499,10 +499,10 @@ index 0000000000000000000000000000000000000000..a6b50c9d8af589cc4747e14d343d2045
+ }
+}
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 7919a001e5b5886a3d0fb64913064bc9607a2102..0f0b5b69a6cf7aac62a9802f2778cce4f08cfb88 100644
index 7919a001e5b5886a3d0fb64913064bc9607a2102..42beeecad288a7600d4906877932ccd701ed7cc2 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2696,6 +2696,141 @@ public final class Bukkit {
@@ -2696,6 +2696,164 @@ public final class Bukkit {
}
// Paper end

Expand Down Expand Up @@ -631,6 +631,21 @@ index 7919a001e5b5886a3d0fb64913064bc9607a2102..0f0b5b69a6cf7aac62a9802f2778cce4
+
+ /**
+ * Returns whether the current thread is ticking a region and that the region being ticked
+ * owns the chunks in the rectangle specified by the min and max parameters.
+ * Specifically, this function checks that every chunk with position x in [minChunkX, maxChunkX] and
+ * position z in [minChunkZ, maxChunkZ] is owned by the current ticking region.
+ * @param world Specified world.
+ * @param minChunkX Specified x-coordinate of the minimum chunk position.
+ * @param minChunkZ Specified z-coordinate of the minimum chunk position.
+ * @param maxChunkX Specified x-coordinate of the maximum chunk position.
+ * @param maxChunkZ Specified z-coordinate of the maximum chunk position.
+ */
+ public static boolean isOwnedByCurrentRegion(@NotNull World world, int minChunkX, int minChunkZ, int maxChunkX, int maxChunkZ) {
+ return server.isOwnedByCurrentRegion(world, minChunkX, minChunkZ, maxChunkX, maxChunkZ);
+ }
+
+ /**
+ * Returns whether the current thread is ticking a region and that the region being ticked
+ * owns the specified entity. Note that this function is the only appropriate method of checking
+ * for ownership of an entity, as retrieving the entity's location is undefined unless the entity is owned
+ * by the current region.
Expand All @@ -639,16 +654,24 @@ index 7919a001e5b5886a3d0fb64913064bc9607a2102..0f0b5b69a6cf7aac62a9802f2778cce4
+ public static boolean isOwnedByCurrentRegion(@NotNull Entity entity) {
+ return server.isOwnedByCurrentRegion(entity);
+ }
+
+ /**
+ * Returns whether the current thread is ticking the global region.
+ * @see io.papermc.paper.threadedregions.scheduler.GlobalRegionScheduler
+ */
+ public static boolean isGlobalTickThread() {
+ return server.isGlobalTickThread();
+ }
+ // Paper end - Folia region threading API
+
@NotNull
public static Server.Spigot spigot() {
return server.spigot();
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 2801f4b27bb77e2d5698f82dd14c4a92d2f4392c..01b1aa2af1aac83ac8b341e7ba2803317373056b 100644
index 2801f4b27bb77e2d5698f82dd14c4a92d2f4392c..ecfe4f0079038e0a4541ac71ab590ac18108d1d3 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -2351,4 +2351,119 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -2351,4 +2351,138 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*/
@NotNull org.bukkit.potion.PotionBrewer getPotionBrewer();
// Paper end
Expand Down Expand Up @@ -760,12 +783,31 @@ index 2801f4b27bb77e2d5698f82dd14c4a92d2f4392c..01b1aa2af1aac83ac8b341e7ba280331
+
+ /**
+ * Returns whether the current thread is ticking a region and that the region being ticked
+ * owns the chunks in the rectangle specified by the min and max parameters.
+ * Specifically, this function checks that every chunk with position x in [minChunkX, maxChunkX] and
+ * position z in [minChunkZ, maxChunkZ] is owned by the current ticking region.
+ * @param world Specified world.
+ * @param minChunkX Specified x-coordinate of the minimum chunk position.
+ * @param minChunkZ Specified z-coordinate of the minimum chunk position.
+ * @param maxChunkX Specified x-coordinate of the maximum chunk position.
+ * @param maxChunkZ Specified z-coordinate of the maximum chunk position.
+ */
+ boolean isOwnedByCurrentRegion(@NotNull World world, int minChunkX, int minChunkZ, int maxChunkX, int maxChunkZ);
+
+ /**
+ * Returns whether the current thread is ticking a region and that the region being ticked
+ * owns the specified entity. Note that this function is the only appropriate method of checking
+ * for ownership of an entity, as retrieving the entity's location is undefined unless the entity is owned
+ * by the current region.
+ * @param entity Specified entity.
+ */
+ boolean isOwnedByCurrentRegion(@NotNull Entity entity);
+
+ /**
+ * Returns whether the current thread is ticking the global region.
+ * @see io.papermc.paper.threadedregions.scheduler.GlobalRegionScheduler
+ */
+ public boolean isGlobalTickThread();
+ // Paper end - Folia region threading API
}
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
Expand Down
6 changes: 3 additions & 3 deletions patches/api/0498-API-to-check-if-the-server-is-sleeping.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ Subject: [PATCH] API to check if the server is sleeping


diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 0b78564256ebc647ebac402e549d86ab6e307c8d..ba366576a571214e67bcc529dc1bca19e1d59ef8 100644
index dcd2699654c8848b985309f3739b4967515e41c7..7266d29ab6bb246e6daaa643951417123d42abcb 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -2572,4 +2572,11 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -2591,4 +2591,11 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*/
boolean isOwnedByCurrentRegion(@NotNull Entity entity);
public boolean isGlobalTickThread();
// Paper end - Folia region threading API
+
+ // Paper start - API to check if the server is sleeping
Expand Down
4 changes: 2 additions & 2 deletions patches/api/0499-API-to-allow-disallow-tick-sleeping.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] API to allow/disallow tick sleeping


diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index ba366576a571214e67bcc529dc1bca19e1d59ef8..f55638eb8b315864052f9fe17ab4846e5e9d8dbb 100644
index 7266d29ab6bb246e6daaa643951417123d42abcb..a92bd4da6788f1331a4838ab5760baec2dc6e8ec 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -2578,5 +2578,14 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -2597,5 +2597,14 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* Returns whether the server is sleeping/paused.
*/
boolean isPaused();
Expand Down
16 changes: 14 additions & 2 deletions patches/server/0834-Folia-scheduler-and-owned-region-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -1249,10 +1249,10 @@ index 4cced854e750ea9057b4a8d686245925e5dc2868..5a2d33b7da60469f27f9782841b0cf87
public void setLevelCallback(EntityInLevelCallback changeListener) {
this.levelCallback = changeListener;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 5c907eca23d936ba3095f2d81256775edaa737da..1bf51d4a1ffb6ab56c4023c49725e412f4350197 100644
index 5c907eca23d936ba3095f2d81256775edaa737da..4c4fa7bbafb075beb0d9c1ef21e3ba2d62b1ae65 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -313,6 +313,76 @@ public final class CraftServer implements Server {
@@ -313,6 +313,88 @@ public final class CraftServer implements Server {
private final io.papermc.paper.logging.SysoutCatcher sysoutCatcher = new io.papermc.paper.logging.SysoutCatcher(); // Paper
private final io.papermc.paper.potion.PaperPotionBrewer potionBrewer; // Paper - Custom Potion Mixes

Expand Down Expand Up @@ -1321,9 +1321,21 @@ index 5c907eca23d936ba3095f2d81256775edaa737da..1bf51d4a1ffb6ab56c4023c49725e412
+ }
+
+ @Override
+ public final boolean isOwnedByCurrentRegion(World world, int minChunkX, int minChunkZ, int maxChunkX, int maxChunkZ) {
+ return ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(
+ ((CraftWorld) world).getHandle(), minChunkX, minChunkZ, maxChunkX, maxChunkZ
+ );
+ }
+
+ @Override
+ public final boolean isOwnedByCurrentRegion(Entity entity) {
+ return ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(((org.bukkit.craftbukkit.entity.CraftEntity) entity).getHandleRaw());
+ }
+
+ @Override
+ public final boolean isGlobalTickThread() {
+ return ca.spottedleaf.moonrise.common.util.TickThread.isTickThread();
+ }
+ // Paper end - Folia reagion threading API
+
static {
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0840-Use-correct-seed-on-api-world-load.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] Use correct seed on api world load


diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 1bf51d4a1ffb6ab56c4023c49725e412f4350197..d5e8cb8a907385e807c786815cf33f1cd9355f0c 100644
index 4c4fa7bbafb075beb0d9c1ef21e3ba2d62b1ae65..54b5dee7cfd19ad58e376eee80d3827f1a80cfcd 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1388,7 +1388,7 @@ public final class CraftServer implements Server {
@@ -1400,7 +1400,7 @@ public final class CraftServer implements Server {
net.minecraft.server.Main.forceUpgrade(worldSession, DataFixers.getDataFixer(), this.console.options.has("eraseCache"), () -> true, iregistrycustom_dimension, this.console.options.has("recreateRegionFiles"));
}

Expand Down
10 changes: 5 additions & 5 deletions patches/server/0843-API-for-updating-recipes-on-clients.patch
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ index 3a6e918e9db6397b6f1cff531041655298ce087d..efc12d629b71ba1da664d9ecfd4575be

public void reloadRecipes() {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index d5e8cb8a907385e807c786815cf33f1cd9355f0c..8e0d8fafa68d909d1d10c6d6a03cca371c0e6fb3 100644
index 54b5dee7cfd19ad58e376eee80d3827f1a80cfcd..a755137d8d4b266a648cb2a4f41a5ed00262f121 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1178,6 +1178,18 @@ public final class CraftServer implements Server {
@@ -1190,6 +1190,18 @@ public final class CraftServer implements Server {
ReloadCommand.reload(this.console);
}

Expand All @@ -60,7 +60,7 @@ index d5e8cb8a907385e807c786815cf33f1cd9355f0c..8e0d8fafa68d909d1d10c6d6a03cca37
private void loadIcon() {
this.icon = new CraftIconCache(null);
try {
@@ -1557,6 +1569,13 @@ public final class CraftServer implements Server {
@@ -1569,6 +1581,13 @@ public final class CraftServer implements Server {

@Override
public boolean addRecipe(Recipe recipe) {
Expand All @@ -74,7 +74,7 @@ index d5e8cb8a907385e807c786815cf33f1cd9355f0c..8e0d8fafa68d909d1d10c6d6a03cca37
CraftRecipe toAdd;
if (recipe instanceof CraftRecipe) {
toAdd = (CraftRecipe) recipe;
@@ -1588,6 +1607,11 @@ public final class CraftServer implements Server {
@@ -1600,6 +1619,11 @@ public final class CraftServer implements Server {
}
}
toAdd.addToCraftingManager();
Expand All @@ -86,7 +86,7 @@ index d5e8cb8a907385e807c786815cf33f1cd9355f0c..8e0d8fafa68d909d1d10c6d6a03cca37
return true;
}

@@ -1768,9 +1792,23 @@ public final class CraftServer implements Server {
@@ -1780,9 +1804,23 @@ public final class CraftServer implements Server {

@Override
public boolean removeRecipe(NamespacedKey recipeKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] Deprecate and replace methods with old StructureType


diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 8e0d8fafa68d909d1d10c6d6a03cca371c0e6fb3..ee79e3374b50ba21620a9685975a0341c15f313b 100644
index a755137d8d4b266a648cb2a4f41a5ed00262f121..eaea08530ca864158a2fa15dca38ca0c25a49bde 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2007,6 +2007,11 @@ public final class CraftServer implements Server {
@@ -2019,6 +2019,11 @@ public final class CraftServer implements Server {

ServerLevel worldServer = ((CraftWorld) world).getHandle();
Location structureLocation = world.locateNearestStructure(location, structureType, radius, findUnexplored);
Expand All @@ -20,7 +20,7 @@ index 8e0d8fafa68d909d1d10c6d6a03cca371c0e6fb3..ee79e3374b50ba21620a9685975a0341
BlockPos structurePosition = CraftLocation.toBlockPosition(structureLocation);

// Create map with trackPlayer = true, unlimitedTracking = true
@@ -2017,6 +2022,31 @@ public final class CraftServer implements Server {
@@ -2029,6 +2034,31 @@ public final class CraftServer implements Server {

return CraftItemStack.asBukkitCopy(stack);
}
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0917-Add-Lifecycle-Event-system.patch
Original file line number Diff line number Diff line change
Expand Up @@ -727,10 +727,10 @@ index 2e96308696e131f3f013469a395e5ddda2c5d529..65a66e484c1c39c5f41d97db52f31c67
} catch (Throwable e) {
LOGGER.error("Failed to run bootstrapper for %s. This plugin will not be loaded.".formatted(provider.getSource()), e);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index ee79e3374b50ba21620a9685975a0341c15f313b..7cc96d03472a4cb94e679251f0969995284f7eaa 100644
index eaea08530ca864158a2fa15dca38ca0c25a49bde..b4a823a62d7088262b7f799c977aec71f8778ff5 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1050,6 +1050,11 @@ public final class CraftServer implements Server {
@@ -1062,6 +1062,11 @@ public final class CraftServer implements Server {

@Override
public void reload() {
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0922-improve-BanList-types.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] improve BanList types


diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 7cc96d03472a4cb94e679251f0969995284f7eaa..54ef70eff81194c85d6433d00382a5909b6d797f 100644
index b4a823a62d7088262b7f799c977aec71f8778ff5..0d62694e2f9086702eaca7a11799eb90a06ce853 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2260,6 +2260,21 @@ public final class CraftServer implements Server {
@@ -2272,6 +2272,21 @@ public final class CraftServer implements Server {
};
}

Expand Down
Loading

0 comments on commit be36e73

Please sign in to comment.