Allow session timeout = 0 (with warnings)

This commit is contained in:
Gabriele C 2015-07-28 00:04:16 +02:00
parent ba06bb514a
commit 5388f08117
2 changed files with 18 additions and 12 deletions

View File

@ -251,6 +251,10 @@ public class AuthMe extends JavaPlugin {
if (!Settings.isForceSingleSessionEnabled) { if (!Settings.isForceSingleSessionEnabled) {
ConsoleLogger.showError("WARNING!!! By disabling ForceSingleSession, your server protection is inadequate!"); ConsoleLogger.showError("WARNING!!! By disabling ForceSingleSession, your server protection is inadequate!");
} }
if (Settings.getSessionTimeout == 0 && Settings.isSessionsEnabled){
ConsoleLogger.showError("WARNING!!! You set session timeout to 0, this may cause security issues!");
}
if (Settings.reloadSupport) if (Settings.reloadSupport)
try { try {

View File

@ -78,18 +78,20 @@ public class AsyncronousQuit {
LimboCache.getInstance().deleteLimboPlayer(name); LimboCache.getInstance().deleteLimboPlayer(name);
} }
if (Settings.isSessionsEnabled && !isKick) { if (Settings.isSessionsEnabled && !isKick) {
BukkitTask task = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() { if (Settings.getSessionTimeout != 0){
BukkitTask task = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
@Override
public void run() { @Override
PlayerCache.getInstance().removePlayer(name); public void run() {
if (database.isLogged(name)) PlayerCache.getInstance().removePlayer(name);
database.setUnlogged(name); if (database.isLogged(name))
plugin.sessions.remove(name); database.setUnlogged(name);
} plugin.sessions.remove(name);
}
}, Settings.getSessionTimeout * 20 * 60);
plugin.sessions.put(name, task); }, Settings.getSessionTimeout * 20 * 60);
plugin.sessions.put(name, task);
}
} else { } else {
PlayerCache.getInstance().removePlayer(name); PlayerCache.getInstance().removePlayer(name);
database.setUnlogged(name); database.setUnlogged(name);