Refactor sessions a bit to fix #419

This commit is contained in:
games647 2016-06-28 16:03:04 +02:00
parent 874869cef8
commit 469e8d3a48
3 changed files with 21 additions and 23 deletions

View File

@ -51,10 +51,9 @@ public class SessionManager implements SettingsDependent {
* @param name The name of the player who's session to cancel. * @param name The name of the player who's session to cancel.
*/ */
public void cancelSession(String name) { public void cancelSession(String name) {
BukkitTask task = sessions.get(name); BukkitTask task = sessions.remove(name);
if (task != null) { if (task != null) {
task.cancel(); task.cancel();
removeSession(name);
} }
} }

View File

@ -142,10 +142,9 @@ public class AsynchronousJoin implements AsynchronousProcess {
} }
// Session logic // Session logic
if (service.getProperty(PluginSettings.SESSIONS_ENABLED) && (playerCache.isAuthenticated(name) || database.isLogged(name))) { if (service.getProperty(PluginSettings.SESSIONS_ENABLED) && (sessionManager.hasSession(name) || database.isLogged(name))) {
if (sessionManager.hasSession(name)) {
sessionManager.cancelSession(name); sessionManager.cancelSession(name);
}
PlayerAuth auth = database.getAuth(name); PlayerAuth auth = database.getAuth(name);
database.setUnlogged(name); database.setUnlogged(name);
playerCache.removePlayer(name); playerCache.removePlayer(name);

View File

@ -86,8 +86,11 @@ public class AsynchronousQuit implements AsynchronousProcess {
isOp = limbo.isOperator(); isOp = limbo.isOperator();
limboCache.deleteLimboPlayer(name); limboCache.deleteLimboPlayer(name);
} }
if (!isKick) {
if (plugin.isEnabled()) { //always unauthenticate the player - use session only for auto logins on the same ip
playerCache.removePlayer(name);
if (plugin.isEnabled() && Settings.isSessionsEnabled) {
BukkitTask task = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() { BukkitTask task = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
@Override @Override
@ -102,10 +105,9 @@ public class AsynchronousQuit implements AsynchronousProcess {
//plugin is disabled; we cannot schedule more tasks so run it directly here //plugin is disabled; we cannot schedule more tasks so run it directly here
postLogout(name); postLogout(name);
} }
} else {
playerCache.removePlayer(name); //always update the database when the player quit the game
database.setUnlogged(name); database.setUnlogged(name);
}
if (plugin.isEnabled()) { if (plugin.isEnabled()) {
syncProcessManager.processSyncPlayerQuit(player, isOp, needToChange); syncProcessManager.processSyncPlayerQuit(player, isOp, needToChange);
@ -117,8 +119,6 @@ public class AsynchronousQuit implements AsynchronousProcess {
} }
private void postLogout(String name) { private void postLogout(String name) {
PlayerCache.getInstance().removePlayer(name);
database.setUnlogged(name);
sessionManager.removeSession(name); sessionManager.removeSession(name);
} }
} }