mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-03 09:10:01 +01:00
Refactor sessions a bit to fix #419
This commit is contained in:
parent
874869cef8
commit
469e8d3a48
@ -51,10 +51,9 @@ public class SessionManager implements SettingsDependent {
|
||||
* @param name The name of the player who's session to cancel.
|
||||
*/
|
||||
public void cancelSession(String name) {
|
||||
BukkitTask task = sessions.get(name);
|
||||
BukkitTask task = sessions.remove(name);
|
||||
if (task != null) {
|
||||
task.cancel();
|
||||
removeSession(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,10 +142,9 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
||||
}
|
||||
|
||||
// Session logic
|
||||
if (service.getProperty(PluginSettings.SESSIONS_ENABLED) && (playerCache.isAuthenticated(name) || database.isLogged(name))) {
|
||||
if (sessionManager.hasSession(name)) {
|
||||
sessionManager.cancelSession(name);
|
||||
}
|
||||
if (service.getProperty(PluginSettings.SESSIONS_ENABLED) && (sessionManager.hasSession(name) || database.isLogged(name))) {
|
||||
sessionManager.cancelSession(name);
|
||||
|
||||
PlayerAuth auth = database.getAuth(name);
|
||||
database.setUnlogged(name);
|
||||
playerCache.removePlayer(name);
|
||||
|
@ -86,27 +86,29 @@ public class AsynchronousQuit implements AsynchronousProcess {
|
||||
isOp = limbo.isOperator();
|
||||
limboCache.deleteLimboPlayer(name);
|
||||
}
|
||||
if (!isKick) {
|
||||
if (plugin.isEnabled()) {
|
||||
BukkitTask task = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
postLogout(name);
|
||||
}
|
||||
//always unauthenticate the player - use session only for auto logins on the same ip
|
||||
playerCache.removePlayer(name);
|
||||
|
||||
}, Settings.getSessionTimeout * TICKS_PER_MINUTE);
|
||||
if (plugin.isEnabled() && Settings.isSessionsEnabled) {
|
||||
BukkitTask task = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
sessionManager.addSession(name, task);
|
||||
} else {
|
||||
//plugin is disabled; we cannot schedule more tasks so run it directly here
|
||||
postLogout(name);
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
postLogout(name);
|
||||
}
|
||||
|
||||
}, Settings.getSessionTimeout * TICKS_PER_MINUTE);
|
||||
|
||||
sessionManager.addSession(name, task);
|
||||
} else {
|
||||
playerCache.removePlayer(name);
|
||||
database.setUnlogged(name);
|
||||
//plugin is disabled; we cannot schedule more tasks so run it directly here
|
||||
postLogout(name);
|
||||
}
|
||||
|
||||
//always update the database when the player quit the game
|
||||
database.setUnlogged(name);
|
||||
|
||||
if (plugin.isEnabled()) {
|
||||
syncProcessManager.processSyncPlayerQuit(player, isOp, needToChange);
|
||||
}
|
||||
@ -117,8 +119,6 @@ public class AsynchronousQuit implements AsynchronousProcess {
|
||||
}
|
||||
|
||||
private void postLogout(String name) {
|
||||
PlayerCache.getInstance().removePlayer(name);
|
||||
database.setUnlogged(name);
|
||||
sessionManager.removeSession(name);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user