Bump lin-bus to support old schematics better

This commit is contained in:
Octavia Togami 2024-10-02 00:34:48 -07:00
parent 485bb41167
commit 6c65f09149
No known key found for this signature in database
GPG Key ID: CC364524D1983C99
2 changed files with 10 additions and 6 deletions

View File

@ -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"

View File

@ -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<String> aliases;
BuiltInClipboardFormat(String... aliases) {