mirror of
https://hub.spigotmc.org/stash/scm/spigot/spigot.git
synced 2024-11-24 15:16:26 +00:00
83 lines
3.4 KiB
Diff
83 lines
3.4 KiB
Diff
From 35c76637d7e0b38dac0426e232658ecfd4f7935f Mon Sep 17 00:00:00 2001
|
|
From: Thinkofdeath <thethinkofdeath@gmail.com>
|
|
Date: Wed, 12 Feb 2014 20:44:14 +0000
|
|
Subject: [PATCH] Allow vanilla commands to be the main version of a command
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
index e58a0762c0..d73fbd7283 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -493,8 +493,11 @@ public final class CraftServer implements Server {
|
|
}
|
|
|
|
if (type == PluginLoadOrder.POSTWORLD) {
|
|
+ // Spigot start - Allow vanilla commands to be forced to be the main command
|
|
+ setVanillaCommands(true);
|
|
commandMap.setFallbackCommands();
|
|
- setVanillaCommands();
|
|
+ setVanillaCommands(false);
|
|
+ // Spigot end
|
|
commandMap.registerServerAliases();
|
|
DefaultPermissions.registerCorePermissions();
|
|
CraftDefaultPermissions.registerCorePermissions();
|
|
@@ -508,12 +511,21 @@ public final class CraftServer implements Server {
|
|
pluginManager.disablePlugins();
|
|
}
|
|
|
|
- private void setVanillaCommands() {
|
|
+ private void setVanillaCommands(boolean first) { // Spigot
|
|
CommandDispatcher dispatcher = console.vanillaCommandDispatcher;
|
|
|
|
// Build a list of all Vanilla commands and create wrappers
|
|
for (CommandNode<CommandListenerWrapper> cmd : dispatcher.getDispatcher().getRoot().getChildren()) {
|
|
- commandMap.register("minecraft", new VanillaCommandWrapper(dispatcher, cmd));
|
|
+ // Spigot start
|
|
+ VanillaCommandWrapper wrapper = new VanillaCommandWrapper(dispatcher, cmd);
|
|
+ if (org.spigotmc.SpigotConfig.replaceCommands.contains( wrapper.getName() ) ) {
|
|
+ if (first) {
|
|
+ commandMap.register("minecraft", wrapper);
|
|
+ }
|
|
+ } else if (!first) {
|
|
+ commandMap.register("minecraft", wrapper);
|
|
+ }
|
|
+ // Spigot end
|
|
}
|
|
}
|
|
|
|
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
|
index 128b826ca9..f20e896f2e 100644
|
|
--- a/src/main/java/org/spigotmc/SpigotConfig.java
|
|
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
|
@@ -8,8 +8,10 @@ import java.lang.reflect.Method;
|
|
import java.lang.reflect.Modifier;
|
|
import java.util.Arrays;
|
|
import java.util.HashMap;
|
|
+import java.util.HashSet;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
+import java.util.Set;
|
|
import java.util.logging.Level;
|
|
import net.minecraft.core.registries.BuiltInRegistries;
|
|
import net.minecraft.resources.MinecraftKey;
|
|
@@ -300,4 +302,16 @@ public class SpigotConfig
|
|
{
|
|
silentCommandBlocks = getBoolean( "commands.silent-commandblock-console", false );
|
|
}
|
|
+
|
|
+ public static Set<String> replaceCommands;
|
|
+ private static void replaceCommands()
|
|
+ {
|
|
+ if ( config.contains( "replace-commands" ) )
|
|
+ {
|
|
+ set( "commands.replace-commands", config.getStringList( "replace-commands" ) );
|
|
+ config.set( "replace-commands", null );
|
|
+ }
|
|
+ replaceCommands = new HashSet<String>( (List<String>) getList( "commands.replace-commands",
|
|
+ Arrays.asList( "setblock", "summon", "testforblock", "tellraw" ) ) );
|
|
+ }
|
|
}
|
|
--
|
|
2.47.0
|
|
|