diff options
author | snowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb> | 2011-05-01 19:38:25 +0000 |
---|---|---|
committer | snowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb> | 2011-05-01 19:38:25 +0000 |
commit | 36808a2cbae29f1a8c2a0473b52223acaba8da6b (patch) | |
tree | 9ad493b6f23b491e7de986879bf30addf293d09e | |
parent | 77cc3c7d97e9ac476615d87aada0cae0e6b4c13f (diff) | |
download | Essentials-36808a2cbae29f1a8c2a0473b52223acaba8da6b.tar Essentials-36808a2cbae29f1a8c2a0473b52223acaba8da6b.tar.gz Essentials-36808a2cbae29f1a8c2a0473b52223acaba8da6b.tar.lz Essentials-36808a2cbae29f1a8c2a0473b52223acaba8da6b.tar.xz Essentials-36808a2cbae29f1a8c2a0473b52223acaba8da6b.zip |
[trunk] Geoip: New permission essentials.geoip.show, that allow the player to see the location of other players.
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1299 e251c2fe-e539-e718-e476-b85c1f46cddb
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandwhois.java | 14 | ||||
-rw-r--r-- | EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java | 11 |
2 files changed, 20 insertions, 5 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java index 81e41aa30..41e7c6dd4 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java @@ -30,16 +30,24 @@ public class Commandwhois extends EssentialsCommand { User u = User.get(p); String dn = ChatColor.stripColor(u.getNick()); - if (!whois.equalsIgnoreCase(dn) && !whois.equalsIgnoreCase(dn.substring(prefixLength)) && !whois.equalsIgnoreCase(u.getName())) continue; + if (!whois.equalsIgnoreCase(dn) && !whois.equalsIgnoreCase(dn.substring(prefixLength)) && !whois.equalsIgnoreCase(u.getName())) + { + continue; + } sender.sendMessage(""); sender.sendMessage(u.getDisplayName() + " is " + u.getName()); sender.sendMessage(ChatColor.BLUE + " - Health: " + u.getHealth() + "/20"); sender.sendMessage(ChatColor.BLUE + " - Location: (" + u.getLocation().getWorld().getName() + ", " + u.getLocation().getBlockX() + ", " + u.getLocation().getBlockY() + ", " + u.getLocation().getBlockZ() + ")"); - if (!parent.getConfiguration().getBoolean("disable-eco", false)) sender.sendMessage(ChatColor.BLUE + " - Money: $" + u.getMoney()); + if (!parent.getConfiguration().getBoolean("disable-eco", false)) + { + sender.sendMessage(ChatColor.BLUE + " - Money: $" + u.getMoney()); + } sender.sendMessage(ChatColor.BLUE + " - Status: " + (parent.away.contains(u) ? "§cAway§f" : "Available")); sender.sendMessage(ChatColor.BLUE + " - IP Address: " + u.getAddress().getAddress().toString()); Object location = u.getMetadata().get("location"); - if (location != null && location instanceof String) { + if (location != null && location instanceof String + && (sender instanceof Player ? User.get(sender).isAuthorized("essentials.geoip.show") : true)) + { sender.sendMessage(ChatColor.BLUE + " - Location: " + location.toString()); } } diff --git a/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java b/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java index d2b431a6b..0037da209 100644 --- a/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java +++ b/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java @@ -18,6 +18,7 @@ import java.net.URLConnection; import java.util.logging.Level; import java.util.logging.Logger; import java.util.zip.GZIPInputStream; +import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerListener; @@ -72,11 +73,17 @@ public class EssentialsGeoIPPlayerListener extends PlayerListener implements ICo } if (config.getBoolean("show-on-whois", true)) { - User.get(event.getPlayer()).setMetadata("location", sb.toString()); + u.setMetadata("location", sb.toString()); } if (config.getBoolean("show-on-login", true)) { - event.getPlayer().getServer().broadcastMessage("Player " + event.getPlayer().getDisplayName() + " comes from " + sb.toString()); + for (Player player : event.getPlayer().getServer().getOnlinePlayers()) + { + User user = User.get(player); + if (user.isAuthorized("essentials.geoip.show")) { + user.sendMessage("Player " + u.getDisplayName() + " comes from " + sb.toString()); + } + } } } |