Optimize the cache, it will slow the server starting, but will be much

easier to get auths
This commit is contained in:
Xephi 2015-04-21 16:43:49 +02:00
parent 41b6c093bb
commit 0e93d502ef
2 changed files with 9 additions and 2 deletions

View File

@ -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

View File

@ -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);