Search in sources :

Example 1 with Skilltree

use of de.Keyle.MyPet.api.skill.skilltree.Skilltree in project MyPet by xXKeyleXx.

the class LevelUpListener method on.

@EventHandler
public void on(MyPetLevelUpEvent event) {
    MyPet myPet = event.getPet();
    int lvl = event.getLevel();
    int lastLvl = event.getLastLevel();
    if (!event.isQuiet()) {
        int maxlevel = myPet.getSkilltree() != null ? myPet.getSkilltree().getMaxLevel() : 0;
        if (maxlevel != 0 && lvl >= maxlevel) {
            myPet.getOwner().sendMessage(Util.formatText(Translation.getString("Message.LevelSystem.ReachedMaxLevel", event.getOwner().getLanguage()), myPet.getPetName(), maxlevel));
        } else {
            myPet.getOwner().sendMessage(Util.formatText(Translation.getString("Message.LevelSystem.LevelUp", event.getOwner().getLanguage()), myPet.getPetName(), event.getLevel()));
        }
    }
    SkillTree skillTree = myPet.getSkilltree();
    if (skillTree != null) {
        if (skillTree.getLastLevelWithSkills() < lvl) {
            lvl = skillTree.getLastLevelWithSkills();
        }
        for (int i = lastLvl + 1; i <= lvl; i++) {
            if (skillTree.hasLevel(i)) {
                SkillTreeLevel level = skillTree.getLevel(i);
                if (!event.isQuiet()) {
                    if (level.hasLevelupMessage()) {
                        myPet.getOwner().sendMessage(Colorizer.setColors(level.getLevelupMessage()));
                    }
                }
                List<SkillInfo> skillList = level.getSkills();
                for (SkillInfo skill : skillList) {
                    myPet.getSkills().getSkill(skill.getName()).upgrade(skill, event.isQuiet());
                }
            }
        }
    }
    if (myPet.getStatus() == MyPet.PetState.Here) {
        MyPetBukkitEntity entity = myPet.getEntity().get();
        entity.getHandle().updateNameTag();
        if (!event.isQuiet()) {
            myPet.setHealth(myPet.getMaxHealth());
            myPet.setSaturation(100);
            final boolean version17 = MyPetApi.getCompatUtil().compareWithMinecraftVersion("1.8") < 0;
            new SpiralAnimation(1, entity.getEyeHeight() + 0.5, new EntityLocationHolder(entity)) {

                @Override
                protected void playParticleEffect(Location location) {
                    if (version17) {
                        MyPetApi.getPlatformHelper().playParticleEffect(location, "magicCrit", 0, 0, 0, 0, 1, 32);
                    } else {
                        MyPetApi.getPlatformHelper().playParticleEffect(location, "CRIT_MAGIC", 0, 0, 0, 0, 1, 32);
                    }
                // MyPetApi.getPlatformHelper().playParticleEffect(location, "flame", 0, 0, 0, 0, 1, 32);
                }
            }.loop(2);
            if (MyPetApi.getCompatUtil().compareWithMinecraftVersion("1.9") >= 0) {
                entity.getWorld().playSound(entity.getLocation(), "entity.player.levelup", 1F, 0.7F);
            } else {
                entity.getWorld().playSound(entity.getLocation(), Sound.valueOf("LEVEL_UP"), 1F, 0.7F);
            }
        }
    }
}
Also used : SkillTreeLevel(de.Keyle.MyPet.api.skill.skilltree.SkillTreeLevel) SkillInfo(de.Keyle.MyPet.api.skill.SkillInfo) MyPet(de.Keyle.MyPet.api.entity.MyPet) SpiralAnimation(de.Keyle.MyPet.api.util.animation.particle.SpiralAnimation) EntityLocationHolder(de.Keyle.MyPet.api.util.location.EntityLocationHolder) SkillTree(de.Keyle.MyPet.api.skill.skilltree.SkillTree) MyPetBukkitEntity(de.Keyle.MyPet.api.entity.MyPetBukkitEntity) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 2 with Skilltree

use of de.Keyle.MyPet.api.skill.skilltree.Skilltree in project MyPet by xXKeyleXx.

the class SkilltreeCreator method skilltreeTreeSetSkilltrees.

