diff options
author | Nate Mortensen <nate.richard.mortensen@gmail.com> | 2013-03-18 00:32:11 -0600 |
---|---|---|
committer | Nate Mortensen <nate.richard.mortensen@gmail.com> | 2013-03-19 20:54:38 -0600 |
commit | dc19d3788f4a729b9fbb648f57b39c87c4497c72 (patch) | |
tree | b5fe1f401de396d0def98522d9f66dadecfd6e6e /src | |
parent | e639690e45cc1eeb2d7ad709ddebe67301da35ab (diff) | |
download | craftbukkit-dc19d3788f4a729b9fbb648f57b39c87c4497c72.tar craftbukkit-dc19d3788f4a729b9fbb648f57b39c87c4497c72.tar.gz craftbukkit-dc19d3788f4a729b9fbb648f57b39c87c4497c72.tar.lz craftbukkit-dc19d3788f4a729b9fbb648f57b39c87c4497c72.tar.xz craftbukkit-dc19d3788f4a729b9fbb648f57b39c87c4497c72.zip |
BlockState for Command Blocks. Adds BUKKIT-3805.
Diffstat (limited to 'src')
3 files changed, 51 insertions, 1 deletions
diff --git a/src/main/java/net/minecraft/server/TileEntityCommand.java b/src/main/java/net/minecraft/server/TileEntityCommand.java index 9967524d..43e03e5e 100644 --- a/src/main/java/net/minecraft/server/TileEntityCommand.java +++ b/src/main/java/net/minecraft/server/TileEntityCommand.java @@ -9,7 +9,7 @@ import com.google.common.base.Joiner; public class TileEntityCommand extends TileEntity implements ICommandListener { private int a = 0; - private String b = ""; + public String b = ""; // CraftBukkit - private -> public private String c = "@"; // CraftBukkit start private final org.bukkit.command.BlockCommandSender sender; diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index 90dae627..ecd08eb6 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -261,6 +261,8 @@ public class CraftBlock implements Block { return new CraftBrewingStand(this); case SKULL: return new CraftSkull(this); + case COMMAND: + return new CraftCommandBlock(this); default: return new CraftBlockState(this); } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java new file mode 100644 index 00000000..4572438d --- /dev/null +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java @@ -0,0 +1,48 @@ +package org.bukkit.craftbukkit.block;
+
+import net.minecraft.server.TileEntityCommand;
+import org.bukkit.block.Block;
+import org.bukkit.block.CommandBlock;
+import org.bukkit.craftbukkit.CraftWorld;
+
+public class CraftCommandBlock extends CraftBlockState implements CommandBlock {
+ private final TileEntityCommand commandBlock;
+ private String command;
+ private String name;
+
+ public CraftCommandBlock(Block block) {
+ super(block);
+
+ CraftWorld world = (CraftWorld) block.getWorld();
+ commandBlock = (TileEntityCommand) world.getTileEntityAt(getX(), getY(), getZ());
+ command = commandBlock.b;
+ name = commandBlock.getName();
+ }
+
+ public String getCommand() {
+ return command;
+ }
+
+ public void setCommand(String command) {
+ this.command = command != null ? command : "";
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name != null ? name : "@";
+ }
+
+ public boolean update(boolean forced) {
+ boolean result = super.update(forced);
+
+ if (result) {
+ commandBlock.b(command);
+ commandBlock.c(name);
+ }
+
+ return result;
+ }
+}
|