3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-03 01:50:07 +01:00

Better logic for selecting schematic format.

- You had to specifically use //schem load <schematic>.schematic mcedit to load legacy schematics, now if you're loading .schematic it assumes you're wanting mcedit format
 - If you end up attempting to load an mcedit schematic with the sponge reader it now throws an exception.
Dieser Commit ist enthalten in:
dordsor21 2020-05-05 16:16:27 +01:00
Ursprung 6dec0ab2ba
Commit 3abf964620
2 geänderte Dateien mit 14 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -201,7 +201,7 @@ public class SchematicCommands {
String formatName) throws FilenameException { String formatName) throws FilenameException {
LocalConfiguration config = worldEdit.getConfiguration(); LocalConfiguration config = worldEdit.getConfiguration();
ClipboardFormat format = ClipboardFormats.findByAlias(formatName); ClipboardFormat format = null;
InputStream in = null; InputStream in = null;
try { try {
URI uri; URI uri;
@ -221,6 +221,7 @@ public class SchematicCommands {
File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(saveDir, actor.getUniqueId().toString()) : saveDir; File dir = Settings.IMP.PATHS.PER_PLAYER_SCHEMATICS ? new File(saveDir, actor.getUniqueId().toString()) : saveDir;
File file; File file;
if (filename.startsWith("#")) { if (filename.startsWith("#")) {
format = ClipboardFormats.findByAlias(formatName);
String[] extensions; String[] extensions;
if (format != null) { if (format != null) {
extensions = format.getFileExtensions().toArray(new String[0]); extensions = format.getFileExtensions().toArray(new String[0]);
@ -237,9 +238,11 @@ public class SchematicCommands {
actor.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.load.other")); actor.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.load.other"));
return; return;
} }
if (format == null && filename.matches(".*\\.[\\w].*")) { if (filename.matches(".*\\.[\\w].*")) {
String extension = filename.substring(filename.lastIndexOf('.') + 1); format = ClipboardFormats
format = ClipboardFormats.findByExtension(extension); .findByExtension(filename.substring(filename.lastIndexOf('.') + 1));
} else {
format = ClipboardFormats.findByAlias(formatName);
} }
file = MainUtil.resolve(dir, filename, format, false); file = MainUtil.resolve(dir, filename, format, false);
} }

Datei anzeigen

@ -69,6 +69,7 @@ public class FastSchematicReader extends NBTSchematicReader {
private final NBTInputStream inputStream; private final NBTInputStream inputStream;
private DataFixer fixer = null; private DataFixer fixer = null;
private int dataVersion = -1; private int dataVersion = -1;
private int version = -1;
private FastByteArrayOutputStream blocksOut; private FastByteArrayOutputStream blocksOut;
private FaweOutputStream blocks; private FaweOutputStream blocks;
@ -119,6 +120,7 @@ public class FastSchematicReader extends NBTSchematicReader {
StreamDelegate root = new StreamDelegate(); StreamDelegate root = new StreamDelegate();
StreamDelegate schematic = root.add("Schematic"); StreamDelegate schematic = root.add("Schematic");
schematic.add("DataVersion").withInt((i, v) -> dataVersion = v); schematic.add("DataVersion").withInt((i, v) -> dataVersion = v);
schematic.add("Version").withInt((i, v) -> version = v);
schematic.add("Width").withInt((i, v) -> width = v); schematic.add("Width").withInt((i, v) -> width = v);
schematic.add("Height").withInt((i, v) -> height = v); schematic.add("Height").withInt((i, v) -> height = v);
schematic.add("Length").withInt((i, v) -> length = v); schematic.add("Length").withInt((i, v) -> length = v);
@ -196,6 +198,11 @@ public class FastSchematicReader extends NBTSchematicReader {
public Clipboard read(UUID uuid, Function<BlockVector3, Clipboard> createOutput) throws IOException { public Clipboard read(UUID uuid, Function<BlockVector3, Clipboard> createOutput) throws IOException {
StreamDelegate root = createDelegate(); StreamDelegate root = createDelegate();
inputStream.readNamedTagLazy(root); inputStream.readNamedTagLazy(root);
if (version != 1 && version != 2) {
throw new IOException("This schematic version is currently not supported");
}
if (blocks != null) blocks.close(); if (blocks != null) blocks.close();
if (biomes != null) biomes.close(); if (biomes != null) biomes.close();
blocks = null; blocks = null;