public void skilltreeTreeSetSkilltrees() {
    DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(mobTypeComboBox.getSelectedItem().toString());
    skilltreeTreeModel.setRoot(rootNode);
    for (SkillTree skillTree : selectedMobtype.getSkillTrees()) {
        SkillTreeNode skillTreeNode = new SkillTreeNode(skillTree);
        rootNode.add(skillTreeNode);
    }
    skilltreeTreeExpandAll();
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) SkillTree(de.Keyle.MyPet.api.skill.skilltree.SkillTree)

Example 3 with Skilltree

use of de.Keyle.MyPet.api.skill.skilltree.Skilltree in project MyPet by xXKeyleXx.

the class CommandShowSkillTree method onCommand.

public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (sender instanceof ConsoleCommandSender) {
        SkillTreeMobType mobType;
        if (args.length >= 1) {
            if (args[0].equalsIgnoreCase("default")) {
                mobType = SkillTreeMobType.DEFAULT;
            } else {
                MyPetType type = MyPetType.byName(args[0]);
                if (type != null) {
                    mobType = SkillTreeMobType.byPetType(type);
                } else {
                    MyPetApi.getLogger().info("There is " + ChatColor.RED + "no" + ChatColor.RESET + " mobtype with the name: " + ChatColor.AQUA + args[0]);
                    return true;
                }
            }
            if (args.length >= 2) {
                if (mobType.hasSkillTree(args[1])) {
                    SkillTree skillTree = mobType.getSkillTree(args[1]);
                    MyPetApi.getLogger().info("----- MyPet Skilltree: " + ChatColor.AQUA + skillTree.getName() + ChatColor.RESET + " - Inherits: " + (skillTree.getInheritance() != null ? ChatColor.AQUA + skillTree.getInheritance() + ChatColor.RESET : ChatColor.DARK_GRAY + "none" + ChatColor.RESET) + " -----");
                    for (SkillTreeLevel lvl : skillTree.getLevelList()) {
                        MyPetApi.getLogger().info(ChatColor.YELLOW + " " + lvl.getLevel() + ChatColor.RESET + ": (" + (lvl.hasLevelupMessage() ? Colorizer.setColors(lvl.getLevelupMessage()) + ChatColor.RESET : "-") + ")");
                        for (SkillInfo skill : lvl.getSkills()) {
                            if (skill.isAddedByInheritance()) {
                                MyPetApi.getLogger().info("   " + ChatColor.DARK_GRAY + skill.getName());
                            } else {
                                MyPetApi.getLogger().info("   " + skill.getName());
                            }
                        }
                    }
                    MyPetApi.getLogger().info("----- MyPet Skilltree " + ChatColor.AQUA + skillTree.getName() + ChatColor.RESET + " end -----");
                } else {
                    MyPetApi.getLogger().info("There is " + ChatColor.RED + "no" + ChatColor.RESET + " skilltree with the name: " + ChatColor.AQUA + args[1]);
                }
            } else {
                MyPetApi.getLogger().info("----- MyPet Skilltrees for: " + ChatColor.GREEN + args[0]);
                for (String skillTreeName : mobType.getSkillTreeNames()) {
                    MyPetApi.getLogger().info("   " + skillTreeName);
                }
            }
        } else {
            return false;
        }
    } else {
        sender.sendMessage("Can only be used in server console");
    }
    return true;
}
Also used : SkillTreeLevel(de.Keyle.MyPet.api.skill.skilltree.SkillTreeLevel) SkillInfo(de.Keyle.MyPet.api.skill.SkillInfo) SkillTreeMobType(de.Keyle.MyPet.api.skill.skilltree.SkillTreeMobType) MyPetType(de.Keyle.MyPet.api.entity.MyPetType) SkillTree(de.Keyle.MyPet.api.skill.skilltree.SkillTree)

Example 4 with Skilltree

use of de.Keyle.MyPet.api.skill.skilltree.Skilltree in project MyPet by xXKeyleXx.

the class SkillTreeLoader method addDefault.

