From e017776585ad5e3c0db0a8e444e28be51c5c6ca3 Mon Sep 17 00:00:00 2001 From: 0KepOnline <78259495+0KepOnline@users.noreply.github.com> Date: Tue, 18 Jun 2024 18:13:43 +0300 Subject: [PATCH] v2.0.1: Fix missing commands --- gradle.properties | 2 +- .../scenariopla/nbtexporter/NBTExporter.java | 2 +- .../command/NBTExporterCommand.java | 4 +- .../nbtexporter/util/NBTFileWriter.java | 73 ------------------- 4 files changed, 4 insertions(+), 77 deletions(-) delete mode 100644 src/main/java/net/scenariopla/nbtexporter/util/NBTFileWriter.java diff --git a/gradle.properties b/gradle.properties index 10230a7..22f49fd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ minecraft_version=1.19 loader_version=0.15.6 # Mod Properties -mod_version=2.0 +mod_version=2.0.1 maven_group=net.scenariopla mod_id=nbtexporter mod_name=NBT Exporter diff --git a/src/main/java/net/scenariopla/nbtexporter/NBTExporter.java b/src/main/java/net/scenariopla/nbtexporter/NBTExporter.java index 36d8984..4bbde17 100644 --- a/src/main/java/net/scenariopla/nbtexporter/NBTExporter.java +++ b/src/main/java/net/scenariopla/nbtexporter/NBTExporter.java @@ -21,7 +21,7 @@ public class NBTExporter implements ClientModInitializer { public class Reference { public static final String MOD_ID = "nbtexporter"; public static final String NAME = "NBT Exporter"; - public static final String VERSION = "2.0"; + public static final String VERSION = "2.0.1"; public static final String MOD_DIRECTORY = MOD_ID; diff --git a/src/main/java/net/scenariopla/nbtexporter/command/NBTExporterCommand.java b/src/main/java/net/scenariopla/nbtexporter/command/NBTExporterCommand.java index cdf988a..5c241dd 100644 --- a/src/main/java/net/scenariopla/nbtexporter/command/NBTExporterCommand.java +++ b/src/main/java/net/scenariopla/nbtexporter/command/NBTExporterCommand.java @@ -17,6 +17,7 @@ import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtIo; import net.minecraft.network.chat.ClickEvent; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.player.Player; @@ -24,7 +25,6 @@ import net.scenariopla.nbtexporter.NBTExporter; import net.scenariopla.nbtexporter.NBTExporter.Reference; -import net.scenariopla.nbtexporter.util.NBTFileWriter; import static net.scenariopla.nbtexporter.command.NBTExporterCommandExceptions.ExceptionCollection; import static net.scenariopla.nbtexporter.command.NBTExporterCommandExceptions.exception; @@ -134,7 +134,7 @@ protected static File writeToFile(File file, ByteArrayOutputStream byteArrayOutputStream = null; try { byteArrayOutputStream = new ByteArrayOutputStream(); - NBTFileWriter.writeCompoundGZIP(tag, byteArrayOutputStream); + NbtIo.writeCompressed(tag, byteArrayOutputStream); return writeToFile(file, byteArrayOutputStream.toByteArray()); } catch (IOException e) { e.printStackTrace(); diff --git a/src/main/java/net/scenariopla/nbtexporter/util/NBTFileWriter.java b/src/main/java/net/scenariopla/nbtexporter/util/NBTFileWriter.java deleted file mode 100644 index 761293a..0000000 --- a/src/main/java/net/scenariopla/nbtexporter/util/NBTFileWriter.java +++ /dev/null @@ -1,73 +0,0 @@ -package net.scenariopla.nbtexporter.util; - -import java.io.BufferedOutputStream; -import java.io.DataOutput; -import java.io.DataOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.zip.GZIPOutputStream; - -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; - -public class NBTFileWriter { - private static void writeSingle(final Tag tag, - final DataOutput output) - throws IOException { - final byte id = tag.getId(); - output.writeByte(id); - if (id != 0) { - output.writeUTF(""); - tag.write(output); - } - } - - public static void writeCompound(final CompoundTag compound, - final DataOutput output) - throws IOException { - writeSingle(compound, output); - } - - public static void writeCompound(final CompoundTag compound, - final File file) - throws IOException { - DataOutputStream dataOutputStream = null; - try { - dataOutputStream = new DataOutputStream( - new FileOutputStream(file)); - writeCompound(compound, dataOutputStream); - } finally { - dataOutputStream.close(); - } - } - - public static void writeCompoundGZIP(final CompoundTag compound, - final File file) - throws IOException { - FileOutputStream fileOutputStream = null; - try { - fileOutputStream = new FileOutputStream(file); - writeCompoundGZIP(compound, new FileOutputStream(file)); - } catch (Exception e) { - throw e; - } finally { - fileOutputStream.close(); - } - } - - public static void writeCompoundGZIP(final CompoundTag compound, - final OutputStream outputStream) - throws IOException { - DataOutputStream dataOutputStream = null; - try { - dataOutputStream = new DataOutputStream( - new BufferedOutputStream( - new GZIPOutputStream(outputStream))); - writeCompound(compound, dataOutputStream); - } finally { - dataOutputStream.close(); - } - } -}