should fix #831 and enhance performance

This commit is contained in:
Gabriele C 2016-07-11 22:42:33 +02:00
parent 09e4124ebb
commit 361039f946

View File

@ -203,7 +203,7 @@ public class AuthMePlayerListener implements Listener {
// We have no performance improvements if we do the same thing on two different events
// Important: the single session feature works if we use the low priority to the sync handler
@EventHandler(priority = EventPriority.LOW)
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerLogin(PlayerLoginEvent event) {
final Player player = event.getPlayer();
if (Utils.isUnrestricted(player)) {
@ -216,14 +216,18 @@ public class AuthMePlayerListener implements Listener {
final String name = player.getName();
final String lowerName = name.toLowerCase();
final PlayerAuth auth = dataSource.getAuth(player.getName());
final boolean isAuthAvailable = (auth != null);
try {
// Fast stuff
onJoinVerifier.checkSingleSession(lowerName);
onJoinVerifier.checkIsValidName(name);
// Get the auth later as this may cause the single session check to fail
// Slow stuff
final PlayerAuth auth = dataSource.getAuth(player.getName());
final boolean isAuthAvailable = (auth != null);
onJoinVerifier.checkAntibot(lowerName, isAuthAvailable);
onJoinVerifier.checkKickNonRegistered(isAuthAvailable);
onJoinVerifier.checkIsValidName(name);
onJoinVerifier.checkNameCasing(player, auth);
onJoinVerifier.checkPlayerCountry(isAuthAvailable, event);
} catch (FailedVerificationException e) {