2024-02-05 12:31:51 +01:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Nassim Jahnke <nassim@njahnke.dev>
|
|
|
|
Date: Mon, 5 Feb 2024 11:54:04 +0100
|
|
|
|
Subject: [PATCH] Improve tag parser handling
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/com/mojang/brigadier/CommandDispatcher.java b/src/main/java/com/mojang/brigadier/CommandDispatcher.java
|
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
|
|
--- a/src/main/java/com/mojang/brigadier/CommandDispatcher.java
|
|
|
|
+++ b/src/main/java/com/mojang/brigadier/CommandDispatcher.java
|
|
|
|
@@ -0,0 +0,0 @@ public class CommandDispatcher<S> {
|
2024-02-18 12:53:27 +01:00
|
|
|
}
|
|
|
|
final CommandContextBuilder<S> context = contextSoFar.copy();
|
|
|
|
final StringReader reader = new StringReader(originalReader);
|
|
|
|
+ boolean stop = false; // Paper - Handle non-recoverable exceptions
|
2024-02-05 12:31:51 +01:00
|
|
|
try {
|
|
|
|
try {
|
|
|
|
child.parse(reader, context);
|
2024-02-18 12:53:27 +01:00
|
|
|
+ // Paper start - Handle non-recoverable exceptions
|
2024-03-26 16:38:26 +01:00
|
|
|
+ } catch (final io.papermc.paper.brigadier.TagParseCommandSyntaxException e) {
|
2024-02-18 12:53:27 +01:00
|
|
|
+ stop = true;
|
2024-02-05 12:31:51 +01:00
|
|
|
+ throw e;
|
2024-02-18 12:53:27 +01:00
|
|
|
+ // Paper end - Handle non-recoverable exceptions
|
2024-02-05 12:31:51 +01:00
|
|
|
} catch (final RuntimeException ex) {
|
|
|
|
throw CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherParseException().createWithContext(reader, ex.getMessage());
|
|
|
|
}
|
2024-02-18 12:53:27 +01:00
|
|
|
@@ -0,0 +0,0 @@ public class CommandDispatcher<S> {
|
|
|
|
}
|
|
|
|
errors.put(child, ex);
|
|
|
|
reader.setCursor(cursor);
|
|
|
|
+ if (stop) return new ParseResults<>(contextSoFar, originalReader, errors); // Paper - Handle non-recoverable exceptions
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2024-03-26 16:38:26 +01:00
|
|
|
diff --git a/src/main/java/io/papermc/paper/brigadier/TagParseCommandSyntaxException.java b/src/main/java/io/papermc/paper/brigadier/TagParseCommandSyntaxException.java
|
2024-02-18 12:53:27 +01:00
|
|
|
new file mode 100644
|
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
|
|
|
--- /dev/null
|
2024-03-26 16:38:26 +01:00
|
|
|
+++ b/src/main/java/io/papermc/paper/brigadier/TagParseCommandSyntaxException.java
|
2024-02-18 12:53:27 +01:00
|
|
|
@@ -0,0 +0,0 @@
|
2024-03-26 16:38:26 +01:00
|
|
|
+package io.papermc.paper.brigadier;
|
2024-02-18 12:53:27 +01:00
|
|
|
+
|
|
|
|
+import com.mojang.brigadier.LiteralMessage;
|
2024-03-26 16:38:26 +01:00
|
|
|
+import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
|
|
|
+import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
2024-02-18 12:53:27 +01:00
|
|
|
+import net.minecraft.network.chat.Component;
|
|
|
|
+
|
|
|
|
+public final class TagParseCommandSyntaxException extends CommandSyntaxException {
|
|
|
|
+
|
|
|
|
+ private static final SimpleCommandExceptionType EXCEPTION_TYPE = new SimpleCommandExceptionType(new LiteralMessage("Error parsing NBT"));
|
|
|
|
+
|
|
|
|
+ public TagParseCommandSyntaxException(final String message) {
|
|
|
|
+ super(EXCEPTION_TYPE, Component.literal(message));
|
|
|
|
+ }
|
|
|
|
+}
|
2024-02-05 12:31:51 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/nbt/TagParser.java b/src/main/java/net/minecraft/nbt/TagParser.java
|
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
|
|
--- a/src/main/java/net/minecraft/nbt/TagParser.java
|
|
|
|
+++ b/src/main/java/net/minecraft/nbt/TagParser.java
|
|
|
|
@@ -0,0 +0,0 @@ public class TagParser {
|
|
|
|
}, CompoundTag::toString);
|
2024-04-25 12:27:57 +02:00
|
|
|
public static final Codec<CompoundTag> LENIENT_CODEC = Codec.withAlternative(AS_CODEC, CompoundTag.CODEC);
|
2024-02-05 12:31:51 +01:00
|
|
|
private final StringReader reader;
|
|
|
|
+ private int depth; // Paper
|
|
|
|
|
|
|
|
public static CompoundTag parseTag(String string) throws CommandSyntaxException {
|
2024-04-12 21:14:06 +02:00
|
|
|
return new TagParser(new StringReader(string)).readSingleStruct();
|
2024-02-05 12:31:51 +01:00
|
|
|
@@ -0,0 +0,0 @@ public class TagParser {
|
|
|
|
|
|
|
|
public CompoundTag readStruct() throws CommandSyntaxException {
|
|
|
|
this.expect('{');
|
|
|
|
+ this.increaseDepth(); // Paper
|
|
|
|
CompoundTag compoundTag = new CompoundTag();
|
|
|
|
this.reader.skipWhitespace();
|
|
|
|
|
|
|
|
@@ -0,0 +0,0 @@ public class TagParser {
|
|
|
|
}
|
|
|
|
|
|
|
|
this.expect('}');
|
|
|
|
+ this.depth--; // Paper
|
|
|
|
return compoundTag;
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -0,0 +0,0 @@ public class TagParser {
|
|
|
|
if (!this.reader.canRead()) {
|
|
|
|
throw ERROR_EXPECTED_VALUE.createWithContext(this.reader);
|
|
|
|
} else {
|
|
|
|
+ this.increaseDepth(); // Paper
|
|
|
|
ListTag listTag = new ListTag();
|
|
|
|
TagType<?> tagType = null;
|
|
|
|
|
|
|
|
@@ -0,0 +0,0 @@ public class TagParser {
|
|
|
|
}
|
|
|
|
|
|
|
|
this.expect(']');
|
|
|
|
+ this.depth--; // Paper
|
|
|
|
return listTag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -0,0 +0,0 @@ public class TagParser {
|
|
|
|
this.reader.skipWhitespace();
|
|
|
|
this.reader.expect(c);
|
|
|
|
}
|
|
|
|
+
|
2024-02-18 12:53:27 +01:00
|
|
|
+ private void increaseDepth() throws CommandSyntaxException {
|
2024-02-05 12:31:51 +01:00
|
|
|
+ this.depth++;
|
|
|
|
+ if (this.depth > 512) {
|
2024-03-26 16:38:26 +01:00
|
|
|
+ throw new io.papermc.paper.brigadier.TagParseCommandSyntaxException("NBT tag is too complex, depth > 512");
|
2024-02-05 12:31:51 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
}
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
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:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java b/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java
|
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
|
|
--- a/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java
|
|
|
|
+++ b/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java
|
|
|
|
@@ -0,0 +0,0 @@ public class TranslatableContents implements ComponentContents {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public <T> Optional<T> visit(FormattedText.ContentConsumer<T> visitor) {
|
2024-03-25 13:26:01 +01:00
|
|
|
+ // Paper start - Count visited parts
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
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:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
+ try {
|
|
|
|
+ return this.visit(new TranslatableContentConsumer<>(visitor));
|
2024-03-25 13:26:01 +01:00
|
|
|
+ } catch (IllegalArgumentException ignored) {
|
|
|
|
+ return visitor.accept("...");
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
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:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ private <T> Optional<T> visit(TranslatableContentConsumer<T> visitor) {
|
2024-03-25 13:26:01 +01:00
|
|
|
+ // Paper end - Count visited parts
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
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:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
this.decompose();
|
|
|
|
|
2024-04-12 21:14:06 +02:00
|
|
|
for (FormattedText formattedText : this.decomposedParts) {
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
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:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
@@ -0,0 +0,0 @@ public class TranslatableContents implements ComponentContents {
|
|
|
|
|
|
|
|
return Optional.empty();
|
|
|
|
}
|
2024-03-25 13:26:01 +01:00
|
|
|
+ // Paper start - Count visited parts
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
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:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
+ private static final class TranslatableContentConsumer<T> implements FormattedText.ContentConsumer<T> {
|
2024-03-25 13:26:01 +01:00
|
|
|
+ private static final IllegalArgumentException EX = new IllegalArgumentException("Too long");
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
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:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
+ private final FormattedText.ContentConsumer<T> visitor;
|
|
|
|
+ private int visited;
|
|
|
|
+
|
|
|
|
+ private TranslatableContentConsumer(FormattedText.ContentConsumer<T> visitor) {
|
|
|
|
+ this.visitor = visitor;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Optional<T> accept(final String asString) {
|
|
|
|
+ if (visited++ > 32) {
|
2024-03-25 13:26:01 +01:00
|
|
|
+ throw EX;
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
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:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
+ }
|
|
|
|
+ return this.visitor.accept(asString);
|
|
|
|
+ }
|
|
|
|
+ }
|
2024-03-25 13:26:01 +01:00
|
|
|
+ // Paper end - Count visited parts
|
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
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:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public MutableComponent resolve(@Nullable CommandSourceStack source, @Nullable Entity sender, int depth) throws CommandSyntaxException {
|
2024-02-05 12:31:51 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundCommandSuggestionPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundCommandSuggestionPacket.java
|
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
|
|
--- a/src/main/java/net/minecraft/network/protocol/game/ServerboundCommandSuggestionPacket.java
|
|
|
|
+++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundCommandSuggestionPacket.java
|
|
|
|
@@ -0,0 +0,0 @@ public class ServerboundCommandSuggestionPacket implements Packet<ServerGamePack
|
|
|
|
|
2024-04-25 12:27:57 +02:00
|
|
|
private ServerboundCommandSuggestionPacket(FriendlyByteBuf buf) {
|
2024-02-05 12:31:51 +01:00
|
|
|
this.id = buf.readVarInt();
|
|
|
|
- this.command = buf.readUtf(32500);
|
|
|
|
+ this.command = buf.readUtf(2048); // Paper
|
|
|
|
}
|
|
|
|
|
2024-04-25 12:27:57 +02:00
|
|
|
private void write(FriendlyByteBuf buf) {
|
2024-02-05 12:31:51 +01:00
|
|
|
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
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Paper end - Don't suggest if tab-complete is disabled
|
|
|
|
+ // Paper start
|
|
|
|
+ final int index;
|
|
|
|
+ if (packet.getCommand().length() > 64 && ((index = packet.getCommand().indexOf(' ')) == -1 || index >= 64)) {
|
|
|
|
+ this.disconnect(Component.translatable("disconnect.spam"), org.bukkit.event.player.PlayerKickEvent.Cause.SPAM);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
// Paper start - AsyncTabCompleteEvent
|
|
|
|
TAB_COMPLETE_EXECUTOR.execute(() -> this.handleCustomCommandSuggestions0(packet));
|
|
|
|
}
|
|
|
|
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
|
|
private void sendServerSuggestions(final ServerboundCommandSuggestionPacket packet, final StringReader stringreader) {
|
|
|
|
// Paper end - AsyncTabCompleteEvent
|
2024-02-18 12:53:27 +01:00
|
|
|
ParseResults<CommandSourceStack> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack());
|
|
|
|
+ // Paper start - Handle non-recoverable exceptions
|
|
|
|
+ if (!parseresults.getExceptions().isEmpty()
|
2024-03-26 16:38:26 +01:00
|
|
|
+ && parseresults.getExceptions().values().stream().anyMatch(e -> e instanceof io.papermc.paper.brigadier.TagParseCommandSyntaxException)) {
|
2024-02-05 12:31:51 +01:00
|
|
|
+ this.disconnect(Component.translatable("disconnect.spam"), org.bukkit.event.player.PlayerKickEvent.Cause.SPAM);
|
|
|
|
+ return;
|
|
|
|
+ }
|
2024-02-18 12:53:27 +01:00
|
|
|
+ // Paper end - Handle non-recoverable exceptions
|
2024-02-05 12:31:51 +01:00
|
|
|
|
|
|
|
this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
|
|
|
|
// Paper start - Don't tab-complete namespaced commands if send-namespaced is false
|