Search in sources :

Example 6 with MyPetLevelUpEvent

use of de.Keyle.MyPet.api.event.MyPetLevelUpEvent in project MyPet by xXKeyleXx.

the class MyPetExperience method addExp.

public double addExp(EntityType type, int percent) {
    MonsterExperience monsterExperience = MonsterExperience.getMonsterExperience(type);
    if (monsterExperience.getEntityType() != EntityType.UNKNOWN) {
        double exp = monsterExperience.getRandomExp() / 100. * percent;
        MyPetExpEvent expEvent = new MyPetExpEvent(myPet, this.exp, Math.min(levelCapExp, this.exp + exp));
        Bukkit.getServer().getPluginManager().callEvent(expEvent);
        if (expEvent.isCancelled()) {
            return 0;
        }
        int tmpLvl = getLevel();
        this.exp = expEvent.getExp();
        if (tmpLvl < getLevel()) {
            Bukkit.getServer().getPluginManager().callEvent(new MyPetLevelUpEvent(myPet, getLevel(), tmpLvl));
        }
        return expEvent.getNewExp() - expEvent.getOldExp();
    }
    return 0;
}
Also used : MyPetLevelUpEvent(de.Keyle.MyPet.api.event.MyPetLevelUpEvent) MonsterExperience(de.Keyle.MyPet.api.skill.experience.MonsterExperience) MyPetExpEvent(de.Keyle.MyPet.api.event.MyPetExpEvent)

Example 7 with MyPetLevelUpEvent

use of de.Keyle.MyPet.api.event.MyPetLevelUpEvent in project MyPet by xXKeyleXx.

the class MyPetExperience method addExp.

public double addExp(double exp) {
    MyPetExpEvent event = new MyPetExpEvent(myPet, this.exp, Math.min(levelCapExp, this.exp + exp));
    Bukkit.getServer().getPluginManager().callEvent(event);
    if (event.isCancelled()) {
        return 0;
    }
    int tmpLvl = getLevel();
    this.exp = event.getExp();
    if (tmpLvl < getLevel()) {
        Bukkit.getServer().getPluginManager().callEvent(new MyPetLevelUpEvent(myPet, getLevel(), tmpLvl));
    }
    return event.getNewExp() - event.getOldExp();
}
Also used : MyPetLevelUpEvent(de.Keyle.MyPet.api.event.MyPetLevelUpEvent) MyPetExpEvent(de.Keyle.MyPet.api.event.MyPetExpEvent)

Example 8 with MyPetLevelUpEvent

use of de.Keyle.MyPet.api.event.MyPetLevelUpEvent in project MyPet by xXKeyleXx.

the class MyPetExperience method addExp.

public double addExp(EntityType type) {
    MonsterExperience monsterExperience = MonsterExperience.getMonsterExperience(type);
    if (monsterExperience.getEntityType() != EntityType.UNKNOWN) {
        MyPetExpEvent expEvent = new MyPetExpEvent(myPet, this.exp, Math.min(levelCapExp, monsterExperience.getRandomExp() + this.exp));
        Bukkit.getServer().getPluginManager().callEvent(expEvent);
        if (expEvent.isCancelled()) {
            return 0;
        }
        int tmpLvl = getLevel();
        this.exp = expEvent.getExp();
        if (tmpLvl < getLevel()) {
            Bukkit.getServer().getPluginManager().callEvent(new MyPetLevelUpEvent(myPet, getLevel(), tmpLvl));
        }
        return expEvent.getNewExp() - expEvent.getOldExp();
    }
    return 0;
}
Also used : MyPetLevelUpEvent(de.Keyle.MyPet.api.event.MyPetLevelUpEvent) MonsterExperience(de.Keyle.MyPet.api.skill.experience.MonsterExperience) MyPetExpEvent(de.Keyle.MyPet.api.event.MyPetExpEvent)

Aggregations

MyPetLevelUpEvent (de.Keyle.MyPet.api.event.MyPetLevelUpEvent)8 MyPetExpEvent (de.Keyle.MyPet.api.event.MyPetExpEvent)5 MyPetLevelDownEvent (de.Keyle.MyPet.api.event.MyPetLevelDownEvent)2 MonsterExperience (de.Keyle.MyPet.api.skill.experience.MonsterExperience)2 MyPet (de.Keyle.MyPet.api.entity.MyPet)1 SkillName (de.Keyle.MyPet.api.skill.SkillName)1 Upgrade (de.Keyle.MyPet.api.skill.Upgrade)1 Skill (de.Keyle.MyPet.api.skill.skilltree.Skill)1 Skilltree (de.Keyle.MyPet.api.skill.skilltree.Skilltree)1 EventHandler (org.bukkit.event.EventHandler)1