mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
Fixup command precprocess cancellation (#11424)
This commit is contained in:
parent
e53a1f5e22
commit
300db3cfd0
3 changed files with 82 additions and 2 deletions
|
@ -60,7 +60,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ private static final byte ARRAY_SERIALIZATION_VERSION = 1;
|
||||
+
|
||||
+ /**
|
||||
+ * Serializes a collection of items to raw bytes in NBT. Serializes empty items as null.
|
||||
+ * Serializes a collection of items to raw bytes in NBT. Serializes null items as {@link #empty()}.
|
||||
+ * <p>
|
||||
+ * If you need a string representation to put into a file, you can for example use {@link java.util.Base64} encoding.
|
||||
+ *
|
||||
|
@ -91,7 +91,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Serializes a collection of items to raw bytes in NBT. Serializes empty items as null.
|
||||
+ * Serializes a collection of items to raw bytes in NBT. Serializes null items as {@link #empty()}.
|
||||
+ * <p>
|
||||
+ * If you need a string representation to put into a file, you can for example use {@link java.util.Base64} encoding.
|
||||
+ *
|
||||
|
|
|
@ -1050,6 +1050,34 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
@NotNull
|
||||
@Override
|
||||
public AnvilView getView() {
|
||||
diff --git a/src/main/java/org/bukkit/event/player/PlayerCommandPreprocessEvent.java b/src/main/java/org/bukkit/event/player/PlayerCommandPreprocessEvent.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/event/player/PlayerCommandPreprocessEvent.java
|
||||
+++ b/src/main/java/org/bukkit/event/player/PlayerCommandPreprocessEvent.java
|
||||
@@ -0,0 +0,0 @@ public class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancell
|
||||
*
|
||||
* @param player New player which this event will execute as
|
||||
* @throws IllegalArgumentException if the player provided is null
|
||||
+ * @deprecated Only works for sign commands; use {@link Player#performCommand(String)}, including those cases
|
||||
*/
|
||||
+ @Deprecated(forRemoval = true)
|
||||
public void setPlayer(@NotNull final Player player) throws IllegalArgumentException {
|
||||
Preconditions.checkArgument(player != null, "Player cannot be null");
|
||||
this.player = player;
|
||||
@@ -0,0 +0,0 @@ public class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancell
|
||||
* unmodifiable set.
|
||||
*
|
||||
* @return All Players who will see this chat message
|
||||
- * @deprecated This method is provided for backward compatibility with no
|
||||
- * guarantee to the effect of viewing or modifying the set.
|
||||
+ * @deprecated This is simply the online players. Modifications have no effect
|
||||
*/
|
||||
@NotNull
|
||||
- @Deprecated
|
||||
+ @Deprecated(forRemoval = true)
|
||||
public Set<Player> getRecipients() {
|
||||
return recipients;
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java b/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Nassim Jahnke <nassim@njahnke.dev>
|
||||
Date: Sat, 21 Sep 2024 22:01:52 +0200
|
||||
Subject: [PATCH] Fix PlayerCommandPreprocessEvent on signed commands
|
||||
|
||||
|
||||
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
|
||||
|
||||
PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(this.getCraftPlayer(), command, new LazyPlayerSet(this.server));
|
||||
this.cserver.getPluginManager().callEvent(event);
|
||||
-
|
||||
- if (event.isCancelled()) {
|
||||
- return;
|
||||
- }
|
||||
command = event.getMessage().substring(1);
|
||||
|
||||
- ParseResults<CommandSourceStack> parseresults = this.parseCommand(command);
|
||||
- // CraftBukkit end
|
||||
-
|
||||
- Map map;
|
||||
+ // Paper start - Fix cancellation and message changing
|
||||
+ ParseResults<CommandSourceStack> parseresults = this.parseCommand(packet.command());
|
||||
|
||||
+ Map<String, PlayerChatMessage> map;
|
||||
try {
|
||||
- map = (packet.command().equals(command)) ? this.collectSignedArguments(packet, SignableCommand.of(parseresults), lastSeenMessages) : Collections.emptyMap(); // CraftBukkit
|
||||
+ // Always parse the original command to add to the chat chain
|
||||
+ map = this.collectSignedArguments(packet, SignableCommand.of(parseresults), lastSeenMessages);
|
||||
} catch (SignedMessageChain.DecodeException signedmessagechain_a) {
|
||||
this.handleMessageDecodeFailure(signedmessagechain_a);
|
||||
return;
|
||||
}
|
||||
|
||||
+ if (event.isCancelled()) {
|
||||
+ // Only now are we actually good to return
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // Remove signed parts if the command was changed
|
||||
+ if (!command.equals(packet.command())) {
|
||||
+ parseresults = this.parseCommand(command);
|
||||
+ map = Collections.emptyMap();
|
||||
+ }
|
||||
+ // Paper end - Fix cancellation and message changing
|
||||
+
|
||||
CommandSigningContext.SignedArguments commandsigningcontext_a = new CommandSigningContext.SignedArguments(map);
|
||||
|
||||
parseresults = Commands.<CommandSourceStack>mapSource(parseresults, (commandlistenerwrapper) -> { // CraftBukkit - decompile error
|
Loading…
Reference in a new issue