Add some colour to the skin server info window

This commit is contained in:
Sollace 2018-07-26 17:25:47 +02:00
parent 01bdac7ed8
commit 485ef8e3fc
5 changed files with 23 additions and 13 deletions

View file

@ -8,7 +8,6 @@ import com.mojang.authlib.yggdrasil.response.MinecraftTexturesPayload;
import com.mojang.util.UUIDTypeAdapter; import com.mojang.util.UUIDTypeAdapter;
import com.voxelmodpack.hdskins.HDSkinManager; import com.voxelmodpack.hdskins.HDSkinManager;
import net.minecraft.util.Session; import net.minecraft.util.Session;
import org.apache.commons.lang3.builder.ToStringBuilder;
import java.io.IOException; import java.io.IOException;
import java.util.Locale; import java.util.Locale;
@ -29,8 +28,8 @@ public class BethlehemSkinServer implements SkinServer {
@Override @Override
public MinecraftTexturesPayload loadProfileData(GameProfile profile) throws IOException { public MinecraftTexturesPayload loadProfileData(GameProfile profile) throws IOException {
// TODO: Fix this
try (MoreHttpResponses response = new NetClient("GET", getPath(profile)).send()) { try (MoreHttpResponses response = new NetClient("GET", getPath(profile)).send()) {
if (!response.ok()) { if (!response.ok()) {
throw new IOException(response.getResponse().getStatusLine().getReasonPhrase()); throw new IOException(response.getResponse().getStatusLine().getReasonPhrase());
} }
@ -85,7 +84,7 @@ public class BethlehemSkinServer implements SkinServer {
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this, IndentedToStringStyle.INSTANCE) return new IndentedToStringStyle.Builder(this)
.append("address", address) .append("address", address)
.build(); .build();
} }

View file

@ -1,20 +1,34 @@
package com.voxelmodpack.hdskins.skins; package com.voxelmodpack.hdskins.skins;
import org.apache.commons.lang3.SystemUtils; import org.apache.commons.lang3.SystemUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import static net.minecraft.util.text.TextFormatting.*;
public class IndentedToStringStyle extends ToStringStyle { public class IndentedToStringStyle extends ToStringStyle {
private static final long serialVersionUID = 2031593562293731492L; private static final long serialVersionUID = 2031593562293731492L;
public static final ToStringStyle INSTANCE = new IndentedToStringStyle(); private static final ToStringStyle INSTANCE = new IndentedToStringStyle();
private IndentedToStringStyle() { private IndentedToStringStyle() {
this.setFieldNameValueSeparator(": " + RESET + ITALIC);
this.setContentStart(null); this.setContentStart(null);
this.setFieldSeparator(SystemUtils.LINE_SEPARATOR + " "); this.setFieldSeparator(SystemUtils.LINE_SEPARATOR + " " + RESET + YELLOW);
this.setFieldSeparatorAtStart(true); this.setFieldSeparatorAtStart(true);
this.setContentEnd(null); this.setContentEnd(null);
this.setUseIdentityHashCode(false); this.setUseIdentityHashCode(false);
this.setUseShortClassName(true); this.setUseShortClassName(true);
} }
public static class Builder extends ToStringBuilder {
public Builder(Object o) {
super(o, IndentedToStringStyle.INSTANCE);
}
public String build() {
return YELLOW + super.build();
}
}
} }

View file

@ -10,7 +10,6 @@ import com.mojang.util.UUIDTypeAdapter;
import com.voxelmodpack.hdskins.HDSkinManager; import com.voxelmodpack.hdskins.HDSkinManager;
import com.voxelmodpack.hdskins.upload.ThreadMultipartPostUpload; import com.voxelmodpack.hdskins.upload.ThreadMultipartPostUpload;
import net.minecraft.util.Session; import net.minecraft.util.Session;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -140,9 +139,9 @@ public class LegacySkinServer implements SkinServer {
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this, IndentedToStringStyle.INSTANCE) return new IndentedToStringStyle.Builder(this)
.append("address", this.address) .append("address", address)
.append("gateway", this.gateway) .append("gateway", gateway)
.build(); .build();
} }
} }

View file

@ -49,5 +49,4 @@ public class NetClient {
return MoreHttpResponses.execute(HDSkinManager.httpClient, request); return MoreHttpResponses.execute(HDSkinManager.httpClient, request);
} }
} }

View file

@ -11,7 +11,6 @@ import com.mojang.util.UUIDTypeAdapter;
import com.voxelmodpack.hdskins.HDSkinManager; import com.voxelmodpack.hdskins.HDSkinManager;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.util.Session; import net.minecraft.util.Session;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.http.HttpHeaders; import org.apache.http.HttpHeaders;
import org.apache.http.NameValuePair; import org.apache.http.NameValuePair;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
@ -208,8 +207,8 @@ public class ValhallaSkinServer implements SkinServer {
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this, IndentedToStringStyle.INSTANCE) return new IndentedToStringStyle.Builder(this)
.append("address", this.address) .append("address", address)
.toString(); .toString();
} }