use of au.com.mineauz.minigamesregions.executors.RegionExecutor in project Minigames by AddstarMC.
the class MenuItemTrigger method onClick.
@Override
public ItemStack onClick() {
if (region != null) {
RegionExecutor exec = new RegionExecutor(trigger);
region.addExecutor(exec);
previous.addItem(new MenuItemRegionExecutor(region, exec));
previous.displayMenu(getContainer().getViewer());
} else {
NodeExecutor exec = new NodeExecutor(trigger);
node.addExecutor(exec);
previous.addItem(new MenuItemNodeExecutor(node, exec));
previous.displayMenu(getContainer().getViewer());
}
return null;
}
use of au.com.mineauz.minigamesregions.executors.RegionExecutor in project Minigames by AddstarMC.
the class TriggerRandomAction method executeRegionAction.
@Override
public void executeRegionAction(MinigamePlayer player, Region region) {
List<RegionExecutor> exs = new ArrayList<>();
for (RegionExecutor ex : region.getExecutors()) {
if (ex.getTrigger().getName().equalsIgnoreCase("RANDOM"))
exs.add(ex);
}
Collections.shuffle(exs);
if (timesTriggered.getFlag() == 1) {
if (region.checkConditions(exs.get(0), player) && exs.get(0).canBeTriggered(player))
region.execute(exs.get(0), player);
} else {
for (int i = 0; i < timesTriggered.getFlag(); i++) {
if (!randomPerTrigger.getFlag()) {
if (i == timesTriggered.getFlag())
break;
if (region.checkConditions(exs.get(i), player) && exs.get(i).canBeTriggered(player))
region.execute(exs.get(i), player);
} else {
if (region.checkConditions(exs.get(0), player) && exs.get(0).canBeTriggered(player))
region.execute(exs.get(0), player);
Collections.shuffle(exs);
}
}
}
}
Aggregations