本文整理了Java中org.bukkit.configuration.file.YamlConfiguration.getConfigurationSection()
方法的一些代码示例,展示了YamlConfiguration.getConfigurationSection()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YamlConfiguration.getConfigurationSection()
方法的具体详情如下:
包路径:org.bukkit.configuration.file.YamlConfiguration
类名称:YamlConfiguration
方法名:getConfigurationSection
暂无
代码示例来源:origin: GlowstoneMC/Glowstone
public ConfigurationSection getWorlds() {
return config.getConfigurationSection("worlds");
}
代码示例来源:origin: GlowstoneMC/Glowstone
/**
* Creates a MaterialValueManager using the data from the resource file
* {@code builtin/materialValues.yml} in the Glowstone jar.
*/
public BuiltinMaterialValueManager() {
values = new EnumMap<>(Material.class);
YamlConfiguration builtinValues = YamlConfiguration.loadConfiguration(new InputStreamReader(
getClass().getClassLoader().getResourceAsStream("builtin/materialValues.yml")));
defaultValue = new BuiltinValueCollection(
builtinValues.getConfigurationSection("default")); // NON-NLS
registerBuiltins(builtinValues);
}
代码示例来源:origin: EpicEricEE/ShopChest
/**
* @return Amount of lines in a hologram
*/
public int getLineCount() {
return config.getConfigurationSection("lines").getKeys(false).size();
}
代码示例来源:origin: com.greatmancode/tools
@Override
public Map<String, String> getStringMap(String path) {
Map<String, String> values = new HashMap<String, String>();
ConfigurationSection configurationSection = configFile.getConfigurationSection(path);
if (configurationSection != null) {
for (Map.Entry<String, Object> entry : configurationSection.getValues(false).entrySet()) {
values.put(entry.getKey(), (String) entry.getValue());
}
}
return values;
}
代码示例来源:origin: DevLeoko/AdvancedBan
@Override
public String[] getKeys(Object file, String path) {
String[] ss = new String[0];
return ((YamlConfiguration) file).getConfigurationSection(path).getKeys(false).toArray(ss);
}
代码示例来源:origin: dzikoysk/WildSkript
protected String[] get(Event event) {
String k = (String) this.key.getSingle(event);
String f = (String) this.file.getSingle(event);
if ((k == null) || (f == null)) {
return null;
}
File file = new File(f.replaceAll("/", Matcher.quoteReplacement(File.separator)));
if (!file.exists()) {
try {
file.getParentFile().mkdirs();
file.createNewFile();
} catch (IOException e) {
}
}
YamlConfiguration yml = YamlConfiguration.loadConfiguration(file);
if (yml == null) {
return null;
}
ConfigurationSection cs = yml.getConfigurationSection(k);
if (cs == null) {
return null;
}
ArrayList<String> list = new ArrayList<String>();
for (String key : cs.getKeys(false)) {
list.add(key);
}
String[] s = new String[list.size()];
return list.toArray(s);
}
代码示例来源: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: 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: eccentricdevotion/TARDIS
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
String lastArg = args[args.length - 1];
if (args.length <= 1) {
return partial(args[0], ROOT_SUBS);
} else if (args.length == 2) {
String sub = args[0];
return partial(lastArg, removeUnwanted(plugin.getGeneralKeeper().getPluginYAML().getConfigurationSection("commands." + sub).getKeys(false)));
}
return ImmutableList.of();
}
代码示例来源:origin: ChestShop-authors/ChestShop-3
private void convertToMaterial(String sectionPath) {
ConfigurationSection section = configuration.getConfigurationSection(sectionPath);
if (section != null) {
for (String typeId : section.getKeys(false)) {
Material material = Material.matchMaterial(typeId);
if (material != null) {
configuration.set(sectionPath + "." + material.toString().toLowerCase(), configuration.get(sectionPath + "." + typeId));
configuration.set(sectionPath + "." + typeId, null);
}
}
}
}
代码示例来源:origin: elBukkit/MagicPlugin
protected void describeParameters(CommandSender sender) {
Collection<String> keys = parameters.getKeys(false);
if (keys.size() == 0) {
sender.sendMessage(ChatColor.GRAY + " (None)");
}
for (String key : keys) {
String value = null;
if (parameters.isConfigurationSection(key)) {
ConfigurationSection child = parameters.getConfigurationSection(key);
value = "(" + child.getKeys(false).size() + " values)";
} else {
value = parameters.getString(key);
}
sender.sendMessage(ChatColor.LIGHT_PURPLE + " " + key + ": " + value);
}
}
代码示例来源:origin: BentoBoxWorld/BentoBox
ConfigurationSection perms = data.getConfigurationSection("permissions");
perms.getKeys(true).forEach(perm -> {
if (perms.contains(perm + ".default") && perms.contains(perm + ".description")) {
代码示例来源:origin: drtshock/PlayerVaults
/**
* Gets an inventory without storing references to it. Used for dropping a players inventories on death.
*
* @param holder The holder of the vault.
* @param number The vault number.
* @return The inventory of the specified holder and vault number.
*/
public Inventory getVault(UUID holder, int number) {
YamlConfiguration playerFile = getPlayerVaultFile(holder);
ConfigurationSection section = playerFile.getConfigurationSection("vault" + number);
int maxSize = VaultOperations.getMaxVaultSize(holder.toString());
String title = Lang.VAULT_TITLE.toString().replace("%number", String.valueOf(number));
if (section == null) {
VaultHolder vaultHolder = new VaultHolder(number);
Inventory inv = Bukkit.createInventory(vaultHolder, maxSize, title);
vaultHolder.setInventory(inv);
return inv;
} else {
List<String> data = new ArrayList<>();
for (String s : section.getKeys(false)) {
String value = section.getString(s);
data.add(value);
}
return Serialization.toInventory(data, number, maxSize, title);
}
}
代码示例来源:origin: EpicEricEE/ShopChest
/**
* @return Whether the hologram text has to change dynamically without reloading
*/
public boolean isDynamic() {
int count = getLineCount();
for (int i = 0; i < count; i++) {
ConfigurationSection options = config.getConfigurationSection("lines." + i + ".options");
for (String key : options.getKeys(false)) {
ConfigurationSection option = options.getConfigurationSection(key);
String format = option.getString("format");
if (format.contains(Placeholder.STOCK.toString()) || format.contains(Placeholder.CHEST_SPACE.toString())) {
return true;
}
for (String req : option.getStringList("requirements")) {
if (req.contains(Requirement.IN_STOCK.toString()) || req.contains(Requirement.CHEST_SPACE.toString())) {
return true;
}
}
}
}
return false;
}
代码示例来源:origin: libraryaddict/LibsDisguises
ConfigurationSection section = disguisesConfig.getConfigurationSection("Disguises");
代码示例来源:origin: EpicEricEE/ShopChest
/**
* Get the format for the given line of the hologram
* @param line Line of the hologram
* @param reqMap Values of the requirements that might be needed by the format (contains {@code null} if not comparable)
* @param plaMap Values of the placeholders that might be needed by the format
* @return The format of the first working option, or an empty String if no option is working
* because of not fulfilled requirements
*/
public String getFormat(int line, Map<Requirement, Object> reqMap, Map<Placeholder, Object> plaMap) {
ConfigurationSection options = config.getConfigurationSection("lines." + line + ".options");
optionLoop:
for (String key : options.getKeys(false)) {
ConfigurationSection option = options.getConfigurationSection(key);
List<String> requirements = option.getStringList("requirements");
String format = option.getString("format");
for (String sReq : requirements) {
for (Requirement req : reqMap.keySet()) {
if (sReq.contains(req.toString())) {
if (!evalRequirement(sReq, reqMap)) {
continue optionLoop;
}
}
}
}
return evalPlaceholder(format, plaMap);
}
return "";
}
代码示例来源:origin: sgtcaze/NametagEdit
private void loadGroups() {
List<GroupData> groupData = new ArrayList<>();
for (String groupName : groups.getConfigurationSection("Groups").getKeys(false)) {
GroupData data = new GroupData();
data.setGroupName(groupName);
data.setPermission(groups.getString("Groups." + groupName + ".Permission", "nte.default"));
data.setPrefix(groups.getString("Groups." + groupName + ".Prefix", ""));
data.setSuffix(groups.getString("Groups." + groupName + ".Suffix", ""));
data.setSortPriority(groups.getInt("Groups." + groupName + ".SortPriority", -1));
groupData.add(data);
}
handler.assignGroupData(groupData);
}
代码示例来源:origin: SkyWars/SkyWars
SkyKit kit;
try {
kit = SkyKitDecoder.decodeKit(config.getConfigurationSection(key), key);
} catch (SkyConfigurationException ex) {
plugin.getLogger().log(Level.SEVERE, "Error loading kit! " + key + " won't be accessible until this is fixed!", ex);
代码示例来源:origin: drtshock/PlayerVaults
} else {
YamlConfiguration playerFile = getPlayerVaultFile(player.getUniqueId());
if (playerFile.getConfigurationSection("vault" + number) == null) {
VaultHolder vaultHolder = new VaultHolder(number);
if (EconomyOperations.payToCreate(player)) {
代码示例来源:origin: mcMMO-Dev/mcMMO
for (String partyName : partiesFile.getConfigurationSection("").getKeys(false)) {
Party party = new Party(partyName);
内容来源于网络,如有侵权,请联系作者删除!