diff --git a/bukkit/pom.xml b/bukkit/pom.xml index 7e69439c..6a0421b7 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -72,7 +72,7 @@ com.comphenix.protocol ProtocolLib - 3.6.5-SNAPSHOT + 4.0.1 true 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 999448a4..46f29279 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 @@ -35,6 +35,11 @@ public class BukkitLoginSession extends LoginSession { this(username, "", ArrayUtils.EMPTY_BYTE_ARRAY, registered, null); } + //cracked player + public BukkitLoginSession(String username, PlayerProfile profile) { + this(username, "", ArrayUtils.EMPTY_BYTE_ARRAY, false, profile); + } + /** * Gets the random generated server id. This makes sure the request sent from the client is just for this server. * diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/ForceLoginTask.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/ForceLoginTask.java index 3c1601a1..c047299e 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/ForceLoginTask.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/ForceLoginTask.java @@ -34,22 +34,15 @@ public class ForceLoginTask implements Runnable { //remove the bungeecord identifier if there is ones String id = '/' + player.getAddress().getAddress().getHostAddress() + ':' + player.getAddress().getPort(); BukkitLoginSession session = plugin.getSessions().remove(id); - - Storage storage = plugin.getCore().getStorage(); - PlayerProfile playerProfile = null; - if (session != null) { - playerProfile = session.getProfile(); + if (session == null) { + return; } - if (session == null) { - //cracked player - if (playerProfile != null) { - playerProfile.setUuid(null); - playerProfile.setPremium(false); - storage.save(playerProfile); - } - //check if it's the same player as we checked before - } else if (player.getName().equals(session.getUsername())) { + Storage storage = plugin.getCore().getStorage(); + PlayerProfile playerProfile = session.getProfile(); + + //check if it's the same player as we checked before + if (session.isVerified() && player.getName().equals(session.getUsername())) { //premium player BukkitAuthPlugin authPlugin = plugin.getAuthPlugin(); if (authPlugin == null) { @@ -77,6 +70,13 @@ public class ForceLoginTask implements Runnable { sendSuccessNotification(); } } + } else { + //cracked player + if (playerProfile != null) { + playerProfile.setUuid(null); + playerProfile.setPremium(false); + storage.save(playerProfile); + } } } diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BukkitJoinListener.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BukkitJoinListener.java index c5a26343..1f3c8dff 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BukkitJoinListener.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BukkitJoinListener.java @@ -2,9 +2,9 @@ package com.github.games647.fastlogin.bukkit.listener; import com.comphenix.protocol.wrappers.WrappedGameProfile; import com.comphenix.protocol.wrappers.WrappedSignedProperty; +import com.github.games647.fastlogin.bukkit.BukkitLoginSession; import com.github.games647.fastlogin.bukkit.FastLoginBukkit; import com.github.games647.fastlogin.bukkit.ForceLoginTask; -import com.github.games647.fastlogin.bukkit.BukkitLoginSession; import org.bukkit.Bukkit; import org.bukkit.entity.Player; diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/ProtocolSupportListener.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/ProtocolSupportListener.java index e981dea9..6b697518 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/ProtocolSupportListener.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/ProtocolSupportListener.java @@ -42,34 +42,37 @@ public class ProtocolSupportListener implements Listener { PlayerProfile profile = plugin.getCore().getStorage().loadProfile(username); if (profile != null) { - if (profile.isPremium()) { - if (profile.getUserId() != -1) { - startPremiumSession(username, loginStartEvent, true, profile); + if (profile.getUserId() == -1) { + UUID premiumUUID = null; + if (plugin.getConfig().getBoolean("nameChangeCheck") || plugin.getConfig().getBoolean("autoRegister")) { + premiumUUID = plugin.getCore().getMojangApiConnector().getPremiumUUID(username); } - } else if (profile.getUserId() == -1) { + //user not exists in the db try { if (plugin.getConfig().getBoolean("nameChangeCheck")) { - UUID premiumUUID = plugin.getCore().getMojangApiConnector().getPremiumUUID(username); - if (premiumUUID != null) { - profile = plugin.getCore().getStorage().loadProfile(premiumUUID); - if (profile != null) { - plugin.getLogger().log(Level.FINER, "Player {0} changed it's username", premiumUUID); - startPremiumSession(username, loginStartEvent, false, profile); - } + profile = plugin.getCore().getStorage().loadProfile(premiumUUID); + if (profile != null) { + plugin.getLogger().log(Level.FINER, "Player {0} changed it's username", premiumUUID); + startPremiumSession(username, loginStartEvent, false, profile); + return; } } if (plugin.getConfig().getBoolean("autoRegister") && !authPlugin.isRegistered(username)) { - UUID premiumUUID = plugin.getCore().getMojangApiConnector().getPremiumUUID(username); - if (premiumUUID != null) { - plugin.getLogger().log(Level.FINER, "Player {0} uses a premium username", username); - startPremiumSession(username, loginStartEvent, false, profile); - } + plugin.getLogger().log(Level.FINER, "Player {0} uses a premium username", username); + startPremiumSession(username, loginStartEvent, false, profile); + return; } + + //no premium check passed so we save it as a cracked player + BukkitLoginSession loginSession = new BukkitLoginSession(username, profile); + plugin.getSessions().put(loginStartEvent.getAddress().toString(), loginSession); } catch (Exception ex) { plugin.getLogger().log(Level.SEVERE, "Failed to query isRegistered", ex); } + } else if (profile.isPremium()) { + startPremiumSession(username, loginStartEvent, true, profile); } } } diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/packet/StartPacketListener.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/packet/StartPacketListener.java index 04f5a10d..20d18b6e 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/packet/StartPacketListener.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/packet/StartPacketListener.java @@ -85,34 +85,37 @@ public class StartPacketListener extends PacketAdapter { PlayerProfile profile = plugin.getCore().getStorage().loadProfile(username); if (profile != null) { - if (profile.isPremium()) { - if (profile.getUserId() != -1) { - enablePremiumLogin(username, profile, sessionKey, player, packetEvent, true); + if (profile.getUserId() == -1) { + UUID premiumUUID = null; + if (plugin.getConfig().getBoolean("nameChangeCheck") || plugin.getConfig().getBoolean("autoRegister")) { + premiumUUID = plugin.getCore().getMojangApiConnector().getPremiumUUID(username); } - } else if (profile.getUserId() == -1) { + //user not exists in the db try { if (plugin.getConfig().getBoolean("nameChangeCheck")) { - UUID premiumUUID = plugin.getCore().getMojangApiConnector().getPremiumUUID(username); - if (premiumUUID != null) { - profile = plugin.getCore().getStorage().loadProfile(premiumUUID); - if (profile != null) { - plugin.getLogger().log(Level.FINER, "Player {0} changed it's username", premiumUUID); - enablePremiumLogin(username, profile, sessionKey, player, packetEvent, false); - } + profile = plugin.getCore().getStorage().loadProfile(premiumUUID); + if (profile != null) { + plugin.getLogger().log(Level.FINER, "Player {0} changed it's username", premiumUUID); + enablePremiumLogin(username, profile, sessionKey, player, packetEvent, false); + return; } } if (plugin.getConfig().getBoolean("autoRegister") && !authPlugin.isRegistered(username)) { - UUID premiumUUID = plugin.getCore().getMojangApiConnector().getPremiumUUID(username); - if (premiumUUID != null) { - plugin.getLogger().log(Level.FINER, "Player {0} uses a premium username", username); - enablePremiumLogin(username, profile, sessionKey, player, packetEvent, false); - } + plugin.getLogger().log(Level.FINER, "Player {0} uses a premium username", username); + enablePremiumLogin(username, profile, sessionKey, player, packetEvent, false); + return; } + + //no premium check passed so we save it as a cracked player + BukkitLoginSession loginSession = new BukkitLoginSession(username, profile); + plugin.getSessions().put(sessionKey, loginSession); } catch (Exception ex) { plugin.getLogger().log(Level.SEVERE, "Failed to query isRegistered", ex); } + } else if (profile.isPremium()) { + enablePremiumLogin(username, profile, sessionKey, player, packetEvent, true); } } } diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java index 57932c43..b28bb766 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java @@ -109,7 +109,7 @@ public class FastLoginBungee extends Plugin { this.bungeeAuthPlugin = authPlugin; } - public Configuration getConfiguration() { + public Configuration getConfig() { return configuration; } 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 4fddd05c..c59bd27f 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 @@ -58,7 +58,7 @@ public class PlayerConnectionListener implements Listener { //bungeecord will do this automatically so override it on disabled option InitialHandler initialHandler = (InitialHandler) connection; - if (!plugin.getConfiguration().getBoolean("premiumUuid")) { + if (!plugin.getConfig().getBoolean("premiumUuid")) { try { UUID offlineUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + username).getBytes(Charsets.UTF_8)); @@ -72,7 +72,7 @@ public class PlayerConnectionListener implements Listener { } } - if (!plugin.getConfiguration().getBoolean("forwardSkin")) { + if (!plugin.getConfig().getBoolean("forwardSkin")) { //this is null on offline mode LoginResult loginProfile = initialHandler.getLoginProfile(); if (loginProfile != null) { diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/PluginMessageListener.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/PluginMessageListener.java index cea9a268..3c24111e 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/PluginMessageListener.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/PluginMessageListener.java @@ -1,7 +1,7 @@ package com.github.games647.fastlogin.bungee.listener; -import com.github.games647.fastlogin.bungee.tasks.AsyncToggleMessage; import com.github.games647.fastlogin.bungee.FastLoginBungee; +import com.github.games647.fastlogin.bungee.tasks.AsyncToggleMessage; import com.github.games647.fastlogin.core.PlayerProfile; import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteStreams; diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/tasks/AsyncPremiumCheck.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/tasks/AsyncPremiumCheck.java index f62eb615..853a6bb7 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/tasks/AsyncPremiumCheck.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/tasks/AsyncPremiumCheck.java @@ -35,8 +35,7 @@ public class AsyncPremiumCheck implements Runnable { if (profile.getUserId() == -1) { UUID premiumUUID = null; - if (plugin.getConfiguration().getBoolean("nameChangeCheck") - || plugin.getConfiguration().getBoolean("autoRegister")) { + if (plugin.getConfig().getBoolean("nameChangeCheck") || plugin.getConfig().getBoolean("autoRegister")) { premiumUUID = plugin.getCore().getMojangApiConnector().getPremiumUUID(username); } @@ -59,7 +58,7 @@ public class AsyncPremiumCheck implements Runnable { private boolean checkPremiumName(String username, PendingConnection connection, PlayerProfile profile) throws Exception { BungeeAuthPlugin authPlugin = plugin.getBungeeAuthPlugin(); - if (plugin.getConfiguration().getBoolean("autoRegister") + if (plugin.getConfig().getBoolean("autoRegister") && (authPlugin == null || !authPlugin.isRegistered(username))) { plugin.getLogger().log(Level.FINER, "Player {0} uses a premium username", username); requestPremiumLogin(connection, profile, username, false); @@ -71,7 +70,7 @@ public class AsyncPremiumCheck implements Runnable { private boolean checkNameChange(UUID premiumUUID, PendingConnection connection, String username) { //user not exists in the db - if (plugin.getConfiguration().getBoolean("nameChangeCheck")) { + if (plugin.getConfig().getBoolean("nameChangeCheck")) { PlayerProfile profile = plugin.getCore().getStorage().loadProfile(premiumUUID); if (profile != null) { //uuid exists in the database diff --git a/core/src/main/java/com/github/games647/fastlogin/core/LoginSession.java b/core/src/main/java/com/github/games647/fastlogin/core/LoginSession.java index 6cac8cf5..25ea447c 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/LoginSession.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/LoginSession.java @@ -16,6 +16,11 @@ public class LoginSession { return username; } + /** + * This value is always false if we authenticate the player with a cracked authentication + * + * @return + */ public boolean needsRegistration() { return !registered; } diff --git a/core/src/main/resources/config.yml b/core/src/main/resources/config.yml index c8c689d2..c8274215 100644 --- a/core/src/main/resources/config.yml +++ b/core/src/main/resources/config.yml @@ -108,7 +108,7 @@ driver: org.sqlite.JDBC # File location database: '{pluginDir}/FastLogin.db' -# MySQL and SQLite +# MySQL #driver: com.mysql.jdbc.Driver #host: localhost #port: 3306