diff --git a/patches/server/Rewrite-dataconverter-system.patch b/patches/server/Rewrite-dataconverter-system.patch index 93625c4205..eefbfe9f14 100644 --- a/patches/server/Rewrite-dataconverter-system.patch +++ b/patches/server/Rewrite-dataconverter-system.patch @@ -2528,6 +2528,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import com.google.gson.JsonParser; +import com.google.gson.JsonPrimitive; +import com.mojang.brigadier.exceptions.CommandSyntaxException; ++import com.mojang.logging.LogUtils; +import com.mojang.serialization.Dynamic; +import com.mojang.serialization.JsonOps; +import net.minecraft.SharedConstants; @@ -2536,6 +2537,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.minecraft.nbt.Tag; +import net.minecraft.nbt.TagParser; +import net.minecraft.util.GsonHelper; ++import org.slf4j.Logger; +import java.util.Iterator; +import java.util.function.Supplier; + @@ -2545,6 +2547,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private static final boolean DISABLE_COMMAND_CONVERTER = Boolean.getBoolean("Paper.DisableCommandConverter"); + ++ private static final Logger LOGGER = LogUtils.getLogger(); ++ + public static String toCommandFormat(final CompoundTag components) { + final StringBuilder ret = new StringBuilder(); + ret.append('['); @@ -2587,11 +2591,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + final String cmdString = cmd.getAsString(); + + if ((actionString.equals("suggest_command") && cmdString.startsWith("/")) || actionString.equals("run_command")) { -+ final Object res = MCDataConverter.convert( -+ MCTypeRegistry.DATACONVERTER_CUSTOM_TYPE_COMMAND, cmdString, MCVersions.V1_20_4, SharedConstants.getCurrentVersion().getDataVersion().getVersion() -+ ); -+ if (res instanceof String newCmd) { -+ clickEvent.addProperty("value", newCmd); ++ try { ++ final Object res = MCDataConverter.convert( ++ MCTypeRegistry.DATACONVERTER_CUSTOM_TYPE_COMMAND, cmdString, MCVersions.V1_20_4, SharedConstants.getCurrentVersion().getDataVersion().getVersion() ++ ); ++ if (res instanceof String newCmd) { ++ clickEvent.addProperty("value", newCmd); ++ } ++ } catch (final Exception ex) { ++ LOGGER.error("Failed to convert command '" + cmdString + "'", ex); + } + } + } @@ -2684,6 +2692,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return GsonHelper.toStableString(element); + } catch (final JsonParseException ex) { + return json; ++ } catch (final Exception ex) { ++ LOGGER.error("Failed to convert text component '" + json + "'", ex); ++ return json; + } + } + @@ -2704,7 +2715,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // We use startsWith("/") because we aren't supporting WorldEdit style commands, + // and passing the context of whether the use supports leading slash would be high effort low return -+ return COMMAND_UPGRADER.get().upgradeCommandArguments(cmd, cmd.startsWith("/")); ++ try { ++ return COMMAND_UPGRADER.get().upgradeCommandArguments(cmd, cmd.startsWith("/")); ++ } catch (final Exception ex) { ++ LOGGER.error("Failed to convert command '" + cmd + "'", ex); ++ return null; ++ } + } + }); +