From 0e9002091b50394092bde673b13bad23e0008238 Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 24 May 2013 14:35:27 +1000 Subject: [PATCH] Add whois command --- .../main/java/net/md_5/bungee/BungeeCord.java | 1 + .../net/md_5/bungee/command/CommandWhois.java | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 proxy/src/main/java/net/md_5/bungee/command/CommandWhois.java diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java index 35ed11e5..e9a74efc 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -138,6 +138,7 @@ public class BungeeCord extends ProxyServer getPluginManager().registerCommand( null, new CommandBungee() ); getPluginManager().registerCommand( null, new CommandPerms() ); getPluginManager().registerCommand( null, new CommandSend() ); + getPluginManager().registerCommand( null, new CommandWhois() ); registerChannel( "BungeeCord" ); } diff --git a/proxy/src/main/java/net/md_5/bungee/command/CommandWhois.java b/proxy/src/main/java/net/md_5/bungee/command/CommandWhois.java new file mode 100644 index 00000000..4fe2dcc1 --- /dev/null +++ b/proxy/src/main/java/net/md_5/bungee/command/CommandWhois.java @@ -0,0 +1,35 @@ +package net.md_5.bungee.command; + +import net.md_5.bungee.api.ChatColor; +import net.md_5.bungee.api.CommandSender; +import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import net.md_5.bungee.api.plugin.Command; + +public class CommandWhois extends Command +{ + + public CommandWhois() + { + super( "whois", "bungeecord.command.whois" ); + } + + @Override + public void execute(CommandSender sender, String[] args) + { + if ( args.length != 1 ) + { + sender.sendMessage( ChatColor.RED + "Please follow this command by a user name" ); + } else + { + ProxiedPlayer player = ProxyServer.getInstance().getPlayer( args[0] ); + if ( player == null || player.getServer() == null ) + { + sender.sendMessage( ChatColor.RED + "That user is not online" ); + } else + { + sender.sendMessage( ChatColor.BLUE + args[0] + " is online at" + player.getServer().getInfo().getName() ); + } + } + } +}