本文整理了Java中org.bukkit.configuration.file.YamlConfiguration.isList()
方法的一些代码示例,展示了YamlConfiguration.isList()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YamlConfiguration.isList()
方法的具体详情如下:
包路径:org.bukkit.configuration.file.YamlConfiguration
类名称:YamlConfiguration
方法名:isList
暂无
代码示例来源:origin: SkyWars/SkyWars
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;
}
}
代码示例来源:origin: SkyWars/SkyWars
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;
}
}
代码示例来源:origin: SkyWars/SkyWars
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();
}
}
代码示例来源:origin: BedwarsRel/BedwarsRel
if (cfg.isList("spawner")) {
for (Object rs : cfg.getList("spawner")) {
if (!(rs instanceof ResourceSpawner)) {
代码示例来源:origin: io.github.bedwarsrel/BedwarsRel-Common
if (cfg.isList("spawner")) {
for (Object rs : cfg.getList("spawner")) {
if (!(rs instanceof ResourceSpawner)) {
内容来源于网络,如有侵权,请联系作者删除!