blob: 9bbc790509758c79d34459984e736a32b2921da3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
package org.bukkit.craftbukkit.block;
import net.minecraft.server.TileEntityCommand;
import org.bukkit.Material;
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.getCommandBlock().getCommand();
name = commandBlock.getCommandBlock().getName();
}
public CraftCommandBlock(final Material material, final TileEntityCommand te) {
super(material);
commandBlock = te;
command = commandBlock.getCommandBlock().getCommand();
name = commandBlock.getCommandBlock().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 force, boolean applyPhysics) {
boolean result = super.update(force, applyPhysics);
if (result) {
commandBlock.getCommandBlock().setCommand(command);
commandBlock.getCommandBlock().setName(name);
}
return result;
}
@Override
public TileEntityCommand getTileEntity() {
return commandBlock;
}
}
|