mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 05:55:44 +01:00
4bc15f13aa
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: e2160a18 Make MapCursor#type not depends on deprecated values CraftBukkit Changes: 6ce172642 SPIGOT-7761: Ender pearl does not damage or spawn endermites f5a63f734 SPIGOT-7759: Chunk not there when requested in ChunkUnloadEvent 28287259c Remove unused import eb9a7dde0 SPIGOT-7757: Cannot set item in Stonecutter Inventory f8be9d752 Move deserialized removed unhandled tags to dedicated removedTags a7e576186 Fix potential mutability issue with CraftMetaItem copy constructor 995885452 SPIGOT-7741: Vanilla ItemComponent in commands can't remove components 9ef69aa0b PR-1284: Move ItemType <-> ItemMeta linking to a centralized place 3e82eafbe PR-1420: Fix DirectEntity and CausingEntity Damager for Creepers ignited by Player c23daa71f SPIGOT-7751: Fix crash caused by arrows from trial spawners Make MapCursor#type not depends on deprecated values SPIGOT-7761: Ender pearl does not damage or spawn endermites
81 lines
4.5 KiB
Diff
81 lines
4.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Thu, 3 Mar 2016 01:17:12 -0600
|
|
Subject: [PATCH] Improve Player chat API handling
|
|
|
|
Properly split up the chat and command handling to reflect the server now
|
|
having separate packets for both, and the client always using the correct packet. Text
|
|
from a chat packet should never be parsed into a command, even if it starts with the `/`
|
|
character.
|
|
|
|
Add a missing async catcher and improve Spigot's async catcher error message.
|
|
|
|
== AT ==
|
|
public net.minecraft.server.network.ServerGamePacketListenerImpl isChatMessageIllegal(Ljava/lang/String;)Z
|
|
|
|
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
|
|
Co-authored-by: SoSeDiK <mrsosedik@gmail.com>
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index c2a22dda4767ec71318cadee8198e8f69a57b56b..6d31f4a9950b526a05fa508ec9da12c1a7fef306 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -2013,7 +2013,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
}
|
|
OutgoingChatMessage outgoing = OutgoingChatMessage.create(original);
|
|
|
|
- if (!async && s.startsWith("/")) {
|
|
+ if (false && !async && s.startsWith("/")) { // Paper - Don't handle commands in chat logic
|
|
this.handleCommand(s);
|
|
} else if (this.player.getChatVisibility() == ChatVisiblity.SYSTEM) {
|
|
// Do nothing, this is coming from a plugin
|
|
@@ -2100,7 +2100,8 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
}
|
|
}
|
|
|
|
- private void handleCommand(String s) {
|
|
+ public void handleCommand(String s) { // Paper - private -> public
|
|
+ org.spigotmc.AsyncCatcher.catchOp("Command Dispatched Async: " + s); // Paper - Add async catcher
|
|
co.aikar.timings.MinecraftTimings.playerCommandTimer.startTiming(); // Paper
|
|
if ( org.spigotmc.SpigotConfig.logCommands ) // Spigot
|
|
this.LOGGER.info(this.player.getScoreboardName() + " issued server command: " + s);
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
index 7c97ec4aa57562a8383a40e493eaa8a3697208bb..78193f0d66c2755ed238824bcd24ced9f9052188 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -925,7 +925,7 @@ public final class CraftServer implements Server {
|
|
public boolean dispatchCommand(CommandSender sender, String commandLine) {
|
|
Preconditions.checkArgument(sender != null, "sender cannot be null");
|
|
Preconditions.checkArgument(commandLine != null, "commandLine cannot be null");
|
|
- org.spigotmc.AsyncCatcher.catchOp("command dispatch"); // Spigot
|
|
+ org.spigotmc.AsyncCatcher.catchOp("Command Dispatched Async: " + commandLine); // Spigot // Paper - Include command in error message
|
|
|
|
if (this.commandMap.dispatch(sender, commandLine)) {
|
|
return true;
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
index 4079cf3d515718a18b41333fbdc96d0c8f56648a..5a8597eac762d311ee8e09f64392e41aee1f13bc 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -546,7 +546,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
|
|
if (this.getHandle().connection == null) return;
|
|
|
|
- this.getHandle().connection.chat(msg, PlayerChatMessage.system(msg), false);
|
|
+ // Paper start - Improve chat handling
|
|
+ if (ServerGamePacketListenerImpl.isChatMessageIllegal(msg)) {
|
|
+ this.getHandle().connection.disconnect(Component.translatable("multiplayer.disconnect.illegal_characters"));
|
|
+ } else {
|
|
+ if (msg.startsWith("/")) {
|
|
+ this.getHandle().connection.handleCommand(msg);
|
|
+ } else {
|
|
+ final PlayerChatMessage playerChatMessage = PlayerChatMessage.system(msg).withUnsignedContent(Component.literal(msg));
|
|
+ // TODO chat decorating
|
|
+ // TODO text filtering
|
|
+ this.getHandle().connection.chat(msg, playerChatMessage, false);
|
|
+ }
|
|
+ }
|
|
+ // Paper end - Improve chat handling
|
|
}
|
|
|
|
@Override
|