diff options
author | Kezz101 <1millionchances@gmail.com> | 2013-07-03 13:40:06 +0100 |
---|---|---|
committer | Travis Ralston <travpc@gmail.com> | 2013-09-10 19:40:03 -0600 |
commit | 3528ca5475b8ef79c830366f325d9415b234b285 (patch) | |
tree | 411f03715cdee74d08cfca650486a24db02efd89 /src/main/java/org | |
parent | eca24a35801403633a301950cebfee4fab7ace9a (diff) | |
download | bukkit-3528ca5475b8ef79c830366f325d9415b234b285.tar bukkit-3528ca5475b8ef79c830366f325d9415b234b285.tar.gz bukkit-3528ca5475b8ef79c830366f325d9415b234b285.tar.lz bukkit-3528ca5475b8ef79c830366f325d9415b234b285.tar.xz bukkit-3528ca5475b8ef79c830366f325d9415b234b285.zip |
Update /say to vanilla behaviour. Fixes BUKKIT-4224
Prior to this commit all /say command output would be a generic "[Server]"
prefixed line. This commit changes that by adding the source into the
message, such as a player. By doing this Bukkit more closely matches
vanilla behaviour and gives a more descriptive message to the client.
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/bukkit/command/defaults/SayCommand.java | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/main/java/org/bukkit/command/defaults/SayCommand.java b/src/main/java/org/bukkit/command/defaults/SayCommand.java index 427897ff..c48c5c30 100644 --- a/src/main/java/org/bukkit/command/defaults/SayCommand.java +++ b/src/main/java/org/bukkit/command/defaults/SayCommand.java @@ -6,6 +6,7 @@ import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; +import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; import com.google.common.collect.ImmutableList; @@ -14,7 +15,7 @@ public class SayCommand extends VanillaCommand { public SayCommand() { super("say"); this.description = "Broadcasts the given message as the console"; - this.usageMessage = "/say <message>"; + this.usageMessage = "/say <message ...>"; this.setPermission("bukkit.command.say"); } @@ -27,20 +28,24 @@ public class SayCommand extends VanillaCommand { } StringBuilder message = new StringBuilder(); + message.append(ChatColor.LIGHT_PURPLE).append("["); + if (sender instanceof ConsoleCommandSender) { + message.append("Server"); + } else if (sender instanceof Player) { + message.append(((Player) sender).getDisplayName()); + } else { + message.append(sender.getName()); + } + message.append(ChatColor.LIGHT_PURPLE).append("] "); + if (args.length > 0) { message.append(args[0]); for (int i = 1; i < args.length; i++) { - message.append(" "); - message.append(args[i]); + message.append(" ").append(args[i]); } } - if (sender instanceof Player) { - Bukkit.getLogger().info("[" + sender.getName() + "] " + message); - } - - Bukkit.broadcastMessage(ChatColor.LIGHT_PURPLE + "[Server] " + message); - + Bukkit.broadcastMessage(message.toString()); return true; } |