diff options
Diffstat (limited to 'EssentialsGeoIP')
-rw-r--r-- | EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java | 26 |
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())); |