diff --git a/CHANGELOG.md b/CHANGELOG.md index f695a015..4cddb42c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ### 1.11 +* Add support for IPv6 proxies +* Shared configuration implementation for easier maintained code +* Use Gson for json parsing, because it's supported on all platforms and removes code duplicates +* Clean up project code * Drop support for deprecated AuthMe API * Remove legacy database migration code * Drop support for RoyalAuth, because it doesn't seem to be supported anymore diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/MojangApiBukkit.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/MojangApiBukkit.java index a68d5779..bcd5a120 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/MojangApiBukkit.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/MojangApiBukkit.java @@ -1,6 +1,5 @@ package com.github.games647.fastlogin.bukkit; -import com.github.games647.fastlogin.core.CommonUtil; import com.github.games647.fastlogin.core.mojang.MojangApiConnector; import com.github.games647.fastlogin.core.mojang.SkinProperties; import com.github.games647.fastlogin.core.mojang.VerificationReply; @@ -44,9 +43,7 @@ public class MojangApiBukkit extends MojangApiConnector { //validate parsing //http://wiki.vg/Protocol_Encryption#Server VerificationReply verification = gson.fromJson(reader, VerificationReply.class); - - String uuid = verification.getId(); - playerSession.setUuid(CommonUtil.parseId(uuid)); + playerSession.setUuid(verification.getId()); SkinProperties[] properties = verification.getProperties(); if (properties != null && properties.length > 0) { diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibListener.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibListener.java index f0ded7b4..6ef0f0bf 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibListener.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibListener.java @@ -77,7 +77,7 @@ public class ProtocolLibListener extends PacketAdapter { PacketContainer packet = packetEvent.getPacket(); String username = packet.getGameProfiles().read(0).getName(); - plugin.getLogger().log(Level.FINER, "Player {0} with {1} connecting", new Object[]{sessionKey, username}); + plugin.getLogger().log(Level.FINER, "GameProfile {0} with {1} connecting", new Object[]{sessionKey, username}); packetEvent.getAsyncMarker().incrementProcessingDelay(); Runnable nameCheckTask = new NameCheckTask(plugin, packetEvent, random, player, username); diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/VerifyResponseTask.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/VerifyResponseTask.java index 63a50200..216a76db 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/VerifyResponseTask.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/VerifyResponseTask.java @@ -52,7 +52,7 @@ public class VerifyResponseTask implements Runnable { BukkitLoginSession session = plugin.getLoginSessions().get(player.getAddress().toString()); if (session == null) { disconnect(plugin.getCore().getMessage("invalid-request"), true - , "Player {0} tried to send encryption response at invalid state", player.getAddress()); + , "GameProfile {0} tried to send encryption response at invalid state", player.getAddress()); } else { verifyResponse(session); } @@ -97,7 +97,7 @@ public class VerifyResponseTask implements Runnable { String username = session.getUsername(); if (plugin.getCore().getApiConnector().hasJoinedServer(session, serverId, player.getAddress())) { - plugin.getLogger().log(Level.INFO, "Player {0} has a verified premium account", username); + plugin.getLogger().log(Level.INFO, "GameProfile {0} has a verified premium account", username); session.setVerified(true); setPremiumUUID(session.getUuid()); @@ -105,7 +105,7 @@ public class VerifyResponseTask implements Runnable { } else { //user tried to fake a authentication disconnect(plugin.getCore().getMessage("invalid-session"), true - , "Player {0} ({1}) tried to log in with an invalid session ServerId: {2}" + , "GameProfile {0} ({1}) tried to log in with an invalid session ServerId: {2}" , session.getUsername(), player.getAddress(), serverId); } } @@ -132,7 +132,7 @@ public class VerifyResponseTask implements Runnable { if (!Arrays.equals(requestVerify, EncryptionUtil.decrypt(cipher, privateKey, responseVerify))) { //check if the verify token are equal to the server sent one disconnect(plugin.getCore().getMessage("invalid-verify-token"), true - , "Player {0} ({1}) tried to login with an invalid verify token. Server: {2} Client: {3}" + , "GameProfile {0} ({1}) tried to login with an invalid verify token. Server: {2} Client: {3}" , session.getUsername(), packetEvent.getPlayer().getAddress(), requestVerify, responseVerify); return false; } diff --git a/core/src/main/java/com/github/games647/fastlogin/core/hooks/AuthPlugin.java b/core/src/main/java/com/github/games647/fastlogin/core/hooks/AuthPlugin.java index cccd4911..9e30c38f 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/hooks/AuthPlugin.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/hooks/AuthPlugin.java @@ -3,7 +3,7 @@ package com.github.games647.fastlogin.core.hooks; /** * Represents a supporting authentication plugin in BungeeCord and Bukkit/Spigot/... servers * - * @param
either org.bukkit.entity.Player for Bukkit or net.md_5.bungee.api.connection.ProxiedPlayer for BungeeCord + * @param
either org.bukkit.entity.GameProfile for Bukkit or net.md_5.bungee.api.connection.ProxiedPlayer for BungeeCord */ public interface AuthPlugin
{
diff --git a/core/src/main/java/com/github/games647/fastlogin/core/mojang/Player.java b/core/src/main/java/com/github/games647/fastlogin/core/mojang/GameProfile.java
similarity index 62%
rename from core/src/main/java/com/github/games647/fastlogin/core/mojang/Player.java
rename to core/src/main/java/com/github/games647/fastlogin/core/mojang/GameProfile.java
index 25656ad4..e2c9447a 100644
--- a/core/src/main/java/com/github/games647/fastlogin/core/mojang/Player.java
+++ b/core/src/main/java/com/github/games647/fastlogin/core/mojang/GameProfile.java
@@ -1,11 +1,13 @@
package com.github.games647.fastlogin.core.mojang;
-public class Player {
+import java.util.UUID;
- private String id;
+public class GameProfile {
+
+ private UUID id;
private String name;
- public String getId() {
+ public UUID getId() {
return id;
}
diff --git a/core/src/main/java/com/github/games647/fastlogin/core/mojang/MojangApiConnector.java b/core/src/main/java/com/github/games647/fastlogin/core/mojang/MojangApiConnector.java
index 0446a2db..46b15c91 100644
--- a/core/src/main/java/com/github/games647/fastlogin/core/mojang/MojangApiConnector.java
+++ b/core/src/main/java/com/github/games647/fastlogin/core/mojang/MojangApiConnector.java
@@ -8,6 +8,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.common.net.HostAndPort;
import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
import java.io.BufferedReader;
import java.io.IOException;
@@ -53,7 +54,7 @@ public class MojangApiConnector {
private final int rateLimit;
private long lastRateLimit;
- protected final Gson gson = new Gson();
+ protected final Gson gson = new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create();
protected final Logger logger;
public MojangApiConnector(Logger logger, Collection Player class
+ * @param GameProfile class
* @param {
}
private boolean checkPremiumName(S source, String username, PlayerProfile profile) throws Exception {
- core.getPlugin().getLogger().log(Level.FINER, "Player {0} uses a premium username", username);
+ core.getPlugin().getLogger().log(Level.FINER, "GameProfile {0} uses a premium username", username);
if (core.getConfig().get("autoRegister", false) && (authHook == null || !authHook.isRegistered(username))) {
requestPremiumLogin(source, profile, username, false);
return true;
@@ -80,7 +80,7 @@ public abstract class JoinManagement {
PlayerProfile profile = core.getStorage().loadProfile(premiumUUID);
if (profile != null) {
//uuid exists in the database
- core.getPlugin().getLogger().log(Level.FINER, "Player {0} changed it's username", premiumUUID);
+ core.getPlugin().getLogger().log(Level.FINER, "GameProfile {0} changed it's username", premiumUUID);
//update the username to the new one in the database
profile.setPlayerName(username);
diff --git a/core/src/main/resources/config.yml b/core/src/main/resources/config.yml
index 11f44ec1..f73e6f52 100644
--- a/core/src/main/resources/config.yml
+++ b/core/src/main/resources/config.yml
@@ -62,7 +62,7 @@ premiumUuid: false
# #### Case 1
# nameChangeCheck = false ----- autoRegister = false
#
-# Player logins as cracked until the player invoked the command /premium. Then we could override the existing database
+# GameProfile logins as cracked until the player invoked the command /premium. Then we could override the existing database
# record.
#
# #### Case 2
diff --git a/core/src/main/resources/messages.yml b/core/src/main/resources/messages.yml
index b4affdbd..34643086 100644
--- a/core/src/main/resources/messages.yml
+++ b/core/src/main/resources/messages.yml
@@ -24,25 +24,25 @@
# Switch mode is activated and a new (non-whitelist) cracked player tries to join
switch-kick-message: '&4Only paid minecraft whitelisted accounts are allowed to join this server'
-# Player activated premium login in order to skip offline authentication
+# GameProfile activated premium login in order to skip offline authentication
add-premium: '&2Added to the list of premium players'
-# Player activated premium login in order to skip offline authentication
+# GameProfile activated premium login in order to skip offline authentication
add-premium-other: '&2Player has been added to the premium list'
-# Player is already set be a paid account
+# GameProfile is already set be a paid account
already-exists: '&4You are already on the premium list'
-# Player is already set be a paid account
+# GameProfile is already set be a paid account
already-exists-other: '&4Player is already on the premium list'
-# Player was changed to be cracked
+# GameProfile was changed to be cracked
remove-premium: '&2Removed from the list of premium players'
-# Player is already set to be cracked
+# GameProfile is already set to be cracked
not-premium: '&4You are not in the premium list'
-# Player is already set to be cracked
+# GameProfile is already set to be cracked
not-premium-other: '&4Player is not in the premium list'
# Admin wanted to change the premium of a user that isn't known to the plugin
@@ -58,7 +58,7 @@ auto-login: '&2Auto logged in'
auto-register: '&2Auto registered with password: %password
You may want change it?'
-# Player is not able to toggle the premium state of other players
+# GameProfile is not able to toggle the premium state of other players
no-permission: '&4Not enough permissions'
# Although the console can toggle the premium state, it's not possible for the console itself.