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


Java FileConfiguration.getConfigurationSection方法代码示例

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


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

示例1: loadCommands

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
/**
 * Loads all of the startup commands from the plugin's configuration file.
 * @param plugin the StartupCommands plugin instance
 */
public static void loadCommands(StartupCommands plugin) {
	FileConfiguration config = plugin.getConfig();
		
		if (config.getConfigurationSection("commands") == null) {
			plugin.getLogger().info("There are no startup commands present.");
		} else {
			int delay = 0;

			for (String command : config.getConfigurationSection("commands").getKeys(false)) {
				delay = config.getInt("commands." + command + ".delay", 0);
				
				// Try to create the command
				try {
					plugin.getCommands().add(new Command(command, delay));
				} catch (IllegalArgumentException e) {
					plugin.getLogger().severe(e.getMessage());
				}
	 		}
		}
}
 
开发者ID:mattgd,项目名称:StartupCommands,代码行数:25,代码来源:Command.java

示例2: onEnable

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
@Override
public void onEnable() {
  world = Bukkit.createWorld(new WorldCreator(OpenUHC.WORLD_DIR_PREFIX + "lobby"));
  // Read lobby yml if it exists
  File lobbyFile = new File(OpenUHC.WORLD_DIR_PREFIX + "lobby/lobby.yml");
  if (lobbyFile.exists()) {
    FileConfiguration lobbyConfig = YamlConfiguration.loadConfiguration(lobbyFile);
    ConfigurationSection spawn = lobbyConfig.getConfigurationSection("spawn");
    if (spawn != null) {
      double x = spawn.getDouble("x", 0);
      double y = spawn.getDouble("y", 64);
      double z = spawn.getDouble("z", 0);
      double r = spawn.getDouble("r", 1);
      this.spawn = new Vector(x, y, z);
      radius = (float) r;
    }
  }
  OpenUHC.registerEvents(this);
}
 
开发者ID:twizmwazin,项目名称:OpenUHC,代码行数:20,代码来源:LobbyModule.java

