public List<Long> getSetLongList(String path, List<Long> defaultList) throws InvalidConfigurationException { if (config.isList(path)) { List<?> unknownList = config.getList(path); List<Long> longList = new ArrayList<>(unknownList.size()); for (Object obj : unknownList) { if (obj instanceof Number) { longList.add(((Number) obj).longValue()); } else { throw new InvalidConfigurationException("Object " + obj + " found in list " + path + " in file " + configFile.toAbsolutePath() + " is not a number"); } } return longList; } else if (config.contains(path)) { throw new InvalidConfigurationException("Object " + config.get(path) + " found under " + path + " in file " + configFile + " is not a list"); } else { logger.log(Level.INFO, "Setting {0} to {1} in file {2}", new Object[]{path, defaultList, configFile}); config.set(path, defaultList); return defaultList; } }
public List<String> getSetStringList(String path, List<String> defaultList) throws InvalidConfigurationException { if (config.isList(path)) { List<?> unknownList = config.getList(path); List<String> stringList = new ArrayList<>(unknownList.size()); for (Object obj : unknownList) { if (obj instanceof String) { stringList.add((String) obj); } else if (obj instanceof Double || obj instanceof Integer || obj instanceof Boolean) { stringList.add(obj.toString()); } else { throw new InvalidConfigurationException("Object " + obj + " found in list " + path + " in file " + configFile.toAbsolutePath() + " is not a string"); } } return stringList; } else if (config.contains(path)) { throw new InvalidConfigurationException("Object " + config.get(path) + " found under " + path + " in file " + configFile + " is not a list"); } else { logger.log(Level.INFO, "Setting {0} to {1} in file {2}", new Object[]{path, defaultList, configFile}); config.set(path, defaultList); return defaultList; } }
public String[] getSetFixedArray(final String path, final String[] defaultValues) throws InvalidConfigurationException { if (config.isList(path)) { List<?> list = config.getList(path); if (list.isEmpty()) { config.set(path, Arrays.asList(defaultValues)); return defaultValues.clone(); } else if (list.size() < defaultValues.length) { throw new InvalidConfigurationException("Too few strings in list " + path + " in file " + configFile + ": expected " + defaultValues.length + ", found " + list.size() + "."); } else if (list.size() > defaultValues.length) { throw new InvalidConfigurationException("Too many strings in list " + path + " in file " + configFile + ": expected " + defaultValues.length + ", found " + list.size() + "."); } String[] result = new String[defaultValues.length]; for (int i = 0; i < defaultValues.length; i++) { result[i] = String.valueOf(list.get(i)); } return result; } else if (config.contains(path)) { throw new InvalidConfigurationException("Object " + config.get(path) + " found under " + path + " in file " + configFile + " is not an array."); } else { config.set(path, Arrays.asList(defaultValues)); return defaultValues.clone(); } }
if (cfg.isList("spawner")) { for (Object rs : cfg.getList("spawner")) { if (!(rs instanceof ResourceSpawner)) {
if (cfg.isList("spawner")) { for (Object rs : cfg.getList("spawner")) { if (!(rs instanceof ResourceSpawner)) {