Search in sources :

Example 1 with Hero

use of com.herocraftonline.heroes.characters.Hero in project MyPet by xXKeyleXx.

the class HeroesHook method canHurt.

@Override
public boolean canHurt(Player attacker, Player defender) {
    try {
        Hero heroAttacker = heroes.getCharacterManager().getHero(attacker);
        Hero heroDefender = heroes.getCharacterManager().getHero(defender);
        int attackerLevel = heroAttacker.getTieredLevel(false);
        int defenderLevel = heroDefender.getTieredLevel(false);
        if (Math.abs(attackerLevel - defenderLevel) > Heroes.properties.pvpLevelRange) {
            return false;
        }
        if ((defenderLevel < Heroes.properties.minPvpLevel) || (attackerLevel < Heroes.properties.minPvpLevel)) {
            return false;
        }
        HeroParty party = heroDefender.getParty();
        if ((party != null) && (party.isNoPvp()) && party.isPartyMember(heroAttacker)) {
            return false;
        }
    } catch (Throwable ignored) {
    }
    return true;
}
Also used : HeroParty(com.herocraftonline.heroes.characters.party.HeroParty) Hero(com.herocraftonline.heroes.characters.Hero)

Example 2 with Hero

use of com.herocraftonline.heroes.characters.Hero 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 3 with Hero

use of com.herocraftonline.heroes.characters.Hero 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 4 with Hero

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

the class HeroesManager method clearCooldown.

public void clearCooldown(Player player) {
    Hero hero = getHero(player);
    if (hero == null)
        return;
    hero.clearCooldowns();
}
Also used : Hero(com.herocraftonline.heroes.characters.Hero)

Example 5 with Hero

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

the class HeroesManager method isInParty.

public boolean isInParty(Player source, Player check, boolean pvpCheck) {
    Hero sourceHero = getHero(source);
    Hero checkHero = getHero(check);
    if (sourceHero == null || checkHero == null)
        return false;
    HeroParty party = sourceHero.getParty();
    if (party == null || (pvpCheck && !party.isNoPvp()))
        return false;
    return party.getMembers().contains(checkHero);
}
Also used : HeroParty(com.herocraftonline.heroes.characters.party.HeroParty) Hero(com.herocraftonline.heroes.characters.Hero)

Aggregations

Hero (com.herocraftonline.heroes.characters.Hero)14 HeroClass (com.herocraftonline.heroes.characters.classes.HeroClass)4 HeroParty (com.herocraftonline.heroes.characters.party.HeroParty)2 ActiveSkill (com.herocraftonline.heroes.characters.skill.ActiveSkill)2 Skill (com.herocraftonline.heroes.characters.skill.Skill)2 HashSet (java.util.HashSet)2 Player (org.bukkit.entity.Player)2 PassiveSkill (com.herocraftonline.heroes.characters.skill.PassiveSkill)1 ArrayList (java.util.ArrayList)1 Nullable (javax.annotation.Nullable)1