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