[ci skip] move custom brig exception to paper package

This commit is contained in:
Jake Potrebic 2024-03-26 08:38:26 -07:00
parent c848b33030
commit 8fa3b24907

View file

@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
try { try {
child.parse(reader, context); child.parse(reader, context);
+ // Paper start - Handle non-recoverable exceptions + // Paper start - Handle non-recoverable exceptions
+ } catch (final com.mojang.brigadier.exceptions.TagParseCommandSyntaxException e) { + } catch (final io.papermc.paper.brigadier.TagParseCommandSyntaxException e) {
+ stop = true; + stop = true;
+ throw e; + throw e;
+ // Paper end - Handle non-recoverable exceptions + // Paper end - Handle non-recoverable exceptions
@ -32,15 +32,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
continue; continue;
} }
diff --git a/src/main/java/com/mojang/brigadier/exceptions/TagParseCommandSyntaxException.java b/src/main/java/com/mojang/brigadier/exceptions/TagParseCommandSyntaxException.java diff --git a/src/main/java/io/papermc/paper/brigadier/TagParseCommandSyntaxException.java b/src/main/java/io/papermc/paper/brigadier/TagParseCommandSyntaxException.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
--- /dev/null --- /dev/null
+++ b/src/main/java/com/mojang/brigadier/exceptions/TagParseCommandSyntaxException.java +++ b/src/main/java/io/papermc/paper/brigadier/TagParseCommandSyntaxException.java
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@
+package com.mojang.brigadier.exceptions; +package io.papermc.paper.brigadier;
+ +
+import com.mojang.brigadier.LiteralMessage; +import com.mojang.brigadier.LiteralMessage;
+import com.mojang.brigadier.exceptions.CommandSyntaxException;
+import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
+import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.Component;
+ +
+public final class TagParseCommandSyntaxException extends CommandSyntaxException { +public final class TagParseCommandSyntaxException extends CommandSyntaxException {
@ -118,7 +120,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private void increaseDepth() throws CommandSyntaxException { + private void increaseDepth() throws CommandSyntaxException {
+ this.depth++; + this.depth++;
+ if (this.depth > 512) { + if (this.depth > 512) {
+ throw new com.mojang.brigadier.exceptions.TagParseCommandSyntaxException("NBT tag is too complex, depth > 512"); + throw new io.papermc.paper.brigadier.TagParseCommandSyntaxException("NBT tag is too complex, depth > 512");
+ } + }
+ } + }
} }
@ -205,7 +207,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
ParseResults<CommandSourceStack> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack()); ParseResults<CommandSourceStack> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack());
+ // Paper start - Handle non-recoverable exceptions + // Paper start - Handle non-recoverable exceptions
+ if (!parseresults.getExceptions().isEmpty() + if (!parseresults.getExceptions().isEmpty()
+ && parseresults.getExceptions().values().stream().anyMatch(e -> e instanceof com.mojang.brigadier.exceptions.TagParseCommandSyntaxException)) { + && parseresults.getExceptions().values().stream().anyMatch(e -> e instanceof io.papermc.paper.brigadier.TagParseCommandSyntaxException)) {
+ this.disconnect(Component.translatable("disconnect.spam"), org.bukkit.event.player.PlayerKickEvent.Cause.SPAM); + this.disconnect(Component.translatable("disconnect.spam"), org.bukkit.event.player.PlayerKickEvent.Cause.SPAM);
+ return; + return;
+ } + }