Search in sources :

Example 1 with ConfigurationNBT

use of de.Keyle.MyPet.api.util.configuration.ConfigurationNBT in project MyPet by xXKeyleXx.

the class SkillTreeLoaderNBT method loadSkillTrees.

public void loadSkillTrees(String configPath, List<String> mobtypes) {
    ConfigurationNBT skilltreeConfig;
    File skillFile;
    for (String mobType : mobtypes) {
        skillFile = new File(configPath + File.separator + mobType.toLowerCase() + ".st");
        SkillTreeMobType skillTreeMobType;
        if (mobType.equalsIgnoreCase("default")) {
            skillTreeMobType = SkillTreeMobType.DEFAULT;
        } else {
            skillTreeMobType = SkillTreeMobType.getMobTypeByName(mobType);
        }
        if (!skillFile.exists()) {
            continue;
        }
        skilltreeConfig = new ConfigurationNBT(skillFile);
        if (skilltreeConfig.load()) {
            try {
                loadSkillTree(skilltreeConfig, skillTreeMobType);
            } catch (Exception e) {
                MyPetApi.getLogger().warning("Error while loading skilltrees from: " + mobType.toLowerCase() + ".st");
                e.printStackTrace();
            }
        }
        skillTreeMobType.cleanupPlaces();
    }
}
Also used : ConfigurationNBT(de.Keyle.MyPet.api.util.configuration.ConfigurationNBT) SkillTreeMobType(de.Keyle.MyPet.api.skill.skilltree.SkillTreeMobType) File(java.io.File)

Example 2 with ConfigurationNBT

use of de.Keyle.MyPet.api.util.configuration.ConfigurationNBT in project MyPet by xXKeyleXx.

the class SkillTreeLoaderNBT method saveSkillTrees.

public List<String> saveSkillTrees(String configPath, String[] mobtypes) {
    ConfigurationNBT nbtConfig;
    File skillFile;
    List<String> savedPetTypes = new ArrayList<>();
    for (String petType : mobtypes) {
        skillFile = new File(configPath + File.separator + petType.toLowerCase() + ".st");
        nbtConfig = new ConfigurationNBT(skillFile);
        if (saveSkillTree(nbtConfig, petType)) {
            savedPetTypes.add(petType);
        }
    }
    return savedPetTypes;
}
Also used : ConfigurationNBT(de.Keyle.MyPet.api.util.configuration.ConfigurationNBT) ArrayList(java.util.ArrayList) File(java.io.File)

Example 3 with ConfigurationNBT

use of de.Keyle.MyPet.api.util.configuration.ConfigurationNBT in project MyPet by xXKeyleXx.

the class NbtRepository method loadData.

private void loadData(File f) {
    ConfigurationNBT nbtConfiguration = new ConfigurationNBT(f);
    if (!nbtConfiguration.load()) {
        return;
    }
    if (nbtConfiguration.getNBTCompound().containsKeyAs("Players", TagList.class)) {
        int playerCount = loadPlayers(nbtConfiguration.getNBTCompound().getAs("Players", TagList.class));
        MyPetApi.getLogger().info("[NBT] " + ChatColor.YELLOW + playerCount + ChatColor.RESET + " PetPlayer(s) loaded");
    }
    int petCount = loadPets(nbtConfiguration.getNBTCompound().getAs("Pets", TagList.class));
    MyPetApi.getLogger().info("[NBT] " + ChatColor.YELLOW + petCount + ChatColor.RESET + " pet(s) loaded");
}
Also used : ConfigurationNBT(de.Keyle.MyPet.api.util.configuration.ConfigurationNBT) TagList(de.keyle.knbt.TagList)

Aggregations

ConfigurationNBT (de.Keyle.MyPet.api.util.configuration.ConfigurationNBT)3 File (java.io.File)2 SkillTreeMobType (de.Keyle.MyPet.api.skill.skilltree.SkillTreeMobType)1 TagList (de.keyle.knbt.TagList)1 ArrayList (java.util.ArrayList)1