--- 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;
@@ -13,6 +12,7 @@
 import com.mojang.brigadier.tree.CommandNode;
 import com.mojang.brigadier.tree.RootCommandNode;
 import com.mojang.logging.LogUtils;
+import java.util.Iterator;
 import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
@@ -116,16 +116,26 @@
 import net.minecraft.util.profiling.jfr.JvmProfiler;
 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 Logger LOGGER = LogUtils.getLogger();
     public static final int LEVEL_ALL = 0;
     public static final int LEVEL_MODERATORS = 1;
     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 environment, CommandBuildContext commandRegistryAccess) {
+        this(); // CraftBukkit
         AdvancementCommands.register(this.dispatcher);
         AttributeCommand.register(this.dispatcher, commandRegistryAccess);
         ExecuteCommand.register(this.dispatcher, commandRegistryAccess);
@@ -210,120 +220,273 @@
         if (environment.includeIntegrated) {
             PublishCommand.register(this.dispatcher);
         }
+        // Paper start
+        for (final CommandNode<CommandSourceStack> node : this.dispatcher.getRoot().getChildren()) {
+            if (node.getRequirement() == com.mojang.brigadier.builder.ArgumentBuilder.<CommandSourceStack>defaultRequirement()) {
+                node.requirement = stack -> stack.source == CommandSource.NULL || stack.getBukkitSender().hasPermission(org.bukkit.craftbukkit.v1_19_R2.command.VanillaCommandWrapper.getPermission(node));
+            }
+        }
+        // Paper end
+        // CraftBukkit start
+    }
 
