Search in sources :

Example 6 with RegionExecutor

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;
}
Also used : RegionExecutor(au.com.mineauz.minigamesregions.executors.RegionExecutor) NodeExecutor(au.com.mineauz.minigamesregions.executors.NodeExecutor)

Example 7 with RegionExecutor

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);
            }
        }
    }
}
Also used : RegionExecutor(au.com.mineauz.minigamesregions.executors.RegionExecutor) ArrayList(java.util.ArrayList)

Aggregations

RegionExecutor (au.com.mineauz.minigamesregions.executors.RegionExecutor)7 NodeExecutor (au.com.mineauz.minigamesregions.executors.NodeExecutor)4 MinigamePlayer (au.com.mineauz.minigames.MinigamePlayer)2 Minigame (au.com.mineauz.minigames.minigame.Minigame)2 ActionInterface (au.com.mineauz.minigamesregions.actions.ActionInterface)2 ConditionInterface (au.com.mineauz.minigamesregions.conditions.ConditionInterface)2 MenuItemNode (au.com.mineauz.minigamesregions.menuitems.MenuItemNode)2 MenuItemRegion (au.com.mineauz.minigamesregions.menuitems.MenuItemRegion)2 ArrayList (java.util.ArrayList)2 EventHandler (org.bukkit.event.EventHandler)2 Menu (au.com.mineauz.minigames.menu.Menu)1 MenuItem (au.com.mineauz.minigames.menu.MenuItem)1 MenuItemPage (au.com.mineauz.minigames.menu.MenuItemPage)1 Location (org.bukkit.Location)1 World (org.bukkit.World)1