diff --git a/pom.xml b/pom.xml
index 76af456..088d381 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
4.0.0
net.sourcewriters.minecraft
vcompat
- 2.1.6
+ 2.1.7
vCompat
diff --git a/src/main/java/net/sourcewriters/minecraft/vcompat/skin/Mojang.java b/src/main/java/net/sourcewriters/minecraft/vcompat/skin/Mojang.java
index c3c40a7..0818411 100644
--- a/src/main/java/net/sourcewriters/minecraft/vcompat/skin/Mojang.java
+++ b/src/main/java/net/sourcewriters/minecraft/vcompat/skin/Mojang.java
@@ -38,12 +38,23 @@ public class Mojang {
private final PlayerProvider> playerProvider = VersionControl.get().getPlayerProvider();
+ private boolean debug = false;
+
public Mojang(ILogger logger, MojangProvider provider, SkinStore store) {
this.logger = logger;
this.provider = provider;
this.store = store;
}
+ public boolean debug() {
+ return debug;
+ }
+
+ public Mojang debug(boolean state) {
+ this.debug = state;
+ return this;
+ }
+
/*
* Getter
*/
@@ -138,6 +149,9 @@ public Skin getSkinFrom(URL url, SkinModel model) {
public Skin getSkinFrom(URL url, SkinModel model, int timeout) {
Profile profile = getUseableProfile();
if (profile == null || url == null || model == null) {
+ if (debug) {
+ logger.log(LogTypeId.DEBUG, "Smth is null (" + (profile == null) + "/" + (url == null) + "/" + (model == null) + ") o.0");
+ }
return null;
}
try {
@@ -161,6 +175,10 @@ public Skin getSkinFrom(URL url, SkinModel model, int timeout) {
request.data("url", url.toString()).data("model", model.toString());
EasyResponse response = request.run(String.format(URL_SKIN_UPLOAD, profile.getUniqueId()));
if (response.getCode() != ResponseCode.NO_CONTENT) {
+ if (debug) {
+ logger.log(LogTypeId.DEBUG, "Code: " + response.getCode() + " / Length: " + response.getData().length);
+ logger.log(LogTypeId.DEBUG, response.getDataAsJson().toPrettyString().split("\n"));
+ }
return null;
}
return apply(MojangProfileServer.getSkinShorten(profile.getUniqueId()));
@@ -195,6 +213,9 @@ public Skin getSkinFrom(String name, URL url, SkinModel model) {
public Skin getSkinFrom(String name, URL url, SkinModel model, int timeout) {
Profile profile = getUseableProfile();
if (profile == null || name != null || url == null || model == null) {
+ if (debug) {
+ logger.log(LogTypeId.DEBUG, "Smth is null (" + (profile == null) + "/" + (url == null) + "/" + (model == null) + ") o.0");
+ }
return null;
}
try {
@@ -218,6 +239,10 @@ public Skin getSkinFrom(String name, URL url, SkinModel model, int timeout) {
request.data("url", url.toString()).data("model", model.toString());
EasyResponse response = request.run(String.format(URL_SKIN_UPLOAD, profile.getUniqueId()), EasyUrlEncodedContent.URL_ENCODED);
if (response.getCode() != ResponseCode.NO_CONTENT) {
+ if (debug) {
+ logger.log(LogTypeId.DEBUG, "Code: " + response.getCode() + " / Length: " + response.getData().length);
+ logger.log(LogTypeId.DEBUG, response.getDataAsJson().toPrettyString().split("\n"));
+ }
return null;
}
return apply(MojangProfileServer.getSkinShorten(name, profile.getUniqueId()));
diff --git a/src/main/java/net/sourcewriters/minecraft/vcompat/skin/Profile.java b/src/main/java/net/sourcewriters/minecraft/vcompat/skin/Profile.java
index 9cf836b..2723a02 100644
--- a/src/main/java/net/sourcewriters/minecraft/vcompat/skin/Profile.java
+++ b/src/main/java/net/sourcewriters/minecraft/vcompat/skin/Profile.java
@@ -23,12 +23,23 @@ public class Profile {
private String authToken;
+ private boolean debug = false;
+
public Profile(MojangProvider provider, String user, String pass) {
this.provider = provider;
this.username = user;
this.password = pass;
}
+ public boolean debug() {
+ return debug;
+ }
+
+ public Profile debug(boolean state) {
+ this.debug = state;
+ return this;
+ }
+
/*
*
*/
@@ -110,6 +121,9 @@ public Profile authenticate() {
object.set("clientToken", provider.getClientIdentifier().toString());
request.data(object);
JsonValue> responseRaw = request.run(String.format(AUTH_SERVER, "authenticate")).getDataAsJson();
+ if (debug) {
+ System.out.println(responseRaw.toPrettyString());
+ }
if (!responseRaw.hasType(ValueType.OBJECT)) {
return this;
}