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.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
|
||||||
import net.Indyuce.mmocore.MMOCore;
|
|
||||||
import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent;
|
import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
||||||
@ -21,17 +20,18 @@ public class LevelUpEventTrigger implements EventTriggerHandler {
|
|||||||
PlayerData player = event.getData();
|
PlayerData player = event.getData();
|
||||||
PlayerClass profess = player.getProfess();
|
PlayerClass profess = player.getProfess();
|
||||||
|
|
||||||
if(event.hasProfession()) {
|
for(int i = event.getOldLevel(); i < event.getNewLevel(); i++) {
|
||||||
String prof = event.getProfession().getId().toLowerCase();
|
int level = i + 1;
|
||||||
MMOCore.debug(2, "[DEBUG] Looking for triggers: level-up-" + prof);
|
if(event.hasProfession()) {
|
||||||
processTrigger(player, profess, "level-up-" + prof);
|
String prof = event.getProfession().getId().toLowerCase();
|
||||||
processTrigger(player, profess, "level-up-" + prof + "-" + event.getNewLevel());
|
processTrigger(player, profess, "level-up-" + prof);
|
||||||
} else {
|
processTrigger(player, profess, "level-up-" + prof + "-" + level);
|
||||||
MMOCore.debug(2, "[DEBUG] Normal level up trigger.");
|
} else {
|
||||||
processTrigger(player, profess, "level-up");
|
processTrigger(player, profess, "level-up");
|
||||||
processTrigger(player, profess, "level-up-" + event.getNewLevel());
|
processTrigger(player, profess, "level-up-" + level);
|
||||||
if(profess.getMaxLevel() == event.getNewLevel())
|
if(profess.getMaxLevel() == level)
|
||||||
processTrigger(player, profess, "level-up-max");
|
processTrigger(player, profess, "level-up-max");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,21 +20,25 @@ public class MultipleLevelUpEventTrigger implements EventTriggerHandler {
|
|||||||
public void a(PlayerLevelUpEvent event) {
|
public void a(PlayerLevelUpEvent event) {
|
||||||
PlayerData player = event.getData();
|
PlayerData player = event.getData();
|
||||||
PlayerClass profess = player.getProfess();
|
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) {
|
public void processTrigger(PlayerData player, PlayerClass profess, String trigger) {
|
||||||
|
Loading…
Reference in New Issue
Block a user