Commits

Cory Redmond authored and md_5 committed 77224288958
Add the ability for commandblocks to be sent messages via the API.
No tags

src/main/java/org/bukkit/craftbukkit/command/CraftBlockCommandSender.java

Modified
1 1 package org.bukkit.craftbukkit.command;
2 2
3 3 import net.minecraft.server.ICommandListener;
4 4 import net.minecraft.server.CommandBlockListenerAbstract;
5 +import net.minecraft.server.IChatBaseComponent;
5 6
6 7 import org.bukkit.block.Block;
7 8 import org.bukkit.command.BlockCommandSender;
9 +import org.bukkit.craftbukkit.util.CraftChatMessage;
8 10
9 11 /**
10 12 * Represents input from a command block
11 13 */
12 14 public class CraftBlockCommandSender extends ServerCommandSender implements BlockCommandSender {
13 15 private final CommandBlockListenerAbstract commandBlock;
14 16
15 17 public CraftBlockCommandSender(CommandBlockListenerAbstract commandBlockListenerAbstract) {
16 18 super();
17 19 this.commandBlock = commandBlockListenerAbstract;
18 20 }
19 21
20 22 public Block getBlock() {
21 23 return commandBlock.getWorld().getWorld().getBlockAt(commandBlock.getChunkCoordinates().getX(), commandBlock.getChunkCoordinates().getY(), commandBlock.getChunkCoordinates().getZ());
22 24 }
23 25
24 26 public void sendMessage(String message) {
27 + for (IChatBaseComponent component : CraftChatMessage.fromString(message)) {
28 + commandBlock.sendMessage(component);
29 + }
25 30 }
26 31
27 32 public void sendMessage(String[] messages) {
33 + for (String message : messages) {
34 + sendMessage(message);
35 + }
28 36 }
29 37
30 38 public String getName() {
31 39 return commandBlock.getName();
32 40 }
33 41
34 42 public boolean isOp() {
35 43 return true;
36 44 }
37 45

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut