diff options
author | Travis Watkins <amaranth@ubuntu.com> | 2013-03-18 17:12:21 -0500 |
---|---|---|
committer | Travis Watkins <amaranth@ubuntu.com> | 2013-03-18 17:12:21 -0500 |
commit | d26336eb4007bb1edfdf824fb970da51b8482d96 (patch) | |
tree | 970d95ac99d2b1949ec86ade28d208b4fee209e8 /src/main/java/net/minecraft/server/TileEntityCommand.java | |
parent | 596047aa6b18c1c18a6b7280f21ddb01e8913479 (diff) | |
download | craftbukkit-d26336eb4007bb1edfdf824fb970da51b8482d96.tar craftbukkit-d26336eb4007bb1edfdf824fb970da51b8482d96.tar.gz craftbukkit-d26336eb4007bb1edfdf824fb970da51b8482d96.tar.lz craftbukkit-d26336eb4007bb1edfdf824fb970da51b8482d96.tar.xz craftbukkit-d26336eb4007bb1edfdf824fb970da51b8482d96.zip |
Add /testfor command support to command block. Adds BUKKIT-3813
Diffstat (limited to 'src/main/java/net/minecraft/server/TileEntityCommand.java')
-rw-r--r-- | src/main/java/net/minecraft/server/TileEntityCommand.java | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/main/java/net/minecraft/server/TileEntityCommand.java b/src/main/java/net/minecraft/server/TileEntityCommand.java index f05573d1..9967524d 100644 --- a/src/main/java/net/minecraft/server/TileEntityCommand.java +++ b/src/main/java/net/minecraft/server/TileEntityCommand.java @@ -31,7 +31,7 @@ public class TileEntityCommand extends TileEntity implements ICommandListener { MinecraftServer minecraftserver = MinecraftServer.getServer(); if (minecraftserver != null && minecraftserver.getEnableCommandBlock()) { - // CraftBukkit start - handle command block as console + // CraftBukkit start - handle command block commands using Bukkit dispatcher org.bukkit.command.SimpleCommandMap commandMap = minecraftserver.server.getCommandMap(); Joiner joiner = Joiner.on(" "); String command = this.b; @@ -58,6 +58,26 @@ public class TileEntityCommand extends TileEntity implements ICommandListener { return 0; } + // testfor command requires special handling + if (args[0].equalsIgnoreCase("testfor")) { + if (args.length < 2) { + return 0; + } + + EntityPlayer[] players = PlayerSelector.getPlayers(this, args[1]); + + if (players != null && players.length > 0) { + return players.length; + } else { + EntityPlayer player = MinecraftServer.getServer().getPlayerList().f(args[1]); // Should be getPlayer + if (player == null) { + return 0; + } else { + return 1; + } + } + } + commands.add(args); // find positions of command block syntax, if any @@ -86,8 +106,9 @@ public class TileEntityCommand extends TileEntity implements ICommandListener { minecraftserver.getLogger().warning(String.format("CommandBlock at (%d,%d,%d) failed to handle command", this.x, this.y, this.z), exception); } } - // CraftBukkit end + return completed; + // CraftBukkit end } else { return 0; } |