blob: 44dc7ae0d9d20af34d7914cd80a2c0396793db59 (
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
|
package org.bukkit.command.defaults;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class SayCommand extends VanillaCommand {
public SayCommand() {
super("say");
this.description = "Broadcasts the given message as the console";
this.usageMessage = "/say <message>";
this.setPermission("bukkit.command.say");
}
@Override
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
if (!testPermission(sender)) return true;
if (args.length == 0) {
sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
return false;
}
StringBuilder message = new StringBuilder();
if (args.length > 0) {
message.append(args[0]);
for (int i = 1; i < args.length; i++) {
message.append(" ");
message.append(args[i]);
}
}
if (sender instanceof Player) {
Bukkit.getLogger().info("[" + sender.getName() + "] " + message);
}
Bukkit.broadcastMessage(ChatColor.LIGHT_PURPLE + "[Server] " + message);
return true;
}
@Override
public boolean matches(String input) {
return input.equalsIgnoreCase("say");
}
}
|