forked from SteamWar/SteamWar
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:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user