From 78a67f00eaef2f5a41714dc12d8579ef21708fc5 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sun, 16 Jun 2024 12:56:00 +0200 Subject: [PATCH] Remove bad server.scheduleOnMain disconnect calls from old patches The new behavior of disconnect to block the current thread until the disconnect succeeded is better than throwing it off to happen at some point --- .../server/Add-PlayerKickEvent-causes.patch | 12 ++++++------ patches/server/Book-Size-Limits.patch | 4 ++-- ...nect-for-book-edit-is-called-on-main.patch | 19 ------------------- patches/server/Limit-recipe-packets.patch | 2 +- 4 files changed, 9 insertions(+), 28 deletions(-) delete mode 100644 patches/server/Ensure-disconnect-for-book-edit-is-called-on-main.patch diff --git a/patches/server/Add-PlayerKickEvent-causes.patch b/patches/server/Add-PlayerKickEvent-causes.patch index 8d9d1f1880..6fd3ee4ca8 100644 --- a/patches/server/Add-PlayerKickEvent-causes.patch +++ b/patches/server/Add-PlayerKickEvent-causes.patch @@ -288,8 +288,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 int byteLength = testString.getBytes(java.nio.charset.StandardCharsets.UTF_8).length; if (byteLength > 256 * 4) { ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send a book with with a page too large!"); -- server.scheduleOnMain(() -> this.disconnect(Component.literal("Book too large!"))); -+ server.scheduleOnMain(() -> this.disconnect(Component.literal("Book too large!"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION)); // Paper - kick event cause +- this.disconnect(Component.literal("Book too large!")); ++ this.disconnect(Component.literal("Book too large!"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause return; } byteTotal += byteLength; @@ -297,8 +297,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (byteTotal > byteAllowed) { ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send too large of a book. Book Size: " + byteTotal + " - Allowed: "+ byteAllowed + " - Pages: " + pageList.size()); -- server.scheduleOnMain(() -> this.disconnect(Component.literal("Book too large!"))); -+ server.scheduleOnMain(() -> this.disconnect(Component.literal("Book too large!"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION)); // Paper - kick event cause +- this.disconnect(Component.literal("Book too large!")); ++ this.disconnect(Component.literal("Book too large!"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause return; } } @@ -404,8 +404,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // Paper start - auto recipe limit if (!org.bukkit.Bukkit.isPrimaryThread()) { if (this.recipeSpamPackets.addAndGet(io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamIncrement) > io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamLimit) { -- this.server.scheduleOnMain(() -> this.disconnect(net.minecraft.network.chat.Component.translatable("disconnect.spam"))); -+ this.server.scheduleOnMain(() -> this.disconnect(net.minecraft.network.chat.Component.translatable("disconnect.spam"), org.bukkit.event.player.PlayerKickEvent.Cause.SPAM)); // Paper - kick event cause +- this.disconnect(net.minecraft.network.chat.Component.translatable("disconnect.spam")); ++ this.disconnect(net.minecraft.network.chat.Component.translatable("disconnect.spam"), org.bukkit.event.player.PlayerKickEvent.Cause.SPAM); // Paper - kick event cause return; } } diff --git a/patches/server/Book-Size-Limits.patch b/patches/server/Book-Size-Limits.patch index a3b15f6af1..7a49f08e7d 100644 --- a/patches/server/Book-Size-Limits.patch +++ b/patches/server/Book-Size-Limits.patch @@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + int byteLength = testString.getBytes(java.nio.charset.StandardCharsets.UTF_8).length; + if (byteLength > 256 * 4) { + ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send a book with with a page too large!"); -+ server.scheduleOnMain(() -> this.disconnect(Component.literal("Book too large!"))); ++ this.disconnect(Component.literal("Book too large!")); + return; + } + byteTotal += byteLength; @@ -47,7 +47,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + if (byteTotal > byteAllowed) { + ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send too large of a book. Book Size: " + byteTotal + " - Allowed: "+ byteAllowed + " - Pages: " + pageList.size()); -+ server.scheduleOnMain(() -> this.disconnect(Component.literal("Book too large!"))); ++ this.disconnect(Component.literal("Book too large!")); + return; + } + } diff --git a/patches/server/Ensure-disconnect-for-book-edit-is-called-on-main.patch b/patches/server/Ensure-disconnect-for-book-edit-is-called-on-main.patch deleted file mode 100644 index 163b593d39..0000000000 --- a/patches/server/Ensure-disconnect-for-book-edit-is-called-on-main.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Shane Freeder -Date: Tue, 22 Jun 2021 19:58:53 +0100 -Subject: [PATCH] Ensure disconnect for book edit is called on main - - -diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - // Paper end - Book size limits - // CraftBukkit start - if (this.lastBookTick + 20 > MinecraftServer.currentTick) { -- this.disconnect(Component.literal("Book edited too quickly!"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause -+ server.scheduleOnMain(() -> this.disconnect(Component.literal("Book edited too quickly!"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION)); // Paper - kick event cause // Paper - Also ensure this is called on main - return; - } - this.lastBookTick = MinecraftServer.currentTick; diff --git a/patches/server/Limit-recipe-packets.patch b/patches/server/Limit-recipe-packets.patch index a5eee77eea..444c51b44c 100644 --- a/patches/server/Limit-recipe-packets.patch +++ b/patches/server/Limit-recipe-packets.patch @@ -31,7 +31,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - auto recipe limit + if (!org.bukkit.Bukkit.isPrimaryThread()) { + if (this.recipeSpamPackets.addAndGet(io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamIncrement) > io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamLimit) { -+ this.server.scheduleOnMain(() -> this.disconnect(net.minecraft.network.chat.Component.translatable("disconnect.spam"))); ++ this.disconnect(net.minecraft.network.chat.Component.translatable("disconnect.spam")); + return; + } + }