diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibLoginSource.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibLoginSource.java index f4830b1e..0cfac665 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibLoginSource.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/ProtocolLibLoginSource.java @@ -12,6 +12,7 @@ import com.github.games647.fastlogin.core.shared.LoginSource; import java.lang.reflect.InvocationTargetException; import java.net.InetSocketAddress; import java.security.PublicKey; +import java.util.Arrays; import java.util.Random; import org.apache.commons.lang.ArrayUtils; @@ -96,4 +97,15 @@ public class ProtocolLibLoginSource implements LoginSource { public byte[] getVerifyToken() { return ArrayUtils.clone(verifyToken); } + + @Override + public String toString() { + return this.getClass().getSimpleName() + '{' + + "packetEvent=" + packetEvent + + ", player=" + player + + ", random=" + random + + ", serverId='" + serverId + '\'' + + ", verifyToken=" + Arrays.toString(verifyToken) + + '}'; + } } diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocolsupport/ProtocolLoginSource.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocolsupport/ProtocolLoginSource.java index d2e4680a..1cc1f42c 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocolsupport/ProtocolLoginSource.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocolsupport/ProtocolLoginSource.java @@ -32,4 +32,11 @@ public class ProtocolLoginSource implements LoginSource { public PlayerLoginStartEvent getLoginStartEvent() { return loginStartEvent; } + + @Override + public String toString() { + return this.getClass().getSimpleName() + '{' + + "loginStartEvent=" + loginStartEvent + + '}'; + } } diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/BungeeLoginSession.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/BungeeLoginSession.java index 4b0b29cb..e38d9c3d 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/BungeeLoginSession.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/BungeeLoginSession.java @@ -31,4 +31,13 @@ public class BungeeLoginSession extends LoginSession { public void setAlreadyLogged(boolean alreadyLogged) { this.alreadyLogged = alreadyLogged; } + + @Override + public String toString() { + return this.getClass().getSimpleName() + '{' + + "alreadySaved=" + alreadySaved + + ", alreadyLogged=" + alreadyLogged + + ", registered=" + registered + + "} " + super.toString(); + } } diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/BungeeLoginSource.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/BungeeLoginSource.java index b0f9bacd..af081d52 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/BungeeLoginSource.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/BungeeLoginSource.java @@ -33,4 +33,11 @@ public class BungeeLoginSource implements LoginSource { public PendingConnection getConnection() { return connection; } + + @Override + public String toString() { + return this.getClass().getSimpleName() + '{' + + "connection=" + connection + + '}'; + } } diff --git a/core/src/main/java/com/github/games647/fastlogin/core/CommonUtil.java b/core/src/main/java/com/github/games647/fastlogin/core/CommonUtil.java index 77d2f7db..9e278c6d 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/CommonUtil.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/CommonUtil.java @@ -7,6 +7,7 @@ import java.util.UUID; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.TimeUnit; import java.util.logging.Level; +import java.util.regex.Pattern; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -14,6 +15,8 @@ import org.slf4j.impl.JDK14LoggerAdapter; public class CommonUtil { + private static final Pattern UUID_PATTERN = Pattern.compile("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})"); + private static final char COLOR_CHAR = '&'; private static final char TRANSLATED_CHAR = 'ยง'; @@ -34,15 +37,7 @@ public class CommonUtil { } public static UUID parseId(String withoutDashes) { - if (withoutDashes == null) { - return null; - } - - return UUID.fromString(withoutDashes.substring(0, 8) - + '-' + withoutDashes.substring(8, 12) - + '-' + withoutDashes.substring(12, 16) - + '-' + withoutDashes.substring(16, 20) - + '-' + withoutDashes.substring(20, 32)); + return UUID.fromString(UUID_PATTERN.matcher(withoutDashes).replaceAll("$1-$2-$3-$4-$5")); } public static String toMojangId(UUID uuid) { diff --git a/core/src/main/java/com/github/games647/fastlogin/core/PlayerProfile.java b/core/src/main/java/com/github/games647/fastlogin/core/PlayerProfile.java index 080d75f2..1da8cd5f 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/PlayerProfile.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/PlayerProfile.java @@ -75,4 +75,16 @@ public class PlayerProfile { public synchronized void setLastLogin(Instant lastLogin) { this.lastLogin = lastLogin; } + + @Override + public String toString() { + return this.getClass().getSimpleName() + '{' + + "playerName='" + playerName + '\'' + + ", userId=" + userId + + ", uuid=" + uuid + + ", premium=" + premium + + ", lastIp='" + lastIp + '\'' + + ", lastLogin=" + lastLogin + + '}'; + } } diff --git a/core/src/main/java/com/github/games647/fastlogin/core/mojang/GameProfile.java b/core/src/main/java/com/github/games647/fastlogin/core/mojang/GameProfile.java index e2c9447a..c15699c1 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/mojang/GameProfile.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/mojang/GameProfile.java @@ -14,4 +14,12 @@ public class GameProfile { public String getName() { return name; } + + @Override + public String toString() { + return this.getClass().getSimpleName() + '{' + + "id=" + id + + ", name='" + name + '\'' + + '}'; + } } diff --git a/core/src/main/java/com/github/games647/fastlogin/core/mojang/SkinProperties.java b/core/src/main/java/com/github/games647/fastlogin/core/mojang/SkinProperties.java index 042729ac..6e97a277 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/mojang/SkinProperties.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/mojang/SkinProperties.java @@ -16,4 +16,13 @@ public class SkinProperties { public String getSignature() { return signature; } + + @Override + public String toString() { + return this.getClass().getSimpleName() + '{' + + "name='" + name + '\'' + + ", value='" + value + '\'' + + ", signature='" + signature + '\'' + + '}'; + } } diff --git a/core/src/main/java/com/github/games647/fastlogin/core/mojang/VerificationReply.java b/core/src/main/java/com/github/games647/fastlogin/core/mojang/VerificationReply.java index 674db4e6..1bd90634 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/mojang/VerificationReply.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/mojang/VerificationReply.java @@ -20,4 +20,13 @@ public class VerificationReply { public SkinProperties[] getProperties() { return Arrays.copyOf(properties, properties.length); } + + @Override + public String toString() { + return this.getClass().getSimpleName() + '{' + + "id=" + id + + ", name='" + name + '\'' + + ", properties=" + Arrays.toString(properties) + + '}'; + } } 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 08abbf43..3facc876 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 @@ -53,4 +53,14 @@ public abstract class LoginSession { public synchronized void setUuid(UUID uuid) { this.uuid = uuid; } + + @Override + public String toString() { + return this.getClass().getSimpleName() + '{' + + "username='" + username + '\'' + + ", profile=" + profile + + ", uuid=" + uuid + + ", registered=" + registered + + '}'; + } }