mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-09 04:02:10 +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) {
|
public CacheDataSource(AuthMe plugin, DataSource source) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.source = source;
|
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
|
@Override
|
||||||
public synchronized boolean isAuthAvailable(String user) {
|
public synchronized boolean isAuthAvailable(String user) {
|
||||||
if (cache.containsKey(user.toLowerCase()))
|
if (cache.containsKey(user.toLowerCase()))
|
||||||
return true;
|
return true;
|
||||||
return source.isAuthAvailable(user.toLowerCase());
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -549,7 +549,6 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
final String name = player.getName().toLowerCase();
|
final String name = player.getName().toLowerCase();
|
||||||
Location spawnLoc = plugin.getSpawnLocation(player);
|
|
||||||
gm = player.getGameMode();
|
gm = player.getGameMode();
|
||||||
gameMode.put(name, gm);
|
gameMode.put(name, gm);
|
||||||
BukkitScheduler sched = plugin.getServer().getScheduler();
|
BukkitScheduler sched = plugin.getServer().getScheduler();
|
||||||
@ -583,6 +582,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Location spawnLoc = plugin.getSpawnLocation(player);
|
||||||
if (data.isAuthAvailable(name)) {
|
if (data.isAuthAvailable(name)) {
|
||||||
if (Settings.isSessionsEnabled) {
|
if (Settings.isSessionsEnabled) {
|
||||||
PlayerAuth auth = data.getAuth(name);
|
PlayerAuth auth = data.getAuth(name);
|
||||||
|
Loading…
Reference in New Issue
Block a user