forked from Upstream/mmocore
Cleaned up level up triggers (format remains the same)
This commit is contained in:
parent
2ea339bc9b
commit
e92b3e655f
@ -20,29 +20,20 @@ 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 (String event1 : profess.getEventTriggers())
|
|
||||||
{
|
|
||||||
if (event1.startsWith("level-up-") && event1.substring(9).equalsIgnoreCase(event.getProfession().getId())) {
|
|
||||||
profess.getEventTriggers(event1).getTriggers().forEach(trigger -> trigger.apply(player));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (event1.startsWith("level-up-") && event1.substring(9).equalsIgnoreCase(event.getProfession().getId() + "-" + event.getNewLevel())) {
|
|
||||||
profess.getEventTriggers(event1).getTriggers().forEach(trigger -> trigger.apply(player));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (event1.startsWith("level-up-") && event1.substring(9).equalsIgnoreCase(event.getProfession().getId() + "-max")) {
|
|
||||||
if(event.getNewLevel() == profess.getMaxLevel())
|
|
||||||
profess.getEventTriggers(event1).getTriggers().forEach(trigger -> trigger.apply(player));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!event.hasProfession() && profess.hasEventTriggers("level-up"))
|
if(event.hasProfession()) {
|
||||||
profess.getEventTriggers("level-up").getTriggers().forEach(trigger -> trigger.apply(player));
|
String prof = event.getProfession().getId().toLowerCase();
|
||||||
if (!event.hasProfession() && profess.hasEventTriggers("level-up-" + event.getNewLevel()))
|
processTrigger(player, profess, "level-up-" + prof);
|
||||||
profess.getEventTriggers("level-up-" + event.getNewLevel()).getTriggers().forEach(trigger -> trigger.apply(player));
|
processTrigger(player, profess, "level-up-" + prof + "-" + event.getNewLevel());
|
||||||
if (!event.hasProfession() && profess.hasEventTriggers("level-up-max"))
|
} else {
|
||||||
if(event.getNewLevel() == profess.getMaxLevel())
|
processTrigger(player, profess, "level-up");
|
||||||
profess.getEventTriggers("level-up-max").getTriggers().forEach(trigger -> trigger.apply(player));
|
processTrigger(player, profess, "level-up-" + event.getNewLevel());
|
||||||
|
if(profess.getMaxLevel() == event.getNewLevel())
|
||||||
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user