Merge pull request #57 from Xephi/master

Up
This commit is contained in:
Gabriele C 2015-10-31 17:48:10 +01:00
commit 8aed29f988
3 changed files with 30 additions and 2 deletions

View File

@ -106,7 +106,18 @@ public class AuthMe extends JavaPlugin {
public ConcurrentHashMap<String, String> cap = new ConcurrentHashMap<>();
public ConcurrentHashMap<String, String> realIp = new ConcurrentHashMap<>();
public static AuthMe getInstance() {
// In case we need to cache PlayerAuths, prevent connection before it's done
private boolean canConnect = true;
public boolean isCanConnect() {
return canConnect;
}
public void setCanConnect(boolean canConnect) {
this.canConnect = canConnect;
}
public static AuthMe getInstance() {
return authme;
}

View File

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

View File

@ -58,6 +58,21 @@ public class AsyncronousJoin {
plugin.ess.getUser(player).setSocialSpyEnabled(false);
}
if (!plugin.isCanConnect())
{
final GameMode gM = AuthMePlayerListener.gameMode.get(name);
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
AuthMePlayerListener.causeByAuthMe.putIfAbsent(name, true);
player.setGameMode(gM);
player.kickPlayer("Server is loading, please wait before joining!");
}
});
}
final String ip = plugin.getIP(player);
if (Settings.isAllowRestrictedIp && !Settings.getRestrictedIp(name, ip)) {
final GameMode gM = AuthMePlayerListener.gameMode.get(name);