private static Collection<TaggedRegion> loadRegions(File file) { Collection<TaggedRegion> ret = Lists.newArrayList(); Storage storage = new NBTStorage(file, "Schematic"); storage.load(); for (DataKey sub : storage.getKey("TaggedRegions").getSubKeys()) { String name = sub.name(); for (DataKey sub2 : sub.getIntegerSubKeys()) { Location min = loadLocation(sub2.getRelative("min")); Location max = loadLocation(sub2.getRelative("max")); ret.add(new TaggedRegion(name, min, max)); } } return ret; }
@Override public void load(DataKey key) throws NPCLoadException { for (DataKey sub : key.getRelative("list").getIntegerSubKeys()) { String[] parts = sub.getString("").split(";"); Location location; try { location = new Location( Bukkit.getServer().getWorld(parts[1]), Double.valueOf(parts[2]), Double.valueOf(parts[3]), Double.valueOf(parts[4])); anchors.add(new Anchor(parts[0], location)); } catch (NumberFormatException e) { Messaging.logTr(Messages.SKIPPING_INVALID_ANCHOR, sub.name(), e.getMessage()); } catch (NullPointerException e) { // Invalid world/location/etc. Still enough data to build an // unloaded anchor anchors.add(new Anchor(parts[0], sub.getString("").split(";", 2)[1])); } } }