Search in sources :

Example 36 with ConfigurationSection

use of org.bukkit.configuration.ConfigurationSection in project Minigames by AddstarMC.

the class Rewards method save.

public void save(ConfigurationSection section) {
    int index = 0;
    for (RewardType item : items) {
        ConfigurationSection itemSection = section.createSection(String.valueOf(index));
        itemSection.set("type", item.getName());
        itemSection.set("rarity", item.getRarity().name());
        item.saveReward("data", itemSection);
        index++;
    }
    for (RewardGroup group : groups) {
        ConfigurationSection groupSection = section.createSection(group.getName());
        group.save(groupSection);
    }
}
Also used : MenuItemRewardGroup(au.com.mineauz.minigames.menu.MenuItemRewardGroup) ConfigurationSection(org.bukkit.configuration.ConfigurationSection)

Example 37 with ConfigurationSection

use of org.bukkit.configuration.ConfigurationSection in project Minigames by AddstarMC.

the class ScoreboardData method loadDisplays.

public void loadDisplays(MinigameSave save, Minigame mgm) {
    FileConfiguration con = save.getConfig();
    ConfigurationSection root = con.getConfigurationSection(mgm.getName(false) + ".scoreboards");
    if (root == null) {
        return;
    }
    for (String key : root.getKeys(false)) {
        ConfigurationSection displayConf = root.getConfigurationSection(key);
        ScoreboardDisplay display = ScoreboardDisplay.load(mgm, displayConf);
        if (display != null) {
            addDisplay(display);
        }
    }
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration) ConfigurationSection(org.bukkit.configuration.ConfigurationSection)

Example 38 with ConfigurationSection

use of org.bukkit.configuration.ConfigurationSection in project Glowstone by GlowstoneMC.

the class CraftingManager method loadRecipes.

/**
     * Load default recipes from built-in recipes.yml file.
     */
@SuppressWarnings("unchecked")
private void loadRecipes() {
    // Load recipes from recipes.yml file
    InputStream in = getClass().getClassLoader().getResourceAsStream("builtin/recipes.yml");
    if (in == null) {
        GlowServer.logger.warning("Could not find default recipes on classpath");
        return;
    }
    ConfigurationSection config = YamlConfiguration.loadConfiguration(in);
    // shaped
    for (Map<?, ?> data : config.getMapList("shaped")) {
        ItemStack resultStack = ItemStack.deserialize((Map<String, Object>) data.get("result"));
        ShapedRecipe recipe = new ShapedRecipe(resultStack);
        List<String> shape = (List<String>) data.get("shape");
        recipe.shape(shape.toArray(new String[shape.size()]));
        Map<String, Map<String, Object>> ingredients = (Map<String, Map<String, Object>>) data.get("ingredients");
        for (Entry<String, Map<String, Object>> entry : ingredients.entrySet()) {
            ItemStack stack = ItemStack.deserialize(entry.getValue());
            recipe.setIngredient(entry.getKey().charAt(0), stack.getData());
        }
        shapedRecipes.add(recipe);
    }
    // shapeless
    for (Map<?, ?> data : config.getMapList("shapeless")) {
        ItemStack resultStack = ItemStack.deserialize((Map<String, Object>) data.get("result"));
        ShapelessRecipe recipe = new ShapelessRecipe(resultStack);
        List<Map<String, Object>> ingreds = (List<Map<String, Object>>) data.get("ingredients");
        for (Map<String, Object> entry : ingreds) {
            recipe.addIngredient(ItemStack.deserialize(entry).getData());
        }
        shapelessRecipes.add(recipe);
    }
    // furnace
    for (Map<?, ?> data : config.getMapList("furnace")) {
        ItemStack inputStack = ItemStack.deserialize((Map<String, Object>) data.get("input"));
        ItemStack resultStack = ItemStack.deserialize((Map<String, Object>) data.get("result"));
        float xp = ((Number) data.get("xp")).floatValue();
        furnaceRecipes.add(new FurnaceRecipe(resultStack, inputStack.getType(), inputStack.getDurability(), xp));
    }
}
Also used : InputStream(java.io.InputStream) ConfigurationSection(org.bukkit.configuration.ConfigurationSection)