-        this.dispatcher.setConsumer((context, success, result) -> {
-            context.getSource().onCommandComplete(context, success, result);
+    public Commands() {
+        // CraftBukkkit end
+        this.dispatcher.setConsumer((commandcontext, flag, i) -> {
+            ((CommandSourceStack) commandcontext.getSource()).onCommandComplete(commandcontext, flag, i);
         });
     }
 
     public static <S> ParseResults<S> mapSource(ParseResults<S> parseResults, UnaryOperator<S> sourceMapper) {
-        CommandContextBuilder<S> commandContextBuilder = parseResults.getContext();
-        CommandContextBuilder<S> commandContextBuilder2 = commandContextBuilder.withSource(sourceMapper.apply(commandContextBuilder.getSource()));
-        return new ParseResults<>(commandContextBuilder2, parseResults.getReader(), parseResults.getExceptions());
+        CommandContextBuilder<S> commandcontextbuilder = parseResults.getContext();
+        CommandContextBuilder<S> commandcontextbuilder1 = commandcontextbuilder.withSource(sourceMapper.apply(commandcontextbuilder.getSource()));
+
+        return new ParseResults(commandcontextbuilder1, parseResults.getReader(), parseResults.getExceptions());
     }
 
+    // CraftBukkit start
+    public int 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 0;
+        }
+        command = event.getCommand();
+
+        String[] args = command.split(" ");
+        if (args.length == 0) return 0; // Paper - empty commands shall not be dispatched
+
+        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 0;
+        }
+
+        // Handle vanilla commands;
+        if (sender.getLevel().getCraftServer().getCommandBlockOverride(args[0])) {
+            args[0] = "minecraft:" + args[0];
+        }
+
+        String newCommand = joiner.join(args);
+        return this.performPrefixedCommand(sender, newCommand, newCommand);
+    }
+    // CraftBukkit end
+
     public int performPrefixedCommand(CommandSourceStack source, String command) {
-        command = command.startsWith("/") ? command.substring(1) : command;
-        return this.performCommand(this.dispatcher.parse(command, source), command);
+        // CraftBukkit start
+        return this.performPrefixedCommand(source, command, command);
+    }
+
+    public int performPrefixedCommand(CommandSourceStack commandlistenerwrapper, String s, String label) {
+        s = s.startsWith("/") ? s.substring(1) : s;
+        return this.performCommand(this.dispatcher.parse(s, commandlistenerwrapper), s, label);
+        // CraftBukkit end
     }
 
     public int performCommand(ParseResults<CommandSourceStack> parseResults, String command) {
-        CommandSourceStack commandSourceStack = parseResults.getContext().getSource();
-        commandSourceStack.getServer().getProfiler().push(() -> {
-            return "/" + command;
+        return this.performCommand(parseResults, command, command);
+    }
+
+    public int performCommand(ParseResults<CommandSourceStack> parseresults, String s, String label) { // CraftBukkit
+        CommandSourceStack commandlistenerwrapper = (CommandSourceStack) parseresults.getContext().getSource();
+
+        commandlistenerwrapper.getServer().getProfiler().push(() -> {
+            return "/" + s;
         });
 
+        byte b0;
+
         try {
+            byte b1;
+
             try {
-                return this.dispatcher.execute(parseResults);
-            } catch (CommandRuntimeException var13) {
-                commandSourceStack.sendFailure(var13.getComponent());
-                return 0;
-            } catch (CommandSyntaxException var14) {
-                commandSourceStack.sendFailure(ComponentUtils.fromMessage(var14.getRawMessage()));
-                if (var14.getInput() != null && var14.getCursor() >= 0) {
-                    int i = Math.min(var14.getInput().length(), var14.getCursor());
-                    MutableComponent mutableComponent = Component.empty().withStyle(ChatFormatting.GRAY).withStyle((style) -> {
-                        return style.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + command));
+                int i = this.dispatcher.execute(parseresults);
+
+                return i;
+            } catch (CommandRuntimeException commandexception) {
+                commandlistenerwrapper.sendFailure(commandexception.getComponent());
+                b1 = 0;
+                return b1;
+            } catch (CommandSyntaxException commandsyntaxexception) {
+                commandlistenerwrapper.sendFailure(ComponentUtils.fromMessage(commandsyntaxexception.getRawMessage()));
+                if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) {
+                    int j = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor());
+                    MutableComponent ichatmutablecomponent = Component.empty().withStyle(ChatFormatting.GRAY).withStyle((chatmodifier) -> {
+                        return chatmodifier.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + label)); // CraftBukkit // Paper
                     });
-                    if (i > 10) {
-                        mutableComponent.append(CommonComponents.ELLIPSIS);
+
+                    if (j > 10) {
+                        ichatmutablecomponent.append(CommonComponents.ELLIPSIS);
                     }
 
-                    mutableComponent.append(var14.getInput().substring(Math.max(0, i - 10), i));
-                    if (i < var14.getInput().length()) {
-                        Component component = Component.literal(var14.getInput().substring(i)).withStyle(ChatFormatting.RED, ChatFormatting.UNDERLINE);
-                        mutableComponent.append(component);
+                    ichatmutablecomponent.append(commandsyntaxexception.getInput().substring(Math.max(0, j - 10), j));
+                    if (j < commandsyntaxexception.getInput().length()) {
+                        MutableComponent ichatmutablecomponent1 = Component.literal(commandsyntaxexception.getInput().substring(j)).withStyle(ChatFormatting.RED, ChatFormatting.UNDERLINE);
+
+                        ichatmutablecomponent.append((Component) ichatmutablecomponent1);
                     }
 
-                    mutableComponent.append(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);
                 }
-            } catch (Exception var15) {
-                MutableComponent mutableComponent2 = Component.literal(var15.getMessage() == null ? var15.getClass().getName() : var15.getMessage());
-                if (LOGGER.isDebugEnabled()) {
-                    LOGGER.error("Command exception: /{}", command, var15);
-                    StackTraceElement[] stackTraceElements = var15.getStackTrace();
 
-                    for(int j = 0; j < Math.min(stackTraceElements.length, 3); ++j) {
-                        mutableComponent2.append("\n\n").append(stackTraceElements[j].getMethodName()).append("\n ").append(stackTraceElements[j].getFileName()).append(":").append(String.valueOf(stackTraceElements[j].getLineNumber()));
+                b1 = 0;
+                return b1;
+            } catch (Exception exception) {
+                MutableComponent ichatmutablecomponent2 = 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 k = 0; k < Math.min(astacktraceelement.length, 3); ++k) {
+                        ichatmutablecomponent2.append("\n\n").append(astacktraceelement[k].getMethodName()).append("\n ").append(astacktraceelement[k].getFileName()).append(":").append(String.valueOf(astacktraceelement[k].getLineNumber()));
                     }
                 }
 
-                commandSourceStack.sendFailure(Component.translatable("command.failed").withStyle((style) -> {
-                    return style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, mutableComponent2));
+                commandlistenerwrapper.sendFailure(Component.translatable("command.failed").withStyle((chatmodifier) -> {
+                    return chatmodifier.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, ichatmutablecomponent2));
                 }));
                 if (SharedConstants.IS_RUNNING_IN_IDE) {
-                    commandSourceStack.sendFailure(Component.literal(Util.describeError(var15)));
-                    LOGGER.error("'/{}' threw an exception", command, var15);
+                    commandlistenerwrapper.sendFailure(Component.literal(Util.describeError(exception)));
+                    Commands.LOGGER.error("'/{}' threw an exception", s, exception);
                 }
 
-                return 0;
+                b0 = 0;
             }
-
-            return 0;
         } finally {
-            commandSourceStack.getServer().getProfiler().pop();
+            commandlistenerwrapper.getServer().getProfiler().pop();
         }
+
+        return b0;
     }
 
     public void sendCommands(ServerPlayer player) {
-        Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> map = Maps.newHashMap();
-        RootCommandNode<SharedSuggestionProvider> rootCommandNode = new RootCommandNode<>();
-        map.put(this.dispatcher.getRoot(), rootCommandNode);
-        this.fillUsableCommands(this.dispatcher.getRoot(), rootCommandNode, player.createCommandSourceStack(), map);
-        player.connection.send(new ClientboundCommandsPacket(rootCommandNode));
+        // Paper start - Send empty commands if tab completion is disabled
+        if ( org.spigotmc.SpigotConfig.tabComplete < 0 ) { //return; // Spigot
+            player.connection.send(new ClientboundCommandsPacket(new RootCommandNode<>()));
+            return;
+        }
+        // Paper end
+        // CraftBukkit start
+        // Register Vanilla commands into builtRoot as before
+        // Paper start - Async command map building
+        COMMAND_SENDING_POOL.execute(() -> {
+                this.sendAsync(player);
+        });
+    }
+
+    public static final java.util.concurrent.ThreadPoolExecutor COMMAND_SENDING_POOL = new java.util.concurrent.ThreadPoolExecutor(
+        0, 2, 60L, java.util.concurrent.TimeUnit.SECONDS,
+        new java.util.concurrent.LinkedBlockingQueue<>(),
+        new com.google.common.util.concurrent.ThreadFactoryBuilder()
+            .setNameFormat("Paper Async Command Builder Thread Pool - %1$d")
+            .setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.LOGGER))
+            .build(),
+        new java.util.concurrent.ThreadPoolExecutor.DiscardPolicy()
+    );
+
+    private void sendAsync(ServerPlayer player) {
+        // Paper end - Async command map building
+        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, player.createCommandSourceStack(), map);
+
+        Collection<String> bukkit = new LinkedHashSet<>();
+        for (CommandNode node : rootcommandnode.getChildren()) {
+            bukkit.add(node.getName());
+        }
+        // Paper start - Async command map building
+        new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent<CommandSourceStack>(player.getBukkitEntity(), (RootCommandNode) rootcommandnode, false).callEvent(); // Paper
+        net.minecraft.server.MinecraftServer.getServer().execute(() -> {
+           runSync(player, bukkit, rootcommandnode);
+        });
+    }
+
+    private void runSync(ServerPlayer player, Collection<String> bukkit, RootCommandNode<SharedSuggestionProvider> rootcommandnode) {
+        // Paper end - Async command map building
+        new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent<CommandSourceStack>(player.getBukkitEntity(), (RootCommandNode) rootcommandnode, false).callEvent(); // Paper
+        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> tree, CommandNode<SharedSuggestionProvider> result, CommandSourceStack source, Map<CommandNode<CommandSourceStack>, CommandNode<SharedSuggestionProvider>> resultNodes) {
-        for(CommandNode<CommandSourceStack> commandNode : tree.getChildren()) {
-            if (commandNode.canUse(source)) {
-                ArgumentBuilder<SharedSuggestionProvider, ?> argumentBuilder = commandNode.createBuilder();
-                argumentBuilder.requires((sourcex) -> {
+        Iterator iterator = tree.getChildren().iterator();
+
+        boolean registeredAskServerSuggestionsForTree = false; // Paper - tell clients to ask server for suggestions for EntityArguments
+        while (iterator.hasNext()) {
+            CommandNode<CommandSourceStack> commandnode2 = (CommandNode) iterator.next();
+            // Paper start
+            if (commandnode2.clientNode != null) {
+                commandnode2 = commandnode2.clientNode;
+            }
+            // Paper end
+            if ( !org.spigotmc.SpigotConfig.sendNamespaced && commandnode2.getName().contains( ":" ) ) continue; // Spigot
+
+            if (commandnode2.canUse(source)) {
+                ArgumentBuilder argumentbuilder = commandnode2.createBuilder(); // CraftBukkit - decompile error
+
+                argumentbuilder.requires((icompletionprovider) -> {
                     return true;
                 });
-                if (argumentBuilder.getCommand() != null) {
-                    argumentBuilder.executes((context) -> {
+                if (argumentbuilder.getCommand() != null) {
+                    argumentbuilder.executes((commandcontext) -> {
                         return 0;
                     });
                 }
 
-                if (argumentBuilder instanceof RequiredArgumentBuilder) {
-                    RequiredArgumentBuilder<SharedSuggestionProvider, ?> requiredArgumentBuilder = (RequiredArgumentBuilder)argumentBuilder;
-                    if (requiredArgumentBuilder.getSuggestionsProvider() != null) {
-                        requiredArgumentBuilder.suggests(SuggestionProviders.safelySwap(requiredArgumentBuilder.getSuggestionsProvider()));
+                if (argumentbuilder instanceof RequiredArgumentBuilder) {
+                    RequiredArgumentBuilder<SharedSuggestionProvider, ?> requiredargumentbuilder = (RequiredArgumentBuilder) argumentbuilder;
+
+                    if (requiredargumentbuilder.getSuggestionsProvider() != null) {
+                        requiredargumentbuilder.suggests(SuggestionProviders.safelySwap(requiredargumentbuilder.getSuggestionsProvider()));
+                        // Paper start - tell clients to ask server for suggestions for EntityArguments
+                        registeredAskServerSuggestionsForTree = requiredargumentbuilder.getSuggestionsProvider() == net.minecraft.commands.synchronization.SuggestionProviders.ASK_SERVER;
+                    } else if (io.papermc.paper.configuration.GlobalConfiguration.get().commands.fixTargetSelectorTagCompletion && !registeredAskServerSuggestionsForTree && requiredargumentbuilder.getType() instanceof net.minecraft.commands.arguments.EntityArgument) {
+                        requiredargumentbuilder.suggests(requiredargumentbuilder.getType()::listSuggestions);
+                        registeredAskServerSuggestionsForTree = true; // You can only
+                        // Paper end - tell clients to ask server for suggestions for EntityArguments
                     }
                 }
 
-                if (argumentBuilder.getRedirect() != null) {
-                    argumentBuilder.redirect(resultNodes.get(argumentBuilder.getRedirect()));
+                if (argumentbuilder.getRedirect() != null) {
+                    argumentbuilder.redirect((CommandNode) resultNodes.get(argumentbuilder.getRedirect()));
                 }
 
-                CommandNode<SharedSuggestionProvider> commandNode2 = argumentBuilder.build();
-                resultNodes.put(commandNode, commandNode2);
-                result.addChild(commandNode2);
-                if (!commandNode.getChildren().isEmpty()) {
-                    this.fillUsableCommands(commandNode, commandNode2, source, resultNodes);
+                CommandNode commandnode3 = argumentbuilder.build(); // CraftBukkit - decompile error
+
+                resultNodes.put(commandnode2, commandnode3);
+                result.addChild(commandnode3);
+                if (!commandnode2.getChildren().isEmpty()) {
+                    this.fillUsableCommands(commandnode2, commandnode3, source, resultNodes);
                 }
             }
         }
@@ -339,37 +502,32 @@
     }
 
     public static Predicate<String> createValidator(Commands.ParseFunction parser) {
-        return (string) -> {
+        return (s) -> {
             try {
-                parser.parse(new StringReader(string));
+                parser.parse(new StringReader(s));
                 return true;
-            } catch (CommandSyntaxException var3) {
+            } catch (CommandSyntaxException commandsyntaxexception) {
                 return false;
             }
         };
     }
 
-    public CommandDispatcher<CommandSourceStack> getDispatcher() {
+    public com.mojang.brigadier.CommandDispatcher<CommandSourceStack> getDispatcher() {
         return this.dispatcher;
     }
 
     @Nullable
     public static <S> CommandSyntaxException getParseException(ParseResults<S> parse) {
-        if (!parse.getReader().canRead()) {
-            return null;
-        } else if (parse.getExceptions().size() == 1) {
-            return parse.getExceptions().values().iterator().next();
-        } else {
-            return parse.getContext().getRange().isEmpty() ? CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownCommand().createWithContext(parse.getReader()) : CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownArgument().createWithContext(parse.getReader());
-        }
+        return !parse.getReader().canRead() ? null : (parse.getExceptions().size() == 1 ? (CommandSyntaxException) parse.getExceptions().values().iterator().next() : (parse.getContext().getRange().isEmpty() ? CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownCommand().createWithContext(parse.getReader()) : CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownArgument().createWithContext(parse.getReader())));
     }
 
     public static CommandBuildContext createValidationContext(final HolderLookup.Provider registryLookup) {
         return new CommandBuildContext() {
             @Override
             public <T> HolderLookup<T> holderLookup(ResourceKey<? extends Registry<T>> registryRef) {
-                final HolderLookup.RegistryLookup<T> registryLookup = registryLookup.lookupOrThrow(registryRef);
-                return new HolderLookup.Delegate<T>(registryLookup) {
+                final HolderLookup.RegistryLookup<T> holderlookup_c = registryLookup.lookupOrThrow(registryRef);
+
+                return new HolderLookup.Delegate<T>(holderlookup_c) {
                     @Override
                     public Optional<HolderSet.Named<T>> get(TagKey<T> tag) {
                         return Optional.of(this.getOrThrow(tag));
@@ -377,9 +535,10 @@
 
                     @Override
                     public HolderSet.Named<T> getOrThrow(TagKey<T> tag) {
-                        Optional<HolderSet.Named<T>> optional = registryLookup.get(tag);
-                        return optional.orElseGet(() -> {
-                            return HolderSet.emptyNamed(registryLookup, tag);
+                        Optional<HolderSet.Named<T>> optional = holderlookup_c.get(tag);
+
+                        return (HolderSet.Named) optional.orElseGet(() -> {
+                            return HolderSet.emptyNamed(holderlookup_c, tag);
                         });
                     }
                 };
@@ -388,40 +547,42 @@
     }
 
     public static void validate() {
-        CommandBuildContext commandBuildContext = createValidationContext(VanillaRegistries.createLookup());
-        CommandDispatcher<CommandSourceStack> commandDispatcher = (new Commands(Commands.CommandSelection.ALL, commandBuildContext)).getDispatcher();
-        RootCommandNode<CommandSourceStack> rootCommandNode = commandDispatcher.getRoot();
-        commandDispatcher.findAmbiguities((parent, child, sibling, inputs) -> {
-            LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", commandDispatcher.getPath(child), commandDispatcher.getPath(sibling), inputs);
+        CommandBuildContext commandbuildcontext = Commands.createValidationContext(VanillaRegistries.createLookup());
+        com.mojang.brigadier.CommandDispatcher<CommandSourceStack> com_mojang_brigadier_commanddispatcher = (new Commands(Commands.CommandSelection.ALL, commandbuildcontext)).getDispatcher();
+        RootCommandNode<CommandSourceStack> rootcommandnode = com_mojang_brigadier_commanddispatcher.getRoot();
+
+        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<?>> set2 = set.stream().filter((type) -> {
-            return !ArgumentTypeInfos.isClassRecognized(type.getClass());
+        Set<ArgumentType<?>> set = ArgumentUtils.findUsedArgumentTypes(rootcommandnode);
+        Set<ArgumentType<?>> set1 = (Set) set.stream().filter((argumenttype) -> {
+            return !ArgumentTypeInfos.isClassRecognized(argumenttype.getClass());
         }).collect(Collectors.toSet());
-        if (!set2.isEmpty()) {
-            LOGGER.warn("Missing type registration for following arguments:\n {}", set2.stream().map((type) -> {
-                return "\t" + type;
+
+        if (!set1.isEmpty()) {
+            Commands.LOGGER.warn("Missing type registration for following arguments:\n {}", set1.stream().map((argumenttype) -> {
+                return "\t" + argumenttype;
             }).collect(Collectors.joining(",\n")));
             throw new IllegalStateException("Unregistered argument types");
         }
     }
 
     public static enum CommandSelection {
-        ALL(true, true),
-        DEDICATED(false, true),
-        INTEGRATED(true, false);
+
+        ALL(true, true), DEDICATED(false, true), INTEGRATED(true, false);
 
         final boolean includeIntegrated;
         final boolean includeDedicated;
 
-        private CommandSelection(boolean integrated, boolean dedicated) {
-            this.includeIntegrated = integrated;
-            this.includeDedicated = dedicated;
+        private CommandSelection(boolean flag, boolean flag1) {
+            this.includeIntegrated = flag;
+            this.includeDedicated = flag1;
         }
     }
 
     @FunctionalInterface
     public interface ParseFunction {
+
         void parse(StringReader reader) throws CommandSyntaxException;
     }
 }
