From 6c65f0914980777da01b222b767b67e46cedfeff Mon Sep 17 00:00:00 2001 From: Octavia Togami Date: Wed, 2 Oct 2024 00:34:48 -0700 Subject: [PATCH] Bump lin-bus to support old schematics better --- gradle/libs.versions.toml | 2 +- .../clipboard/io/BuiltInClipboardFormat.java | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 69c0652ba..ac66e70a4 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -49,7 +49,7 @@ fabric-mixin = "net.fabricmc:sponge-mixin:0.13.3+mixin.0.8.5" paperweight = "io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.7.2" -linBus-bom = "org.enginehub.lin-bus:lin-bus-bom:0.1.0" +linBus-bom = "org.enginehub.lin-bus:lin-bus-bom:0.2.0" linBus-common.module = "org.enginehub.lin-bus:lin-bus-common" linBus-stream.module = "org.enginehub.lin-bus:lin-bus-stream" linBus-tree.module = "org.enginehub.lin-bus:lin-bus-tree" diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java index 2c64915ca..c2c8173e6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java @@ -26,6 +26,7 @@ import com.sk89q.worldedit.extent.clipboard.io.sponge.SpongeSchematicV3Reader; import com.sk89q.worldedit.extent.clipboard.io.sponge.SpongeSchematicV3Writer; import org.enginehub.linbus.stream.LinBinaryIO; +import org.enginehub.linbus.stream.LinReadOptions; import org.enginehub.linbus.tree.LinCompoundTag; import org.enginehub.linbus.tree.LinIntTag; import org.enginehub.linbus.tree.LinRootEntry; @@ -58,7 +59,8 @@ public String getPrimaryFileExtension() { @Override public ClipboardReader getReader(InputStream inputStream) throws IOException { return new MCEditSchematicReader(LinBinaryIO.read( - new DataInputStream(new GZIPInputStream(inputStream)) + new DataInputStream(new GZIPInputStream(inputStream)), + LEGACY_OPTIONS )); } @@ -72,7 +74,7 @@ public boolean isFormat(InputStream inputStream) { LinRootEntry rootEntry; try { DataInputStream stream = new DataInputStream(new GZIPInputStream(inputStream)); - rootEntry = LinBinaryIO.readUsing(stream, LinRootEntry::readFrom); + rootEntry = LinBinaryIO.readUsing(stream, LEGACY_OPTIONS, LinRootEntry::readFrom); } catch (Exception e) { return false; } @@ -92,7 +94,7 @@ public String getPrimaryFileExtension() { @Override public ClipboardReader getReader(InputStream inputStream) throws IOException { return new SpongeSchematicV1Reader(LinBinaryIO.read( - new DataInputStream(new GZIPInputStream(inputStream)) + new DataInputStream(new GZIPInputStream(inputStream)), LEGACY_OPTIONS )); } @@ -116,7 +118,7 @@ public String getPrimaryFileExtension() { @Override public ClipboardReader getReader(InputStream inputStream) throws IOException { return new SpongeSchematicV2Reader(LinBinaryIO.read( - new DataInputStream(new GZIPInputStream(inputStream)) + new DataInputStream(new GZIPInputStream(inputStream)), LEGACY_OPTIONS )); } @@ -175,7 +177,7 @@ private static boolean detectOldSpongeSchematic(InputStream inputStream, int ver LinRootEntry rootEntry; try { DataInputStream stream = new DataInputStream(new GZIPInputStream(inputStream)); - rootEntry = LinBinaryIO.readUsing(stream, LinRootEntry::readFrom); + rootEntry = LinBinaryIO.readUsing(stream, LEGACY_OPTIONS, LinRootEntry::readFrom); } catch (Exception e) { return false; } @@ -200,6 +202,8 @@ private static boolean detectOldSpongeSchematic(InputStream inputStream, int ver @Deprecated public static final BuiltInClipboardFormat SPONGE_SCHEMATIC = SPONGE_V2_SCHEMATIC; + private static final LinReadOptions LEGACY_OPTIONS = LinReadOptions.builder().allowNormalUtf8Encoding(true).build(); + private final ImmutableSet aliases; BuiltInClipboardFormat(String... aliases) {