Cleaned up level up triggers (format remains the same)

This commit is contained in:
Aria Sangarin 2020-03-04 14:53:19 +01:00
parent 2ea339bc9b
commit e92b3e655f

View File

@ -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(event.hasProfession()) {
{ String prof = event.getProfession().getId().toLowerCase();
if (event1.startsWith("level-up-") && event1.substring(9).equalsIgnoreCase(event.getProfession().getId())) { processTrigger(player, profess, "level-up-" + prof);
profess.getEventTriggers(event1).getTriggers().forEach(trigger -> trigger.apply(player)); processTrigger(player, profess, "level-up-" + prof + "-" + event.getNewLevel());
break; } else {
} processTrigger(player, profess, "level-up");
if (event1.startsWith("level-up-") && event1.substring(9).equalsIgnoreCase(event.getProfession().getId() + "-" + event.getNewLevel())) { processTrigger(player, profess, "level-up-" + event.getNewLevel());
profess.getEventTriggers(event1).getTriggers().forEach(trigger -> trigger.apply(player)); if(profess.getMaxLevel() == event.getNewLevel())
break; processTrigger(player, profess, "level-up-max");
} }
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)); public void processTrigger(PlayerData player, PlayerClass profess, String trigger) {
} if(profess.hasEventTriggers(trigger)) profess.getEventTriggers(trigger).getTriggers().forEach(t -> t.apply(player));
}
if (!event.hasProfession() && profess.hasEventTriggers("level-up"))
profess.getEventTriggers("level-up").getTriggers().forEach(trigger -> trigger.apply(player));
if (!event.hasProfession() && profess.hasEventTriggers("level-up-" + event.getNewLevel()))
profess.getEventTriggers("level-up-" + event.getNewLevel()).getTriggers().forEach(trigger -> trigger.apply(player));
if (!event.hasProfession() && profess.hasEventTriggers("level-up-max"))
if(event.getNewLevel() == profess.getMaxLevel())
profess.getEventTriggers("level-up-max").getTriggers().forEach(trigger -> trigger.apply(player));
} }
} }