2016-03-01 00:23:45 +00:00
|
|
|
From d9b1b2946e2c2db031144ba4dc96b5e06f297b79 Mon Sep 17 00:00:00 2001
|
2014-11-28 01:17:45 +00:00
|
|
|
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
|
2016-02-29 21:33:06 +00:00
|
|
|
index 1a5f14d..940fdd2 100644
|
2014-11-28 01:17:45 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -322,8 +322,11 @@ public final class CraftServer implements Server {
|
2014-11-28 01:17:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
loadCustomPermissions();
|
|
|
|
DefaultPermissions.registerCorePermissions();
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -336,10 +339,19 @@ public final class CraftServer implements Server {
|
2014-11-28 01:17:45 +00:00
|
|
|
pluginManager.disablePlugins();
|
|
|
|
}
|
|
|
|
|
|
|
|
- private void setVanillaCommands() {
|
|
|
|
+ private void setVanillaCommands(boolean first) { // Spigot
|
2016-02-29 21:33:06 +00:00
|
|
|
Map<String, ICommand> commands = new CommandDispatcher(console).getCommands();
|
2014-11-28 01:17:45 +00:00
|
|
|
for (ICommand cmd : commands.values()) {
|
|
|
|
- commandMap.register("minecraft", new VanillaCommandWrapper((CommandAbstract) cmd, LocaleI18n.get(cmd.getUsage(null))));
|
|
|
|
+ // Spigot start
|
|
|
|
+ VanillaCommandWrapper wrapper = new VanillaCommandWrapper((CommandAbstract) cmd, LocaleI18n.get(cmd.getUsage(null)));
|
|
|
|
+ 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
|
2015-05-25 19:09:58 +00:00
|
|
|
index 686b8bd..3a8734f 100644
|
2014-11-28 01:17:45 +00:00
|
|
|
--- 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 gnu.trove.map.hash.TObjectIntHashMap;
|
|
|
|
import net.minecraft.server.MinecraftServer;
|
2015-05-25 19:09:58 +00:00
|
|
|
@@ -302,4 +304,16 @@ public class SpigotConfig
|
2014-11-28 01:17:45 +00:00
|
|
|
{
|
|
|
|
filterCreativeItems = getBoolean( "settings.filter-creative-items", true );
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ 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" ) ) );
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
--
|
2016-02-29 21:33:06 +00:00
|
|
|
2.5.0
|
2014-11-28 01:17:45 +00:00
|
|
|
|