summaryrefslogtreecommitdiffstats
path: root/EssentialsGeoIP/src/com
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
commit45135e4b63126ecb0533537dedd6e0fa6055066f (patch)
tree27c9e36d599ffe183a2bf0aab703f485ec2113c8 /EssentialsGeoIP/src/com
parent4ceaf2183b78842cd29b1f5bca86630139b12135 (diff)
downloadEssentials-45135e4b63126ecb0533537dedd6e0fa6055066f.tar
Essentials-45135e4b63126ecb0533537dedd6e0fa6055066f.tar.gz
Essentials-45135e4b63126ecb0533537dedd6e0fa6055066f.tar.lz
Essentials-45135e4b63126ecb0533537dedd6e0fa6055066f.tar.xz
Essentials-45135e4b63126ecb0533537dedd6e0fa6055066f.zip
Give user chance to get display name set before displaying geoip.
Diffstat (limited to 'EssentialsGeoIP/src/com')
-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()));