diff options
author | Travis Watkins <amaranth@ubuntu.com> | 2012-10-31 06:36:55 -0500 |
---|---|---|
committer | Travis Watkins <amaranth@ubuntu.com> | 2012-10-31 06:37:46 -0500 |
commit | 46d7cd1e0502edbbca323b2a289a49fbf951628d (patch) | |
tree | 095034bea876ce241ed3c2f401903071069bb913 /src/main/java/net/minecraft/server/TileEntityCommand.java | |
parent | 9e4e2c62af6b6d12cc6a15cbf117d0a7586372c6 (diff) | |
download | craftbukkit-46d7cd1e0502edbbca323b2a289a49fbf951628d.tar craftbukkit-46d7cd1e0502edbbca323b2a289a49fbf951628d.tar.gz craftbukkit-46d7cd1e0502edbbca323b2a289a49fbf951628d.tar.lz craftbukkit-46d7cd1e0502edbbca323b2a289a49fbf951628d.tar.xz craftbukkit-46d7cd1e0502edbbca323b2a289a49fbf951628d.zip |
Use BlockCommandSender for dispatching Command block commands
Also allow commands that don't start with a / to match vanilla behavior
Diffstat (limited to 'src/main/java/net/minecraft/server/TileEntityCommand.java')
-rw-r--r-- | src/main/java/net/minecraft/server/TileEntityCommand.java | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/main/java/net/minecraft/server/TileEntityCommand.java b/src/main/java/net/minecraft/server/TileEntityCommand.java index 1a8317a4..78e462a3 100644 --- a/src/main/java/net/minecraft/server/TileEntityCommand.java +++ b/src/main/java/net/minecraft/server/TileEntityCommand.java @@ -9,8 +9,11 @@ import com.google.common.base.Joiner; public class TileEntityCommand extends TileEntity implements ICommandListener { private String a = ""; + private final org.bukkit.command.BlockCommandSender sender; - public TileEntityCommand() {} + public TileEntityCommand() { + sender = new org.bukkit.craftbukkit.command.CraftBlockCommandSender(this); + } public void b(String s) { this.a = s; @@ -23,15 +26,12 @@ public class TileEntityCommand extends TileEntity implements ICommandListener { if (minecraftserver != null && minecraftserver.getEnableCommandBlock()) { // CraftBukkit start - handle command block as console TODO: add new CommandSender for this - // Commands in command block must start with / - if (!this.a.startsWith("/")) { - return; - } - org.bukkit.command.SimpleCommandMap commandMap = minecraftserver.server.getCommandMap(); - org.bukkit.command.ConsoleCommandSender sender = minecraftserver.server.getConsoleSender(); Joiner joiner = Joiner.on(" "); - String command = this.a.substring(1); + String command = this.a; + if (this.a.startsWith("/")) { + command = this.a.substring(1); + } String[] args = command.split(" "); ArrayList<String[]> commands = new ArrayList<String[]>(); @@ -50,13 +50,16 @@ public class TileEntityCommand extends TileEntity implements ICommandListener { commands.add(args); // find positions of command block syntax, if any + ArrayList<String[]> newCommands = new ArrayList<String[]>(); for (int i = 0; i < args.length; i++) { if (PlayerSelector.isPattern(args[i])) { - ArrayList<String[]> newCommands = new ArrayList<String[]>(); for (int j = 0; j < commands.size(); j++) { newCommands.addAll(this.buildCommands(commands.get(j), i)); } + ArrayList<String[]> temp = commands; commands = newCommands; + newCommands = temp; + newCommands.clear(); } } |