Search in sources :

Example 6 with MyPetExpEvent

use of de.Keyle.MyPet.api.event.MyPetExpEvent 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)

Example 7 with MyPetExpEvent

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

the class MyPetExperience method removeExp.

public void removeExp(double exp) {
    exp = this.exp - exp < 0 ? this.exp : exp;
    MyPetExpEvent expEvent = new MyPetExpEvent(myPet, this.exp, this.exp - exp);
    Bukkit.getServer().getPluginManager().callEvent(expEvent);
    if (expEvent.isCancelled()) {
        return;
    }
    this.exp = expEvent.getExp();
}
Also used : MyPetExpEvent(de.Keyle.MyPet.api.event.MyPetExpEvent)

Aggregations

MyPetExpEvent (de.Keyle.MyPet.api.event.MyPetExpEvent)7 MyPetLevelUpEvent (de.Keyle.MyPet.api.event.MyPetLevelUpEvent)5 MonsterExperience (de.Keyle.MyPet.api.skill.experience.MonsterExperience)2 MyPetLevelDownEvent (de.Keyle.MyPet.api.event.MyPetLevelDownEvent)1