use of au.com.mineauz.minigamesregions.executors.NodeExecutor in project Minigames by AddstarMC.
the class TriggerRandomAction method executeNodeAction.
@Override
public void executeNodeAction(MinigamePlayer player, Node node) {
List<NodeExecutor> exs = new ArrayList<>();
for (NodeExecutor ex : node.getExecutors()) {
if (ex.getTrigger().getName().equalsIgnoreCase("RANDOM"))
exs.add(ex);
}
Collections.shuffle(exs);
if (timesTriggered.getFlag() == 1) {
if (node.checkConditions(exs.get(0), player) && exs.get(0).canBeTriggered(player))
node.execute(exs.get(0), player);
} else {
for (int i = 0; i < timesTriggered.getFlag(); i++) {
if (!randomPerTrigger.getFlag()) {
if (i == timesTriggered.getFlag())
break;
if (node.checkConditions(exs.get(i), player) && exs.get(i).canBeTriggered(player))
node.execute(exs.get(i), player);
} else {
if (node.checkConditions(exs.get(0), player) && exs.get(0).canBeTriggered(player))
node.execute(exs.get(0), player);
Collections.shuffle(exs);
}
}
}
}
Aggregations