Merge pull request 'Fix Schematics Readers' (#72) from Schematics/1.21 into main

Reviewed-on: https://steamwar.de/devlabs/SteamWar/SteamWar/pulls/72
Reviewed-by: Lixfel <lixfel@steamwar.de>
This commit is contained in:
Lixfel
2025-01-01 12:42:01 +01:00
19 changed files with 205 additions and 132 deletions
@@ -23,6 +23,7 @@ import com.sk89q.jnbt.NBTInputStream;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.*;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.NodeData;
import java.io.IOException;
import java.io.InputStream;
@@ -31,11 +32,19 @@ public class WorldEditWrapper18 extends WorldEditWrapper14 {
@Override
@SuppressWarnings("removal")
public Clipboard getClipboard(InputStream is, boolean schemFormat) throws IOException {
public Clipboard getClipboard(InputStream is, NodeData.SchematicFormat schemFormat) throws IOException {
NBTInputStream nbtStream = new NBTInputStream(is);
//Use FAWE reader due to FAWE capability of reading corrupt FAWE schems
try {
return (schemFormat ? new SpongeSchematicReader(nbtStream) : new MCEditSchematicReader(nbtStream)).read();
switch (schemFormat) {
case MCEDIT:
return new MCEditSchematicReader(nbtStream).read();
case SPONGE_V2:
case SPONGE_V3:
return new WorldEditWrapper14.SpongeSchematicReader(nbtStream).read();
default:
throw new IllegalArgumentException("Unsupported schematic format");
}
} catch (NullPointerException e) {
throw new NoClipboardException();
}