public static void addDefault(SkillTreeMobType skillTreeMobType) {
    SkillTreeMobType defaultSkillTreeMobType = SkillTreeMobType.DEFAULT;
    for (String skillTreeName : defaultSkillTreeMobType.getSkillTreeNames()) {
        if (!skillTreeMobType.hasSkillTree(skillTreeName) && defaultSkillTreeMobType.hasSkillTree(skillTreeName)) {
            SkillTree newSkillTree = defaultSkillTreeMobType.getSkillTree(skillTreeName).clone();
            for (SkillTreeLevel level : newSkillTree.getLevelList()) {
                for (SkillInfo skill : level.getSkills()) {
                    skill.setIsInherited(true);
                }
            }
            skillTreeMobType.addSkillTree(newSkillTree);
        }
    }
}
Also used : SkillTreeLevel(de.Keyle.MyPet.api.skill.skilltree.SkillTreeLevel) SkillInfo(de.Keyle.MyPet.api.skill.SkillInfo) SkillTreeMobType(de.Keyle.MyPet.api.skill.skilltree.SkillTreeMobType) SkillTree(de.Keyle.MyPet.api.skill.skilltree.SkillTree)

Example 5 with Skilltree

use of de.Keyle.MyPet.api.skill.skilltree.Skilltree in project MyPet by xXKeyleXx.

the class SkillTreeLoader method manageInheritance.

protected static void manageInheritance(SkillTreeMobType skillTreeMobType, SkillTree startSkillTree, SkillTree skillTree, Map<SkillTree, SkillTree> clones, int depth) {
    if (skillTree.hasInheritance() && depth < 20) {
        if (skillTreeMobType.hasSkillTree(skillTree.getInheritance())) {
            SkillTree skillTreeInherit = skillTreeMobType.getSkillTree(skillTree.getInheritance());
            if (!alreadyLoadedInheritance.contains(skillTreeInherit)) {
                if (skillTreeInherit.hasInheritance() && Configuration.Skilltree.INHERIT_ALREADY_INHERITED_SKILLS) {
                    alreadyLoadedInheritance.add(skillTreeInherit);
                    manageInheritance(skillTreeMobType, startSkillTree, skillTreeInherit, clones, depth + 1);
                } else {
                    alreadyLoadedInheritance.add(skillTreeInherit);
                }
                SkillTree skillTreeClone = clones.get(skillTreeInherit);
                for (SkillTreeLevel level : skillTreeClone.getLevelList()) {
                    for (SkillInfo skill : level.getSkills()) {
                        SkillInfo skillClone = skill.cloneSkill();
                        if (skillClone != null) {
                            skillClone.setIsInherited(true);
                            startSkillTree.addSkillToLevel(level.getLevel(), skillClone, true);
                        }
                    }
                }
            }
        }
    }
}
Also used : SkillTreeLevel(de.Keyle.MyPet.api.skill.skilltree.SkillTreeLevel) SkillInfo(de.Keyle.MyPet.api.skill.SkillInfo) SkillTree(de.Keyle.MyPet.api.skill.skilltree.SkillTree)

Aggregations

Skilltree (de.Keyle.MyPet.api.skill.skilltree.Skilltree)16 MyPet (de.Keyle.MyPet.api.entity.MyPet)10 SkillTree (de.Keyle.MyPet.api.skill.skilltree.SkillTree)9 SkillInfo (de.Keyle.MyPet.api.skill.SkillInfo)6 SkillTreeLevel (de.Keyle.MyPet.api.skill.skilltree.SkillTreeLevel)6 InactiveMyPet (de.Keyle.MyPet.entity.InactiveMyPet)5 IOException (java.io.IOException)5 StoredMyPet (de.Keyle.MyPet.api.entity.StoredMyPet)4 MyPetPlayer (de.Keyle.MyPet.api.player.MyPetPlayer)4 SkillTreeMobType (de.Keyle.MyPet.api.skill.skilltree.SkillTreeMobType)4 Player (org.bukkit.entity.Player)4 EventHandler (org.bukkit.event.EventHandler)4 SkillName (de.Keyle.MyPet.api.skill.SkillName)3 Upgrade (de.Keyle.MyPet.api.skill.Upgrade)3 Skill (de.Keyle.MyPet.api.skill.skilltree.Skill)3 EntityLocationHolder (de.Keyle.MyPet.api.util.location.EntityLocationHolder)3 RepositoryMyPetConverterService (de.Keyle.MyPet.api.util.service.types.RepositoryMyPetConverterService)3 TagString (de.keyle.knbt.TagString)3 Location (org.bukkit.Location)3 MyPetType (de.Keyle.MyPet.api.entity.MyPetType)2