Add a join blocker in case Cache Loading

This commit is contained in:
vanhec_a
2015-10-31 17:34:16 +01:00
parent e466f01791
commit f722fa161a
3 changed files with 30 additions and 2 deletions
@@ -20,9 +20,10 @@ public class CacheDataSource implements DataSource {
private final ExecutorService exec;
private final ConcurrentHashMap<String, PlayerAuth> cache = new ConcurrentHashMap<>();
public CacheDataSource(AuthMe pl, DataSource src) {
public CacheDataSource(final AuthMe pl, DataSource src) {
this.source = src;
this.exec = Executors.newCachedThreadPool();
pl.setCanConnect(false);
/*
* We need to load all players in cache ... It will took more time to
@@ -35,6 +36,7 @@ public class CacheDataSource implements DataSource {
for (PlayerAuth auth : source.getAllAuths()) {
cache.put(auth.getNickname().toLowerCase(), auth);
}
pl.setCanConnect(true);
}
});
}