From 4e76d3138726c4b631adc0a3b0d3c78a31a73c2e Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sat, 11 Jun 2022 11:02:09 +0200 Subject: [PATCH] Fix some references to obfuscated code --- patches/server/Add-PlayerKickEvent-causes.patch | 2 +- patches/server/Adventure.patch | 4 ++-- patches/server/AsyncTabCompleteEvent.patch | 2 +- .../Break-up-and-make-tab-spam-limits-configurable.patch | 2 +- patches/server/InventoryCloseEvent-Reason-API.patch | 5 ++--- patches/server/MC-4-Fix-item-position-desync.patch | 2 +- .../server/Prevent-opening-inventories-when-frozen.patch | 4 ++-- ....patch => handle-ServerboundKeepAlivePacket-async.patch} | 6 +++--- 8 files changed, 13 insertions(+), 14 deletions(-) rename patches/server/{handle-PacketPlayInKeepAlive-async.patch => handle-ServerboundKeepAlivePacket-async.patch} (86%) diff --git a/patches/server/Add-PlayerKickEvent-causes.patch b/patches/server/Add-PlayerKickEvent-causes.patch index 643bbeab93..f0f9ce6401 100644 --- a/patches/server/Add-PlayerKickEvent-causes.patch +++ b/patches/server/Add-PlayerKickEvent-causes.patch @@ -141,7 +141,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Entity entity = this.player.getRootVehicle(); @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser - // PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.getWorldServer()); // Paper - run this async + // PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); // Paper - run this async // CraftBukkit start if (this.chatSpamTickCount.addAndGet(io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.tabSpamIncrement) > io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.tabSpamLimit && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { // Paper start - split and make configurable - server.scheduleOnMain(() -> this.disconnect(Component.translatable("disconnect.spam", new Object[0]))); // Paper diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index bd03943a2a..8ee17758d1 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -2425,7 +2425,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (adventure$title == null) adventure$title = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(container.getBukkitView().getTitle()); // Paper - player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, CraftChatMessage.fromString(title)[0])); -+ //player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); // Paper // Paper - comment ++ //player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, CraftChatMessage.fromString(title)[0])); // Paper - comment + player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper player.containerMenu = container; player.initMenu(container); @@ -2440,7 +2440,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + //String title = inventory.getTitle(); // Paper - comment + net.kyori.adventure.text.Component adventure$title = inventory.title(); // Paper + if (adventure$title == null) adventure$title = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(inventory.getTitle()); // Paper -+ //player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); // Paper - comment ++ //player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, CraftChatMessage.fromString(title)[0])); // Paper - comment + player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper player.containerMenu = container; player.initMenu(container); diff --git a/patches/server/AsyncTabCompleteEvent.patch b/patches/server/AsyncTabCompleteEvent.patch index 5316d37427..6dfea770cb 100644 --- a/patches/server/AsyncTabCompleteEvent.patch +++ b/patches/server/AsyncTabCompleteEvent.patch @@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void handleCustomCommandSuggestions(ServerboundCommandSuggestionPacket packet) { - PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); -+ // PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.getWorldServer()); // Paper - run this async ++ // PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); // Paper - run this async // CraftBukkit start if (this.chatSpamTickCount.addAndGet(1) > 500 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { - this.disconnect(Component.translatable("disconnect.spam")); diff --git a/patches/server/Break-up-and-make-tab-spam-limits-configurable.patch b/patches/server/Break-up-and-make-tab-spam-limits-configurable.patch index 221127d001..2f9e97a707 100644 --- a/patches/server/Break-up-and-make-tab-spam-limits-configurable.patch +++ b/patches/server/Break-up-and-make-tab-spam-limits-configurable.patch @@ -43,7 +43,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --this.chatSpamTickCount; @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser public void handleCustomCommandSuggestions(ServerboundCommandSuggestionPacket packet) { - // PlayerConnectionUtils.ensureMainThread(packetplayintabcomplete, this, this.player.getWorldServer()); // Paper - run this async + // PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); // Paper - run this async // CraftBukkit start - if (this.chatSpamTickCount.addAndGet(1) > 500 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { + if (this.chatSpamTickCount.addAndGet(io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.tabSpamIncrement) > io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.tabSpamLimit && !this.server.getPlayerList().isOp(this.player.getGameProfile())) { // Paper start - split and make configurable diff --git a/patches/server/InventoryCloseEvent-Reason-API.patch b/patches/server/InventoryCloseEvent-Reason-API.patch index 8d95eb766b..a7390e7bc1 100644 --- a/patches/server/InventoryCloseEvent-Reason-API.patch +++ b/patches/server/InventoryCloseEvent-Reason-API.patch @@ -90,13 +90,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void handleContainerClose(ServerboundContainerClosePacket packet) { -- PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); + // Paper start + handleContainerClose(packet, InventoryCloseEvent.Reason.PLAYER); + } -+ public void handleContainerClose(ServerboundContainerClosePacket packetplayinclosewindow, InventoryCloseEvent.Reason reason) { ++ public void handleContainerClose(ServerboundContainerClosePacket packet, InventoryCloseEvent.Reason reason) { + // Paper end -+ PacketUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.getLevel()); + PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); if (this.player.isImmobile()) return; // CraftBukkit - CraftEventFactory.handleInventoryCloseEvent(this.player); // CraftBukkit diff --git a/patches/server/MC-4-Fix-item-position-desync.patch b/patches/server/MC-4-Fix-item-position-desync.patch index 356baf31c2..46ee5cb911 100644 --- a/patches/server/MC-4-Fix-item-position-desync.patch +++ b/patches/server/MC-4-Fix-item-position-desync.patch @@ -37,7 +37,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - fix MC-4 + if (this instanceof ItemEntity) { + if (io.papermc.paper.configuration.GlobalConfiguration.get().misc.fixEntityPositionDesync) { -+ // encode/decode from PacketPlayOutEntity ++ // encode/decode from ClientboundMoveEntityPacket + x = Mth.lfloor(x * 4096.0D) * (1 / 4096.0D); + y = Mth.lfloor(y * 4096.0D) * (1 / 4096.0D); + z = Mth.lfloor(z * 4096.0D) * (1 / 4096.0D); diff --git a/patches/server/Prevent-opening-inventories-when-frozen.patch b/patches/server/Prevent-opening-inventories-when-frozen.patch index 06ac60c3eb..370b369832 100644 --- a/patches/server/Prevent-opening-inventories-when-frozen.patch +++ b/patches/server/Prevent-opening-inventories-when-frozen.patch @@ -33,7 +33,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { if (adventure$title == null) adventure$title = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(container.getBukkitView().getTitle()); // Paper - //player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); // Paper // Paper - comment + //player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, CraftChatMessage.fromString(title)[0])); // Paper - comment - player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper + if (!player.isImmobile()) player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper player.containerMenu = container; @@ -42,7 +42,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { net.kyori.adventure.text.Component adventure$title = inventory.title(); // Paper if (adventure$title == null) adventure$title = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(inventory.getTitle()); // Paper - //player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); // Paper - comment + //player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, CraftChatMessage.fromString(title)[0])); // Paper - comment - player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper + if (!player.isImmobile()) player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper player.containerMenu = container; diff --git a/patches/server/handle-PacketPlayInKeepAlive-async.patch b/patches/server/handle-ServerboundKeepAlivePacket-async.patch similarity index 86% rename from patches/server/handle-PacketPlayInKeepAlive-async.patch rename to patches/server/handle-ServerboundKeepAlivePacket-async.patch index 587c3619a7..fff231cc7c 100644 --- a/patches/server/handle-PacketPlayInKeepAlive-async.patch +++ b/patches/server/handle-ServerboundKeepAlivePacket-async.patch @@ -1,9 +1,9 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Thu, 5 Oct 2017 01:54:07 +0100 -Subject: [PATCH] handle PacketPlayInKeepAlive async +Subject: [PATCH] handle ServerboundKeepAlivePacket async -In 1.12.2, Mojang moved the processing of PacketPlayInKeepAlive off the main +In 1.12.2, Mojang moved the processing of ServerboundKeepAlivePacket off the main thread, while entirely correct for the server, this causes issues with plugins which are expecting the PlayerQuitEvent on the main thread. @@ -23,7 +23,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public void handleKeepAlive(ServerboundKeepAlivePacket packet) { - PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); // CraftBukkit -+ //PlayerConnectionUtils.ensureMainThread(packetplayinkeepalive, this, this.player.getWorldServer()); // CraftBukkit // Paper - This shouldn't be on the main thread ++ //PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); // CraftBukkit // Paper - This shouldn't be on the main thread if (this.keepAlivePending && packet.getId() == this.keepAliveChallenge) { int i = (int) (Util.getMillis() - this.keepAliveTime);