Commits
blablubbabc authored and md_5 committed 560b65c4f8a
1 1 | package org.bukkit.craftbukkit.block; |
2 2 | |
3 3 | import net.minecraft.server.TileEntityCommand; |
4 4 | import org.bukkit.Material; |
5 5 | import org.bukkit.block.Block; |
6 6 | import org.bukkit.block.CommandBlock; |
7 7 | import org.bukkit.craftbukkit.util.CraftChatMessage; |
8 8 | |
9 9 | public class CraftCommandBlock extends CraftBlockEntityState<TileEntityCommand> implements CommandBlock { |
10 10 | |
11 - | private String command; |
12 - | private String name; |
13 - | |
14 11 | public CraftCommandBlock(Block block) { |
15 12 | super(block, TileEntityCommand.class); |
16 13 | } |
17 14 | |
18 15 | public CraftCommandBlock(final Material material, final TileEntityCommand te) { |
19 16 | super(material, te); |
20 17 | } |
21 18 | |
22 - | |
23 - | public void load(TileEntityCommand commandBlock) { |
24 - | super.load(commandBlock); |
25 - | |
26 - | command = commandBlock.getCommandBlock().getCommand(); |
27 - | name = CraftChatMessage.fromComponent(commandBlock.getCommandBlock().getName()); |
28 - | } |
29 - | |
30 19 | |
31 20 | public String getCommand() { |
32 - | return command; |
21 + | return getSnapshot().getCommandBlock().getCommand(); |
33 22 | } |
34 23 | |
35 24 | |
36 25 | public void setCommand(String command) { |
37 - | this.command = command != null ? command : ""; |
26 + | getSnapshot().getCommandBlock().setCommand(command != null ? command : ""); |
38 27 | } |
39 28 | |
40 29 | |
41 30 | public String getName() { |
42 - | return name; |
31 + | return CraftChatMessage.fromComponent(getSnapshot().getCommandBlock().getName()); |
43 32 | } |
44 33 | |
45 34 | |
46 35 | public void setName(String name) { |
47 - | this.name = name != null ? name : "@"; |
48 - | } |
49 - | |
50 - | |
51 - | public void applyTo(TileEntityCommand commandBlock) { |
52 - | super.applyTo(commandBlock); |
53 - | |
54 - | commandBlock.getCommandBlock().setCommand(command); |
55 - | commandBlock.getCommandBlock().setName(CraftChatMessage.fromStringOrNull(name)); |
36 + | getSnapshot().getCommandBlock().setName(CraftChatMessage.fromStringOrNull(name != null ? name : "@")); |
56 37 | } |
57 38 | } |