Archiviert
13
0

Add /testfor command support to command block. Adds BUKKIT-3813

Dieser Commit ist enthalten in:
Travis Watkins 2013-03-18 17:12:21 -05:00
Ursprung 596047aa6b
Commit d26336eb40

Datei anzeigen

@ -31,7 +31,7 @@ public class TileEntityCommand extends TileEntity implements ICommandListener {
MinecraftServer minecraftserver = MinecraftServer.getServer(); MinecraftServer minecraftserver = MinecraftServer.getServer();
if (minecraftserver != null && minecraftserver.getEnableCommandBlock()) { 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(); org.bukkit.command.SimpleCommandMap commandMap = minecraftserver.server.getCommandMap();
Joiner joiner = Joiner.on(" "); Joiner joiner = Joiner.on(" ");
String command = this.b; String command = this.b;
@ -58,6 +58,26 @@ public class TileEntityCommand extends TileEntity implements ICommandListener {
return 0; 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); commands.add(args);
// find positions of command block syntax, if any // 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); 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; return completed;
// CraftBukkit end
} else { } else {
return 0; return 0;
} }