Search in sources :

Example 1 with Skill

use of com.herocraftonline.heroes.characters.skill.Skill in project MagicPlugin by elBukkit.

the class HeroesManager method getSkillList.

public List<String> getSkillList(Player player, boolean showUnuseable, boolean showPassive) {
    if (skills == null)
        return emptySkillList;
    Hero hero = getHero(player);
    if (hero == null)
        return emptySkillList;
    HeroClass heroClass = hero.getHeroClass();
    HeroClass secondClass = hero.getSecondClass();
    Set<String> primarySkills = new HashSet<>();
    Set<String> secondarySkills = new HashSet<>();
    addSkills(hero, heroClass, primarySkills, showUnuseable, showPassive);
    addSkills(hero, secondClass, secondarySkills, showUnuseable, showPassive);
    secondarySkills.removeAll(primarySkills);
    Multimap<Integer, Skill> primaryMap = mapSkillsByLevel(hero, primarySkills);
    Multimap<Integer, Skill> secondaryMap = mapSkillsByLevel(hero, secondarySkills);
    List<String> skillNames = new ArrayList<>();
    for (Skill skill : primaryMap.values()) {
        skillNames.add(skill.getName());
    }
    for (Skill skill : secondaryMap.values()) {
        skillNames.add(skill.getName());
    }
    return skillNames;
}
Also used : Skill(com.herocraftonline.heroes.characters.skill.Skill) ActiveSkill(com.herocraftonline.heroes.characters.skill.ActiveSkill) HeroClass(com.herocraftonline.heroes.characters.classes.HeroClass) Hero(com.herocraftonline.heroes.characters.Hero) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Example 2 with Skill

use of com.herocraftonline.heroes.characters.skill.Skill in project MagicPlugin by elBukkit.

the class HeroesManager method getSkillLevel.

public int getSkillLevel(Player player, String skillName) {
    Skill skill = skills.getSkill(skillName);
    if (skill == null)
        return 0;
    Hero hero = getHero(player);
    if (hero == null)
        return 0;
    return SkillConfigManager.getUseSetting(hero, skill, SkillSetting.LEVEL, 1, true);
}
Also used : Skill(com.herocraftonline.heroes.characters.skill.Skill) ActiveSkill(com.herocraftonline.heroes.characters.skill.ActiveSkill) Hero(com.herocraftonline.heroes.characters.Hero)

Example 3 with Skill

use of com.herocraftonline.heroes.characters.skill.Skill in project MagicPlugin by elBukkit.

the class HeroesManager method createSkillSpell.

@Nullable
public SpellTemplate createSkillSpell(MagicController controller, String skillName) {
    if (skills == null)
        return null;
    Skill skill = skills.getSkill(skillName);
    if (skill == null)
        return null;
    MageSpell newSpell = new HeroesSkillSpell();
    newSpell.initialize(controller);
    ConfigurationSection config = new MemoryConfiguration();
    String iconURL = SkillConfigManager.getRaw(skill, "icon-url", SkillConfigManager.getRaw(skill, "icon_url", null));
    if (iconURL == null || iconURL.isEmpty()) {
        String icon = SkillConfigManager.getRaw(skill, "icon", null);
        if (icon == null || icon.isEmpty()) {
            config.set("icon", controller.getDefaultSkillIcon());
        } else if (icon.startsWith("http://")) {
            config.set("icon_url", icon);
        } else {
            config.set("icon", icon);
        }
    } else {
        config.set("icon_url", iconURL);
    }
    String iconDisabledURL = SkillConfigManager.getRaw(skill, "icon-disabled-url", SkillConfigManager.getRaw(skill, "icon_disabled_url", null));
    if (iconDisabledURL == null || iconDisabledURL.isEmpty()) {
        String icon = SkillConfigManager.getRaw(skill, "icon-disabled", SkillConfigManager.getRaw(skill, "icon_disabled", null));
        if (icon != null && !icon.isEmpty()) {
            if (icon.startsWith("http://")) {
                config.set("icon_disabled_url", icon);
            } else {
                config.set("icon_disabled", icon);
            }
        }
    } else {
        config.set("icon_disabled_url", iconDisabledURL);
    }
    String nameTemplate = controller.getMessages().get("skills.item_name", "$skill");
    String skillDisplayName = SkillConfigManager.getRaw(skill, "name", skill.getName());
    config.set("name", nameTemplate.replace("$skill", skillDisplayName));
    config.set("category", "skills");
    String descriptionTemplate = controller.getMessages().get("skills.item_description", "$description");
    descriptionTemplate = descriptionTemplate.replace("$description", SkillConfigManager.getRaw(skill, "description", ""));
    config.set("description", descriptionTemplate);
    newSpell.loadTemplate("heroes*" + skillName, config);
    return newSpell;
}
Also used : Skill(com.herocraftonline.heroes.characters.skill.Skill) ActiveSkill(com.herocraftonline.heroes.characters.skill.ActiveSkill) MemoryConfiguration(org.bukkit.configuration.MemoryConfiguration) MageSpell(com.elmakers.mine.bukkit.api.spell.MageSpell) ConfigurationSection(org.bukkit.configuration.ConfigurationSection) Nullable(javax.annotation.Nullable)

Example 4 with Skill

use of com.herocraftonline.heroes.characters.skill.Skill in project MagicPlugin by elBukkit.

the class HeroesManager method mapSkillsByLevel.

private Multimap<Integer, Skill> mapSkillsByLevel(Hero hero, Collection<String> skillNames) {
    Multimap<Integer, Skill> skillMap = TreeMultimap.create(Ordering.natural(), new Comparator<Skill>() {

        @Override
        public int compare(Skill skill1, Skill skill2) {
            return skill1.getName().compareTo(skill2.getName());
        }
    });
    for (String skillName : skillNames) {
        Skill skill = skills.getSkill(skillName);
        if (skill == null)
            continue;
        int level = SkillConfigManager.getUseSetting(hero, skill, SkillSetting.LEVEL, 1, true);
        skillMap.put(level, skill);
    }
    return skillMap;
}
Also used : Skill(com.herocraftonline.heroes.characters.skill.Skill) ActiveSkill(com.herocraftonline.heroes.characters.skill.ActiveSkill)

Aggregations

ActiveSkill (com.herocraftonline.heroes.characters.skill.ActiveSkill)4 Skill (com.herocraftonline.heroes.characters.skill.Skill)4 Hero (com.herocraftonline.heroes.characters.Hero)2 MageSpell (com.elmakers.mine.bukkit.api.spell.MageSpell)1 HeroClass (com.herocraftonline.heroes.characters.classes.HeroClass)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Nullable (javax.annotation.Nullable)1 ConfigurationSection (org.bukkit.configuration.ConfigurationSection)1 MemoryConfiguration (org.bukkit.configuration.MemoryConfiguration)1