Example 39 with ConfigurationSection

use of org.bukkit.configuration.ConfigurationSection in project Glowstone by GlowstoneMC.

the class GlowHelpMap method loadConfig.

/**
     * Reads the general topics from help.yml and adds them to the help index.
     *
     * @param config The configuration to read from.
     */
public void loadConfig(ConfigurationSection config) {
    // general topics
    ConfigurationSection general = config.getConfigurationSection("general-topics");
    if (general != null) {
        for (String key : general.getKeys(false)) {
            ConfigurationSection topic = general.getConfigurationSection(key);
            if (topic != null) {
                String shortText = topic.getString("shortText", "");
                String fullText = topic.getString("fullText", "");
                if (!shortText.isEmpty()) {
                    if (fullText.isEmpty()) {
                        fullText = shortText;
                    } else {
                        fullText = shortText + "\n" + ChatColor.RESET + fullText;
                    }
                }
                addTopic(new GeneralHelpTopic(key, color(shortText), color(fullText), topic.getString("permission", null)));
            }
        }
    }
    // index topics
    ConfigurationSection index = config.getConfigurationSection("index-topics");
    if (index != null) {
        for (String key : index.getKeys(false)) {
            ConfigurationSection topic = index.getConfigurationSection(key);
            if (topic != null) {
                String shortText = color(topic.getString("shortText", ""));
                String preamble = color(topic.getString("preamble", null));
                String permission = topic.getString("permission", null);
                HelpTopic helpTopic = new LazyIndexTopic(key, shortText, permission, topic.getStringList("commands"), preamble);
                if (key.equals("Default")) {
                    defaultTopic = helpTopic;
                } else {
                    addTopic(helpTopic);
                }
            }
        }
    }
    // ignore plugins and command topics settings
    ignoredPlugins.addAll(config.getStringList("ignore-plugins"));
    commandsInIndex = config.getBoolean("command-topics-in-master-index", true);
}
Also used : ConfigurationSection(org.bukkit.configuration.ConfigurationSection)

Example 40 with ConfigurationSection

use of org.bukkit.configuration.ConfigurationSection in project Glowstone by GlowstoneMC.

the class GlowServer method getCommandAliases.

@Override
public Map<String, String[]> getCommandAliases() {
    Map<String, String[]> aliases = new HashMap<>();
    ConfigurationSection section = config.getConfigFile(Key.COMMANDS_FILE).getConfigurationSection("aliases");
    if (section == null) {
        return aliases;
    }
    for (String key : section.getKeys(false)) {
        List<String> list = section.getStringList(key);
        aliases.put(key, list.toArray(new String[list.size()]));
    }
    return aliases;
}
Also used : ConfigurationSection(org.bukkit.configuration.ConfigurationSection)

Aggregations

ConfigurationSection (org.bukkit.configuration.ConfigurationSection)49 ItemStack (org.bukkit.inventory.ItemStack)7 IOException (java.io.IOException)6 Material (org.bukkit.Material)6 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)6 File (java.io.File)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)3 MemoryConfiguration (org.bukkit.configuration.MemoryConfiguration)3 EntityType (org.bukkit.entity.EntityType)3 Rewards (au.com.mineauz.minigames.minigame.reward.Rewards)2 ChatColor (com.gamingmesh.jobs.util.ChatColor)2 ASkyBlock (com.wasteofplastic.acidisland.ASkyBlock)2 BigDecimal (java.math.BigDecimal)2 Enchantment (org.bukkit.enchantments.Enchantment)2 SQLiteBackend (au.com.mineauz.minigames.backend.sqlite.SQLiteBackend)1 MenuItemRewardGroup (au.com.mineauz.minigames.menu.MenuItemRewardGroup)1 LoadoutAddon (au.com.mineauz.minigames.minigame.modules.LoadoutModule.LoadoutAddon)1 StandardRewardScheme (au.com.mineauz.minigames.minigame.reward.scheme.StandardRewardScheme)1 NoChargeException (com.earth2me.essentials.commands.NoChargeException)1