From 87ca00d75d48cf4cf4f6472f8d4c6c45fec262c9 Mon Sep 17 00:00:00 2001 From: games647 Date: Wed, 21 Sep 2016 09:16:19 +0200 Subject: [PATCH] [SwitchMode] Kick the player only if the player is unknown to us --- CHANGELOG.md | 14 +++++------ .../fastlogin/bukkit/BukkitLoginSession.java | 21 ----------------- .../listener/PlayerConnectionListener.java | 2 ++ .../fastlogin/core/shared/JoinManagement.java | 9 ++++---- .../fastlogin/core/shared/LoginSession.java | 23 +++++++++++++++++++ 5 files changed, 37 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97627535..1b5e1794 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,21 +1,21 @@ ######1.9 -* Remove the nasty UltraAuth fakeplayer workaround by using a new api method. You should UltraAuth if you have it -* Upgrade to Java 8 -* Drop support for LoginSecurity 1.X since 2.X seems to be stable -* Refactored/Cleaned up a lot of code -* [API] Deprecated platform specific authplugin. Please use AuthPlugin< platform specific player type > -* [API] Deprecated bukkit's password generator. Please use PasswordGenerator< platform specific player type > * Added second attempt login -> cracked login * Added cracked whitelist (switch-mode -> switching to online-mode from offlinemode) * Added configuration to disable auto logins for 2Factor authentication -* Add missing add-premium-other message +* Added missing add-premium-other message +* Upgrade to Java 8 -> Minimize file size +* Refactored/Cleaned up a lot of code +* [API] Deprecated platform specific authplugin. Please use AuthPlugin< platform specific player type > +* [API] Deprecated bukkit's password generator. Please use PasswordGenerator< platform specific player type > * Fix ProtocolSupport autoRegister * Fix update username in FastLogin database after nameChange * Fix logging exceptions on encryption enabling * Fix compatibility with older ProtocolLib versions (for 1.7) because of the missing getMethodAcccessorOrNull method * Fix correct cracked permission for bukkit * A try to fix SQLite timestamp parsing +* Drop support for LoginSecurity 1.X since 2.X seems to be stable +* Remove the nasty UltraAuth fakeplayer workaround by using a new api method. You should UltraAuth if you have it ######1.8 diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/BukkitLoginSession.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/BukkitLoginSession.java index 9d4e2c86..2d9fb8c7 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/BukkitLoginSession.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/BukkitLoginSession.java @@ -3,8 +3,6 @@ package com.github.games647.fastlogin.bukkit; import com.github.games647.fastlogin.core.PlayerProfile; import com.github.games647.fastlogin.core.shared.LoginSession; -import java.util.UUID; - import org.apache.commons.lang.ArrayUtils; /** @@ -17,7 +15,6 @@ public class BukkitLoginSession extends LoginSession { private final String serverId; private final byte[] verifyToken; - private UUID uuid; private boolean verified; private String encodedSkinData; @@ -93,24 +90,6 @@ public class BukkitLoginSession extends LoginSession { this.verified = verified; } - /** - * Get the premium UUID of this player - * - * @return the premium UUID or null if not fetched - */ - public synchronized UUID getUuid() { - return uuid; - } - - /** - * Set the online UUID if it's fetched - * - * @param uuid premium UUID - */ - public synchronized void setUuid(UUID uuid) { - this.uuid = uuid; - } - /** * Get whether the player has a premium (paid account) account and valid session * diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/PlayerConnectionListener.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/PlayerConnectionListener.java index 0976bc39..35945342 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/PlayerConnectionListener.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/PlayerConnectionListener.java @@ -66,6 +66,8 @@ public class PlayerConnectionListener implements Listener { plugin.getCore().getPendingLogins().remove(ip + username); LoginSession session = plugin.getSession().get(connection); + session.setUuid(connection.getUniqueId()); + PlayerProfile playerProfile = session.getProfile(); playerProfile.setUuid(connection.getUniqueId()); diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/JoinManagement.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/JoinManagement.java index db6ba71d..62cd0bb2 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/shared/JoinManagement.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/JoinManagement.java @@ -46,15 +46,16 @@ public abstract class JoinManagement { || (!checkNameChange(source, username, premiumUUID) && !checkPremiumName(source, username, profile))) { //nothing detected the player as premium -> start a cracked session + if (core.getConfig().get("switchMode", false)) { + source.kick(core.getMessage("switch-kick-message")); + return; + } + startCrackedSession(source, profile, username); } } else if (profile.isPremium()) { requestPremiumLogin(source, profile, username, true); } else { - if (core.getConfig().get("switchMode", false)) { - source.kick(core.getMessage("switch-kick-message")); - return; - } startCrackedSession(source, profile, username); } diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/LoginSession.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/LoginSession.java index a22345e1..08abbf43 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/shared/LoginSession.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/LoginSession.java @@ -2,10 +2,15 @@ package com.github.games647.fastlogin.core.shared; import com.github.games647.fastlogin.core.PlayerProfile; +import java.util.UUID; + public abstract class LoginSession { private final String username; private final PlayerProfile profile; + + private UUID uuid; + protected boolean registered; public LoginSession(String username, boolean registered, PlayerProfile profile) { @@ -30,4 +35,22 @@ public abstract class LoginSession { public PlayerProfile getProfile() { return profile; } + + /** + * Get the premium UUID of this player + * + * @return the premium UUID or null if not fetched + */ + public synchronized UUID getUuid() { + return uuid; + } + + /** + * Set the online UUID if it's fetched + * + * @param uuid premium UUID + */ + public synchronized void setUuid(UUID uuid) { + this.uuid = uuid; + } }