Add toString methods to all relevant classes

This commit is contained in:
games647
2018-02-17 19:10:43 +01:00
parent 2bdd051a41
commit 06bb4b80dd
10 changed files with 87 additions and 9 deletions

View File

@ -12,6 +12,7 @@ import com.github.games647.fastlogin.core.shared.LoginSource;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.security.PublicKey; import java.security.PublicKey;
import java.util.Arrays;
import java.util.Random; import java.util.Random;
import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.ArrayUtils;
@ -96,4 +97,15 @@ public class ProtocolLibLoginSource implements LoginSource {
public byte[] getVerifyToken() { public byte[] getVerifyToken() {
return ArrayUtils.clone(verifyToken); return ArrayUtils.clone(verifyToken);
} }
@Override
public String toString() {
return this.getClass().getSimpleName() + '{' +
"packetEvent=" + packetEvent +
", player=" + player +
", random=" + random +
", serverId='" + serverId + '\'' +
", verifyToken=" + Arrays.toString(verifyToken) +
'}';
}
} }

View File

@ -32,4 +32,11 @@ public class ProtocolLoginSource implements LoginSource {
public PlayerLoginStartEvent getLoginStartEvent() { public PlayerLoginStartEvent getLoginStartEvent() {
return loginStartEvent; return loginStartEvent;
} }
@Override
public String toString() {
return this.getClass().getSimpleName() + '{' +
"loginStartEvent=" + loginStartEvent +
'}';
}
} }

View File

@ -31,4 +31,13 @@ public class BungeeLoginSession extends LoginSession {
public void setAlreadyLogged(boolean alreadyLogged) { public void setAlreadyLogged(boolean alreadyLogged) {
this.alreadyLogged = alreadyLogged; this.alreadyLogged = alreadyLogged;
} }
@Override
public String toString() {
return this.getClass().getSimpleName() + '{' +
"alreadySaved=" + alreadySaved +
", alreadyLogged=" + alreadyLogged +
", registered=" + registered +
"} " + super.toString();
}
} }

View File

@ -33,4 +33,11 @@ public class BungeeLoginSource implements LoginSource {
public PendingConnection getConnection() { public PendingConnection getConnection() {
return connection; return connection;
} }
@Override
public String toString() {
return this.getClass().getSimpleName() + '{' +
"connection=" + connection +
'}';
}
} }

View File

@ -7,6 +7,7 @@ import java.util.UUID;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.regex.Pattern;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -14,6 +15,8 @@ import org.slf4j.impl.JDK14LoggerAdapter;
public class CommonUtil { 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 COLOR_CHAR = '&';
private static final char TRANSLATED_CHAR = '§'; private static final char TRANSLATED_CHAR = '§';
@ -34,15 +37,7 @@ public class CommonUtil {
} }
public static UUID parseId(String withoutDashes) { public static UUID parseId(String withoutDashes) {
if (withoutDashes == null) { return UUID.fromString(UUID_PATTERN.matcher(withoutDashes).replaceAll("$1-$2-$3-$4-$5"));
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));
} }
public static String toMojangId(UUID uuid) { public static String toMojangId(UUID uuid) {

View File

@ -75,4 +75,16 @@ public class PlayerProfile {
public synchronized void setLastLogin(Instant lastLogin) { public synchronized void setLastLogin(Instant lastLogin) {
this.lastLogin = lastLogin; this.lastLogin = lastLogin;
} }
@Override
public String toString() {
return this.getClass().getSimpleName() + '{' +
"playerName='" + playerName + '\'' +
", userId=" + userId +
", uuid=" + uuid +
", premium=" + premium +
", lastIp='" + lastIp + '\'' +
", lastLogin=" + lastLogin +
'}';
}
} }

View File

@ -14,4 +14,12 @@ public class GameProfile {
public String getName() { public String getName() {
return name; return name;
} }
@Override
public String toString() {
return this.getClass().getSimpleName() + '{' +
"id=" + id +
", name='" + name + '\'' +
'}';
}
} }

View File

@ -16,4 +16,13 @@ public class SkinProperties {
public String getSignature() { public String getSignature() {
return signature; return signature;
} }
@Override
public String toString() {
return this.getClass().getSimpleName() + '{' +
"name='" + name + '\'' +
", value='" + value + '\'' +
", signature='" + signature + '\'' +
'}';
}
} }

View File

@ -20,4 +20,13 @@ public class VerificationReply {
public SkinProperties[] getProperties() { public SkinProperties[] getProperties() {
return Arrays.copyOf(properties, properties.length); return Arrays.copyOf(properties, properties.length);
} }
@Override
public String toString() {
return this.getClass().getSimpleName() + '{' +
"id=" + id +
", name='" + name + '\'' +
", properties=" + Arrays.toString(properties) +
'}';
}
} }

View File

@ -53,4 +53,14 @@ public abstract class LoginSession {
public synchronized void setUuid(UUID uuid) { public synchronized void setUuid(UUID uuid) {
this.uuid = uuid; this.uuid = uuid;
} }
@Override
public String toString() {
return this.getClass().getSimpleName() + '{' +
"username='" + username + '\'' +
", profile=" + profile +
", uuid=" + uuid +
", registered=" + registered +
'}';
}
} }