From 73fe3123f6eb4472d0f189f307cf2ca4e2d3c9eb Mon Sep 17 00:00:00 2001 From: Thinkofdeath Date: Wed, 12 Feb 2014 20:45:59 +0000 Subject: [PATCH] Re-add the replace-commands feature --- ...mmands-to-be-the-main-version-of-a-c.patch | 172 ++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 CraftBukkit-Patches/0110-Allow-vanilla-commands-to-be-the-main-version-of-a-c.patch diff --git a/CraftBukkit-Patches/0110-Allow-vanilla-commands-to-be-the-main-version-of-a-c.patch b/CraftBukkit-Patches/0110-Allow-vanilla-commands-to-be-the-main-version-of-a-c.patch new file mode 100644 index 0000000000..06b63974dd --- /dev/null +++ b/CraftBukkit-Patches/0110-Allow-vanilla-commands-to-be-the-main-version-of-a-c.patch @@ -0,0 +1,172 @@ +From 7d4c6d3b7b69a67c0d82284800b0fa2ffeb6fbb6 Mon Sep 17 00:00:00 2001 +From: Thinkofdeath +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 b9a72d8..931cae7 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +@@ -117,6 +117,7 @@ import org.bukkit.command.CommandSender; + import org.bukkit.command.ConsoleCommandSender; + import org.bukkit.command.PluginCommand; + import org.bukkit.command.SimpleCommandMap; ++import org.bukkit.command.defaults.VanillaCommand; + import org.bukkit.configuration.ConfigurationSection; + import org.bukkit.configuration.file.YamlConfiguration; + import org.bukkit.configuration.serialization.ConfigurationSerialization; +@@ -381,8 +382,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(); + loadCustomPermissions(); + DefaultPermissions.registerCorePermissions(); +@@ -394,49 +398,62 @@ public final class CraftServer implements Server { + pluginManager.disablePlugins(); + } + +- private void setVanillaCommands() { +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandAchievement(), "/achievement give [player]")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandBan(), "/ban [reason]")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandBanIp(), "/ban-ip ")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandBanList(), "/banlist [ips]")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandClear(), "/clear [item] [metadata]")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandGamemodeDefault(), "/defaultgamemode ")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandDeop(), "/deop ")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandDifficulty(), "/difficulty ")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandEffect(), "/effect [seconds] [amplifier]")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandEnchant(), "/enchant [enchantment level]")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandGamemode(), "/gamemode [player]")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandGamerule(), "/gamerule [true|false]")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandGive(), "/give [amount] [metadata] [dataTag]")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandHelp(), "/help [page|commandname]")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandIdleTimeout(), "/setidletimeout ")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandKick(), "/kick [reason]")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandKill(), "/kill [playername]")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandList(), "/list")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandMe(), "/me ")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandOp(), "/op ")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandPardon(), "/pardon ")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandPardonIP(), "/pardon-ip ")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandPlaySound(), "/playsound [x] [y] [z] [volume] [pitch] [minimumVolume]")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandSay(), "/say ")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandScoreboard(), "/scoreboard")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandSeed(), "/seed")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandSetBlock(), "/setblock [datavalue] [oldblockHandling] [dataTag]")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandSetWorldSpawn(), "/setworldspawn [x] [y] [z]")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandSpawnpoint(), "/spawnpoint [x] [y] [z]")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandSpreadPlayers(), "/spreadplayers [spreadDistance] [maxRange] [respectTeams] ")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandSummon(), "/summon [x] [y] [z] [dataTag]")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandTp(), "/tp [player] \n/tp [player] ")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandTell(), "/tell ")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandTellRaw(), "/tellraw ")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandTestFor(), "/testfor [dataTag]")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandTestForBlock(), "/testforblock [datavalue] [dataTag]")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandTime(), "/time set \n/time add ")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandToggleDownfall(), "/toggledownfall")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandWeather(), "/weather [duration in seconds]")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandWhitelist(), "/whitelist (add|remove) \n/whitelist (on|off|list|reload)")); +- commandMap.register("minecraft", new VanillaCommandWrapper(new CommandXp(), "/xp [player]\n/xp L [player]")); +- } ++ // Spigot start ++ private void tryRegister(VanillaCommandWrapper commandWrapper, boolean first) { ++ if (org.spigotmc.SpigotConfig.replaceCommands.contains( commandWrapper.getName() ) ) { ++ if (first) { ++ commandMap.register( "minecraft", commandWrapper ); ++ } ++ } else if (!first) { ++ commandMap.register( "minecraft", commandWrapper ); ++ } ++ } ++ ++ private void setVanillaCommands(boolean first) ++ { ++ tryRegister( new VanillaCommandWrapper( new CommandAchievement(), "/achievement give [player]" ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandBan(), "/ban [reason]" ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandBanIp(), "/ban-ip " ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandBanList(), "/banlist [ips]" ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandClear(), "/clear [item] [metadata]" ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandGamemodeDefault(), "/defaultgamemode " ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandDeop(), "/deop " ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandDifficulty(), "/difficulty " ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandEffect(), "/effect [seconds] [amplifier]" ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandEnchant(), "/enchant [enchantment level]" ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandGamemode(), "/gamemode [player]" ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandGamerule(), "/gamerule [true|false]" ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandGive(), "/give [amount] [metadata] [dataTag]" ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandHelp(), "/help [page|commandname]" ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandIdleTimeout(), "/setidletimeout " ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandKick(), "/kick [reason]" ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandKill(), "/kill [playername]" ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandList(), "/list" ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandMe(), "/me " ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandOp(), "/op " ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandPardon(), "/pardon " ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandPardonIP(), "/pardon-ip " ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandPlaySound(), "/playsound [x] [y] [z] [volume] [pitch] [minimumVolume]" ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandSay(), "/say " ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandScoreboard(), "/scoreboard" ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandSeed(), "/seed" ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandSetBlock(), "/setblock [datavalue] [oldblockHandling] [dataTag]" ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandSetWorldSpawn(), "/setworldspawn [x] [y] [z]" ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandSpawnpoint(), "/spawnpoint [x] [y] [z]" ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandSpreadPlayers(), "/spreadplayers [spreadDistance] [maxRange] [respectTeams] " ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandSummon(), "/summon [x] [y] [z] [dataTag]" ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandTp(), "/tp [player] \n/tp [player] " ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandTell(), "/tell " ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandTellRaw(), "/tellraw " ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandTestFor(), "/testfor [dataTag]" ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandTestForBlock(), "/testforblock [datavalue] [dataTag]" ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandTime(), "/time set \n/time add " ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandToggleDownfall(), "/toggledownfall" ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandWeather(), "/weather [duration in seconds]" ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandWhitelist(), "/whitelist (add|remove) \n/whitelist (on|off|list|reload)" ), first ); ++ tryRegister( new VanillaCommandWrapper( new CommandXp(), "/xp [player]\n/xp L [player]" ), first ); ++ } ++ // Spigot end + + private void loadPlugin(Plugin plugin) { + try { +diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java +index 7589246..df70756 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 gnu.trove.map.hash.TObjectIntHashMap; +@@ -273,4 +275,16 @@ public class SpigotConfig + { + filterCreativeItems = getBoolean( "settings.filter-creative-items", true ); + } ++ ++ public static Set 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( (List) getList( "commands.replace-commands", ++ Arrays.asList( "setblock", "summon", "testforblock", "tellraw" ) ) ); ++ } + } +-- +1.8.4.msysgit.0 +