mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 12:23:59 +00:00
Move player loading and updates to new thread, to reduce on join lag.
This commit is contained in:
parent
6504c88bf7
commit
9e86681722
1 changed files with 37 additions and 18 deletions
|
@ -122,15 +122,26 @@ public class EssentialsPlayerListener implements Listener
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||||
|
{
|
||||||
|
ess.scheduleAsyncDelayedTask(new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
delayedJoin(event.getPlayer());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delayedJoin(final Player player)
|
||||||
{
|
{
|
||||||
ess.getBackup().onPlayerJoin();
|
ess.getBackup().onPlayerJoin();
|
||||||
final User user = ess.getUser(event.getPlayer());
|
final User user = ess.getUser(player);
|
||||||
|
|
||||||
user.setDisplayNick();
|
user.setDisplayNick();
|
||||||
user.setLastLogin(System.currentTimeMillis());
|
|
||||||
|
|
||||||
user.updateActivity(false);
|
|
||||||
updateCompass(user);
|
updateCompass(user);
|
||||||
|
user.setLastLogin(System.currentTimeMillis());
|
||||||
|
user.updateActivity(false);
|
||||||
|
|
||||||
if (user.isAuthorized("essentials.sleepingignored"))
|
if (user.isAuthorized("essentials.sleepingignored"))
|
||||||
{
|
{
|
||||||
user.setSleepingIgnored(true);
|
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)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onPlayerLogin(final PlayerLoginEvent event)
|
public void onPlayerLogin(final PlayerLoginEvent event)
|
||||||
{
|
{
|
||||||
|
@ -211,19 +243,6 @@ public class EssentialsPlayerListener implements Listener
|
||||||
event.allow();
|
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)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onPlayerTeleport(final PlayerTeleportEvent event)
|
public void onPlayerTeleport(final PlayerTeleportEvent event)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue