本文整理汇总了Java中org.bukkit.configuration.ConfigurationSection.getKeys方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationSection.getKeys方法的具体用法?Java ConfigurationSection.getKeys怎么用?Java ConfigurationSection.getKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.configuration.ConfigurationSection
的用法示例。
在下文中一共展示了ConfigurationSection.getKeys方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIndexTopics
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
/**
* Extracts a list of all index topics from help.yml
*
* @return A list of index topics.
*/
public List<HelpTopic> getIndexTopics() {
List<HelpTopic> topics = new LinkedList<HelpTopic>();
ConfigurationSection indexTopics = helpYaml.getConfigurationSection("index-topics");
if (indexTopics != null) {
for (String topicName : indexTopics.getKeys(false)) {
ConfigurationSection section = indexTopics.getConfigurationSection(topicName);
String shortText = ChatColor.translateAlternateColorCodes(ALT_COLOR_CODE, section.getString("shortText", ""));
String preamble = ChatColor.translateAlternateColorCodes(ALT_COLOR_CODE, section.getString("preamble", ""));
String permission = ChatColor.translateAlternateColorCodes(ALT_COLOR_CODE, section.getString("permission", ""));
List<String> commands = section.getStringList("commands");
topics.add(new CustomIndexHelpTopic(server.getHelpMap(), topicName, shortText, permission, commands, preamble));
}
}
return topics;
}
示例2: stats
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
private static void stats()
{
disableStatSaving = getBoolean( "stats.disable-saving", false );
if ( !config.contains( "stats.forced-stats" ) ) {
config.createSection( "stats.forced-stats" );
}
ConfigurationSection section = config.getConfigurationSection( "stats.forced-stats" );
for ( String name : section.getKeys( true ) )
{
if ( section.isInt( name ) )
{
forcedStats.put( name, section.getInt( name ) );
}
}
if ( disableStatSaving && section.getInt( "achievement.openInventory", 0 ) < 1 )
{
Bukkit.getLogger().warning( "*** WARNING *** stats.disable-saving is true but stats.forced-stats.achievement.openInventory" +
" isn't set to 1. Disabling stat saving without forcing the achievement may cause it to get stuck on the player's " +
"screen." );
}
}
示例3: CPNode
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
public CPNode(ConfigurationSection section, MessageManager manager, String name){
super(section, manager, name);
commands = new ArrayList<CommandPlus>();
ConfigurationSection node = section.getConfigurationSection(Node.NODE.getList());
ErrorLogger.addPrefix(Node.NODE.getList());
if(node == null){
Error.INVALID.add();
}else{
for(String key : node.getKeys(false)){
ErrorLogger.addPrefix(key);
ConfigurationSection sub = node.getConfigurationSection(key);
CommandPlus command = VanillaPlusCore.getCommandManager().create(sub.getString(Node.TYPE.get(), Node.NODE.get()), sub, manager, key);
if(command != null)
commands.add(command);
ErrorLogger.removePrefix();
}
}
ErrorLogger.removePrefix();
if(section.contains(Node.DEFAULT.get())){
ErrorLogger.addPrefix(Node.DEFAULT.get());
defaultCommand = VanillaPlusCore.getCommandManager().create(section.getConfigurationSection(Node.DEFAULT.get())
.getString(Node.TYPE.get(), Node.NODE.get()), section.getConfigurationSection(Node.DEFAULT.get()), manager, getName());
ErrorLogger.removePrefix();
}
}
示例4: CPMulti
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
public CPMulti(ConfigurationSection section, MessageManager manager, String name){
super(section, manager, name);
commands = new ArrayList<CommandPlus>();
ErrorLogger.addPrefix("SUB_LIST");
ConfigurationSection node = section.getConfigurationSection("SUB_LIST");
if(node == null)
Error.INVALID.add();
else
for(String key : node.getKeys(false)){
ErrorLogger.addPrefix(key);
ConfigurationSection sub = node.getConfigurationSection(key);
CommandPlus command = VanillaPlusCore.getCommandManager().create(sub.getString(Node.TYPE.get(), Node.NODE.get()), key, sub);
if(command != null)
commands.add(command);
ErrorLogger.removePrefix();
}
ErrorLogger.removePrefix();
}
示例5: applyCompound
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
public static void applyCompound(ConfigurationSection section, NBTCompound nbtCompound){
for(String key : section.getKeys(false)){
Object value = section.get(key);
if(value instanceof Integer){
nbtCompound.setInteger(key, (int)value);
}else if(value instanceof Double){
nbtCompound.setDouble(key, (double)value);
}else if(value instanceof Boolean){
nbtCompound.setBoolean(key, (boolean)value);
}else if(value instanceof String){
nbtCompound.setString(key, (String)value);
}else if(value instanceof ConfigurationSection) {
NBTCompound compound = nbtCompound.getCompound(key);
if(compound == null)
compound = nbtCompound.addCompound(key);
applyCompound((ConfigurationSection) value, compound);
}
}
}
示例6: setupConfiguration
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
private void setupConfiguration(final ConfigurationSection section) {
if (section.isConfigurationSection("worlds")) {
final ConfigurationSection wSection = section
.getConfigurationSection("worlds");
for (String wName : wSection.getKeys(false)) {
final int centerX = wSection.getInt(wName + ".centerX", 0);
final int centerZ = wSection.getInt(wName + ".centerZ", 0);
final int distance = wSection.getInt(
wName + ".distance", DEFAULT_DISTANCE);
final double knockback = wSection.getDouble(
wName + ".knockback-distance", DEFAULT_KNOCKBACK);
WorldBorder wb = new BasicWorldBorder(
centerX, centerZ, distance);
wb.setKnockbackDistance(knockback);
this.worldBorders.put(wName, wb);
this.plugin.getLogger().log(Level.INFO, "Created border"
+ " for world '" + wName + "'!" + lineSeparator()
+ "Knockback=" + knockback + lineSeparator()
+ "Distance = " + distance
);
}
}
}
示例7: prefillToolList
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
/**
* Bootstraps the standalone tools configurations, if any are defined.
*/
private void prefillToolList() {
ToolConfig.clear();
ConfigurationSection toolDefinitions = config.getConfigurationSection("tools");
if (toolDefinitions != null) {
for (String toolDefine : toolDefinitions.getKeys(false)) {
ToolConfig.initTool(toolDefinitions.getConfigurationSection(toolDefine));
}
} else {
CropControl.getPlugin().warning("No tools defined; if any crop configuration uses a tool config, it will result in a new warning.");
}
}
示例8: initPost
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
public void initPost(VanillaPlusExtension extension) {
ConfigurationSection section = ConfigUtils.getYaml(extension.getInstance(), "Achievement", false);
if(section == null)return;
ErrorLogger.addPrefix("Achievement.yml");
ConfigurationSection achievementSub = section.getConfigurationSection(Node.ACHIEVEMENT.getList());
ErrorLogger.addPrefix(Node.ACHIEVEMENT.getList());
if(achievementSub != null){
for(String key : achievementSub.getKeys(false)){
ErrorLogger.addPrefix(key);
ConfigurationSection sub = achievementSub.getConfigurationSection(key);
if(sub == null){
Error.INVALID.add();
}else{
int id = Utils.parseInt(key, 0, true);
if(id< Short.MIN_VALUE || id == 0 || id > Short.MAX_VALUE){
Error.INVALID.add();
}else{
Achievement achievement = achievements.get((short)id);
if(achievement == null)continue;
achievement.initPost(sub, extension.getMessageCManager());
}
}
ErrorLogger.removePrefix();
}
}
ErrorLogger.removePrefix();
ErrorLogger.removePrefix();
}
示例9: Message
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
public Message(MessageManager manager, ConfigurationSection messageNode) {
if(messageNode == null)
return;
for(String key : messageNode.getKeys(false)){
if(key.equalsIgnoreCase(Node.TYPE.get()))
continue;
ErrorLogger.addPrefix(key);
MComponent message = manager.getComponentManager().get(key, messageNode.getCurrentPath()+"."+key);
ErrorLogger.removePrefix();
if(message != null)
messages.add(message);
}
}
示例10: init
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
public void init(VanillaPlusExtension extension) {
ConfigurationSection section = ConfigUtils.getYaml(extension.getInstance(), "Stat", false);
if(section == null)return;
ErrorLogger.addPrefix("Stat.yml");
ConfigurationSection statSub = section.getConfigurationSection("STAT_LIST");
if(statSub != null){
ErrorLogger.addPrefix("STAT_LIST");
for(String key : statSub.getKeys(false)){
ErrorLogger.addPrefix(key);
ConfigurationSection sub = statSub.getConfigurationSection(key);
if(sub == null){
Error.INVALID.add();
}else{
int id = Utils.parseInt(key, 0, true);
if(id==0 || id < Short.MIN_VALUE || id > Short.MAX_VALUE)
Error.INVALID.add();
else{
if(id>bigger)
bigger = id;
Stat stat = create(sub.getString(Node.TYPE.get(), Node.BASE.get()), (short)id, sub, extension.getMessageCManager());
register((short) id, stat, true);
}
}
ErrorLogger.removePrefix();
}
ErrorLogger.removePrefix();
}
ErrorLogger.removePrefix();
}
示例11: FoodStatus
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
FoodStatus(ConfigurationSection section){
abso = section.getInt(Node.ABSORPTION.get(), -1);
defaultAbso = abso;
food = section.getInt(Node.FOOD.get(), 0);
defaultFood = food;
saturation = section.getInt(Node.SATURATION.get(), 0);
defaultSaturation = saturation;
volume = (float) section.getDouble("VOLUME", 1);
pitch = (float) section.getDouble("SPEED", 1);
sound = Utils.matchEnum(Sound.values(), section.getString("SOUND"), true);
ConfigurationSection potion = section.getConfigurationSection(Node.EFFECT.getList());
effects = new ArrayList<PotionEffect>();
if(potion == null)
return;
for(String key : potion.getKeys(false)){
ConfigurationSection sub = potion.getConfigurationSection(key);
if(sub == null){
ErrorLogger.addError(key + " invalid !");
continue;
}
PotionEffect effect = MinecraftUtils.craftPotionEffect(key, sub);
if(effect.getType().equals(PotionEffectType.ABSORPTION)) {
absoEffect = effect;
reset();
}else
this.effects.add(effect);
}
}
示例12: load
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
void load(ConfigurationSection config) throws InvalidConfigurationException {
final boolean enabled;
final BaseComponent title;
final ItemStack openButtonIcon;
final Map<Slot.Container, Button> buttons = new HashMap<>();
try {
enabled = config.getBoolean("enabled", false);
title = new TranslatableComponent(config.getString("title", "navigator.title"));
final ItemConfigurationParser itemParser = new ItemConfigurationParser(config);
openButtonIcon = itemParser.getItem(config, "icon", () -> new ItemStack(Material.SIGN));
if(enabled) {
final ConfigurationSection buttonSection = config.getSection("buttons");
for(String key : buttonSection.getKeys()) {
final Button button = new Button(buttonSection.getSection(key), itemParser);
buttons.put(button.slot, button);
}
}
} catch(InvalidConfigurationException e) {
buttons.values().forEach(Button::release);
throw e;
}
clear();
NavigatorInterface.this.enabled = enabled;
NavigatorInterface.this.title = title;
NavigatorInterface.this.openButtonIcon = openButtonIcon;
NavigatorInterface.this.buttons = ImmutableMap.copyOf(buttons);
NavigatorInterface.this.height = buttons.values()
.stream()
.mapToInt(button -> button.slot.getRow() + 1)
.max()
.orElse(0);
}
示例13: load
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
public static void load(ConfigurationSection servers) {
for (String name : servers.getKeys(false)) {
List<ServerRange> ranges = new ArrayList<ServerRange>();
for (String raw : servers.getStringList(name + ".servers")) {
String ip = raw.split(":")[0];
String ports = raw.split(":")[1];
int first = Integer.parseInt(ports.split(",")[0]);
int second = Integer.parseInt(ports.split(",")[1]);
ranges.add(new ServerRange(ip, first, second));
}
List<Block> blocks = new ArrayList<Block>();
for (String s : servers.getStringList(name + ".signs")) {
int x = Integer.parseInt(s.split(",")[0]);
int y = Integer.parseInt(s.split(",")[1]);
int z = Integer.parseInt(s.split(",")[2]);
Block b = Bukkit.getWorld("void").getBlockAt(x, y, z);
blocks.add(b);
}
MiniGame g = new MiniGame(ranges, blocks);
g.setTitle(servers.getString(name + ".title"));
}
Chat.log("Loaded " + MiniGame.getList().size() + " minigames!");
}
示例14: load
import org.bukkit.configuration.ConfigurationSection; //导入方法依赖的package包/类
public static void load(ConfigurationSection servers) {
for (String name : servers.getKeys(false)) {
String title = servers.getString(name + ".title");
String line_1 = servers.getString(name + ".line_1");
String line_2 = servers.getString(name + ".line_2");
String address = servers.getString(name + ".address");
new Game(Chat.colors(title), line_1, line_2, address);
}
Chat.log("Loaded " + Game.getList().size() + " games!");
}
示例15: 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);
}
}
}