summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server
diff options
context:
space:
mode:
authorTravis Watkins <amaranth@ubuntu.com>2012-10-31 06:36:55 -0500
committerTravis Watkins <amaranth@ubuntu.com>2012-10-31 06:37:46 -0500
commit46d7cd1e0502edbbca323b2a289a49fbf951628d (patch)
tree095034bea876ce241ed3c2f401903071069bb913 /src/main/java/net/minecraft/server
parent9e4e2c62af6b6d12cc6a15cbf117d0a7586372c6 (diff)
downloadcraftbukkit-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')
-rw-r--r--src/main/java/net/minecraft/server/TileEntity.java2
-rw-r--r--src/main/java/net/minecraft/server/TileEntityCommand.java21
2 files changed, 13 insertions, 10 deletions
diff --git a/src/main/java/net/minecraft/server/TileEntity.java b/src/main/java/net/minecraft/server/TileEntity.java
index 87d5cd26..b763b482 100644
--- a/src/main/java/net/minecraft/server/TileEntity.java
+++ b/src/main/java/net/minecraft/server/TileEntity.java
@@ -9,7 +9,7 @@ public class TileEntity {
private static Map a = new HashMap();
private static Map b = new HashMap();
- protected World world;
+ public World world; // CraftBukkit - protected -> public
public int x;
public int y;
public int z;
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();
}
}