Fix session system (#1337)

* Old session system

* Actually check if sessions are enabled

* Cleanup

* Don't use cached isLogged value
This commit is contained in:
Gabriele C
2017-09-30 15:15:25 +02:00
committed by GitHub
parent f45092bdd2
commit e59df84a84
6 changed files with 26 additions and 32 deletions
@@ -1,7 +1,6 @@
package fr.xephi.authme.process.quit;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.data.SessionManager;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.datasource.CacheDataSource;
@@ -10,6 +9,7 @@ import fr.xephi.authme.process.AsynchronousProcess;
import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.process.SyncProcessManager;
import fr.xephi.authme.settings.SpawnLoader;
import fr.xephi.authme.settings.properties.PluginSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.util.PlayerUtils;
import fr.xephi.authme.service.ValidationService;
@@ -38,9 +38,6 @@ public class AsynchronousQuit implements AsynchronousProcess {
@Inject
private SyncProcessManager syncProcessManager;
@Inject
private SessionManager sessionManager;
@Inject
private SpawnLoader spawnLoader;
@@ -79,19 +76,20 @@ public class AsynchronousQuit implements AsynchronousProcess {
.lastLogin(System.currentTimeMillis())
.build();
database.updateSession(auth);
sessionManager.addSession(name);
}
//always unauthenticate the player - use session only for auto logins on the same ip
playerCache.removePlayer(name);
//always update the database when the player quit the game
database.setUnlogged(name);
//always update the database when the player quit the game (if sessions are disabled)
if(!wasLoggedIn || !service.getProperty(PluginSettings.SESSIONS_ENABLED)) {
database.setUnlogged(name);
}
if (plugin.isEnabled()) {
syncProcessManager.processSyncPlayerQuit(player, wasLoggedIn);
}
// remove player from cache
if (database instanceof CacheDataSource) {
((CacheDataSource) database).getCachedAuths().invalidate(name);