mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-04 09:40:05 +01:00
Optimize the cache, it will slow the server starting, but will be much
easier to get auths
This commit is contained in:
parent
41b6c093bb
commit
0e93d502ef
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user