From 8fa3b24907465ea8e28f48283f84f7cb4c78931e Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Tue, 26 Mar 2024 08:38:26 -0700 Subject: [PATCH] [ci skip] move custom brig exception to paper package --- patches/server/Improve-tag-parser-handling.patch | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/patches/server/Improve-tag-parser-handling.patch b/patches/server/Improve-tag-parser-handling.patch index 9996ed519d..91d1197501 100644 --- a/patches/server/Improve-tag-parser-handling.patch +++ b/patches/server/Improve-tag-parser-handling.patch @@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 try { child.parse(reader, context); + // Paper start - Handle non-recoverable exceptions -+ } catch (final com.mojang.brigadier.exceptions.TagParseCommandSyntaxException e) { ++ } catch (final io.papermc.paper.brigadier.TagParseCommandSyntaxException e) { + stop = true; + throw e; + // Paper end - Handle non-recoverable exceptions @@ -32,15 +32,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 --- /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 @@ -+package com.mojang.brigadier.exceptions; ++package io.papermc.paper.brigadier; + +import com.mojang.brigadier.LiteralMessage; ++import com.mojang.brigadier.exceptions.CommandSyntaxException; ++import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; +import net.minecraft.network.chat.Component; + +public final class TagParseCommandSyntaxException extends CommandSyntaxException { @@ -118,7 +120,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private void increaseDepth() throws CommandSyntaxException { + this.depth++; + 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 parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack()); + // Paper start - Handle non-recoverable exceptions + 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); + return; + }