From 065a01eb161adb381b886c159dcfcd9caf36572c Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 28 May 2025 16:41:29 +0200 Subject: [PATCH] Move event down a little --- .../ServerGamePacketListenerImpl.java.patch | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index 171929bcd9..d14d56ed88 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -1485,7 +1485,7 @@ ParseResults parseResults = this.parseCommand(command); if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseResults)) { LOGGER.error( -@@ -1416,13 +_,24 @@ +@@ -1416,13 +_,21 @@ Optional optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages()); if (!optional.isEmpty()) { this.tryHandleChat(packet.command(), () -> { @@ -1503,22 +1503,24 @@ + if (org.spigotmc.SpigotConfig.logCommands) { + LOGGER.info("{} issued server command: {}", this.player.getScoreboardName(), slashCommand); + } -+ -+ final org.bukkit.event.player.PlayerCommandPreprocessEvent event = new org.bukkit.event.player.PlayerCommandPreprocessEvent(this.getCraftPlayer(), slashCommand, new org.bukkit.craftbukkit.util.LazyPlayerSet(this.server)); -+ event.callEvent(); + // Paper end + ParseResults parseResults = this.parseCommand(packet.command()); Map map; -@@ -1433,11 +_,25 @@ +@@ -1433,11 +_,30 @@ return; } + // Paper start + // Parsing commands to be on main :cryingandshaking: - if that weren't the case, both this and chat could be pushed off to the chat message chain immediately -+ // Always decode message arguments before cancelling -+ if (event.isCancelled() || this.player.isRemoved()) { ++ // Always decode message arguments before cancelling, else the chat chain will be broken ++ if (this.player.isRemoved()) { ++ return; ++ } ++ ++ final org.bukkit.event.player.PlayerCommandPreprocessEvent event = new org.bukkit.event.player.PlayerCommandPreprocessEvent(this.getCraftPlayer(), slashCommand, new org.bukkit.craftbukkit.util.LazyPlayerSet(this.server)); ++ if (!event.callEvent()) { + return; + } +