diff options
Diffstat (limited to 'Essentials/src/com/earth2me/essentials/commands/Commandwhois.java')
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandwhois.java | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java index 1769202f5..c5d10a2e8 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java @@ -1,11 +1,13 @@ package com.earth2me.essentials.commands; -import org.bukkit.Server; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; +import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import java.util.Locale; import org.bukkit.ChatColor; +import org.bukkit.Server; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; public class Commandwhois extends EssentialsCommand @@ -16,7 +18,7 @@ public class Commandwhois extends EssentialsCommand } @Override - public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { if (args.length < 1) { @@ -34,39 +36,42 @@ public class Commandwhois extends EssentialsCommand { showhidden = true; } - String whois = args[0].toLowerCase(); - int prefixLength = ChatColor.stripColor(ess.getSettings().getNicknamePrefix()).length(); - for (Player p : server.getOnlinePlayers()) + final String whois = args[0].toLowerCase(Locale.ENGLISH); + final int prefixLength = ChatColor.stripColor(ess.getSettings().getNicknamePrefix()).length(); + for (Player onlinePlayer : server.getOnlinePlayers()) { - User u = ess.getUser(p); - if (u.isHidden() && !showhidden) + final User user = ess.getUser(onlinePlayer); + if (user.isHidden() && !showhidden) { continue; } - String dn = ChatColor.stripColor(u.getNick()); - if (!whois.equalsIgnoreCase(dn) - && !whois.equalsIgnoreCase(dn.substring(prefixLength)) - && !whois.equalsIgnoreCase(u.getName())) + final String nickName = ChatColor.stripColor(user.getNickname()); + if (!whois.equalsIgnoreCase(nickName) + && !whois.substring(prefixLength).equalsIgnoreCase(nickName) + && !whois.equalsIgnoreCase(user.getName())) { continue; } sender.sendMessage(""); - sender.sendMessage(Util.format("whoisIs", u.getDisplayName(), u.getName())); - sender.sendMessage(Util.format("whoisHealth", u.getHealth())); - sender.sendMessage(Util.format("whoisLocation", u.getLocation().getWorld().getName(), u.getLocation().getBlockX(), u.getLocation().getBlockY(), u.getLocation().getBlockZ())); + sender.sendMessage(_("whoisIs", user.getDisplayName(), user.getName())); + sender.sendMessage(_("whoisHealth", user.getHealth())); + sender.sendMessage(_("whoisOP", (user.isOp() ? _("true") : _("false")))); + sender.sendMessage(_("whoisGod", (user.isGodModeEnabled() ? _("true") : _("false")))); + sender.sendMessage(_("whoisGamemode", _(user.getGameMode().toString().toLowerCase(Locale.ENGLISH)))); + sender.sendMessage(_("whoisLocation", user.getLocation().getWorld().getName(), user.getLocation().getBlockX(), user.getLocation().getBlockY(), user.getLocation().getBlockZ())); if (!ess.getSettings().isEcoDisabled()) { - sender.sendMessage(Util.format("whoisMoney", Util.formatCurrency(u.getMoney(), ess))); + sender.sendMessage(_("whoisMoney", Util.formatCurrency(user.getMoney(), ess))); } - sender.sendMessage(u.isAfk() - ? Util.i18n("whoisStatusAway") - : Util.i18n("whoisStatusAvailable")); - sender.sendMessage(Util.format("whoisIPAddress", u.getAddress().getAddress().toString())); - final String location = u.getGeoLocation(); - if (location != null + sender.sendMessage(user.isAfk() + ? _("whoisStatusAway") + : _("whoisStatusAvailable")); + sender.sendMessage(_("whoisIPAddress", user.getAddress().getAddress().toString())); + final String location = user.getGeoLocation(); + if (location != null && (sender instanceof Player ? ess.getUser(sender).isAuthorized("essentials.geoip.show") : true)) { - sender.sendMessage(Util.format("whoisGeoLocation", location)); + sender.sendMessage(_("whoisGeoLocation", location)); } } } |