2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2024-11-22 20:28:00 +00:00

Add sendtoall command

This commit is contained in:
vemacs 2014-01-16 17:49:57 -07:00
parent bcdbf9ba54
commit acde2310c2
2 changed files with 22 additions and 0 deletions

View File

@ -205,6 +205,7 @@ public final class RedisBungee extends Plugin implements Listener {
getProxy().getPluginManager().registerCommand(this, new RedisBungeeCommands.FindCommand());
getProxy().getPluginManager().registerCommand(this, new RedisBungeeCommands.LastSeenCommand());
getProxy().getPluginManager().registerCommand(this, new RedisBungeeCommands.IpCommand());
getProxy().getPluginManager().registerCommand(this, new RedisBungeeCommands.SendToAll());
getProxy().getPluginManager().registerListener(this, this);
api = new RedisBungeeAPI(this);
psl = new PubSubListener();

View File

@ -33,6 +33,8 @@ class RedisBungeeCommands {
new ComponentBuilder("").color(ChatColor.RED).append("You must specify a player name.").create();
private static final BaseComponent[] PLAYER_NOT_FOUND =
new ComponentBuilder("").color(ChatColor.RED).append("No such player found.").create();
private static final BaseComponent[] NO_COMMAND_SPECIFIED =
new ComponentBuilder("").color(ChatColor.RED).append("You must specify a command to be run.").create();
public static class GlistCommand extends Command {
GlistCommand() {
@ -144,4 +146,23 @@ class RedisBungeeCommands {
}
}
}
public static class SendToAll extends Command {
SendToAll() {
super("sendtoall", "redisbungee.command.sendtoall");
}
@Override
public void execute(CommandSender sender, String[] args) {
if (args.length > 0) {
String command = Joiner.on(" ").skipNulls().join(args);
RedisBungee.getApi().sendProxyCommand(command);
TextComponent message = new TextComponent();
message.setColor(ChatColor.GREEN);
message.setText("Sent the command /" + command + " to all proxies.");
} else {
sender.sendMessage(NO_COMMAND_SPECIFIED);
}
}
}
}