diff --git a/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java b/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java index 524652c55..e005d0621 100644 --- a/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java +++ b/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java @@ -18,13 +18,20 @@ public class CacheDataSource implements DataSource { public CacheDataSource(AuthMe plugin, DataSource source) { this.plugin = plugin; this.source = source; + /* + * We need to load all players in cache ... + * It will took more time to load the server, + * but it will be much easier to check for an isAuthAvailable ! + */ + for(PlayerAuth auth : source.getAllAuths()) + cache.put(auth.getNickname(), auth); } @Override public synchronized boolean isAuthAvailable(String user) { if (cache.containsKey(user.toLowerCase())) return true; - return source.isAuthAvailable(user.toLowerCase()); + return false; } @Override diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java index 20279b827..bb189feed 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java @@ -549,7 +549,6 @@ public class AuthMePlayerListener implements Listener { } Player player = event.getPlayer(); final String name = player.getName().toLowerCase(); - Location spawnLoc = plugin.getSpawnLocation(player); gm = player.getGameMode(); gameMode.put(name, gm); BukkitScheduler sched = plugin.getServer().getScheduler(); @@ -583,6 +582,7 @@ public class AuthMePlayerListener implements Listener { return; } } + Location spawnLoc = plugin.getSpawnLocation(player); if (data.isAuthAvailable(name)) { if (Settings.isSessionsEnabled) { PlayerAuth auth = data.getAuth(name);