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
commit19f54fa030f83fbb414f43235dd2a0062f36c987 (patch)
treec9d5f1a7cca6db16df83d0955ba414644a40175a /EssentialsGeoIP
parent315c4ec1f27f34070ab96068e3bd014241ed887b (diff)
downloadEssentials-19f54fa030f83fbb414f43235dd2a0062f36c987.tar
Essentials-19f54fa030f83fbb414f43235dd2a0062f36c987.tar.gz
Essentials-19f54fa030f83fbb414f43235dd2a0062f36c987.tar.lz
Essentials-19f54fa030f83fbb414f43235dd2a0062f36c987.tar.xz
Essentials-19f54fa030f83fbb414f43235dd2a0062f36c987.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()));