Add toString methods to all relevant classes

This commit is contained in:
games647
2018-02-24 20:43:18 +01:00
parent 2bdd051a41
commit 06bb4b80dd
10 changed files with 87 additions and 9 deletions
@@ -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) {
@@ -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 +
'}';
}
}
@@ -14,4 +14,12 @@ public class GameProfile {
public String getName() {
return name;
}
@Override
public String toString() {
return this.getClass().getSimpleName() + '{' +
"id=" + id +
", name='" + name + '\'' +
'}';
}
}
@@ -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 + '\'' +
'}';
}
}
@@ -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) +
'}';
}
}
@@ -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 +
'}';
}
}