本文整理了Java中org.bukkit.configuration.file.YamlConfiguration.createSection()
方法的一些代码示例,展示了YamlConfiguration.createSection()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YamlConfiguration.createSection()
方法的具体详情如下:
包路径:org.bukkit.configuration.file.YamlConfiguration
类名称:YamlConfiguration
方法名:createSection
暂无
代码示例来源:origin: SkyWars/SkyWars
public ConfigurationSection getSetSection(String path, Map<String, String> defaultValues) throws InvalidConfigurationException {
if (config.isConfigurationSection(path)) {
return config.getConfigurationSection(path);
} else if (config.contains(path)) {
throw new InvalidConfigurationException("Object " + config.get(path) + " found under " + path + " in file " + configFile + " is not a configuration section");
} else {
logger.log(Level.INFO, "Setting {0} to {1} in file {2}", new Object[]{path, defaultValues, configFile});
ConfigurationSection section = config.createSection(path);
for (Map.Entry<String, String> entry : defaultValues.entrySet()) {
section.set(entry.getKey(), entry.getValue());
}
return section;
}
}
代码示例来源:origin: SkyWars/SkyWars
public Map<String, String> getSetStringMap(String path, Map<String, String> defaultValues) throws InvalidConfigurationException {
if (config.isConfigurationSection(path)) {
ConfigurationSection section = config.getConfigurationSection(path);
Map<String, Object> entries = section.getValues(false);
Map<String, String> values = new HashMap<>(entries.size());
for (Map.Entry<String, Object> entry : entries.entrySet()) {
Object obj = entry.getValue();
if (obj instanceof String) {
values.put(entry.getKey(), (String) obj);
} else if (obj instanceof Double || obj instanceof Integer || obj instanceof Boolean) {
values.put(entry.getKey(), obj.toString());
} else {
throw new InvalidConfigurationException("Object " + obj + " found in map " + path + " in file " + configFile.toAbsolutePath() + " is not an integerr");
}
}
return values;
} else if (config.contains(path)) {
throw new InvalidConfigurationException("Object " + config.get(path) + " found under " + path + " in file " + configFile + " is not a map");
} else {
logger.log(Level.INFO, "Setting {0} to {1} in file {2}", new Object[]{path, defaultValues, configFile});
ConfigurationSection section = config.createSection(path);
for (Map.Entry<String, String> entry : defaultValues.entrySet()) {
section.set(entry.getKey(), entry.getValue());
}
return defaultValues;
}
}
代码示例来源:origin: elBukkit/MagicPlugin
private void register() {
registerFile.getParentFile().mkdirs();
YamlConfiguration registered = new YamlConfiguration();
if (registerFile.exists()) {
try {
registered.load(registerFile);
} catch (Exception ex) {
logger.log(Level.WARNING, "Error reading " + registerFile, ex);
return;
}
}
ConfigurationSection playerSection = registered.createSection(playerId);
playerSection.set("name", playerName);
playerSection.set("code", code);
playerSection.set("skin_url", skinURL);
try {
registered.save(registerFile);
} catch (Exception ex) {
logger.log(Level.WARNING, "Error saving " + registerFile, ex);
return;
}
}
}
代码示例来源:origin: elBukkit/MagicPlugin
ConfigurationSection rpSection = rpConfig.createSection(rpKey);
代码示例来源:origin: elBukkit/MagicPlugin
YamlConfiguration configuration = new YamlConfiguration();
for (URLMap map : saveMaps) {
ConfigurationSection mapConfig = configuration.createSection(Short.toString(map.id));
mapConfig.set("world", map.world);
mapConfig.set("url", map.url);
代码示例来源:origin: io.github.bedwarsrel/BedwarsRel-Common
private void loadYml(File ymlFile) {
try {
BedwarsRel.getInstance().getServer().getConsoleSender().sendMessage(
ChatWriter.pluginMessage(ChatColor.GREEN + "Loading statistics from YAML-File ..."));
YamlConfiguration config = null;
Map<OfflinePlayer, PlayerStatistic> map = new HashMap<>();
this.databaseFile = ymlFile;
if (!ymlFile.exists()) {
ymlFile.getParentFile().mkdirs();
ymlFile.createNewFile();
config = new YamlConfiguration();
config.createSection("data");
config.save(ymlFile);
} else {
config = YamlConfiguration.loadConfiguration(ymlFile);
}
this.fileDatabase = config;
} catch (Exception ex) {
BedwarsRel.getInstance().getBugsnag().notify(ex);
ex.printStackTrace();
}
BedwarsRel.getInstance().getServer().getConsoleSender()
.sendMessage(ChatWriter.pluginMessage(ChatColor.GREEN + "Done!"));
}
代码示例来源:origin: BedwarsRel/BedwarsRel
private void loadYml(File ymlFile) {
try {
BedwarsRel.getInstance().getServer().getConsoleSender().sendMessage(
ChatWriter.pluginMessage(ChatColor.GREEN + "Loading statistics from YAML-File ..."));
YamlConfiguration config = null;
Map<OfflinePlayer, PlayerStatistic> map = new HashMap<>();
this.databaseFile = ymlFile;
if (!ymlFile.exists()) {
ymlFile.getParentFile().mkdirs();
ymlFile.createNewFile();
config = new YamlConfiguration();
config.createSection("data");
config.save(ymlFile);
} else {
config = YamlConfiguration.loadConfiguration(ymlFile);
}
this.fileDatabase = config;
} catch (Exception ex) {
BedwarsRel.getInstance().getBugsnag().notify(ex);
ex.printStackTrace();
}
BedwarsRel.getInstance().getServer().getConsoleSender()
.sendMessage(ChatWriter.pluginMessage(ChatColor.GREEN + "Done!"));
}
代码示例来源:origin: NuVotifier/NuVotifier
tokenSection = cfg.createSection("tokens");
tokenSection.set("default", token);
tokens.put("default", KeyCreator.createKeyFrom(token));
代码示例来源:origin: elBukkit/MagicPlugin
ConfigurationSection itemSection = itemConfig.createSection(template);
itemSection.set("creator_id", player.getUniqueId().toString());
itemSection.set("creator", player.getName());
代码示例来源:origin: elBukkit/MagicPlugin
ConfigurationSection wandSection = wandConfig.createSection(template);
wand.save(wandSection, true);
wandSection.set("creator_id", player.getUniqueId().toString());
代码示例来源:origin: io.github.bedwarsrel/BedwarsRel-Common
yml.createSection("teams", this.teams);
代码示例来源:origin: BentoBoxWorld/BentoBox
ConfigurationSection s = blockConfig.createSection(BLOCKS_YAML_PREFIX + "." + pos);
ConfigurationSection en = blockConfig.createSection(ENTITIES_YAML_PREFIX + pos + "." + e.getUniqueId());
en.set("type", e.getType().name());
en.set("name", e.getCustomName());
ConfigurationSection a = blockConfig.createSection(ATTACHED_YAML_PREFIX + pos);
a.set("bd", block.getBlockData().getAsString());
代码示例来源:origin: BedwarsRel/BedwarsRel
yml.createSection("teams", this.teams);
内容来源于网络,如有侵权,请联系作者删除!