2011-03-30 04:03:21 +00:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
|
|
|
import org.bukkit.Server;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import com.earth2me.essentials.Essentials;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import com.earth2me.essentials.User;
|
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
|
|
|
|
|
|
|
|
public class Commandwhois extends EssentialsCommand
|
|
|
|
{
|
|
|
|
public Commandwhois()
|
|
|
|
{
|
|
|
|
super("whois");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void run(Server server, Essentials parent, CommandSender sender, String commandLabel, String[] args) throws Exception
|
|
|
|
{
|
|
|
|
if (args.length < 1)
|
|
|
|
{
|
|
|
|
sender.sendMessage("§cUsage: /whois [nickname]");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
String whois = args[0].toLowerCase();
|
|
|
|
User.charge(sender, this);
|
|
|
|
int prefixLength = ChatColor.stripColor(Essentials.getSettings().getNicknamePrefix()).length();
|
|
|
|
for (Player p : server.getOnlinePlayers())
|
|
|
|
{
|
|
|
|
User u = User.get(p);
|
|
|
|
String dn = ChatColor.stripColor(u.getNick());
|
2011-05-01 19:38:25 +00:00
|
|
|
if (!whois.equalsIgnoreCase(dn) && !whois.equalsIgnoreCase(dn.substring(prefixLength)) && !whois.equalsIgnoreCase(u.getName()))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2011-03-30 04:03:21 +00:00
|
|
|
sender.sendMessage("");
|
|
|
|
sender.sendMessage(u.getDisplayName() + " is " + u.getName());
|
|
|
|
sender.sendMessage(ChatColor.BLUE + " - Health: " + u.getHealth() + "/20");
|
2011-03-30 12:56:34 +00:00
|
|
|
sender.sendMessage(ChatColor.BLUE + " - Location: (" + u.getLocation().getWorld().getName() + ", " + u.getLocation().getBlockX() + ", " + u.getLocation().getBlockY() + ", " + u.getLocation().getBlockZ() + ")");
|
2011-05-01 19:38:25 +00:00
|
|
|
if (!parent.getConfiguration().getBoolean("disable-eco", false))
|
|
|
|
{
|
|
|
|
sender.sendMessage(ChatColor.BLUE + " - Money: $" + u.getMoney());
|
|
|
|
}
|
2011-03-30 12:56:34 +00:00
|
|
|
sender.sendMessage(ChatColor.BLUE + " - Status: " + (parent.away.contains(u) ? "§cAway§f" : "Available"));
|
2011-03-30 04:03:21 +00:00
|
|
|
sender.sendMessage(ChatColor.BLUE + " - IP Address: " + u.getAddress().getAddress().toString());
|
2011-05-01 11:04:34 +00:00
|
|
|
Object location = u.getMetadata().get("location");
|
2011-05-01 19:38:25 +00:00
|
|
|
if (location != null && location instanceof String
|
|
|
|
&& (sender instanceof Player ? User.get(sender).isAuthorized("essentials.geoip.show") : true))
|
|
|
|
{
|
2011-05-01 11:04:34 +00:00
|
|
|
sender.sendMessage(ChatColor.BLUE + " - Location: " + location.toString());
|
|
|
|
}
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|