From 361039f9465fa263d116d8ca75a1c54ad93d02ac Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Mon, 11 Jul 2016 22:42:33 +0200 Subject: [PATCH] should fix #831 and enhance performance --- .../xephi/authme/listener/AuthMePlayerListener.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java index 0e5915e1d..8eb947a7f 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java @@ -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) {