summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-04-06 19:19:08 +0100
committerKHobbits <rob@khobbits.co.uk>2012-04-06 19:19:08 +0100
commitf2c0fe934f83d258b63dd29c69d6c3080095d870 (patch)
tree816d98faa7d0e31eed04812236bf254b74faaa0b
parent507c138dc413557c9a26bb6a60670cfb80a562d8 (diff)
downloadEssentials-f2c0fe934f83d258b63dd29c69d6c3080095d870.tar
Essentials-f2c0fe934f83d258b63dd29c69d6c3080095d870.tar.gz
Essentials-f2c0fe934f83d258b63dd29c69d6c3080095d870.tar.lz
Essentials-f2c0fe934f83d258b63dd29c69d6c3080095d870.tar.xz
Essentials-f2c0fe934f83d258b63dd29c69d6c3080095d870.zip
Move player loading and updates to new thread, to reduce on join lag.
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java53
1 files changed, 36 insertions, 17 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
index 2f97490bc..604703770 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
@@ -123,14 +123,25 @@ public class EssentialsPlayerListener implements Listener
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(final PlayerJoinEvent event)
{
- ess.getBackup().onPlayerJoin();
- final User user = ess.getUser(event.getPlayer());
+ ess.scheduleAsyncDelayedTask(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ delayedJoin(event.getPlayer());
+ }
+ });
+ }
+ public void delayedJoin(final Player player)
+ {
+ ess.getBackup().onPlayerJoin();
+ final User user = ess.getUser(player);
user.setDisplayNick();
+ updateCompass(user);
user.setLastLogin(System.currentTimeMillis());
-
user.updateActivity(false);
- updateCompass(user);
+
if (user.isAuthorized("essentials.sleepingignored"))
{
user.setSleepingIgnored(true);
@@ -172,6 +183,27 @@ public class EssentialsPlayerListener implements Listener
}
}
+ private void updateCompass(final User user)
+ {
+ Location loc = user.getHome(user.getLocation());
+ if (loc == null)
+ {
+ loc = user.getBedSpawnLocation();
+ }
+ if (loc != null)
+ {
+ final Location updateLoc = loc;
+ ess.scheduleSyncDelayedTask(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ user.setCompassTarget(updateLoc);
+ }
+ });
+ }
+ }
+
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerLogin(final PlayerLoginEvent event)
{
@@ -211,19 +243,6 @@ public class EssentialsPlayerListener implements Listener
event.allow();
}
- private void updateCompass(final User user)
- {
- Location loc = user.getHome(user.getLocation());
- if (loc == null)
- {
- loc = user.getBedSpawnLocation();
- }
- if (loc != null)
- {
- user.setCompassTarget(loc);
- }
- }
-
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerTeleport(final PlayerTeleportEvent event)
{