From 42d0d6e79a5bb854505ce7ca13bb08914068fd24 Mon Sep 17 00:00:00 2001 From: wizjany Date: Fri, 29 Mar 2019 23:44:18 -0400 Subject: [PATCH] Use getTag instead of requireTag in a few places. --- .../clipboard/io/MCEditSchematicReader.java | 6 ++---- .../clipboard/io/SpongeSchematicReader.java | 15 ++++++--------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java index c20c72df8..3997f28c7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java @@ -253,9 +253,8 @@ public class MCEditSchematicReader extends NBTSchematicReader { // Entities // ==================================================================== - try { - List entityTags = requireTag(schematic, "Entities", ListTag.class).getValue(); - + List entityTags = getTag(schematic, "Entities", ListTag.class).getValue(); + if (entityTags != null) { for (Tag tag : entityTags) { if (tag instanceof CompoundTag) { CompoundTag compound = (CompoundTag) tag; @@ -273,7 +272,6 @@ public class MCEditSchematicReader extends NBTSchematicReader { } } } - } catch (IOException ignored) { // No entities? No problem } return clipboard; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java index 3b944018e..8cdc084bc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java @@ -87,12 +87,10 @@ public class SpongeSchematicReader extends NBTSchematicReader { // Check Map schematic = schematicTag.getValue(); int version = requireTag(schematic, "Version", IntTag.class).getValue(); - switch (version) { - case 1: - return readVersion1(schematicTag); - default: - throw new IOException("This schematic version is currently not supported"); + if (version == 1) { + return readVersion1(schematicTag); } + throw new IOException("This schematic version is currently not supported"); } private Clipboard readVersion1(CompoundTag schematicTag) throws IOException { @@ -152,8 +150,9 @@ public class SpongeSchematicReader extends NBTSchematicReader { byte[] blocks = requireTag(schematic, "BlockData", ByteArrayTag.class).getValue(); Map> tileEntitiesMap = new HashMap<>(); - try { - List> tileEntityTags = requireTag(schematic, "TileEntities", ListTag.class).getValue().stream() + ListTag tileEntities = getTag(schematic, "TileEntities", ListTag.class); + if (tileEntities != null) { + List> tileEntityTags = tileEntities.getValue().stream() .map(tag -> (CompoundTag) tag) .map(CompoundTag::getValue) .collect(Collectors.toList()); @@ -162,8 +161,6 @@ public class SpongeSchematicReader extends NBTSchematicReader { int[] pos = requireTag(tileEntity, "Pos", IntArrayTag.class).getValue(); tileEntitiesMap.put(BlockVector3.at(pos[0], pos[1], pos[2]), tileEntity); } - } catch (Exception e) { - throw new IOException("Failed to load Tile Entities: " + e.getMessage()); } BlockArrayClipboard clipboard = new BlockArrayClipboard(region);