diff --git a/common/pom.xml b/common/pom.xml
index 4f2853a39..0bee6d76a 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -13,7 +13,6 @@
viaversion-common
-
org.yaml
snakeyaml
diff --git a/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/NBTType.java b/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/NBTType.java
index 862e26b21..76b8e66c1 100644
--- a/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/NBTType.java
+++ b/common/src/main/java/us/myles/ViaVersion/api/type/types/minecraft/NBTType.java
@@ -8,7 +8,9 @@ import org.spacehq.opennbt.NBTIO;
import org.spacehq.opennbt.tag.builtin.CompoundTag;
import us.myles.ViaVersion.api.type.Type;
+import java.io.DataInput;
import java.io.DataInputStream;
+import java.io.DataOutput;
import java.io.DataOutputStream;
public class NBTType extends Type {
@@ -28,7 +30,7 @@ public class NBTType extends Type {
buffer.readerIndex(readerIndex);
ByteBufInputStream bytebufStream = new ByteBufInputStream(buffer);
try (DataInputStream dataInputStream = new DataInputStream(bytebufStream)) {
- return (CompoundTag) NBTIO.readTag(dataInputStream);
+ return (CompoundTag) NBTIO.readTag((DataInput) dataInputStream);
}
}
}
@@ -41,7 +43,7 @@ public class NBTType extends Type {
ByteBufOutputStream bytebufStream = new ByteBufOutputStream(buffer);
DataOutputStream dataOutputStream = new DataOutputStream(bytebufStream);
- NBTIO.writeTag(dataOutputStream, object);
+ NBTIO.writeTag((DataOutput) dataOutputStream, object);
dataOutputStream.close();
}
diff --git a/common/src/main/java/us/myles/ViaVersion/commands/defaultsubs/DumpSubCmd.java b/common/src/main/java/us/myles/ViaVersion/commands/defaultsubs/DumpSubCmd.java
index 59e3945f2..3cad7c16a 100644
--- a/common/src/main/java/us/myles/ViaVersion/commands/defaultsubs/DumpSubCmd.java
+++ b/common/src/main/java/us/myles/ViaVersion/commands/defaultsubs/DumpSubCmd.java
@@ -1,5 +1,6 @@
package us.myles.ViaVersion.commands.defaultsubs;
+import com.google.common.io.CharStreams;
import com.google.gson.JsonObject;
import net.md_5.bungee.api.ChatColor;
import us.myles.ViaVersion.api.Via;
@@ -10,6 +11,7 @@ import us.myles.ViaVersion.dump.DumpTemplate;
import us.myles.ViaVersion.dump.VersionInfo;
import us.myles.ViaVersion.util.GsonUtil;
+import java.io.IOException;
import java.io.InputStreamReader;
import java.io.InvalidObjectException;
import java.io.OutputStream;
@@ -50,10 +52,19 @@ public class DumpSubCmd extends ViaSubCommand {
Via.getPlatform().runAsync(new Runnable() {
@Override
public void run() {
- try {
- HttpURLConnection con = (HttpURLConnection) new URL("http://hastebin.com/documents").openConnection();
+ HttpURLConnection con = null;
+ try {
+ con = (HttpURLConnection) new URL("http://hastebin.com/documents").openConnection();
+ } catch (IOException e) {
+ sender.sendMessage(ChatColor.RED + "Failed to dump, please check the console for more information");
+ Via.getPlatform().getLogger().log(Level.WARNING, "Could not paste ViaVersion dump to Hastebin", e);
+ return;
+ }
+ try {
con.setRequestProperty("Content-Type", "text/plain");
+ // Bypass cloudflare :(
+ con.addRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36");
con.setRequestMethod("POST");
con.setDoOutput(true);
@@ -61,8 +72,11 @@ public class DumpSubCmd extends ViaSubCommand {
out.write(GsonUtil.getGsonBuilder().setPrettyPrinting().create().toJson(template).getBytes(Charset.forName("UTF-8")));
out.close();
- JsonObject output = GsonUtil.getGson().fromJson(new InputStreamReader(con.getInputStream()), JsonObject.class);
+ String rawOutput = CharStreams.toString(new InputStreamReader(con.getInputStream()));
con.getInputStream().close();
+ System.out.println("Raw output: " + rawOutput);
+ JsonObject output = GsonUtil.getGson().fromJson(rawOutput, JsonObject.class);
+
if (!output.has("key"))
throw new InvalidObjectException("Key is not given in Hastebin output");
@@ -71,6 +85,15 @@ public class DumpSubCmd extends ViaSubCommand {
} catch (Exception e) {
sender.sendMessage(ChatColor.RED + "Failed to dump, please check the console for more information");
Via.getPlatform().getLogger().log(Level.WARNING, "Could not paste ViaVersion dump to Hastebin", e);
+ try {
+ if (con.getResponseCode() < 200 || con.getResponseCode() > 400) {
+ String rawOutput = CharStreams.toString(new InputStreamReader(con.getErrorStream()));
+ con.getErrorStream().close();
+ Via.getPlatform().getLogger().log(Level.WARNING, "Page returned: " + rawOutput);
+ }
+ } catch (IOException e1) {
+ Via.getPlatform().getLogger().log(Level.WARNING, "Failed to capture further info", e1);
+ }
}
}
});
diff --git a/pom.xml b/pom.xml
index 7cbc5e693..388bfea93 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,6 +65,7 @@
1.16.6
provided
+
org.javassist
@@ -74,11 +75,11 @@
true
-
+
org.spacehq
opennbt
- 1.0
+ 1.1
compile
true