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;
}
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();
}
Aggregations