From 3eab42ae68662ff924c380c785074c800a471744 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Sun, 5 Feb 2017 13:40:11 +0100 Subject: [PATCH] Remove obsolete "session expires on IP change" config - Session always expire on IP change; the config only controlled whether an error message was shown or not --- .../authme/process/join/AsynchronousJoin.java | 28 ++++++++++--------- .../settings/SettingsMigrationService.java | 3 +- .../settings/properties/PluginSettings.java | 11 +------- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java b/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java index 0f7e819f..3dcfe8e0 100644 --- a/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java +++ b/src/main/java/fr/xephi/authme/process/join/AsynchronousJoin.java @@ -1,6 +1,5 @@ package fr.xephi.authme.process.join; -import fr.xephi.authme.AuthMe; import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.data.SessionManager; import fr.xephi.authme.data.auth.PlayerAuth; @@ -8,30 +7,31 @@ import fr.xephi.authme.data.auth.PlayerCache; import fr.xephi.authme.data.limbo.LimboCache; import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.events.ProtectInventoryEvent; -import fr.xephi.authme.service.PluginHookService; import fr.xephi.authme.message.MessageKey; import fr.xephi.authme.permission.AuthGroupType; import fr.xephi.authme.permission.PlayerStatePermission; import fr.xephi.authme.process.AsynchronousProcess; -import fr.xephi.authme.service.CommonService; import fr.xephi.authme.process.login.AsynchronousLogin; +import fr.xephi.authme.service.BukkitService; +import fr.xephi.authme.service.CommonService; +import fr.xephi.authme.service.PluginHookService; 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.task.LimboPlayerTaskManager; -import fr.xephi.authme.service.BukkitService; import fr.xephi.authme.util.PlayerUtils; import org.bukkit.GameMode; +import org.bukkit.Server; import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import javax.inject.Inject; -import static fr.xephi.authme.settings.properties.RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN; import static fr.xephi.authme.service.BukkitService.TICKS_PER_SECOND; +import static fr.xephi.authme.settings.properties.RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN; /** * Asynchronous process for when a player joins. @@ -39,7 +39,7 @@ import static fr.xephi.authme.service.BukkitService.TICKS_PER_SECOND; public class AsynchronousJoin implements AsynchronousProcess { @Inject - private AuthMe plugin; + private Server server; @Inject private DataSource database; @@ -97,7 +97,7 @@ public class AsynchronousJoin implements AsynchronousProcess { public void run() { player.kickPlayer(service.retrieveSingleMessage(MessageKey.NOT_OWNER_ERROR)); if (service.getProperty(RestrictionSettings.BAN_UNKNOWN_IP)) { - plugin.getServer().banIP(ip); + server.banIP(ip); } } }); @@ -130,12 +130,14 @@ public class AsynchronousJoin implements AsynchronousProcess { PlayerAuth auth = database.getAuth(name); database.setUnlogged(name); playerCache.removePlayer(name); - if (auth != null && auth.getIp().equals(ip)) { - service.send(player, MessageKey.SESSION_RECONNECTION); - bukkitService.runTaskOptionallyAsync(() -> asynchronousLogin.forceLogin(player)); - return; - } else if (service.getProperty(PluginSettings.SESSIONS_EXPIRE_ON_IP_CHANGE)) { - service.send(player, MessageKey.SESSION_EXPIRED); + if (auth != null) { + if (auth.getIp().equals(ip)) { + service.send(player, MessageKey.SESSION_RECONNECTION); + bukkitService.runTaskOptionallyAsync(() -> asynchronousLogin.forceLogin(player)); + return; + } else { + service.send(player, MessageKey.SESSION_EXPIRED); + } } } } else { diff --git a/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java b/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java index e4b175b7..ade6833d 100644 --- a/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java +++ b/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java @@ -82,7 +82,8 @@ public class SettingsMigrationService extends PlainMigrationService { "VeryGames", "settings.restrictions.allowAllCommandsIfRegistrationIsOptional", "DataSource.mySQLWebsite", "Hooks.customAttributes", "Security.stop.kickPlayersBeforeStopping", "settings.restrictions.keepCollisionsDisabled", "settings.forceCommands", "settings.forceCommandsAsConsole", - "settings.forceRegisterCommands", "settings.forceRegisterCommandsAsConsole"}; + "settings.forceRegisterCommands", "settings.forceRegisterCommandsAsConsole", + "settings.sessions.sessionExpireOnIpChange"}; for (String deprecatedPath : deprecatedProperties) { if (resource.contains(deprecatedPath)) { return true; diff --git a/src/main/java/fr/xephi/authme/settings/properties/PluginSettings.java b/src/main/java/fr/xephi/authme/settings/properties/PluginSettings.java index eb6ffd6d..5f45ca5d 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/PluginSettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/PluginSettings.java @@ -22,20 +22,11 @@ public class PluginSettings implements SettingsHolder { @Comment({ "After how many minutes should a session expire?", - "Remember that sessions will end only after the timeout, and", - "if the player's IP has changed but the timeout hasn't expired,", - "the player will be kicked from the server due to invalid session" + "A player's session ends after the timeout or if his IP has changed" }) public static final Property SESSIONS_TIMEOUT = newProperty("settings.sessions.timeout", 10); - @Comment({ - "Should the session expire if the player tries to log in with", - "another IP address?" - }) - public static final Property SESSIONS_EXPIRE_ON_IP_CHANGE = - newProperty("settings.sessions.sessionExpireOnIpChange", true); - @Comment({ "Message language, available languages:", "https://github.com/AuthMe/AuthMeReloaded/blob/master/docs/translations.md"