mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
Few tweaks to schematic loading and error fixes.
* Not all EntityTypes in Bukkit have the correct enum name. * Don't read entire schematic files to list. Go off file extension only. (Reading in files is more accurate, but slow.) * Enforce extensions. (Due to the above, while you can technically make a schematic called 'test.txt', it's better that we save it as 'test.txt.schem'.) * Fix a few minor warnings.
This commit is contained in:
@ -46,9 +46,7 @@ public abstract class NBTSchematicReader implements ClipboardReader {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected static <T extends Tag> T getTag(CompoundTag tag, Class<T> expected, String key) {
|
||||
Map<String, Tag> items = tag.getValue();
|
||||
|
||||
protected static <T extends Tag> T getTag(Map<String, Tag> items, String key, Class<T> expected) {
|
||||
if (!items.containsKey(key)) {
|
||||
return null;
|
||||
}
|
||||
|
@ -88,16 +88,16 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
int version = requireTag(schematic, "Version", IntTag.class).getValue();
|
||||
switch (version) {
|
||||
case 1:
|
||||
return readVersion1(schematic);
|
||||
return readVersion1(schematicTag);
|
||||
default:
|
||||
throw new IOException("This schematic version is currently not supported");
|
||||
}
|
||||
}
|
||||
|
||||
private Clipboard readVersion1(Map<String, Tag> schematic) throws IOException {
|
||||
private Clipboard readVersion1(CompoundTag schematicTag) throws IOException {
|
||||
BlockVector3 origin;
|
||||
Region region;
|
||||
|
||||
Map<String, Tag> schematic = schematicTag.getValue();
|
||||
Map<String, Tag> metadata = requireTag(schematic, "Metadata", CompoundTag.class).getValue();
|
||||
|
||||
int width = requireTag(schematic, "Width", ShortTag.class).getValue();
|
||||
@ -143,7 +143,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
try {
|
||||
state = WorldEdit.getInstance().getBlockFactory().parseFromInput(palettePart, parserContext).toImmutableState();
|
||||
} catch (InputParseException e) {
|
||||
throw new IOException("Invalid BlockState in schematic: " + palettePart + ". Are you missing a mod of using a schematic made in a newer version of Minecraft?");
|
||||
throw new IOException("Invalid BlockState in schematic: " + palettePart + ". Are you missing a mod or using a schematic made in a newer version of Minecraft?");
|
||||
}
|
||||
palette.put(id, state);
|
||||
}
|
||||
|
Reference in New Issue
Block a user