--- a/net/minecraft/commands/CommandDispatcher.java
+++ b/net/minecraft/commands/CommandDispatcher.java
@@ -103,6 +103,14 @@
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.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 CommandDispatcher {
 
     private static final Logger LOGGER = LogManager.getLogger();
@@ -114,6 +122,7 @@
     private final com.mojang.brigadier.CommandDispatcher<CommandListenerWrapper> dispatcher = new com.mojang.brigadier.CommandDispatcher();
 
     public CommandDispatcher(CommandDispatcher.ServerType commanddispatcher_servertype) {
+        this(); // CraftBukkit
         CommandAdvancement.a(this.dispatcher);
         CommandAttribute.a(this.dispatcher);
         CommandExecute.a(this.dispatcher);
@@ -195,17 +204,61 @@
         }
 
         this.dispatcher.findAmbiguities((commandnode, commandnode1, commandnode2, collection) -> {
-            CommandDispatcher.LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", this.dispatcher.getPath(commandnode1), this.dispatcher.getPath(commandnode2), collection);
+            // CommandDispatcher.LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", this.b.getPath(commandnode1), this.b.getPath(commandnode2), collection); // CraftBukkit
         });
-        this.dispatcher.setConsumer((commandcontext, flag, i) -> {
-            ((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag, i);
+    }
+
+    // CraftBukkit start
+    public CommandDispatcher() {
+        this.dispatcher.setConsumer((commandcontext, flag1, i) -> {
+            ((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag1, i);
         });
     }
 
+    public int dispatchServerCommand(CommandListenerWrapper 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(" ");
+
+        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.getWorld().getCraftServer().getCommandBlockOverride(args[0])) {
+            args[0] = "minecraft:" + args[0];
+        }
+
+        String newCommand = joiner.join(args);
+        return this.a(sender, newCommand, newCommand, false);
+    }
+
     public int a(CommandListenerWrapper commandlistenerwrapper, String s) {
+        return this.a(commandlistenerwrapper, s, s, true);
+    }
+
+    public int a(CommandListenerWrapper commandlistenerwrapper, String s, String label, boolean stripSlash) {
         StringReader stringreader = new StringReader(s);
 
-        if (stringreader.canRead() && stringreader.peek() == '/') {
+        if (stripSlash && stringreader.canRead() && stringreader.peek() == '/') {
+            // CraftBukkit end
             stringreader.skip();
         }
 
@@ -229,7 +282,7 @@
                 if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) {
                     int j = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor());
                     IChatMutableComponent ichatmutablecomponent = (new ChatComponentText("")).a(EnumChatFormat.GRAY).format((chatmodifier) -> {
-                        return chatmodifier.setChatClickable(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, s));
+                        return chatmodifier.setChatClickable(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, label)); // CraftBukkit
                     });
 
                     if (j > 10) {
@@ -279,11 +332,36 @@
     }
 
     public void a(EntityPlayer entityplayer) {
-        Map<CommandNode<CommandListenerWrapper>, CommandNode<ICompletionProvider>> map = Maps.newHashMap();
+        // CraftBukkit start
+        // Register Vanilla commands into builtRoot as before
+        Map<CommandNode<CommandListenerWrapper>, CommandNode<ICompletionProvider>> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues
+        RootCommandNode vanillaRoot = new RootCommandNode();
+
+        RootCommandNode<CommandListenerWrapper> vanilla = entityplayer.server.vanillaCommandDispatcher.a().getRoot();
+        map.put(vanilla, vanillaRoot);
+        this.a(vanilla, vanillaRoot, entityplayer.getCommandListener(), (Map) map);
+
+        // Now build the global commands in a second pass
         RootCommandNode<ICompletionProvider> rootcommandnode = new RootCommandNode();
 
         map.put(this.dispatcher.getRoot(), rootcommandnode);
         this.a(this.dispatcher.getRoot(), rootcommandnode, entityplayer.getCommandListener(), (Map) map);
+
+        Collection<String> bukkit = new LinkedHashSet<>();
+        for (CommandNode node : rootcommandnode.getChildren()) {
+            bukkit.add(node.getName());
+        }
+
+        PlayerCommandSendEvent event = new PlayerCommandSendEvent(entityplayer.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
         entityplayer.connection.sendPacket(new PacketPlayOutCommands(rootcommandnode));
     }
 
@@ -294,7 +372,7 @@
             CommandNode<CommandListenerWrapper> commandnode2 = (CommandNode) iterator.next();
 
             if (commandnode2.canUse(commandlistenerwrapper)) {
-                ArgumentBuilder<ICompletionProvider, ?> argumentbuilder = commandnode2.createBuilder();
+                ArgumentBuilder argumentbuilder = commandnode2.createBuilder(); // CraftBukkit - decompile error
 
                 argumentbuilder.requires((icompletionprovider) -> {
                     return true;
@@ -317,7 +395,7 @@
                     argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect()));
                 }
 
-                CommandNode<ICompletionProvider> commandnode3 = argumentbuilder.build();
+                CommandNode commandnode3 = argumentbuilder.build(); // CraftBukkit - decompile error
 
                 map.put(commandnode2, commandnode3);
                 commandnode1.addChild(commandnode3);
