当前位置: 首页>>代码示例>>Java>>正文


Java FileConfiguration.contains方法代码示例

本文整理汇总了Java中org.bukkit.configuration.file.FileConfiguration.contains方法的典型用法代码示例。如果您正苦于以下问题:Java FileConfiguration.contains方法的具体用法?Java FileConfiguration.contains怎么用?Java FileConfiguration.contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.configuration.file.FileConfiguration的用法示例。


在下文中一共展示了FileConfiguration.contains方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initiateArenas

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
private void initiateArenas() {
    FileConfiguration config = ManagerHandler.getConfig().getArenasConfig().getConfig();

    if (!config.contains("arenas")) return;

    for (String name : config.getConfigurationSection("arenas").getKeys(false)) {
        try {
            String displayName = config.getString("arenas." + name + ".display-name");
            Integer displayOrder = config.getInt("arenas." + name + ".display-order");
            Location location1 = LocationUtils.getLocation(config.getString("arenas." + name + ".location1"));
            Location location2 = LocationUtils.getLocation(config.getString("arenas." + name + ".location2"));
            Arena arena = new Arena(name, displayName, displayOrder, location1, location2);
            this.arenas.put(name, arena);
        }
        catch (Exception e) {
            PracticePlugin.getInstance().getLogger().severe("Failed to load arena '" + name + "', stack trace below:");
            PracticePlugin.getInstance().getLogger().severe("------------------------------------------------------");
            e.printStackTrace();
            PracticePlugin.getInstance().getLogger().severe("------------------------------------------------------");
        }
    }
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:23,代码来源:ArenaManager.java

示例2: removeCommand

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
/**
 * Static method for removing a command from the configuration.
 * @param plugin The StartupCommands instance.
 * @param removeStr The String of the command to remove. If it is an Integer
 * the command will be removed by index, otherwise, the method looks for a matching
 * command String.
 * @return removeStr The command String of the removed command.
 * @throws IllegalArgumentException if the command doesn't exist, if the index provided 
 * is less than zero or greater than commands.size() - 1, or if the configuration file 
 * cannot be saved.
 */
public static String removeCommand(StartupCommands plugin, String removeStr) {
	FileConfiguration config = plugin.getConfig();

	// Find the command String if removeStr is an Integer
	if (StartupCommands.isInteger(removeStr)) {
		List<Command> commands = plugin.getCommands();
		int index = Integer.parseInt(removeStr) - 1;
		
		// Ensure index is valid
		if (index < 0 || index > commands.size() - 1) {
			throw new IllegalArgumentException("Index must be greater than 0 and less than the number of startup commands.");
		}
		
		removeStr = plugin.getCommands().remove(index).getCommand();
	}

	if (config.contains("commands." + removeStr)) {
		config.set("commands." + removeStr, null);
		
		// Try to save configuration
		try {
			config.save(plugin.getDataFolder() + File.separator + "config.yml");
		} catch (IOException e) {
			throw new IllegalArgumentException("Could not save configuration file.");
		}
		
		return removeStr;
	} else {
		throw new IllegalArgumentException("Could not identify command to remove by " + removeStr + ".");
	}
}
 
开发者ID:mattgd,项目名称:StartupCommands,代码行数:43,代码来源:Command.java

示例3: loadConfig

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
public BukkitMotdConfig loadConfig() {
    saveDefaultConfig();
    reloadConfig();
    FileConfiguration config = getConfig();

    // check for ColorMOTD 1.x
    if (!config.contains("version")) {
        logger.info("ColorMOTD 1.x detected, renaming 'config.yml' to 'config.old.yml' ...");

        File oldLocation = new File(getDataFolder(), "config.yml");
        File newLocation = new File(getDataFolder(), "config.old.yml");
        newLocation.delete();
        if (!oldLocation.renameTo(newLocation)) {
            throw new RuntimeException("Unable to rename 'config.yml' to 'config.old.yml'!");
        }
        saveDefaultConfig();
        reloadConfig();
    }

    BukkitMotdConfig r = new BukkitMotdConfig();

    for (Object motdObj : config.getList("motds")) {
        if (motdObj instanceof String) {
            r.addMotd(((String) motdObj).replace("\\n", "\n"));
        } else if (motdObj instanceof Map) {
            @SuppressWarnings("unchecked")
            Map<String, Object> map = (Map<String, Object>) motdObj;
            String line1 = map.getOrDefault("line1", "").toString();
            String line2 = map.get("line2").toString();
            r.addMotd(line1 + (line2 == null ? "" : "\n" + line2));
        } else {
            throw new RuntimeException("Unknown motd type: " + motdObj.getClass().getCanonicalName());
        }
    }

    File iconFolder = new File(getDataFolder(), "favicons/");
    if(!iconFolder.isDirectory()) iconFolder.mkdirs();
    //noinspection ConstantConditions
    for(File file : iconFolder.listFiles((dir, name) ->
            SUPPORTED_IMAGE_FORMAT.stream().anyMatch(name::endsWith))) {
        try {
            BufferedImage image = ImageIO.read(file);
            r.addServerIcon(new BukkitMotdServerIcon(image));
        } catch (IOException e) {
            throw new UncheckedIOException("Unable to load " + file.getName(), e);
        }
    }

    return r;
}
 
开发者ID:andylizi,项目名称:ColorMOTD,代码行数:51,代码来源:BukkitMain.java

示例4: Board

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
public Board(File dir) {
    for (File file : dir.listFiles()) {
        regions.add(new Region(file));
    }
    File oldBoard = new File(FactionsXL.getInstance().getDataFolder(), "board.yml");
    if (oldBoard.exists()) {
        FileConfiguration config = YamlConfiguration.loadConfiguration(oldBoard);
        if (config.contains("regions")) {
            for (Entry<String, Object> region : ConfigUtil.getMap(config, "regions").entrySet()) {
                int id = Integer.parseInt(region.getKey());
                regions.add(new Region(id, (ConfigurationSection) region.getValue()));
            }
        }
    }
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:16,代码来源:Board.java

示例5: load

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
public void load() {
    projEffectMap.clear();
    File particleFile = new File(SkyWarsReloaded.get().getDataFolder(), "projectileeffects.yml");

    if (!particleFile.exists()) {
    	SkyWarsReloaded.get().saveResource("projectileeffects.yml", false);
    }

    if (particleFile.exists()) {
        FileConfiguration storage = YamlConfiguration.loadConfiguration(particleFile);

        if (storage.contains("effects")) {
            for (String item : storage.getStringList("effects")) {
                List<String> itemData = new LinkedList<String>(Arrays.asList(item.split(" ")));

                int cost = Integer.parseInt(itemData.get(1));
    
                String effect = itemData.get(0).toLowerCase();
                String name = null;
                
                if (effects.contains(effect)) {
                	name = new Messaging.MessageFormatter().format("effects." + effect);
                }
                                    
                if (name != null) {
                	projEffectMap.put(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', name)), new ParticleItem(effect, name, cost));
                }
            }
        }
    }
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:32,代码来源:ProjectileController.java

示例6: load

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
public void load() {
    particleMap.clear();
    File particleFile = new File(SkyWarsReloaded.get().getDataFolder(), "particleeffects.yml");

    if (!particleFile.exists()) {
    	SkyWarsReloaded.get().saveResource("particleeffects.yml", false);
    }

    if (particleFile.exists()) {
        FileConfiguration storage = YamlConfiguration.loadConfiguration(particleFile);

        if (storage.contains("effects")) {
            for (String item : storage.getStringList("effects")) {
                List<String> itemData = new LinkedList<String>(Arrays.asList(item.split(" ")));

                int cost = Integer.parseInt(itemData.get(1));
    
                String effect = itemData.get(0).toLowerCase();
                String name = null;

                if (effects.contains(effect)) {
                	name = new Messaging.MessageFormatter().format("effects." + effect);
                }
                
                if (name != null) {
                	particleMap.put(ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', name)), new ParticleItem(effect, name, cost));
                }
            }
        }
    }
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:32,代码来源:ParticleController.java

示例7: loadLadders

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
private void loadLadders() {
    FileConfiguration config = gameConfig.getConfig();

    if (config.getConfigurationSection("ladder") == null) {
        PracticePlugin.getInstance().getLogger().info("There are no ladders stored in the configuration.");
        return;
    }

    for (String s : config.getConfigurationSection("ladder").getKeys(false)) {
        try {
            Ladder ladder = new Ladder(s);

            if (!config.contains("ladder." + s + ".displayName")) {
                ladder.setDisplayName(s);
            } else {
                ladder.setDisplayName(config.getString("ladder." + s + ".displayName"));
            }

            if (config.contains("ladder." + s + ".displayIcon")) {
                ladder.setDisplayIcon(InventoryUtils.itemStackFromString(config.getString("ladder." + s + ".displayIcon")));
            } else {
                ladder.setDisplayIcon(new ItemStack(Material.DIAMOND_SWORD));
            }

            if (config.contains("ladder." + s + ".displayOrder")) {
                ladder.setDisplayOrder(config.getInt("ladder." + s + ".displayOrder"));
            } else {
                ladder.setDisplayOrder(0);
            }

            ladder.setDefaultInventory(InventoryUtils.playerInventoryFromString(config.getString("ladder." + s + ".defaultInventory")));

            if (config.contains("ladder." + s + ".hitDelay")) {
                ladder.setHitDelay(config.getInt("ladder." + s + ".hitDelay"));
            }

            if (config.getString("ladder." + s + ".allowEdit") != null) {
                ladder.allowEdit(config.getBoolean("ladder." + s + ".allowEdit"));
            }

            if (config.getString("ladder." + s + ".allowHeal") != null) {
                ladder.allowHeal(config.getBoolean("ladder." + s + ".allowHeal"));
            }

            if (config.getString("ladder." + s + ".allowHunger") != null) {
                ladder.allowHunger(config.getBoolean("ladder." + s + ".allowHunger"));
            }

            ladders.put(s, ladder);

            ManagerHandler.getStorageBackend().addColumn(ladder.getName());
        }
        catch (Exception e) {
            PracticePlugin.getInstance().getLogger().severe("[ARENAS] Failed to load arena '" + s + "'!");
        }
    }
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:58,代码来源:LadderManager.java


注:本文中的org.bukkit.configuration.file.FileConfiguration.contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。