Attempt to optimize Essentials login event.

This commit is contained in:
KHobbits 2013-02-11 23:11:37 +00:00
parent a1f1319990
commit c298fb9332
2 changed files with 28 additions and 23 deletions

View File

@ -166,9 +166,17 @@ public class EssentialsPlayerListener implements Listener
{ {
return; return;
} }
ess.getBackup().onPlayerJoin(); ess.getBackup().onPlayerJoin();
final User user = ess.getUser(player); final User user = ess.getUser(player);
user.setLastLogin(System.currentTimeMillis());
if (user.isNPC())
{
user.setNPC(false);
}
final long currentTime = System.currentTimeMillis();
user.checkMuteTimeout(currentTime);
user.updateActivity(false); user.updateActivity(false);
ess.scheduleSyncDelayedTask(new Runnable() ess.scheduleSyncDelayedTask(new Runnable()
@ -176,6 +184,7 @@ public class EssentialsPlayerListener implements Listener
@Override @Override
public void run() public void run()
{ {
user.setLastLogin(currentTime);
user.setDisplayNick(); user.setDisplayNick();
updateCompass(user); updateCompass(user);
@ -277,7 +286,6 @@ public class EssentialsPlayerListener implements Listener
{ {
switch (event.getResult()) switch (event.getResult())
{ {
case ALLOWED:
case KICK_FULL: case KICK_FULL:
case KICK_BANNED: case KICK_BANNED:
break; break;
@ -286,17 +294,11 @@ public class EssentialsPlayerListener implements Listener
} }
final User user = ess.getUser(event.getPlayer()); final User user = ess.getUser(event.getPlayer());
if (user.isNPC())
if (event.getResult() == Result.KICK_BANNED || user.isBanned())
{ {
user.setNPC(false); final boolean banExpired = user.checkBanTimeout(System.currentTimeMillis());
} if (!banExpired)
final long currentTime = System.currentTimeMillis();
final boolean banExpired = user.checkBanTimeout(currentTime);
user.checkMuteTimeout(currentTime);
user.checkJailTimeout(currentTime);
if (!banExpired && (user.isBanned() || event.getResult() == Result.KICK_BANNED))
{ {
String banReason = user.getBanReason(); String banReason = user.getBanReason();
if (banReason == null || banReason.isEmpty() || banReason.equalsIgnoreCase("ban")) if (banReason == null || banReason.isEmpty() || banReason.equalsIgnoreCase("ban"))
@ -311,6 +313,7 @@ public class EssentialsPlayerListener implements Listener
event.disallow(Result.KICK_BANNED, banReason); event.disallow(Result.KICK_BANNED, banReason);
return; return;
} }
}
if (event.getResult() == Result.KICK_FULL && !user.isAuthorized("essentials.joinfullserver")) if (event.getResult() == Result.KICK_FULL && !user.isAuthorized("essentials.joinfullserver"))
{ {

View File

@ -310,6 +310,8 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
public void onPlayerJoin(final PlayerJoinEvent event) public void onPlayerJoin(final PlayerJoinEvent event)
{ {
final User user = ess.getUser(event.getPlayer()); final User user = ess.getUser(event.getPlayer());
final long currentTime = System.currentTimeMillis();
user.checkJailTimeout(currentTime);
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty()) if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
{ {
return; return;