mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-09 04:02:10 +01:00
Fix LowerCase/Session Stolen issue
This commit is contained in:
parent
253b54da1d
commit
11db85ac26
@ -46,6 +46,8 @@ public class DataManager {
|
||||
return result.get();
|
||||
} catch (Exception e) {
|
||||
return (null);
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,4 +161,32 @@ public class DataManager {
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " Permissions");
|
||||
}
|
||||
|
||||
public boolean isOnline(Player player, final String name) {
|
||||
if (player.isOnline())
|
||||
return true;
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
Future<Boolean> result = executor.submit(new Callable<Boolean>() {
|
||||
|
||||
public synchronized Boolean call() throws Exception {
|
||||
Boolean result = null;
|
||||
try {
|
||||
for (OfflinePlayer op : Bukkit.getOnlinePlayers())
|
||||
if (op.getName().equalsIgnoreCase(name)) {
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
});
|
||||
try {
|
||||
return result.get().booleanValue();
|
||||
} catch (Exception e) {
|
||||
return (false);
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -446,15 +446,16 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
// Check if forceSingleSession is set to true, so kick player that has
|
||||
// joined with same nick of online player
|
||||
if (player.isOnline() && Settings.isForceSingleSessionEnabled) {
|
||||
if (plugin.dataManager.isOnline(player, name) && Settings.isForceSingleSessionEnabled) {
|
||||
event.setKickMessage(m.send("same_nick")[0]);
|
||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||
if (LimboCache.getInstance().hasLimboPlayer(name))
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase());
|
||||
if (PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
||||
if (player != null && limbo != null && PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase())) {
|
||||
Utils.getInstance().addNormal(player, limbo.getGroup());
|
||||
LimboCache.getInstance().deleteLimboPlayer(player.getName().toLowerCase());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user