本文整理汇总了Java中org.bukkit.configuration.ConfigurationSection.isString方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationSection.isString方法的具体用法?Java ConfigurationSection.isString怎么用?Java ConfigurationSection.isString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.configuration.ConfigurationSection
的用法示例。
在下文中一共展示了ConfigurationSection.isString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getItem
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
public ItemStack getItem(ConfigurationSection section, String key, Supplier<ItemStack> def) throws InvalidConfigurationException {
if(section.isString(key)) {
return new ItemStack(needItemType(section, key));
}
if(!section.isConfigurationSection(key)) {
return def.get();
}
final ConfigurationSection itemSection = section.needSection(key);
if(itemSection.isString("skull")) {
return needSkull(itemSection, "skull");
}
final Material material = needItemType(itemSection, "id");
final int damage = itemSection.getInt("damage", 0);
if(damage < Short.MIN_VALUE || damage > Short.MAX_VALUE) {
throw new InvalidConfigurationException(itemSection, "damage", "Item damage out of range");
}
final ItemStack stack = new ItemStack(material, 1, (short) damage);
if(itemSection.isString("skin")) {
needSkull(stack, itemSection, "skin");
}
return stack;
}
示例2: Button
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
Button(ConfigurationSection config, ItemConfigurationParser itemParser) throws InvalidConfigurationException {
this.slot = itemParser.needSlotByPosition(config, null, null, Slot.Container.class);
this.icon = config.isString("skull") ? itemParser.needSkull(config, "skull")
: itemParser.needItem(config, "icon");
this.connector = navigator.combineConnectors(ConfigUtils.needValueOrList(config, "to", String.class).stream()
.map(rethrowFunction(token -> parseConnector(config, "to", token)))
.collect(Collectors.toList()));
this.connector.startObserving(observer);
}
示例3: loadLanguageSection
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
/**
* add all language items from section into language map recursively
* overwrite existing items
* The '&' will be transformed to color code.
*
* @param section source section
* @param prefix used in recursion to determine the proper prefix
* @param ignoreInternal ignore keys prefixed with `internal'
* @param ignoreNormal ignore keys not prefixed with `internal'
*/
private static void loadLanguageSection(Map<String, String> map, ConfigurationSection section, String prefix, boolean ignoreInternal, boolean ignoreNormal) {
if (map == null || section == null || prefix == null) return;
for (String key : section.getKeys(false)) {
String path = prefix + key;
if (section.isString(key)) {
if (path.startsWith("internal") && ignoreInternal) continue;
if (!path.startsWith("internal") && ignoreNormal) continue;
map.put(path, ChatColor.translateAlternateColorCodes('&', section.getString(key)));
} else if (section.isConfigurationSection(key)) {
loadLanguageSection(map, section.getConfigurationSection(key), path + ".", ignoreInternal, ignoreNormal);
}
}
}