Maybe, Fix Schematics Readers

This commit is contained in:
2024-12-03 22:43:14 +01:00
parent 57d4727f35
commit 0134ef1f61
18 changed files with 1010 additions and 125 deletions
@@ -19,10 +19,12 @@
package de.steamwar.core;
import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicReader;
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 +33,18 @@ 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 V2:
return new SpongeSchematicReader(nbtStream).read();
default:
throw new IllegalArgumentException("Unsupported schematic format");
}
} catch (NullPointerException e) {
throw new NoClipboardException();
}