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;
}
ess.getBackup().onPlayerJoin();
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);
ess.scheduleSyncDelayedTask(new Runnable()
@ -176,6 +184,7 @@ public class EssentialsPlayerListener implements Listener
@Override
public void run()
{
user.setLastLogin(currentTime);
user.setDisplayNick();
updateCompass(user);
@ -277,7 +286,6 @@ public class EssentialsPlayerListener implements Listener
{
switch (event.getResult())
{
case ALLOWED:
case KICK_FULL:
case KICK_BANNED:
break;
@ -286,30 +294,25 @@ public class EssentialsPlayerListener implements Listener
}
final User user = ess.getUser(event.getPlayer());
if (user.isNPC())
{
user.setNPC(false);
}
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))
if (event.getResult() == Result.KICK_BANNED || user.isBanned())
{
String banReason = user.getBanReason();
if (banReason == null || banReason.isEmpty() || banReason.equalsIgnoreCase("ban"))
final boolean banExpired = user.checkBanTimeout(System.currentTimeMillis());
if (!banExpired)
{
banReason = _("defaultBanReason");
String banReason = user.getBanReason();
if (banReason == null || banReason.isEmpty() || banReason.equalsIgnoreCase("ban"))
{
banReason = _("defaultBanReason");
}
if (user.getBanTimeout() > 0)
{
//TODO: TL This
banReason += "\n\n" + "Expires in " + Util.formatDateDiff(user.getBanTimeout());
}
event.disallow(Result.KICK_BANNED, banReason);
return;
}
if (user.getBanTimeout() > 0)
{
//TODO: TL This
banReason += "\n\n" + "Expires in " + Util.formatDateDiff(user.getBanTimeout());
}
event.disallow(Result.KICK_BANNED, banReason);
return;
}
if (event.getResult() == Result.KICK_FULL && !user.isAuthorized("essentials.joinfullserver"))

View File

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