示例3: load

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
private void load(JavaPlugin plugin) {
    try {
        final FileConfiguration configuration = new YamlConfiguration();
        final File file = new File(plugin.getDataFolder(), "bungeecord_signs.yml");
        if (!file.exists()) {
            if (!file.createNewFile()) {
                Bukkit.getLogger().log(Level.WARNING, "File cannot get created.");
            }
        }
        configuration.load(file);
        if (configuration.getConfigurationSection("signs") != null) {
            final Map<String, Object> data = configuration.getConfigurationSection("signs").getValues(false);
            for (final String s : data.keySet()) {
                this.signs.add(new BungeeCordSignInfo.Container(((ConfigurationSection) data.get(s)).getValues(true)));
            }
        }
    } catch (IOException | InvalidConfigurationException e) {
        Bukkit.getLogger().log(Level.WARNING, "Save load location.", e);
    }
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:21,代码来源:BungeeCordController.java

示例4: reloadConfig

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
public void reloadConfig(File configFile) {
    extensionsToEngineName = new HashMap<>();

    FileConfiguration config = YamlConfiguration.loadConfiguration(configFile);
    ConfigurationSection section = config.getConfigurationSection("engines");
    for (Map.Entry<String, Object> obj : section.getValues(false).entrySet())
        extensionsToEngineName.put(obj.getKey(), obj.getValue().toString());
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:9,代码来源:ScriptManager.java

示例5: loadConfig

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
private void loadConfig() {
    FileConfiguration config = new YamlConfiguration();
    try {
        config.load(new File(getDataFolder(), "config.yml"));
        config.options().copyDefaults(true);

        String user = config.getString("jdbc-username", "root");
        String password = config.getString("jdbc-password", "password");
        String jdbcUrl = config.getString("jdbc-url", "jdbc:mysql://localhost:3306/minecraft");

        databaseManager = new DatabaseManager(jdbcUrl, user, password);
        databaseManager.connect();

        ConfigurationSection definitions = config.getConfigurationSection("definitions");
        for (String definitionKey : definitions.getKeys(false)) {
            ConfigurationSection definition = definitions.getConfigurationSection(definitionKey);

            int priority = definition.getInt("priority", 1);
            ImageType type = ImageType.valueOf(definition.getString("type", ImageType.OVERLAY.name()));
            String permission = definition.getString("permission");
            List<String> images = definition.getStringList("images");

            SpigotImageDetails imageDetails = new SpigotImageDetails(priority, type, permission, images);
            imageHandler.addImage(imageDetails);
        }

        config.save(new File(getDataFolder(), "config.yml"));
    } catch (IOException | InvalidConfigurationException e) {
        e.printStackTrace();
    }
}
 
开发者ID:me4502,项目名称:AdvancedServerListIcons,代码行数:32,代码来源:AdvancedServerListIconsSpigot.java

示例6: CheckManager

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
/**
 * Handle getting all the check data.
 *
 * @param configuration the configuration file.
 */
public CheckManager(FileConfiguration configuration) {
    this.configuration = configuration;
    for (CheckType check : CheckType.values()) {
        String checkName = check.getCheckName().toLowerCase();

        ConfigurationSection section = configuration.getConfigurationSection(checkName);
        boolean isEnabled = configuration.getBoolean(checkName + ".enabled");

        // if were not enabled, continue.
        if (!isEnabled) {
            continue;
        }

        // collect the violation levels from the config.
        int banViolations = section.getInt("ban");
        int cancelViolations = section.getInt("cancel-vl");
        int notifyViolations = section.getInt("notify");

        // populate the map with the new check data.
        boolean cancelCheck = section.getBoolean("cancel");
        CheckData data = new CheckData(notifyViolations, cancelViolations, banViolations, cancelCheck, banViolations > 0);
        CHECK_DATA.put(check, data);

        Arc.getPlugin().getLogger().info("Finished getting data for check: " + checkName);
    }

}
 
开发者ID:Vrekt,项目名称:Arc-v2,代码行数:33,代码来源:CheckManager.java

示例7: reload

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
/**
 * Reload the configuration.
 */
public void reload(FileConfiguration configuration) {
    this.configuration = configuration;
    for (CheckType check : CheckType.values()) {
        String checkName = check.getCheckName().toLowerCase();

        ConfigurationSection section = configuration.getConfigurationSection(checkName);
        boolean isEnabled = configuration.getBoolean(checkName + ".enabled");

        // if were not enabled, continue.
        if (!isEnabled) {
            continue;
        }

        // collect the violation levels from the config.
        int banViolations = section.getInt("ban");
        int cancelViolations = section.getInt("cancel-vl");
        int notifyViolations = section.getInt("notify");

        // populate the map with the new check data.
        boolean cancelCheck = section.getBoolean("cancel");

        CHECK_DATA.remove(check);
        CheckData data = new CheckData(notifyViolations, cancelViolations, banViolations, cancelCheck, banViolations > 0);
        CHECK_DATA.put(check, data);

        Arc.getPlugin().getLogger().info("Finished getting data for check: " + checkName);
    }
}
 
开发者ID:Vrekt,项目名称:Arc-v2,代码行数:32,代码来源:CheckManager.java

示例8: onEnable

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
@Override
    public void onEnable() {
        tgm = this;
        FileConfiguration fileConfiguration = getConfig();
        saveDefaultConfig();

        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.registerTypeAdapter(MapInfo.class, new MapInfoDeserializer());
        this.gson = gsonBuilder.create();

        ConfigurationSection apiConfig = fileConfiguration.getConfigurationSection("api");
        if (apiConfig.getBoolean("enabled")) {
            teamClient = new HttpClient(new HttpClientConfig() {
                @Override
                public String getBaseUrl() {
                    return apiConfig.getString("url");
                }

                @Override
                public String getAuthToken() {
                    return apiConfig.getString("auth");
                }
            });
        } else {
            teamClient = new OfflineClient();
        }

        this.commands = new CommandsManager<CommandSender>() {
            @Override
            public boolean hasPermission(CommandSender sender, String perm) {
                return sender instanceof ConsoleCommandSender || sender.hasPermission(perm);
            }
        };

        matchManager = new MatchManager(fileConfiguration);
        playerManager = new PlayerManager();
        joinManager = new JoinManager();
//        playerListManager = new PlayerListManager();
        tracker = new TrackerPlugin(this);
        grave = new GravePlugin(this);
        apiManager = new ApiManager();

        this.commandManager = new CommandsManagerRegistration(this, this.commands);
        commandManager.register(CycleCommands.class);

        GameRuleModule.setGameRules(Bukkit.getWorlds().get(0)); //Set gamerules in main unused world

        try {
            matchManager.cycleNextMatch();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:54,代码来源:TGM.java

示例9: onLoad

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
@SuppressWarnings("ResultOfMethodCallIgnored")
@Override
public void onLoad() {
	instance = this;
	if (!working) return;

	dependencyFolder = new File(getDataFolder(), "Dependencies");
	if (!dependencyFolder.exists()) dependencyFolder.mkdirs();

	saveDefaultConfig();

	FileConfiguration config = getConfig();
	showDebug = config.getBoolean("options.showDebug", false);
	enforceFileCheck = config.getBoolean("options.showDebug", true);

	Urls.addRepositories(config.getStringList("options.repositories"));

	PluginDescriptionFile pluginDesc = getDescription();

	log(Level.INFO,
			" ", " ",
			blockBar(45),
			"<  ",
			"< Dependency Loader " + pluginDesc.getVersion() + " by - " + pluginDesc.getAuthors(),
			"<  ",
			"< Showing Debug Messages? -> " + showDebug,
			"< Enforcing File Check? -> " + enforceFileCheck,
			"<  ",
			blockBar(45),
			" ", " ");

	ConfigurationSection configDeps = config.getConfigurationSection("dependencies");
	if (configDeps == null) return;


	Set<String> keys = configDeps.getKeys(false);

	keys.forEach(name -> {

		String  groupId      = configDeps.getString(name + ".group", "");
		String  version      = configDeps.getString(name + ".version", "");
		String  artifactId   = configDeps.getString(name + ".artifact", "");
		String  customRepo   = configDeps.getString(name + ".repository", "");
		boolean alwaysUpdate = configDeps.getBoolean(name + ".always-update", false);

		if (version.isEmpty() || groupId.isEmpty() || artifactId.isEmpty()) {
			log(Level.SEVERE,
					" ", " ",
					blockBar(45),
					"< ",
					"< Dependency " + name + " has incomplete details",
					"< Requires, case-sensitive",
					"< 'version', 'group', 'artifact'",
					"< ",
					blockBar(45),
					" ", " ");
		} else {
			final Dependency dependency = new Dependency(name.toLowerCase(), version, groupId, artifactId, customRepo, alwaysUpdate);
			if (dependencies.containsValue(dependency)) debug("Dependency " + name + " has a duplicate");

			debug("Attempting load of Dependency " + name + " From Config");
			load(dependency);
		}
	});

}
 
开发者ID:Sxtanna,项目名称:dependency-loader,代码行数:67,代码来源:DLoader.java

示例10: 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

示例11: parseDragonLoot

import org.bukkit.configuration.file.FileConfiguration; //导入方法依赖的package包/类
private void parseDragonLoot() {
	if (template.file == null) return; // No file to parse loot from
	
	Logger logger = JavaPlugin.getPlugin(DragonEggDrop.class).getLogger();
	FileConfiguration dragonFile = template.configFile;
	
	// Parse the basic loot rewards (i.e. spawn chances & names)
	this.eggSpawnChance = dragonFile.getDouble("egg-spawn-chance", 100.0);
	this.eggName = ChatColor.translateAlternateColorCodes('&', dragonFile.getString("egg-name", "%dragon%&r's Egg"));
	this.eggLore = dragonFile.getStringList("egg-lore").stream()
			.map(s -> ChatColor.translateAlternateColorCodes('&', s))
			.collect(Collectors.toList());
	
	this.chestSpawnChance = dragonFile.getDouble("chest-spawn-chance", 0);
	this.chestName = dragonFile.getString("chest-name", "Loot Chest");
	this.minLootGen = dragonFile.getInt("min-loot");
	this.maxLootGen = dragonFile.getInt("max-loot");
	
	this.commands = dragonFile.getStringList("death-commands");
	
	// Parse loot items
	ConfigurationSection lootSection = dragonFile.getConfigurationSection("loot");
	if (lootSection == null) return;
	
	for (String itemKey : lootSection.getKeys(false)) {
		// Parse root values (type, damage, amount and weight)
		double weight = lootSection.getDouble(itemKey + ".weight");
		
		Material type = EnumUtils.getEnum(Material.class, lootSection.getString(itemKey + ".type").toUpperCase());
		byte data = (byte) lootSection.getInt(itemKey + ".data");
		short damage = (short) lootSection.getInt(itemKey + ".damage");
		int amount = lootSection.getInt(itemKey + ".amount");
		
		if (type == null) {
			logger.warning("Invalid material type \"" + lootSection.getString(itemKey + ".type") + "\". Ignoring loot value...");
			continue;
		}
		
		// Create new item stack with passed values
		@SuppressWarnings("deprecation")
		ItemStack item = new ItemStack(type, 1, damage, data);
		item.setAmount(amount);
		
		// Parse meta
		String displayName = lootSection.getString(itemKey + ".display-name");
		List<String> lore = lootSection.getStringList(itemKey + ".lore");
		Map<Enchantment, Integer> enchantments = new HashMap<>();
		
		// Enchantment parsing
		if (lootSection.contains(itemKey + ".enchantments")) {
			for (String enchant : lootSection.getConfigurationSection(itemKey + ".enchantments").getKeys(false)) {
				Enchantment enchantment = Enchantment.getByName(enchant);
				int level = lootSection.getInt(itemKey + ".enchantments." + enchant);
				
				if (enchantment == null || level == 0) {
					logger.warning("Invalid enchantment \"" + enchant + "\" with level " + level);
					continue;
				}
				
				enchantments.put(enchantment, level);
			}
		}
		
		// Meta updating
		ItemMeta meta = item.getItemMeta();
		if (displayName != null) meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', displayName));
		if (!lore.isEmpty()) meta.setLore(lore.stream().map(s -> ChatColor.translateAlternateColorCodes('&', s)).collect(Collectors.toList()));
		enchantments.forEach((e, level) -> meta.addEnchant(e, level, true));
		item.setItemMeta(meta);
		
		this.loot.add(weight, item);
	}
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:74,代码来源:DragonLoot.java


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