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:
@@ -1,7 +1,6 @@
|
||||
package fr.xephi.authme.process.join;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.data.SessionManager;
|
||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
import fr.xephi.authme.data.auth.PlayerCache;
|
||||
import fr.xephi.authme.data.limbo.LimboService;
|
||||
@@ -18,6 +17,7 @@ import fr.xephi.authme.service.PluginHookService;
|
||||
import fr.xephi.authme.service.ValidationService;
|
||||
import fr.xephi.authme.settings.commandconfig.CommandManager;
|
||||
import fr.xephi.authme.settings.properties.HooksSettings;
|
||||
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||
import fr.xephi.authme.util.PlayerUtils;
|
||||
@@ -53,9 +53,6 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
||||
@Inject
|
||||
private LimboService limboService;
|
||||
|
||||
@Inject
|
||||
private SessionManager sessionManager;
|
||||
|
||||
@Inject
|
||||
private PluginHookService pluginHookService;
|
||||
|
||||
@@ -174,17 +171,22 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
||||
|
||||
private boolean canResumeSession(Player player) {
|
||||
final String name = player.getName();
|
||||
if (sessionManager.hasSession(name) || database.isLogged(name)) {
|
||||
PlayerAuth auth = database.getAuth(name);
|
||||
if (database.isLogged(name)) {
|
||||
database.setUnlogged(name);
|
||||
playerCache.removePlayer(name);
|
||||
if (auth != null) {
|
||||
if (auth.getIp().equals(PlayerUtils.getPlayerIp(player))) {
|
||||
RestoreSessionEvent event = bukkitService.createAndCallEvent(
|
||||
isAsync -> new RestoreSessionEvent(player, isAsync));
|
||||
return !event.isCancelled();
|
||||
} else {
|
||||
service.send(player, MessageKey.SESSION_EXPIRED);
|
||||
if(service.getProperty(PluginSettings.SESSIONS_ENABLED)) {
|
||||
PlayerAuth auth = database.getAuth(name);
|
||||
if (auth != null) {
|
||||
long timeSinceLastLogin = System.currentTimeMillis() - auth.getLastLogin();
|
||||
if(timeSinceLastLogin < 0
|
||||
|| timeSinceLastLogin > (service.getProperty(PluginSettings.SESSIONS_TIMEOUT) * 60 * 60 * 1000)
|
||||
|| !auth.getIp().equals(PlayerUtils.getPlayerIp(player))) {
|
||||
service.send(player, MessageKey.SESSION_EXPIRED);
|
||||
} else {
|
||||
RestoreSessionEvent event = bukkitService.createAndCallEvent(
|
||||
isAsync -> new RestoreSessionEvent(player, isAsync));
|
||||
return !event.isCancelled();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user