mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-28 00:55:29 +01:00
level-up
triggers now work when leveling up more than 1 level at once
This commit is contained in:
parent
7b16bced13
commit
ecf31ff8ee
@ -3,7 +3,6 @@ package net.Indyuce.mmocore.api.player.profess.event.trigger;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
||||
@ -21,19 +20,20 @@ public class LevelUpEventTrigger implements EventTriggerHandler {
|
||||
PlayerData player = event.getData();
|
||||
PlayerClass profess = player.getProfess();
|
||||
|
||||
for(int i = event.getOldLevel(); i < event.getNewLevel(); i++) {
|
||||
int level = i + 1;
|
||||
if(event.hasProfession()) {
|
||||
String prof = event.getProfession().getId().toLowerCase();
|
||||
MMOCore.debug(2, "[DEBUG] Looking for triggers: level-up-" + prof);
|
||||
processTrigger(player, profess, "level-up-" + prof);
|
||||
processTrigger(player, profess, "level-up-" + prof + "-" + event.getNewLevel());
|
||||
processTrigger(player, profess, "level-up-" + prof + "-" + level);
|
||||
} else {
|
||||
MMOCore.debug(2, "[DEBUG] Normal level up trigger.");
|
||||
processTrigger(player, profess, "level-up");
|
||||
processTrigger(player, profess, "level-up-" + event.getNewLevel());
|
||||
if(profess.getMaxLevel() == event.getNewLevel())
|
||||
processTrigger(player, profess, "level-up-" + level);
|
||||
if(profess.getMaxLevel() == level)
|
||||
processTrigger(player, profess, "level-up-max");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void processTrigger(PlayerData player, PlayerClass profess, String trigger) {
|
||||
if(profess.hasEventTriggers(trigger)) profess.getEventTriggers(trigger).getTriggers().forEach(t -> t.apply(player));
|
||||
|
@ -20,11 +20,15 @@ public class MultipleLevelUpEventTrigger implements EventTriggerHandler {
|
||||
public void a(PlayerLevelUpEvent event) {
|
||||
PlayerData player = event.getData();
|
||||
PlayerClass profess = player.getProfess();
|
||||
|
||||
for(int i = event.getOldLevel(); i < event.getNewLevel(); i++) {
|
||||
int level = i + 1;
|
||||
|
||||
for (String t : profess.getEventTriggers()){
|
||||
if (t.startsWith("level-up-multiple")) {
|
||||
String[] split = t.split("-");
|
||||
double multiple = Double.parseDouble(split[split.length-1]);
|
||||
if (event.getNewLevel()/multiple % 1 == 0) {
|
||||
if (level / multiple % 1 == 0) {
|
||||
DecimalFormat f = new DecimalFormat("#");
|
||||
if (event.hasProfession()) {
|
||||
processTrigger(player, profess, "level-up-multiple-" + event.getProfession().getId().toLowerCase() + "-" + f.format(multiple));
|
||||
@ -34,7 +38,7 @@ public class MultipleLevelUpEventTrigger implements EventTriggerHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void processTrigger(PlayerData player, PlayerClass profess, String trigger) {
|
||||
|
Loading…
Reference in New Issue
Block a user