Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 08:30:09 +01:00
Update OpenNBT
Dieser Commit ist enthalten in:
Ursprung
ea4487e33f
Commit
528a8e5587
@ -13,7 +13,6 @@
|
|||||||
<artifactId>viaversion-common</artifactId>
|
<artifactId>viaversion-common</artifactId>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- Snake YAML -->
|
<!-- Snake YAML -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.yaml</groupId>
|
<groupId>org.yaml</groupId>
|
||||||
<artifactId>snakeyaml</artifactId>
|
<artifactId>snakeyaml</artifactId>
|
||||||
|
@ -8,7 +8,9 @@ import org.spacehq.opennbt.NBTIO;
|
|||||||
import org.spacehq.opennbt.tag.builtin.CompoundTag;
|
import org.spacehq.opennbt.tag.builtin.CompoundTag;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
|
|
||||||
|
import java.io.DataInput;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
|
import java.io.DataOutput;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
|
||||||
public class NBTType extends Type<CompoundTag> {
|
public class NBTType extends Type<CompoundTag> {
|
||||||
@ -28,7 +30,7 @@ public class NBTType extends Type<CompoundTag> {
|
|||||||
buffer.readerIndex(readerIndex);
|
buffer.readerIndex(readerIndex);
|
||||||
ByteBufInputStream bytebufStream = new ByteBufInputStream(buffer);
|
ByteBufInputStream bytebufStream = new ByteBufInputStream(buffer);
|
||||||
try (DataInputStream dataInputStream = new DataInputStream(bytebufStream)) {
|
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<CompoundTag> {
|
|||||||
ByteBufOutputStream bytebufStream = new ByteBufOutputStream(buffer);
|
ByteBufOutputStream bytebufStream = new ByteBufOutputStream(buffer);
|
||||||
DataOutputStream dataOutputStream = new DataOutputStream(bytebufStream);
|
DataOutputStream dataOutputStream = new DataOutputStream(bytebufStream);
|
||||||
|
|
||||||
NBTIO.writeTag(dataOutputStream, object);
|
NBTIO.writeTag((DataOutput) dataOutputStream, object);
|
||||||
|
|
||||||
dataOutputStream.close();
|
dataOutputStream.close();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package us.myles.ViaVersion.commands.defaultsubs;
|
package us.myles.ViaVersion.commands.defaultsubs;
|
||||||
|
|
||||||
|
import com.google.common.io.CharStreams;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import us.myles.ViaVersion.api.Via;
|
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.dump.VersionInfo;
|
||||||
import us.myles.ViaVersion.util.GsonUtil;
|
import us.myles.ViaVersion.util.GsonUtil;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.InvalidObjectException;
|
import java.io.InvalidObjectException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
@ -50,10 +52,19 @@ public class DumpSubCmd extends ViaSubCommand {
|
|||||||
Via.getPlatform().runAsync(new Runnable() {
|
Via.getPlatform().runAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
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");
|
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.setRequestMethod("POST");
|
||||||
con.setDoOutput(true);
|
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.write(GsonUtil.getGsonBuilder().setPrettyPrinting().create().toJson(template).getBytes(Charset.forName("UTF-8")));
|
||||||
out.close();
|
out.close();
|
||||||
|
|
||||||
JsonObject output = GsonUtil.getGson().fromJson(new InputStreamReader(con.getInputStream()), JsonObject.class);
|
String rawOutput = CharStreams.toString(new InputStreamReader(con.getInputStream()));
|
||||||
con.getInputStream().close();
|
con.getInputStream().close();
|
||||||
|
System.out.println("Raw output: " + rawOutput);
|
||||||
|
JsonObject output = GsonUtil.getGson().fromJson(rawOutput, JsonObject.class);
|
||||||
|
|
||||||
|
|
||||||
if (!output.has("key"))
|
if (!output.has("key"))
|
||||||
throw new InvalidObjectException("Key is not given in Hastebin output");
|
throw new InvalidObjectException("Key is not given in Hastebin output");
|
||||||
@ -71,6 +85,15 @@ public class DumpSubCmd extends ViaSubCommand {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
sender.sendMessage(ChatColor.RED + "Failed to dump, please check the console for more information");
|
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);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
5
pom.xml
5
pom.xml
@ -65,6 +65,7 @@
|
|||||||
<version>1.16.6</version>
|
<version>1.16.6</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Javassist (Bytecode Library) -->
|
<!-- Javassist (Bytecode Library) -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.javassist</groupId>
|
<groupId>org.javassist</groupId>
|
||||||
@ -74,11 +75,11 @@
|
|||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- NBT Edit Library -->
|
<!-- OpenNBT Library -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spacehq</groupId>
|
<groupId>org.spacehq</groupId>
|
||||||
<artifactId>opennbt</artifactId>
|
<artifactId>opennbt</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.1</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren