mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-24 00:15:16 +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,17 +20,18 @@ public class LevelUpEventTrigger implements EventTriggerHandler {
|
||||
PlayerData player = event.getData();
|
||||
PlayerClass profess = player.getProfess();
|
||||
|
||||
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());
|
||||
} 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-max");
|
||||
for(int i = event.getOldLevel(); i < event.getNewLevel(); i++) {
|
||||
int level = i + 1;
|
||||
if(event.hasProfession()) {
|
||||
String prof = event.getProfession().getId().toLowerCase();
|
||||
processTrigger(player, profess, "level-up-" + prof);
|
||||
processTrigger(player, profess, "level-up-" + prof + "-" + level);
|
||||
} else {
|
||||
processTrigger(player, profess, "level-up");
|
||||
processTrigger(player, profess, "level-up-" + level);
|
||||
if(profess.getMaxLevel() == level)
|
||||
processTrigger(player, profess, "level-up-max");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,21 +20,25 @@ public class MultipleLevelUpEventTrigger implements EventTriggerHandler {
|
||||
public void a(PlayerLevelUpEvent event) {
|
||||
PlayerData player = event.getData();
|
||||
PlayerClass profess = player.getProfess();
|
||||
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) {
|
||||
DecimalFormat f = new DecimalFormat("#");
|
||||
if (event.hasProfession()) {
|
||||
processTrigger(player, profess, "level-up-multiple-" + event.getProfession().getId().toLowerCase() + "-" + f.format(multiple));
|
||||
} else {
|
||||
processTrigger(player, profess, "level-up-multiple-" + f.format(multiple));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 (level / multiple % 1 == 0) {
|
||||
DecimalFormat f = new DecimalFormat("#");
|
||||
if (event.hasProfession()) {
|
||||
processTrigger(player, profess, "level-up-multiple-" + event.getProfession().getId().toLowerCase() + "-" + f.format(multiple));
|
||||
} else {
|
||||
processTrigger(player, profess, "level-up-multiple-" + f.format(multiple));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void processTrigger(PlayerData player, PlayerClass profess, String trigger) {
|
||||
|
Loading…
Reference in New Issue
Block a user