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
commit9e866817222fd23c2ad267a936cc50efd32088d7 (patch)
tree5ba249be1f69a0f57815ed05f57924415093839d
parent6504c88bf7cb406acce0dda2c45623bc8be15734 (diff)
downloadEssentials-9e866817222fd23c2ad267a936cc50efd32088d7.tar
Essentials-9e866817222fd23c2ad267a936cc50efd32088d7.tar.gz
Essentials-9e866817222fd23c2ad267a936cc50efd32088d7.tar.lz
Essentials-9e866817222fd23c2ad267a936cc50efd32088d7.tar.xz
Essentials-9e866817222fd23c2ad267a936cc50efd32088d7.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)
{