Add alert command.

This commit is contained in:
md_5 2012-10-16 16:57:19 +11:00
parent 7901cdfed6
commit 914949d34e
2 changed files with 33 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import java.util.concurrent.Executors;
import java.util.logging.Level;
import static net.md_5.bungee.Logger.$;
import net.md_5.bungee.command.Command;
import net.md_5.bungee.command.CommandAlert;
import net.md_5.bungee.command.CommandEnd;
import net.md_5.bungee.command.CommandIP;
import net.md_5.bungee.command.CommandList;
@ -73,6 +74,7 @@ public class BungeeCord {
commandMap.put("glist", new CommandList());
commandMap.put("server", new CommandServer());
commandMap.put("ip", new CommandIP());
commandMap.put("alert", new CommandAlert());
}
/**

View File

@ -0,0 +1,31 @@
package net.md_5.bungee.command;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.ChatColor;
import net.md_5.bungee.Permission;
import net.md_5.bungee.UserConnection;
public class CommandAlert extends Command {
@Override
public void execute(CommandSender sender, String[] args) {
if (getPermission(sender) != Permission.ADMIN) {
sender.sendMessage(ChatColor.RED + "You do not have permission to execute this command!");
return;
}
if (args.length == 0) {
sender.sendMessage(ChatColor.RED + "Please follow this command by an announcement to make");
} else {
StringBuilder builder = new StringBuilder();
builder.append(ChatColor.DARK_PURPLE);
builder.append(" [Alert] ");
for (String s : args) {
builder.append(s);
}
String message = builder.toString();
for (UserConnection con : BungeeCord.instance.connections.values()) {
con.sendMessage(message.toString());
}
}
}
}