From dc621507f55a14d278a359d247e62134556a136a Mon Sep 17 00:00:00 2001 From: Owen <23108066+Owen1212055@users.noreply.github.com> Date: Tue, 26 Dec 2023 15:00:21 -0500 Subject: [PATCH] Catch async usage of playsound (#10021) --- patches/server/0010-Adventure.patch | 17 ++++++--- patches/server/0011-Paper-command.patch | 4 +-- ...llow-Reloading-of-Custom-Permissions.patch | 4 +-- ...2-Allow-Reloading-of-Command-Aliases.patch | 4 +-- ...n-option-to-prevent-player-names-fro.patch | 4 +-- .../server/0138-Basic-PlayerProfile-API.patch | 4 +-- ...ld.spawnParticle-API-and-add-Builder.patch | 4 +-- ...ault-permission-message-configurable.patch | 4 +-- ...310-Expose-the-internal-current-tick.patch | 4 +-- ...354-Expose-MinecraftServer-isRunning.patch | 4 +-- .../server/0387-Implement-Mob-Goal-API.patch | 4 +-- ...-Plugin-Tickets-to-API-Chunk-Methods.patch | 6 ++-- .../0513-Added-WorldGameRuleChangeEvent.patch | 6 ++-- patches/server/0573-More-World-API.patch | 4 +-- .../server/0588-Add-basic-Datapack-API.patch | 4 +-- ...0665-Improve-and-expand-AsyncCatcher.patch | 36 +++++++++++++++++++ patches/server/0763-Custom-Potion-Mixes.patch | 4 +-- ...s-ServerLevel-for-gamerule-callbacks.patch | 6 ++-- ...-on-plugins-accessing-faraway-chunks.patch | 4 +-- ...ingEffect-powers-lightning-rods-and-.patch | 6 ++-- 20 files changed, 88 insertions(+), 45 deletions(-) diff --git a/patches/server/0010-Adventure.patch b/patches/server/0010-Adventure.patch index 978296fb1b..30dd4ffc50 100644 --- a/patches/server/0010-Adventure.patch +++ b/patches/server/0010-Adventure.patch @@ -3309,7 +3309,7 @@ index 23bdb77690ba15bcbbfb0c70af23336d08ac7752..8f144a357174bbe096ac9b38a5e67a61 } collection = icons; diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 0a39f95c77f0a2015200bb95b17eee9cbe95c416..67e90e18793852baf6dbd1aa41351a6943ef3d07 100644 +index 0a39f95c77f0a2015200bb95b17eee9cbe95c416..4e155510337d73cd65f722c1360d87d14312b874 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -608,8 +608,10 @@ public final class CraftServer implements Server { @@ -3439,7 +3439,7 @@ index 0a39f95c77f0a2015200bb95b17eee9cbe95c416..67e90e18793852baf6dbd1aa41351a69 @Override public String getMotd() { return this.console.getMotd(); -@@ -2534,4 +2591,53 @@ public final class CraftServer implements Server { +@@ -2534,4 +2591,57 @@ public final class CraftServer implements Server { return this.spigot; } // Spigot end @@ -3447,6 +3447,7 @@ index 0a39f95c77f0a2015200bb95b17eee9cbe95c416..67e90e18793852baf6dbd1aa41351a69 + // Paper start - adventure sounds + @Override + public void playSound(final net.kyori.adventure.sound.Sound sound) { ++ if (sound.seed().isEmpty()) org.spigotmc.AsyncCatcher.catchOp("play sound; cannot generate seed with world random"); // Paper + final long seed = sound.seed().orElseGet(this.console.overworld().getRandom()::nextLong); + for (ServerPlayer player : this.playerList.getPlayers()) { + player.connection.send(io.papermc.paper.adventure.PaperAdventure.asSoundPacket(sound, player.getX(), player.getY(), player.getZ(), seed, null)); @@ -3455,17 +3456,20 @@ index 0a39f95c77f0a2015200bb95b17eee9cbe95c416..67e90e18793852baf6dbd1aa41351a69 + + @Override + public void playSound(final net.kyori.adventure.sound.Sound sound, final double x, final double y, final double z) { ++ org.spigotmc.AsyncCatcher.catchOp("play sound"); // Paper + io.papermc.paper.adventure.PaperAdventure.asSoundPacket(sound, x, y, z, sound.seed().orElseGet(this.console.overworld().getRandom()::nextLong), this.playSound0(x, y, z, this.console.getAllLevels())); + } + + @Override + public void playSound(final net.kyori.adventure.sound.Sound sound, final net.kyori.adventure.sound.Sound.Emitter emitter) { ++ if (sound.seed().isEmpty()) org.spigotmc.AsyncCatcher.catchOp("play sound; cannot generate seed with world random"); // Paper + final long seed = sound.seed().orElseGet(this.console.overworld().getRandom()::nextLong); + if (emitter == net.kyori.adventure.sound.Sound.Emitter.self()) { + for (ServerPlayer player : this.playerList.getPlayers()) { + player.connection.send(io.papermc.paper.adventure.PaperAdventure.asSoundPacket(sound, player, seed, null)); + } + } else if (emitter instanceof org.bukkit.craftbukkit.entity.CraftEntity craftEntity) { ++ org.spigotmc.AsyncCatcher.catchOp("play sound; cannot use entity emitter"); // Paper + final net.minecraft.world.entity.Entity entity = craftEntity.getHandle(); + io.papermc.paper.adventure.PaperAdventure.asSoundPacket(sound, entity, seed, this.playSound0(entity.getX(), entity.getY(), entity.getZ(), List.of((ServerLevel) entity.level()))); + } else { @@ -3494,7 +3498,7 @@ index 0a39f95c77f0a2015200bb95b17eee9cbe95c416..67e90e18793852baf6dbd1aa41351a69 + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 8bc43dde03f461d9f7470c521f47e959d07cde67..1ae3d9fc4ed6bba1881079b86b965e2f51bcb5e2 100644 +index 8bc43dde03f461d9f7470c521f47e959d07cde67..d98020ea7f56418fdab03c7e7772ce062672b728 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -155,6 +155,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @@ -3505,13 +3509,14 @@ index 8bc43dde03f461d9f7470c521f47e959d07cde67..1ae3d9fc4ed6bba1881079b86b965e2f private static final Random rand = new Random(); -@@ -1646,6 +1647,39 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1646,6 +1647,42 @@ public class CraftWorld extends CraftRegionAccessor implements World { entityTracker.broadcastAndSend(packet); } } + // Paper start - Adventure + @Override + public void playSound(final net.kyori.adventure.sound.Sound sound) { ++ org.spigotmc.AsyncCatcher.catchOp("play sound"); // Paper + final long seed = sound.seed().orElseGet(this.world.getRandom()::nextLong); + for (ServerPlayer player : this.getHandle().players()) { + player.connection.send(io.papermc.paper.adventure.PaperAdventure.asSoundPacket(sound, player.getX(), player.getY(), player.getZ(), seed, null)); @@ -3520,11 +3525,13 @@ index 8bc43dde03f461d9f7470c521f47e959d07cde67..1ae3d9fc4ed6bba1881079b86b965e2f + + @Override + public void playSound(final net.kyori.adventure.sound.Sound sound, final double x, final double y, final double z) { ++ org.spigotmc.AsyncCatcher.catchOp("play sound"); // Paper + io.papermc.paper.adventure.PaperAdventure.asSoundPacket(sound, x, y, z, sound.seed().orElseGet(this.world.getRandom()::nextLong), this.playSound0(x, y, z)); + } + + @Override + public void playSound(final net.kyori.adventure.sound.Sound sound, final net.kyori.adventure.sound.Sound.Emitter emitter) { ++ org.spigotmc.AsyncCatcher.catchOp("play sound"); // Paper + final long seed = sound.seed().orElseGet(this.getHandle().getRandom()::nextLong); + if (emitter == net.kyori.adventure.sound.Sound.Emitter.self()) { + for (ServerPlayer player : this.getHandle().players()) { @@ -3545,7 +3552,7 @@ index 8bc43dde03f461d9f7470c521f47e959d07cde67..1ae3d9fc4ed6bba1881079b86b965e2f private static Map> gamerules; public static synchronized Map> getGameRulesNMS() { -@@ -2054,5 +2088,18 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2054,5 +2091,18 @@ public class CraftWorld extends CraftRegionAccessor implements World { return ret; } diff --git a/patches/server/0011-Paper-command.patch b/patches/server/0011-Paper-command.patch index 7d030d45dc..32ca916d95 100644 --- a/patches/server/0011-Paper-command.patch +++ b/patches/server/0011-Paper-command.patch @@ -617,7 +617,7 @@ index 458c04786f7b56f3c006e1e717c0ac709fddb1a0..6c83df6290e4ec59c596f1b9e2f10f0a this.setPvpAllowed(dedicatedserverproperties.pvp); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 67e90e18793852baf6dbd1aa41351a6943ef3d07..5f03d77a64e5ba2e86343599e0faafecbda316b1 100644 +index 085844c5257c667838f637e98f32688b5e2ceaca..b7a7258321b5c312b9697ce40c1ea7bee469b3fc 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -939,6 +939,7 @@ public final class CraftServer implements Server { @@ -628,7 +628,7 @@ index 67e90e18793852baf6dbd1aa41351a6943ef3d07..5f03d77a64e5ba2e86343599e0faafec this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*"); this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions"); -@@ -2631,6 +2632,34 @@ public final class CraftServer implements Server { +@@ -2635,6 +2636,34 @@ public final class CraftServer implements Server { // Paper end // Paper start diff --git a/patches/server/0066-Allow-Reloading-of-Custom-Permissions.patch b/patches/server/0066-Allow-Reloading-of-Custom-Permissions.patch index 36fa504007..fbfb36d4e2 100644 --- a/patches/server/0066-Allow-Reloading-of-Custom-Permissions.patch +++ b/patches/server/0066-Allow-Reloading-of-Custom-Permissions.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Allow Reloading of Custom Permissions https://github.com/PaperMC/Paper/issues/49 diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index fb2b1c13538ed7123beb3d1bc9169a2b313e87ea..4eb1a2bbdb03973e38ec7cdc93601ddab3e44f8e 100644 +index 88e37ce4f8bfd9dd6681c16d0dcfdf3cae8b9f12..01a281dd074726f417c43db33f36a5cfce02d058 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -2717,5 +2717,23 @@ public final class CraftServer implements Server { +@@ -2721,5 +2721,23 @@ public final class CraftServer implements Server { } return this.adventure$audiences; } diff --git a/patches/server/0112-Allow-Reloading-of-Command-Aliases.patch b/patches/server/0112-Allow-Reloading-of-Command-Aliases.patch index ece1b73341..b01f90503e 100644 --- a/patches/server/0112-Allow-Reloading-of-Command-Aliases.patch +++ b/patches/server/0112-Allow-Reloading-of-Command-Aliases.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Allow Reloading of Command Aliases Reload the aliases stored in commands.yml diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index a7c5f9b5c734243c81894e6b073e9ccef191f296..4cc530605843faf8ce296ed34314592250fa9f9f 100644 +index 4e08bf3b40fc066359898259c49ad98edbb4143d..3dca4710f2d95febd9a5c2f64ab50f13c825b472 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -2743,5 +2743,24 @@ public final class CraftServer implements Server { +@@ -2747,5 +2747,24 @@ public final class CraftServer implements Server { DefaultPermissions.registerCorePermissions(); CraftDefaultPermissions.registerCorePermissions(); } diff --git a/patches/server/0131-Add-configuration-option-to-prevent-player-names-fro.patch b/patches/server/0131-Add-configuration-option-to-prevent-player-names-fro.patch index 2070657485..bf2ba03dfc 100644 --- a/patches/server/0131-Add-configuration-option-to-prevent-player-names-fro.patch +++ b/patches/server/0131-Add-configuration-option-to-prevent-player-names-fro.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Add configuration option to prevent player names from being diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 4cc530605843faf8ce296ed34314592250fa9f9f..3be38200f46973dfaa0371337d5ed9544aa0aeaa 100644 +index 3dca4710f2d95febd9a5c2f64ab50f13c825b472..6147774dbfddf50cc2f1fb26ee29122f94d4e009 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -2762,5 +2762,10 @@ public final class CraftServer implements Server { +@@ -2766,5 +2766,10 @@ public final class CraftServer implements Server { commandMap.registerServerAliases(); return true; } diff --git a/patches/server/0138-Basic-PlayerProfile-API.patch b/patches/server/0138-Basic-PlayerProfile-API.patch index 05a9807eb6..e283ed05fa 100644 --- a/patches/server/0138-Basic-PlayerProfile-API.patch +++ b/patches/server/0138-Basic-PlayerProfile-API.patch @@ -612,7 +612,7 @@ index fdf3194499512614355b02aa11e34574cdd89c59..4dc08b0abf0a1edb51cc586d1a89444b String s1 = name.toLowerCase(Locale.ROOT); GameProfileCache.GameProfileInfo usercache_usercacheentry = (GameProfileCache.GameProfileInfo) this.profilesByName.get(s1); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 68d9ba337885ef9158d5f42154526596d8fefe07..a4426373070ca065884ae80e6aa9215df89c741d 100644 +index 5096bc714c6b4731974da5d5cacafd46814f36f7..74fc348a64cfbb119f97e45dacc02512dbe150d5 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -260,6 +260,9 @@ import org.yaml.snakeyaml.error.MarkedYAMLException; @@ -633,7 +633,7 @@ index 68d9ba337885ef9158d5f42154526596d8fefe07..a4426373070ca065884ae80e6aa9215d CraftItemFactory.instance(); } -@@ -2771,5 +2775,42 @@ public final class CraftServer implements Server { +@@ -2775,5 +2779,42 @@ public final class CraftServer implements Server { public boolean suggestPlayerNamesWhenNullTabCompletions() { return io.papermc.paper.configuration.GlobalConfiguration.get().commands.suggestPlayerNamesWhenNullTabCompletions; } diff --git a/patches/server/0191-Expand-World.spawnParticle-API-and-add-Builder.patch b/patches/server/0191-Expand-World.spawnParticle-API-and-add-Builder.patch index 83fa85538f..04bf7ca110 100644 --- a/patches/server/0191-Expand-World.spawnParticle-API-and-add-Builder.patch +++ b/patches/server/0191-Expand-World.spawnParticle-API-and-add-Builder.patch @@ -34,10 +34,10 @@ index 418f9ed95179a234a4f7df3ba5813e9642b5f44c..4190c31fae199e6b6481d2b840f15fe6 if (this.sendParticles(entityplayer, force, d0, d1, d2, packetplayoutworldparticles)) { // CraftBukkit diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index d139361e0a75eaaeabd36d2d134e90d4253972a1..73202aa2fe5f58ad03973de36422f37168426aa6 100644 +index eeb62a48a4c56d3465f74f63278bf76c6abe84ec..ac6bafab570738db2b706bf2b045ea4eec12131c 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -1945,13 +1945,20 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1948,13 +1948,20 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) { diff --git a/patches/server/0277-Make-the-default-permission-message-configurable.patch b/patches/server/0277-Make-the-default-permission-message-configurable.patch index a1e71df95f..e1e9e00d2b 100644 --- a/patches/server/0277-Make-the-default-permission-message-configurable.patch +++ b/patches/server/0277-Make-the-default-permission-message-configurable.patch @@ -18,10 +18,10 @@ index 0dd48e4098191c8b6e29945d62bc473e9f3a1e77..ae51993e0de706cb62c96795ca9de766 } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index f8499f4a70fbbaa99df0cc73aff6405bbbb135ad..ac8478720a4f4cf7016333cdf78f474e165f0492 100644 +index 2f278d75eeacede5081bd7bbabf18ed3f2462f47..f8b947f1fa45d5669cabc71f4b1409a0945e6cc1 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -2804,6 +2804,16 @@ public final class CraftServer implements Server { +@@ -2808,6 +2808,16 @@ public final class CraftServer implements Server { return io.papermc.paper.configuration.GlobalConfiguration.get().commands.suggestPlayerNamesWhenNullTabCompletions; } diff --git a/patches/server/0310-Expose-the-internal-current-tick.patch b/patches/server/0310-Expose-the-internal-current-tick.patch index a7dec7ae2d..e33e3bdd76 100644 --- a/patches/server/0310-Expose-the-internal-current-tick.patch +++ b/patches/server/0310-Expose-the-internal-current-tick.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Expose the internal current tick diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index ac8478720a4f4cf7016333cdf78f474e165f0492..83242862a49e39c40dd8467f1d2a0ac74ced8343 100644 +index f8b947f1fa45d5669cabc71f4b1409a0945e6cc1..58eb725b4f41bad64b2e5f51e5008cf13f2eba15 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -2850,5 +2850,10 @@ public final class CraftServer implements Server { +@@ -2854,5 +2854,10 @@ public final class CraftServer implements Server { profile.getProperties().putAll(((CraftPlayer) player).getHandle().getGameProfile().getProperties()); return new com.destroystokyo.paper.profile.CraftPlayerProfile(profile); } diff --git a/patches/server/0354-Expose-MinecraftServer-isRunning.patch b/patches/server/0354-Expose-MinecraftServer-isRunning.patch index bb5fecfe5f..7d7c6af3d6 100644 --- a/patches/server/0354-Expose-MinecraftServer-isRunning.patch +++ b/patches/server/0354-Expose-MinecraftServer-isRunning.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Expose MinecraftServer#isRunning This allows for plugins to detect if the server is actually turning off in onDisable rather than just plugins reloading. diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 0ace3d1efa29565d02602574347e24ed425c8f35..cc08a752db71b7729f2474e129426153eb4fbc17 100644 +index 4e01f9ef532e141a8b095b275fd4673db4886d36..bf51059e6afa67dae47f42952aaadd6e3db34159 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -2865,5 +2865,10 @@ public final class CraftServer implements Server { +@@ -2869,5 +2869,10 @@ public final class CraftServer implements Server { public int getCurrentTick() { return net.minecraft.server.MinecraftServer.currentTick; } diff --git a/patches/server/0387-Implement-Mob-Goal-API.patch b/patches/server/0387-Implement-Mob-Goal-API.patch index fe80446fd0..7e0cedac72 100644 --- a/patches/server/0387-Implement-Mob-Goal-API.patch +++ b/patches/server/0387-Implement-Mob-Goal-API.patch @@ -794,10 +794,10 @@ index 4379b9948f1eecfe6fd7dea98e298ad5f761019a..3f081183521603824430709886a9cc31 LOOK, JUMP, diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 41bf17ccb60c3f66505539085de83017e2125afe..7ffd0447becaaaf4f26fa5a6be7f6d83bd816fb3 100644 +index b6fb3f6c56d890f4a0b8bfdf691ace17e2e9fc67..b63cf735388872879e3e0641a13ebf8254490a8b 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -2878,5 +2878,11 @@ public final class CraftServer implements Server { +@@ -2882,5 +2882,11 @@ public final class CraftServer implements Server { public boolean isStopping() { return net.minecraft.server.MinecraftServer.getServer().hasStopped(); } diff --git a/patches/server/0417-Add-Plugin-Tickets-to-API-Chunk-Methods.patch b/patches/server/0417-Add-Plugin-Tickets-to-API-Chunk-Methods.patch index 110c1ed390..44ef76e313 100644 --- a/patches/server/0417-Add-Plugin-Tickets-to-API-Chunk-Methods.patch +++ b/patches/server/0417-Add-Plugin-Tickets-to-API-Chunk-Methods.patch @@ -22,7 +22,7 @@ wants it to collect even faster, they can restore that setting back to 1 instead Not adding it to .getType() though to keep behavior consistent with vanilla for performance reasons. diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 1b43d61f3464218bdf5221ffbf87a7280fa8028c..84ff901c4805516bbe438b4ad808e75cd2e15a9d 100644 +index e0a77a76a652e55539e97a58bfab5cd3b1fe6279..7f30a9b4d39e7547441af2f07b29aa0c62de9597 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -377,7 +377,7 @@ public final class CraftServer implements Server { @@ -44,7 +44,7 @@ index 1b43d61f3464218bdf5221ffbf87a7280fa8028c..84ff901c4805516bbe438b4ad808e75c this.printSaveWarning = false; this.console.autosavePeriod = this.configuration.getInt("ticks-per.autosave"); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index dac7ea0b6b8c5ded3e17847cedc81805de80cbe7..453e8160c60fd41b06e84211340f762616422479 100644 +index bf8a645d310a307e5ea7e93a00eb336481100768..8efc044e5a38766aa29cb62db553a8390de50139 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -282,7 +282,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { @@ -116,7 +116,7 @@ index dac7ea0b6b8c5ded3e17847cedc81805de80cbe7..453e8160c60fd41b06e84211340f7626 world.getChunkSource().getChunk(x, z, ChunkStatus.FULL, true); return true; // Paper end -@@ -2266,6 +2281,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2269,6 +2284,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { io.papermc.paper.chunk.system.ChunkSystem.scheduleChunkLoad(this.getHandle(), x, z, gen, ChunkStatus.FULL, true, priority, (c) -> { net.minecraft.server.MinecraftServer.getServer().scheduleOnMain(() -> { net.minecraft.world.level.chunk.LevelChunk chunk = (net.minecraft.world.level.chunk.LevelChunk)c; diff --git a/patches/server/0513-Added-WorldGameRuleChangeEvent.patch b/patches/server/0513-Added-WorldGameRuleChangeEvent.patch index dfdde05b9d..0c45472f91 100644 --- a/patches/server/0513-Added-WorldGameRuleChangeEvent.patch +++ b/patches/server/0513-Added-WorldGameRuleChangeEvent.patch @@ -64,10 +64,10 @@ index 334001cb749600c973c82391e1c11f0e40bd2dfb..2a480026c3bfb06e6556fe5b11d9712c public int get() { diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 37726d7bf6e179130e7ce4f28c2a5d9a26d13c09..69dfd085369bdf0c0bd12b4cb6aa043af0159352 100644 +index 52628759695a441ff21f3077cfe9f75a6e999456..3fbc0ea59ac2e56e3f024104c7904614827c8e04 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -1927,8 +1927,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1930,8 +1930,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { if (!this.isGameRule(rule)) return false; @@ -82,7 +82,7 @@ index 37726d7bf6e179130e7ce4f28c2a5d9a26d13c09..69dfd085369bdf0c0bd12b4cb6aa043a handle.onChanged(this.getHandle().getServer()); return true; } -@@ -1964,8 +1969,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1967,8 +1972,12 @@ public class CraftWorld extends CraftRegionAccessor implements World { if (!this.isGameRule(rule.getName())) return false; diff --git a/patches/server/0573-More-World-API.patch b/patches/server/0573-More-World-API.patch index 7200ddd8ef..ce1ceead86 100644 --- a/patches/server/0573-More-World-API.patch +++ b/patches/server/0573-More-World-API.patch @@ -5,10 +5,10 @@ Subject: [PATCH] More World API diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 69dfd085369bdf0c0bd12b4cb6aa043af0159352..52baae96454715658505eba2cf9472aa71c9a1eb 100644 +index 3fbc0ea59ac2e56e3f024104c7904614827c8e04..6ab03cc55658789baedf5374ebb9c0a6c0187826 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -2173,6 +2173,53 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2176,6 +2176,53 @@ public class CraftWorld extends CraftRegionAccessor implements World { return new CraftStructureSearchResult(CraftStructure.minecraftToBukkit(found.getSecond().value()), CraftLocation.toBukkit(found.getFirst(), this)); } diff --git a/patches/server/0588-Add-basic-Datapack-API.patch b/patches/server/0588-Add-basic-Datapack-API.patch index 3492a32538..f0490f3fbd 100644 --- a/patches/server/0588-Add-basic-Datapack-API.patch +++ b/patches/server/0588-Add-basic-Datapack-API.patch @@ -92,7 +92,7 @@ index 0000000000000000000000000000000000000000..cf4374493c11057451a62a655514415c + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 0d0f575c07fc1cc31a3b648720558c6f8d639eb5..cda604e72a6335e18bdff0ab0f1d61d1584fa925 100644 +index 354a8bfb7afc233b2bac6a4904ef6427ae0f7c41..d7fe701f3eb474895c8175c0539afd4875bd0092 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -301,6 +301,7 @@ public final class CraftServer implements Server { @@ -111,7 +111,7 @@ index 0d0f575c07fc1cc31a3b648720558c6f8d639eb5..cda604e72a6335e18bdff0ab0f1d61d1 } public boolean getCommandBlockOverride(String command) { -@@ -2946,5 +2948,11 @@ public final class CraftServer implements Server { +@@ -2950,5 +2952,11 @@ public final class CraftServer implements Server { public com.destroystokyo.paper.entity.ai.MobGoals getMobGoals() { return mobGoals; } diff --git a/patches/server/0665-Improve-and-expand-AsyncCatcher.patch b/patches/server/0665-Improve-and-expand-AsyncCatcher.patch index 4c5e53aac1..b44d9aa474 100644 --- a/patches/server/0665-Improve-and-expand-AsyncCatcher.patch +++ b/patches/server/0665-Improve-and-expand-AsyncCatcher.patch @@ -165,6 +165,42 @@ index bbbf6dd8e566ecdca8794e3b03765fe7e426a2bd..66ab901956ca394c251c420338643d39 if (!this.currentSection.remove(this.entity)) { PersistentEntitySectionManager.LOGGER.warn("Entity {} wasn't found in section {} (destroying due to {})", new Object[]{this.entity, SectionPos.of(this.currentSectionKey), reason}); } +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +index 392714a19fc977678a7a7041d48ff553934ecf51..5910373dfbe561e52c507129d506f68aa9252249 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +@@ -1803,6 +1803,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { + + @Override + public void playSound(Location loc, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch, long seed) { ++ org.spigotmc.AsyncCatcher.catchOp("play sound"); // Paper + if (loc == null || sound == null || category == null) return; + + double x = loc.getX(); +@@ -1814,6 +1815,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { + + @Override + public void playSound(Location loc, String sound, org.bukkit.SoundCategory category, float volume, float pitch, long seed) { ++ org.spigotmc.AsyncCatcher.catchOp("play sound"); // Paper + if (loc == null || sound == null || category == null) return; + + double x = loc.getX(); +@@ -1846,6 +1848,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { + + @Override + public void playSound(Entity entity, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch, long seed) { ++ org.spigotmc.AsyncCatcher.catchOp("play sound"); // Paper + if (!(entity instanceof CraftEntity craftEntity) || entity.getWorld() != this || sound == null || category == null) return; + + ClientboundSoundEntityPacket packet = new ClientboundSoundEntityPacket(CraftSound.bukkitToMinecraftHolder(sound), net.minecraft.sounds.SoundSource.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, seed); +@@ -1857,6 +1860,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { + + @Override + public void playSound(Entity entity, String sound, org.bukkit.SoundCategory category, float volume, float pitch, long seed) { ++ org.spigotmc.AsyncCatcher.catchOp("play sound"); // Paper + if (!(entity instanceof CraftEntity craftEntity) || entity.getWorld() != this || sound == null || category == null) return; + + ClientboundSoundEntityPacket packet = new ClientboundSoundEntityPacket(Holder.direct(SoundEvent.createVariableRangeEvent(new ResourceLocation(sound))), net.minecraft.sounds.SoundSource.valueOf(category.name()), craftEntity.getHandle(), volume, pitch, seed); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index bd5e80a04a035f670160a5eef94805ab90372cf6..3e79a73e42875936e373f797dcde6a60a904a880 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java diff --git a/patches/server/0763-Custom-Potion-Mixes.patch b/patches/server/0763-Custom-Potion-Mixes.patch index b860cd65c7..c7cc845636 100644 --- a/patches/server/0763-Custom-Potion-Mixes.patch +++ b/patches/server/0763-Custom-Potion-Mixes.patch @@ -172,7 +172,7 @@ index 424406d2692856cfd82b6f3b7b6228fa3bd20c2f..c57efcb9a79337ec791e4e8f6671612f @Override diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index be57ec31869e2cf9db131ec64c7581564f2b42e6..37822390d9cf71890a81e66509fa9f5ef77b2f5d 100644 +index 21e66ea18be81dab53be94f95683b5054d9e1a55..80b9727ffd55f2c6b047f10b73fa71757d1f0633 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -304,6 +304,7 @@ public final class CraftServer implements Server { @@ -192,7 +192,7 @@ index be57ec31869e2cf9db131ec64c7581564f2b42e6..37822390d9cf71890a81e66509fa9f5e // Ugly hack :( if (!Main.useConsole) { -@@ -3073,5 +3074,10 @@ public final class CraftServer implements Server { +@@ -3077,5 +3078,10 @@ public final class CraftServer implements Server { return datapackManager; } diff --git a/patches/server/0787-Pass-ServerLevel-for-gamerule-callbacks.patch b/patches/server/0787-Pass-ServerLevel-for-gamerule-callbacks.patch index b4b8c0ab77..fb8ac848b1 100644 --- a/patches/server/0787-Pass-ServerLevel-for-gamerule-callbacks.patch +++ b/patches/server/0787-Pass-ServerLevel-for-gamerule-callbacks.patch @@ -167,10 +167,10 @@ index 2a480026c3bfb06e6556fe5b11d9712c8e02debe..6c1af24f2f02ef5fe1be135b4071362f this.onChanged(server); } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index bbd0bc0e0ccd5e895ba054182024f5480416e849..56a020427757ad4e91f9bffd1e75fe78bcb4d6af 100644 +index 6dbd45103571f033daafe085c5ccb962e5d9a17a..9ced82941e051a77a4832929f10d28f7bce82b0d 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -2031,7 +2031,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2038,7 +2038,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { // Paper end GameRules.Value handle = this.getHandle().getGameRules().getRule(CraftWorld.getGameRulesNMS().get(rule)); handle.deserialize(event.getValue()); // Paper @@ -179,7 +179,7 @@ index bbd0bc0e0ccd5e895ba054182024f5480416e849..56a020427757ad4e91f9bffd1e75fe78 return true; } -@@ -2072,7 +2072,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2079,7 +2079,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { // Paper end GameRules.Value handle = this.getHandle().getGameRules().getRule(CraftWorld.getGameRulesNMS().get(rule.getName())); handle.deserialize(event.getValue()); // Paper diff --git a/patches/server/0824-Warn-on-plugins-accessing-faraway-chunks.patch b/patches/server/0824-Warn-on-plugins-accessing-faraway-chunks.patch index 9b9a5e7d20..b44ffd26eb 100644 --- a/patches/server/0824-Warn-on-plugins-accessing-faraway-chunks.patch +++ b/patches/server/0824-Warn-on-plugins-accessing-faraway-chunks.patch @@ -18,7 +18,7 @@ index 2e96fadbead617096ef6dd96b37f967da9a30395..440e99f24fdbc73fa51d5d3aa8aabfae private static boolean isOutsideSpawnableHeight(int y) { diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 56a020427757ad4e91f9bffd1e75fe78bcb4d6af..c96d1956049eecfb395ad75b971c07dcd4c71107 100644 +index 9ced82941e051a77a4832929f10d28f7bce82b0d..4c5d7988e3feea1b8f50d8c1795a4c4301fe2ecb 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -312,9 +312,24 @@ public class CraftWorld extends CraftRegionAccessor implements World { @@ -86,7 +86,7 @@ index 56a020427757ad4e91f9bffd1e75fe78bcb4d6af..c96d1956049eecfb395ad75b971c07dc // Transient load for this tick return this.world.getChunk(x >> 4, z >> 4).getHeight(CraftHeightMap.toNMS(heightMap), x, z); } -@@ -2417,6 +2437,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2424,6 +2444,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { // Spigot end // Paper start public java.util.concurrent.CompletableFuture getChunkAtAsync(int x, int z, boolean gen, boolean urgent) { diff --git a/patches/server/1035-Fix-strikeLightningEffect-powers-lightning-rods-and-.patch b/patches/server/1035-Fix-strikeLightningEffect-powers-lightning-rods-and-.patch index 5c85aa14e3..5f62f3b55a 100644 --- a/patches/server/1035-Fix-strikeLightningEffect-powers-lightning-rods-and-.patch +++ b/patches/server/1035-Fix-strikeLightningEffect-powers-lightning-rods-and-.patch @@ -46,7 +46,7 @@ index 255fb5e922c63130708e4bcab208b4db52a58387..1e76230c078ef07418345b0bc50c574c BlockState iblockdata = BaseFireBlock.getState(this.level(), blockposition); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index c394e12e73680761d22612c5eec4bac9dd8893e3..e652368f56a3e1f90d0162277d025f696c560ed2 100644 +index 5fc06ade042f96ae9f623b18faaa1069d769153f..fd37494da843e70cbb5e707714ff77724d7ff0bb 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -773,7 +773,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @@ -58,7 +58,7 @@ index c394e12e73680761d22612c5eec4bac9dd8893e3..e652368f56a3e1f90d0162277d025f69 this.world.strikeLightning(lightning, LightningStrikeEvent.Cause.CUSTOM); return (LightningStrike) lightning.getBukkitEntity(); } -@@ -2433,7 +2433,6 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2440,7 +2440,6 @@ public class CraftWorld extends CraftRegionAccessor implements World { { LightningBolt lightning = EntityType.LIGHTNING_BOLT.create( CraftWorld.this.world ); lightning.moveTo( loc.getX(), loc.getY(), loc.getZ() ); @@ -66,7 +66,7 @@ index c394e12e73680761d22612c5eec4bac9dd8893e3..e652368f56a3e1f90d0162277d025f69 CraftWorld.this.world.strikeLightning( lightning, LightningStrikeEvent.Cause.CUSTOM ); return (LightningStrike) lightning.getBukkitEntity(); } -@@ -2443,8 +2442,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2450,8 +2449,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { { LightningBolt lightning = EntityType.LIGHTNING_BOLT.create( CraftWorld.this.world ); lightning.moveTo( loc.getX(), loc.getY(), loc.getZ() );