From b2e98af2d1f47ae77e4eaaeedd7e154567b85a1a Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 26 Jul 2018 17:25:47 +0200 Subject: [PATCH] Add some colour to the skin server info window --- .../hdskins/skins/AbstractSkinServer.java | 3 +-- .../hdskins/skins/BethlehemSkinServer.java | 8 -------- .../hdskins/skins/IndentedToStringStyle.java | 18 ++++++++++++++++-- .../hdskins/skins/LegacySkinServer.java | 3 +-- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/skins/AbstractSkinServer.java b/src/hdskins/java/com/voxelmodpack/hdskins/skins/AbstractSkinServer.java index f75f9774..5196d443 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/skins/AbstractSkinServer.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/skins/AbstractSkinServer.java @@ -9,7 +9,6 @@ import java.util.concurrent.CompletableFuture; import javax.annotation.Nullable; -import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.logging.log4j.util.Strings; import com.google.gson.JsonParseException; @@ -64,7 +63,7 @@ public abstract class AbstractSkinServer implements SkinServer { @Override public String toString() { - return new ToStringBuilder(this, IndentedToStringStyle.INSTANCE) + return new IndentedToStringStyle.Builder(this) .append("address", address) .build(); } diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/skins/BethlehemSkinServer.java b/src/hdskins/java/com/voxelmodpack/hdskins/skins/BethlehemSkinServer.java index fa93d0f5..8fd33315 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/skins/BethlehemSkinServer.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/skins/BethlehemSkinServer.java @@ -4,7 +4,6 @@ import java.io.IOException; import java.net.URI; import java.util.Locale; import java.util.Map; -import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.http.HttpStatus; import com.google.common.collect.ImmutableMap; @@ -76,11 +75,4 @@ public class BethlehemSkinServer extends AbstractSkinServer { private String getPath(GameProfile profile) { return String.format("%s/profile/%s", address, UUIDTypeAdapter.fromUUID(profile.getId())); } - - @Override - public String toString() { - return new ToStringBuilder(this, IndentedToStringStyle.INSTANCE) - .append("address", address) - .build(); - } } diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/skins/IndentedToStringStyle.java b/src/hdskins/java/com/voxelmodpack/hdskins/skins/IndentedToStringStyle.java index 44255b78..44d1d521 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/skins/IndentedToStringStyle.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/skins/IndentedToStringStyle.java @@ -1,20 +1,34 @@ package com.voxelmodpack.hdskins.skins; import org.apache.commons.lang3.SystemUtils; +import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; +import static net.minecraft.util.text.TextFormatting.*; + public class IndentedToStringStyle extends ToStringStyle { private static final long serialVersionUID = 2031593562293731492L; - public static final ToStringStyle INSTANCE = new IndentedToStringStyle(); + private static final ToStringStyle INSTANCE = new IndentedToStringStyle(); private IndentedToStringStyle() { + this.setFieldNameValueSeparator(": " + RESET + ITALIC); this.setContentStart(null); - this.setFieldSeparator(SystemUtils.LINE_SEPARATOR + " "); + this.setFieldSeparator(SystemUtils.LINE_SEPARATOR + " " + RESET + YELLOW); this.setFieldSeparatorAtStart(true); this.setContentEnd(null); this.setUseIdentityHashCode(false); this.setUseShortClassName(true); } + + public static class Builder extends ToStringBuilder { + public Builder(Object o) { + super(o, IndentedToStringStyle.INSTANCE); + } + + public String build() { + return YELLOW + super.build(); + } + } } diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/skins/LegacySkinServer.java b/src/hdskins/java/com/voxelmodpack/hdskins/skins/LegacySkinServer.java index e87af0b4..1657d17e 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/skins/LegacySkinServer.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/skins/LegacySkinServer.java @@ -11,7 +11,6 @@ import com.mojang.authlib.yggdrasil.response.MinecraftTexturesPayload; import com.mojang.util.UUIDTypeAdapter; import net.minecraft.util.Session; -import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.http.HttpStatus; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -130,7 +129,7 @@ public class LegacySkinServer extends AbstractSkinServer { @Override public String toString() { - return new ToStringBuilder(this, IndentedToStringStyle.INSTANCE) + return new IndentedToStringStyle.Builder(this) .append("address", address) .append("gateway", gateway) .build();