summaryrefslogtreecommitdiffstats
path: root/EssentialsGeoIP
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-09-08 14:40:19 +0100
committerKHobbits <rob@khobbits.co.uk>2012-09-08 14:40:19 +0100
commite502a7e6fd12b9f6073ba592cc744f820c62c5db (patch)
tree6bcd5a12f6713f09e358ab4475d6112d78b3fb3a /EssentialsGeoIP
parentacf4d0bcf509ce89b907567b2ce102cc353c8abf (diff)
downloadEssentials-e502a7e6fd12b9f6073ba592cc744f820c62c5db.tar
Essentials-e502a7e6fd12b9f6073ba592cc744f820c62c5db.tar.gz
Essentials-e502a7e6fd12b9f6073ba592cc744f820c62c5db.tar.lz
Essentials-e502a7e6fd12b9f6073ba592cc744f820c62c5db.tar.xz
Essentials-e502a7e6fd12b9f6073ba592cc744f820c62c5db.zip
Give user chance to get display name set before displaying geoip.
Diffstat (limited to 'EssentialsGeoIP')
-rw-r--r--EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java26
1 files changed, 19 insertions, 7 deletions
diff --git a/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java b/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java
index ab72cfa9f..c8de953cf 100644
--- a/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java
+++ b/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java
@@ -40,16 +40,28 @@ public class EssentialsGeoIPPlayerListener implements Listener, IConf
config.setTemplateName("/config.yml", EssentialsGeoIP.class);
reloadConfig();
}
-
+
@EventHandler(priority = EventPriority.MONITOR)
- public void onPlayerJoin(PlayerJoinEvent event)
+ public void onPlayerJoin(final PlayerJoinEvent event)
+ {
+ ess.scheduleAsyncDelayedTask(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ delayedJoin(event.getPlayer());
+ }
+ });
+ }
+
+ public void delayedJoin(Player player)
{
- User u = ess.getUser(event.getPlayer());
- if (u.isAuthorized("essentials.geoip.hide") || event.getPlayer().getAddress() == null)
+ User u = ess.getUser(player);
+ if (u.isAuthorized("essentials.geoip.hide") || player.getAddress() == null)
{
return;
}
- InetAddress address = event.getPlayer().getAddress().getAddress();
+ InetAddress address = player.getAddress().getAddress();
StringBuilder sb = new StringBuilder();
if (config.getBoolean("database.show-cities", false))
{
@@ -79,9 +91,9 @@ public class EssentialsGeoIPPlayerListener implements Listener, IConf
}
if (config.getBoolean("show-on-login", true) && !u.isHidden())
{
- for (Player player : event.getPlayer().getServer().getOnlinePlayers())
+ for (Player onlinePlayer : player.getServer().getOnlinePlayers())
{
- User user = ess.getUser(player);
+ User user = ess.getUser(onlinePlayer);
if (user.isAuthorized("essentials.geoip.show"))
{
user.sendMessage(_("geoipJoinFormat", u.getDisplayName(), sb.toString()));