aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/commands/Commands.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/commands/Commands.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/commands/Commands.java.patch482
1 files changed, 482 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/commands/Commands.java.patch b/patch-remap/mache-spigotflower/net/minecraft/commands/Commands.java.patch
new file mode 100644
index 0000000000..1a4e576de0
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/commands/Commands.java.patch
@@ -0,0 +1,482 @@
+--- a/net/minecraft/commands/Commands.java
++++ b/net/minecraft/commands/Commands.java
+@@ -1,7 +1,6 @@
+ package net.minecraft.commands;
+
+ import com.google.common.collect.Maps;
+-import com.mojang.brigadier.CommandDispatcher;
+ import com.mojang.brigadier.ParseResults;
+ import com.mojang.brigadier.StringReader;
+ import com.mojang.brigadier.arguments.ArgumentType;
+@@ -135,6 +134,14 @@
+ import net.minecraft.world.level.GameRules;
+ import org.slf4j.Logger;
+
++// CraftBukkit start
++import com.google.common.base.Joiner;
++import java.util.Collection;
++import java.util.LinkedHashSet;
++import org.bukkit.event.player.PlayerCommandSendEvent;
++import org.bukkit.event.server.ServerCommandEvent;
++// CraftBukkit end
++
+ public class Commands {
+
+ private static final ThreadLocal<ExecutionContext<CommandSourceStack>> CURRENT_EXECUTION_CONTEXT = new ThreadLocal();
+@@ -144,41 +151,42 @@
+ public static final int LEVEL_GAMEMASTERS = 2;
+ public static final int LEVEL_ADMINS = 3;
+ public static final int LEVEL_OWNERS = 4;
+- private final CommandDispatcher<CommandSourceStack> dispatcher = new CommandDispatcher();
++ private final com.mojang.brigadier.CommandDispatcher<CommandSourceStack> dispatcher = new com.mojang.brigadier.CommandDispatcher();
+
+- public Commands(Commands.CommandSelection commands_commandselection, CommandBuildContext commandbuildcontext) {
++ public Commands(Commands.CommandSelection selection, CommandBuildContext context) {
++ this(); // CraftBukkit
+ AdvancementCommands.register(this.dispatcher);
+- AttributeCommand.register(this.dispatcher, commandbuildcontext);
+- ExecuteCommand.register(this.dispatcher, commandbuildcontext);
++ AttributeCommand.register(this.dispatcher, context);
++ ExecuteCommand.register(this.dispatcher, context);
+ BossBarCommands.register(this.dispatcher);
+- ClearInventoryCommands.register(this.dispatcher, commandbuildcontext);
+- CloneCommands.register(this.dispatcher, commandbuildcontext);
+- DamageCommand.register(this.dispatcher, commandbuildcontext);
++ ClearInventoryCommands.register(this.dispatcher, context);
++ CloneCommands.register(this.dispatcher, context);
++ DamageCommand.register(this.dispatcher, context);
+ DataCommands.register(this.dispatcher);
+ DataPackCommand.register(this.dispatcher);
+ DebugCommand.register(this.dispatcher);
+ DefaultGameModeCommands.register(this.dispatcher);
+ DifficultyCommand.register(this.dispatcher);
+- EffectCommands.register(this.dispatcher, commandbuildcontext);
++ EffectCommands.register(this.dispatcher, context);
+ EmoteCommands.register(this.dispatcher);
+- EnchantCommand.register(this.dispatcher, commandbuildcontext);
++ EnchantCommand.register(this.dispatcher, context);
+ ExperienceCommand.register(this.dispatcher);
+- FillCommand.register(this.dispatcher, commandbuildcontext);
+- FillBiomeCommand.register(this.dispatcher, commandbuildcontext);
++ FillCommand.register(this.dispatcher, context);
++ FillBiomeCommand.register(this.dispatcher, context);
+ ForceLoadCommand.register(this.dispatcher);
+ FunctionCommand.register(this.dispatcher);
+ GameModeCommand.register(this.dispatcher);
+ GameRuleCommand.register(this.dispatcher);
+- GiveCommand.register(this.dispatcher, commandbuildcontext);
++ GiveCommand.register(this.dispatcher, context);
+ HelpCommand.register(this.dispatcher);
+- ItemCommands.register(this.dispatcher, commandbuildcontext);
++ ItemCommands.register(this.dispatcher, context);
+ KickCommand.register(this.dispatcher);
+ KillCommand.register(this.dispatcher);
+ ListPlayersCommand.register(this.dispatcher);
+- LocateCommand.register(this.dispatcher, commandbuildcontext);
+- LootCommand.register(this.dispatcher, commandbuildcontext);
++ LocateCommand.register(this.dispatcher, context);
++ LootCommand.register(this.dispatcher, context);
+ MsgCommand.register(this.dispatcher);
+- ParticleCommand.register(this.dispatcher, commandbuildcontext);
++ ParticleCommand.register(this.dispatcher, context);
+ PlaceCommand.register(this.dispatcher);
+ PlaySoundCommand.register(this.dispatcher);
+ RandomCommand.register(this.dispatcher);
+@@ -189,14 +197,14 @@
+ SayCommand.register(this.dispatcher);
+ ScheduleCommand.register(this.dispatcher);
+ ScoreboardCommand.register(this.dispatcher);
+- SeedCommand.register(this.dispatcher, commands_commandselection != Commands.CommandSelection.INTEGRATED);
+- SetBlockCommand.register(this.dispatcher, commandbuildcontext);
++ SeedCommand.register(this.dispatcher, selection != Commands.CommandSelection.INTEGRATED);
++ SetBlockCommand.register(this.dispatcher, context);
+ SetSpawnCommand.register(this.dispatcher);
+ SetWorldSpawnCommand.register(this.dispatcher);
+ SpectateCommand.register(this.dispatcher);
+ SpreadPlayersCommand.register(this.dispatcher);
+ StopSoundCommand.register(this.dispatcher);
+- SummonCommand.register(this.dispatcher, commandbuildcontext);
++ SummonCommand.register(this.dispatcher, context);
+ TagCommand.register(this.dispatcher);
+ TeamCommand.register(this.dispatcher);
+ TeamMsgCommand.register(this.dispatcher);
+@@ -221,12 +229,12 @@
+ WardenSpawnTrackerCommand.register(this.dispatcher);
+ SpawnArmorTrimsCommand.register(this.dispatcher);
+ ServerPackCommand.register(this.dispatcher);
+- if (commands_commandselection.includeDedicated) {
++ if (selection.includeDedicated) {
+ DebugConfigCommand.register(this.dispatcher);
+ }
+ }
+
+- if (commands_commandselection.includeDedicated) {
++ if (selection.includeDedicated) {
+ BanIpCommands.register(this.dispatcher);
+ BanListCommands.register(this.dispatcher);
+ BanPlayerCommands.register(this.dispatcher);
+@@ -243,100 +251,152 @@
+ WhitelistCommand.register(this.dispatcher);
+ }
+
+- if (commands_commandselection.includeIntegrated) {
++ if (selection.includeIntegrated) {
+ PublishCommand.register(this.dispatcher);
+ }
+
++ // CraftBukkit start
++ }
++
++ public Commands() {
++ // CraftBukkkit end
+ this.dispatcher.setConsumer(ExecutionCommandSource.resultConsumer());
+ }
+
+- public static <S> ParseResults<S> mapSource(ParseResults<S> parseresults, UnaryOperator<S> unaryoperator) {
+- CommandContextBuilder<S> commandcontextbuilder = parseresults.getContext();
+- CommandContextBuilder<S> commandcontextbuilder1 = commandcontextbuilder.withSource(unaryoperator.apply(commandcontextbuilder.getSource()));
++ public static <S> ParseResults<S> mapSource(ParseResults<S> parseResults, UnaryOperator<S> mapper) {
++ CommandContextBuilder<S> commandcontextbuilder = parseResults.getContext();
++ CommandContextBuilder<S> commandcontextbuilder1 = commandcontextbuilder.withSource(mapper.apply(commandcontextbuilder.getSource()));
+
+- return new ParseResults(commandcontextbuilder1, parseresults.getReader(), parseresults.getExceptions());
++ return new ParseResults(commandcontextbuilder1, parseResults.getReader(), parseResults.getExceptions());
+ }
+
+- public void performPrefixedCommand(CommandSourceStack commandsourcestack, String s) {
++ // CraftBukkit start
++ public void dispatchServerCommand(CommandSourceStack sender, String command) {
++ Joiner joiner = Joiner.on(" ");
++ if (command.startsWith("/")) {
++ command = command.substring(1);
++ }
++
++ ServerCommandEvent event = new ServerCommandEvent(sender.getBukkitSender(), command);
++ org.bukkit.Bukkit.getPluginManager().callEvent(event);
++ if (event.isCancelled()) {
++ return;
++ }
++ command = event.getCommand();
++
++ String[] args = command.split(" ");
++
++ String cmd = args[0];
++ if (cmd.startsWith("minecraft:")) cmd = cmd.substring("minecraft:".length());
++ if (cmd.startsWith("bukkit:")) cmd = cmd.substring("bukkit:".length());
++
++ // Block disallowed commands
++ if (cmd.equalsIgnoreCase("stop") || cmd.equalsIgnoreCase("kick") || cmd.equalsIgnoreCase("op")
++ || cmd.equalsIgnoreCase("deop") || cmd.equalsIgnoreCase("ban") || cmd.equalsIgnoreCase("ban-ip")
++ || cmd.equalsIgnoreCase("pardon") || cmd.equalsIgnoreCase("pardon-ip") || cmd.equalsIgnoreCase("reload")) {
++ return;
++ }
++
++ // Handle vanilla commands;
++ if (sender.getLevel().getCraftServer().getCommandBlockOverride(args[0])) {
++ args[0] = "minecraft:" + args[0];
++ }
++
++ String newCommand = joiner.join(args);
++ this.performPrefixedCommand(sender, newCommand, newCommand);
++ }
++ // CraftBukkit end
++
++ public void performPrefixedCommand(CommandSourceStack commandlistenerwrapper, String s) {
++ // CraftBukkit start
++ this.performPrefixedCommand(commandlistenerwrapper, s, s);
++ }
++
++ public void performPrefixedCommand(CommandSourceStack commandlistenerwrapper, String s, String label) {
+ s = s.startsWith("/") ? s.substring(1) : s;
+- this.performCommand(this.dispatcher.parse(s, commandsourcestack), s);
++ this.performCommand(this.dispatcher.parse(s, commandlistenerwrapper), s, label);
++ // CraftBukkit end
+ }
+
+ public void performCommand(ParseResults<CommandSourceStack> parseresults, String s) {
+- CommandSourceStack commandsourcestack = (CommandSourceStack) parseresults.getContext().getSource();
++ this.performCommand(parseresults, s, s);
++ }
+
+- commandsourcestack.getServer().getProfiler().push(() -> {
++ public void performCommand(ParseResults<CommandSourceStack> parseresults, String s, String label) { // CraftBukkit
++ CommandSourceStack commandlistenerwrapper = (CommandSourceStack) parseresults.getContext().getSource();
++
++ commandlistenerwrapper.getServer().getProfiler().push(() -> {
+ return "/" + s;
+ });
+- ContextChain contextchain = finishParsing(parseresults, s, commandsourcestack);
++ ContextChain contextchain = finishParsing(parseresults, s, commandlistenerwrapper, label); // CraftBukkit
+
+ try {
+ if (contextchain != null) {
+- executeCommandInContext(commandsourcestack, (executioncontext) -> {
+- ExecutionContext.queueInitialCommandExecution(executioncontext, s, contextchain, commandsourcestack, CommandResultCallback.EMPTY);
++ executeCommandInContext(commandlistenerwrapper, (executioncontext) -> {
++ ExecutionContext.queueInitialCommandExecution(executioncontext, s, contextchain, commandlistenerwrapper, CommandResultCallback.EMPTY);
+ });
+ }
+ } catch (Exception exception) {
+- MutableComponent mutablecomponent = Component.literal(exception.getMessage() == null ? exception.getClass().getName() : exception.getMessage());
++ MutableComponent ichatmutablecomponent = Component.literal(exception.getMessage() == null ? exception.getClass().getName() : exception.getMessage());
+
+ if (Commands.LOGGER.isDebugEnabled()) {
+ Commands.LOGGER.error("Command exception: /{}", s, exception);
+ StackTraceElement[] astacktraceelement = exception.getStackTrace();
+
+ for (int i = 0; i < Math.min(astacktraceelement.length, 3); ++i) {
+- mutablecomponent.append("\n\n").append(astacktraceelement[i].getMethodName()).append("\n ").append(astacktraceelement[i].getFileName()).append(":").append(String.valueOf(astacktraceelement[i].getLineNumber()));
++ ichatmutablecomponent.append("\n\n").append(astacktraceelement[i].getMethodName()).append("\n ").append(astacktraceelement[i].getFileName()).append(":").append(String.valueOf(astacktraceelement[i].getLineNumber()));
+ }
+ }
+
+- commandsourcestack.sendFailure(Component.translatable("command.failed").withStyle((style) -> {
+- return style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, mutablecomponent));
++ commandlistenerwrapper.sendFailure(Component.translatable("command.failed").withStyle((chatmodifier) -> {
++ return chatmodifier.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, ichatmutablecomponent));
+ }));
+ if (SharedConstants.IS_RUNNING_IN_IDE) {
+- commandsourcestack.sendFailure(Component.literal(Util.describeError(exception)));
++ commandlistenerwrapper.sendFailure(Component.literal(Util.describeError(exception)));
+ Commands.LOGGER.error("'/{}' threw an exception", s, exception);
+ }
+ } finally {
+- commandsourcestack.getServer().getProfiler().pop();
++ commandlistenerwrapper.getServer().getProfiler().pop();
+ }
+
+ }
+
+ @Nullable
+- private static ContextChain<CommandSourceStack> finishParsing(ParseResults<CommandSourceStack> parseresults, String s, CommandSourceStack commandsourcestack) {
++ private static ContextChain<CommandSourceStack> finishParsing(ParseResults<CommandSourceStack> parseresults, String s, CommandSourceStack commandlistenerwrapper, String label) { // CraftBukkit
+ try {
+ validateParseResults(parseresults);
+ return (ContextChain) ContextChain.tryFlatten(parseresults.getContext().build(s)).orElseThrow(() -> {
+ return CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownCommand().createWithContext(parseresults.getReader());
+ });
+ } catch (CommandSyntaxException commandsyntaxexception) {
+- commandsourcestack.sendFailure(ComponentUtils.fromMessage(commandsyntaxexception.getRawMessage()));
++ commandlistenerwrapper.sendFailure(ComponentUtils.fromMessage(commandsyntaxexception.getRawMessage()));
+ if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) {
+ int i = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor());
+- MutableComponent mutablecomponent = Component.empty().withStyle(ChatFormatting.GRAY).withStyle((style) -> {
+- return style.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + s));
++ MutableComponent ichatmutablecomponent = Component.empty().withStyle(ChatFormatting.GRAY).withStyle((chatmodifier) -> {
++ return chatmodifier.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, label)); // CraftBukkit
+ });
+
+ if (i > 10) {
+- mutablecomponent.append(CommonComponents.ELLIPSIS);
++ ichatmutablecomponent.append(CommonComponents.ELLIPSIS);
+ }
+
+- mutablecomponent.append(commandsyntaxexception.getInput().substring(Math.max(0, i - 10), i));
++ ichatmutablecomponent.append(commandsyntaxexception.getInput().substring(Math.max(0, i - 10), i));
+ if (i < commandsyntaxexception.getInput().length()) {
+- MutableComponent mutablecomponent1 = Component.literal(commandsyntaxexception.getInput().substring(i)).withStyle(ChatFormatting.RED, ChatFormatting.UNDERLINE);
++ MutableComponent ichatmutablecomponent1 = Component.literal(commandsyntaxexception.getInput().substring(i)).withStyle(ChatFormatting.RED, ChatFormatting.UNDERLINE);
+
+- mutablecomponent.append((Component) mutablecomponent1);
++ ichatmutablecomponent.append((Component) ichatmutablecomponent1);
+ }
+
+- mutablecomponent.append((Component) Component.translatable("command.context.here").withStyle(ChatFormatting.RED, ChatFormatting.ITALIC));
+- commandsourcestack.sendFailure(mutablecomponent);
++ ichatmutablecomponent.append((Component) Component.translatable("command.context.here").withStyle(ChatFormatting.RED, ChatFormatting.ITALIC));
++ commandlistenerwrapper.sendFailure(ichatmutablecomponent);
+ }
+
+ return null;
+ }
+ }
+
+- public static void executeCommandInContext(CommandSourceStack commandsourcestack, Consumer<ExecutionContext<CommandSourceStack>> consumer) {
+- MinecraftServer minecraftserver = commandsourcestack.getServer();
++ public static void executeCommandInContext(CommandSourceStack commandlistenerwrapper, Consumer<ExecutionContext<CommandSourceStack>> consumer) {
++ MinecraftServer minecraftserver = commandlistenerwrapper.getServer();
+ ExecutionContext<CommandSourceStack> executioncontext = (ExecutionContext) Commands.CURRENT_EXECUTION_CONTEXT.get();
+ boolean flag = executioncontext == null;
+
+@@ -363,7 +423,7 @@
+
+ executioncontext1.close();
+ } finally {
+- Commands.CURRENT_EXECUTION_CONTEXT.set((Object) null);
++ Commands.CURRENT_EXECUTION_CONTEXT.set(null); // CraftBukkit - decompile error
+ }
+ } else {
+ consumer.accept(executioncontext);
+@@ -371,25 +431,50 @@
+
+ }
+
+- public void sendCommands(ServerPlayer serverplayer) {
+- Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> map = Maps.newHashMap();
++ public void sendCommands(ServerPlayer player) {
++ // CraftBukkit start
++ // Register Vanilla commands into builtRoot as before
++ Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues
++ RootCommandNode vanillaRoot = new RootCommandNode();
++
++ RootCommandNode<CommandSourceStack> vanilla = player.server.vanillaCommandDispatcher.getDispatcher().getRoot();
++ map.put(vanilla, vanillaRoot);
++ this.fillUsableCommands(vanilla, vanillaRoot, player.createCommandSourceStack(), (Map) map);
++
++ // Now build the global commands in a second pass
+ RootCommandNode<SharedSuggestionProvider> rootcommandnode = new RootCommandNode();
+
+ map.put(this.dispatcher.getRoot(), rootcommandnode);
+- this.fillUsableCommands(this.dispatcher.getRoot(), rootcommandnode, serverplayer.createCommandSourceStack(), map);
+- serverplayer.connection.send(new ClientboundCommandsPacket(rootcommandnode));
++ this.fillUsableCommands(this.dispatcher.getRoot(), rootcommandnode, player.createCommandSourceStack(), map);
++
++ Collection<String> bukkit = new LinkedHashSet<>();
++ for (CommandNode node : rootcommandnode.getChildren()) {
++ bukkit.add(node.getName());
++ }
++
++ PlayerCommandSendEvent event = new PlayerCommandSendEvent(player.getBukkitEntity(), new LinkedHashSet<>(bukkit));
++ event.getPlayer().getServer().getPluginManager().callEvent(event);
++
++ // Remove labels that were removed during the event
++ for (String orig : bukkit) {
++ if (!event.getCommands().contains(orig)) {
++ rootcommandnode.removeCommand(orig);
++ }
++ }
++ // CraftBukkit end
++ player.connection.send(new ClientboundCommandsPacket(rootcommandnode));
+ }
+
+- private void fillUsableCommands(CommandNode<CommandSourceStack> commandnode, CommandNode<SharedSuggestionProvider> commandnode1, CommandSourceStack commandsourcestack, Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> map) {
+- Iterator iterator = commandnode.getChildren().iterator();
++ private void fillUsableCommands(CommandNode<CommandSourceStack> rootCommandSource, CommandNode<SharedSuggestionProvider> rootSuggestion, CommandSourceStack source, Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> commandNodeToSuggestionNode) {
++ Iterator iterator = rootCommandSource.getChildren().iterator();
+
+ while (iterator.hasNext()) {
+ CommandNode<CommandSourceStack> commandnode2 = (CommandNode) iterator.next();
+
+- if (commandnode2.canUse(commandsourcestack)) {
+- ArgumentBuilder<SharedSuggestionProvider, ?> argumentbuilder = commandnode2.createBuilder();
++ if (commandnode2.canUse(source)) {
++ ArgumentBuilder argumentbuilder = commandnode2.createBuilder(); // CraftBukkit - decompile error
+
+- argumentbuilder.requires((sharedsuggestionprovider) -> {
++ argumentbuilder.requires((icompletionprovider) -> {
+ return true;
+ });
+ if (argumentbuilder.getCommand() != null) {
+@@ -407,33 +492,33 @@
+ }
+
+ if (argumentbuilder.getRedirect() != null) {
+- argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect()));
++ argumentbuilder.redirect((CommandNode) commandNodeToSuggestionNode.get(argumentbuilder.getRedirect()));
+ }
+
+- CommandNode<SharedSuggestionProvider> commandnode3 = argumentbuilder.build();
++ CommandNode commandnode3 = argumentbuilder.build(); // CraftBukkit - decompile error
+
+- map.put(commandnode2, commandnode3);
+- commandnode1.addChild(commandnode3);
++ commandNodeToSuggestionNode.put(commandnode2, commandnode3);
++ rootSuggestion.addChild(commandnode3);
+ if (!commandnode2.getChildren().isEmpty()) {
+- this.fillUsableCommands(commandnode2, commandnode3, commandsourcestack, map);
++ this.fillUsableCommands(commandnode2, commandnode3, source, commandNodeToSuggestionNode);
+ }
+ }
+ }
+
+ }
+
+- public static LiteralArgumentBuilder<CommandSourceStack> literal(String s) {
+- return LiteralArgumentBuilder.literal(s);
++ public static LiteralArgumentBuilder<CommandSourceStack> literal(String name) {
++ return LiteralArgumentBuilder.literal(name);
+ }
+
+- public static <T> RequiredArgumentBuilder<CommandSourceStack, T> argument(String s, ArgumentType<T> argumenttype) {
+- return RequiredArgumentBuilder.argument(s, argumenttype);
++ public static <T> RequiredArgumentBuilder<CommandSourceStack, T> argument(String name, ArgumentType<T> type) {
++ return RequiredArgumentBuilder.argument(name, type);
+ }
+
+- public static Predicate<String> createValidator(Commands.ParseFunction commands_parsefunction) {
++ public static Predicate<String> createValidator(Commands.ParseFunction parser) {
+ return (s) -> {
+ try {
+- commands_parsefunction.parse(new StringReader(s));
++ parser.parse(new StringReader(s));
+ return true;
+ } catch (CommandSyntaxException commandsyntaxexception) {
+ return false;
+@@ -441,7 +526,7 @@
+ };
+ }
+
+- public CommandDispatcher<CommandSourceStack> getDispatcher() {
++ public com.mojang.brigadier.CommandDispatcher<CommandSourceStack> getDispatcher() {
+ return this.dispatcher;
+ }
+
+@@ -454,31 +539,28 @@
+ }
+
+ @Nullable
+- public static <S> CommandSyntaxException getParseException(ParseResults<S> parseresults) {
+- return !parseresults.getReader().canRead() ? null : (parseresults.getExceptions().size() == 1 ? (CommandSyntaxException) parseresults.getExceptions().values().iterator().next() : (parseresults.getContext().getRange().isEmpty() ? CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownCommand().createWithContext(parseresults.getReader()) : CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownArgument().createWithContext(parseresults.getReader())));
++ public static <S> CommandSyntaxException getParseException(ParseResults<S> result) {
++ return !result.getReader().canRead() ? null : (result.getExceptions().size() == 1 ? (CommandSyntaxException) result.getExceptions().values().iterator().next() : (result.getContext().getRange().isEmpty() ? CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownCommand().createWithContext(result.getReader()) : CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownArgument().createWithContext(result.getReader())));
+ }
+
+- public static CommandBuildContext createValidationContext(final HolderLookup.Provider holderlookup_provider) {
++ public static CommandBuildContext createValidationContext(final HolderLookup.Provider provider) {
+ return new CommandBuildContext() {
+ @Override
+- @Override
+- public <T> HolderLookup<T> holderLookup(ResourceKey<? extends Registry<T>> resourcekey) {
+- final HolderLookup.RegistryLookup<T> holderlookup_registrylookup = holderlookup_provider.lookupOrThrow(resourcekey);
++ public <T> HolderLookup<T> holderLookup(ResourceKey<? extends Registry<T>> registryResourceKey) {
++ final HolderLookup.RegistryLookup<T> holderlookup_c = provider.lookupOrThrow(registryResourceKey);
+
+- return new HolderLookup.Delegate<T>(holderlookup_registrylookup) {
++ return new HolderLookup.Delegate<T>(holderlookup_c) {
+ @Override
+- @Override
+- public Optional<HolderSet.Named<T>> get(TagKey<T> tagkey) {
+- return Optional.of(this.getOrThrow(tagkey));
++ public Optional<HolderSet.Named<T>> get(TagKey<T> tagKey) {
++ return Optional.of(this.getOrThrow(tagKey));
+ }
+
+ @Override
+- @Override
+- public HolderSet.Named<T> getOrThrow(TagKey<T> tagkey) {
+- Optional<HolderSet.Named<T>> optional = holderlookup_registrylookup.get(tagkey);
++ public HolderSet.Named<T> getOrThrow(TagKey<T> tagKey) {
++ Optional<HolderSet.Named<T>> optional = holderlookup_c.get(tagKey);
+
+ return (HolderSet.Named) optional.orElseGet(() -> {
+- return HolderSet.emptyNamed(holderlookup_registrylookup, tagkey);
++ return HolderSet.emptyNamed(holderlookup_c, tagKey);
+ });
+ }
+ };
+@@ -488,11 +570,11 @@
+
+ public static void validate() {
+ CommandBuildContext commandbuildcontext = createValidationContext(VanillaRegistries.createLookup());
+- CommandDispatcher<CommandSourceStack> commanddispatcher = (new Commands(Commands.CommandSelection.ALL, commandbuildcontext)).getDispatcher();
+- RootCommandNode<CommandSourceStack> rootcommandnode = commanddispatcher.getRoot();
++ com.mojang.brigadier.CommandDispatcher<CommandSourceStack> com_mojang_brigadier_commanddispatcher = (new Commands(Commands.CommandSelection.ALL, commandbuildcontext)).getDispatcher();
++ RootCommandNode<CommandSourceStack> rootcommandnode = com_mojang_brigadier_commanddispatcher.getRoot();
+
+- commanddispatcher.findAmbiguities((commandnode, commandnode1, commandnode2, collection) -> {
+- Commands.LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", new Object[]{commanddispatcher.getPath(commandnode1), commanddispatcher.getPath(commandnode2), collection});
++ com_mojang_brigadier_commanddispatcher.findAmbiguities((commandnode, commandnode1, commandnode2, collection) -> {
++ Commands.LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", new Object[]{com_mojang_brigadier_commanddispatcher.getPath(commandnode1), com_mojang_brigadier_commanddispatcher.getPath(commandnode2), collection});
+ });
+ Set<ArgumentType<?>> set = ArgumentUtils.findUsedArgumentTypes(rootcommandnode);
+ Set<ArgumentType<?>> set1 = (Set) set.stream().filter((argumenttype) -> {