Search in sources :

Example 16 with InteractionInterface

use of au.com.mineauz.minigames.menu.InteractionInterface in project Minigames by AddstarMC.

the class SpawnEntityAction method displayMenu.

@Override
public boolean displayMenu(MinigamePlayer player, Menu previous) {
    Menu m = new Menu(3, "Spawn Entity", player);
    m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, previous), m.getSize() - 9);
    List<String> options = new ArrayList<>();
    for (EntityType type : EntityType.values()) {
        if (type != EntityType.ITEM_FRAME && type != EntityType.LEASH_HITCH && type != EntityType.PLAYER && type != EntityType.COMPLEX_PART && type != EntityType.WEATHER && type != EntityType.LIGHTNING && type != EntityType.PAINTING && type != EntityType.UNKNOWN && type != EntityType.DROPPED_ITEM)
            options.add(MinigameUtils.capitalize(type.toString().replace("_", " ")));
    }
    m.addItem(new MenuItemList("Entity Type", Material.SKULL_ITEM, new Callback<String>() {

        @Override
        public void setValue(String value) {
            type.setFlag(value.toUpperCase().replace(" ", "_"));
            settings.clear();
            addBaseSettings();
        }

        @Override
        public String getValue() {
            return MinigameUtils.capitalize(type.getFlag().replace("_", " "));
        }
    }, options));
    m.addItem(new MenuItemDecimal("X Velocity", Material.ARROW, new Callback<Double>() {

        @Override
        public void setValue(Double value) {
            settings.put("velocityx", value.toString());
        }

        @Override
        public Double getValue() {
            return Double.valueOf(settings.get("velocityx"));
        }
    }, 0.5, 1, null, null));
    m.addItem(new MenuItemDecimal("Y Velocity", Material.ARROW, new Callback<Double>() {

        @Override
        public void setValue(Double value) {
            settings.put("velocityy", value.toString());
        }

        @Override
        public Double getValue() {
            return Double.valueOf(settings.get("velocityy"));
        }
    }, 0.5, 1, null, null));
    m.addItem(new MenuItemDecimal("Z Velocity", Material.ARROW, new Callback<Double>() {

        @Override
        public void setValue(Double value) {
            settings.put("velocityz", value.toString());
        }

        @Override
        public Double getValue() {
            return Double.valueOf(settings.get("velocityz"));
        }
    }, 0.5, 1, null, null));
    m.addItem(new MenuItemNewLine());
    final Menu eSet = new Menu(3, "Settings", player);
    final MenuItemPage backButton = new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, m);
    final MenuItemCustom cus = new MenuItemCustom("Entity Settings", Material.CHEST);
    final MinigamePlayer fply = player;
    cus.setClick(new InteractionInterface() {

        @Override
        public Object interact(Object object) {
            if (type.getFlag().equals("ZOMBIE")) {
                eSet.clearMenu();
                eSet.addItem(backButton, eSet.getSize() - 9);
                livingEntitySettings(eSet);
                eSet.displayMenu(fply);
                return null;
            }
            return cus.getItem();
        }
    });
    m.addItem(cus);
    m.displayMenu(player);
    return true;
}
Also used : MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) MenuItemPage(au.com.mineauz.minigames.menu.MenuItemPage) ArrayList(java.util.ArrayList) MenuItemNewLine(au.com.mineauz.minigames.menu.MenuItemNewLine) MenuItemString(au.com.mineauz.minigames.menu.MenuItemString) MenuItemCustom(au.com.mineauz.minigames.menu.MenuItemCustom) EntityType(org.bukkit.entity.EntityType) Callback(au.com.mineauz.minigames.menu.Callback) MenuItemList(au.com.mineauz.minigames.menu.MenuItemList) InteractionInterface(au.com.mineauz.minigames.menu.InteractionInterface) Menu(au.com.mineauz.minigames.menu.Menu) MenuItemDecimal(au.com.mineauz.minigames.menu.MenuItemDecimal)

Example 17 with InteractionInterface

use of au.com.mineauz.minigames.menu.InteractionInterface in project Minigames by AddstarMC.

the class RegionToolMode method onSetMode.

@Override
public void onSetMode(final MinigamePlayer player, MinigameTool tool) {
    tool.addSetting("Region", "None");
    final Menu m = new Menu(2, "Region Selection", player);
    if (player.isInMenu()) {
        m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, player.getMenu()), m.getSize() - 9);
    }
    final MinigameTool ftool = tool;
    m.addItem(new MenuItemString("Region Name", Material.PAPER, new Callback<String>() {

        @Override
        public void setValue(String value) {
            ftool.changeSetting("Region", value);
        }

        @Override
        public String getValue() {
            return ftool.getSetting("Region");
        }
    }));
    if (tool.getMinigame() != null) {
        // Node selection menu
        RegionModule module = RegionModule.getMinigameModule(tool.getMinigame());
        Menu regionMenu = new Menu(6, "Regions", player);
        List<MenuItem> items = new ArrayList<MenuItem>();
        for (final Region region : module.getRegions()) {
            MenuItemCustom item = new MenuItemCustom(region.getName(), Material.CHEST);
            // Set the node and go back to the main menu
            item.setClick(new InteractionInterface() {

                @Override
                public Object interact(Object object) {
                    ftool.changeSetting("Region", region.getName());
                    m.displayMenu(player);
                    return object;
                }
            });
            items.add(item);
        }
        regionMenu.addItems(items);
        regionMenu.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, m), regionMenu.getSize() - 9);
        m.addItem(new MenuItemPage("Edit Region", Material.CHEST, regionMenu));
    }
    m.displayMenu(player);
}
Also used : MenuItemPage(au.com.mineauz.minigames.menu.MenuItemPage) MinigameTool(au.com.mineauz.minigames.tool.MinigameTool) ArrayList(java.util.ArrayList) MenuItem(au.com.mineauz.minigames.menu.MenuItem) MenuItemString(au.com.mineauz.minigames.menu.MenuItemString) MenuItemCustom(au.com.mineauz.minigames.menu.MenuItemCustom) MenuItemString(au.com.mineauz.minigames.menu.MenuItemString) Callback(au.com.mineauz.minigames.menu.Callback) InteractionInterface(au.com.mineauz.minigames.menu.InteractionInterface) Menu(au.com.mineauz.minigames.menu.Menu)

Example 18 with InteractionInterface

use of au.com.mineauz.minigames.menu.InteractionInterface in project Minigames by AddstarMC.

the class MenuItemRegionExecutor method onClick.

@Override
public ItemStack onClick() {
    final MinigamePlayer fviewer = getContainer().getViewer();
    Menu m = new Menu(3, "Executor", fviewer);
    final Menu ffm = m;
    MenuItemCustom ca = new MenuItemCustom("Actions", Material.CHEST);
    ca.setClick(new InteractionInterface() {

        @Override
        public Object interact(Object object) {
            Actions.displayMenu(fviewer, ex, ffm);
            return null;
        }
    });
    m.addItem(ca);
    MenuItemCustom c2 = new MenuItemCustom("Conditions", Material.CHEST);
    c2.setClick(new InteractionInterface() {

        @Override
        public Object interact(Object object) {
            Conditions.displayMenu(fviewer, ex, ffm);
            return null;
        }
    });
    m.addItem(c2);
    m.addItem(new MenuItemNewLine());
    m.addItem(new MenuItemInteger("Trigger Count", MinigameUtils.stringToList("Number of times this;node can be;triggered"), Material.STONE, ex.getTriggerCountCallback(), 0, null));
    m.addItem(new MenuItemBoolean("Trigger Per Player", MinigameUtils.stringToList("Whether this node;is triggered per player;or just on count"), Material.ENDER_PEARL, ex.getIsTriggerPerPlayerCallback()));
    m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, getContainer()), m.getSize() - 9);
    m.displayMenu(fviewer);
    return null;
}
Also used : MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) InteractionInterface(au.com.mineauz.minigames.menu.InteractionInterface) MenuItemInteger(au.com.mineauz.minigames.menu.MenuItemInteger) MenuItemPage(au.com.mineauz.minigames.menu.MenuItemPage) MenuItemNewLine(au.com.mineauz.minigames.menu.MenuItemNewLine) MenuItemBoolean(au.com.mineauz.minigames.menu.MenuItemBoolean) Menu(au.com.mineauz.minigames.menu.Menu) MenuItemCustom(au.com.mineauz.minigames.menu.MenuItemCustom)

Aggregations

InteractionInterface (au.com.mineauz.minigames.menu.InteractionInterface)18 MenuItemCustom (au.com.mineauz.minigames.menu.MenuItemCustom)18 Menu (au.com.mineauz.minigames.menu.Menu)17 ArrayList (java.util.ArrayList)10 MenuItemPage (au.com.mineauz.minigames.menu.MenuItemPage)9 MinigamePlayer (au.com.mineauz.minigames.MinigamePlayer)6 Callback (au.com.mineauz.minigames.menu.Callback)6 MenuItemNewLine (au.com.mineauz.minigames.menu.MenuItemNewLine)5 MenuItemString (au.com.mineauz.minigames.menu.MenuItemString)5 MenuItem (au.com.mineauz.minigames.menu.MenuItem)4 MenuItemBoolean (au.com.mineauz.minigames.menu.MenuItemBoolean)4 MenuItemInteger (au.com.mineauz.minigames.menu.MenuItemInteger)4 MenuItemList (au.com.mineauz.minigames.menu.MenuItemList)4 MenuItemBack (au.com.mineauz.minigames.menu.MenuItemBack)2 MinigameTool (au.com.mineauz.minigames.tool.MinigameTool)2 FutureCallback (com.google.common.util.concurrent.FutureCallback)2 PlayerLoadout (au.com.mineauz.minigames.PlayerLoadout)1 MinigameType (au.com.mineauz.minigames.gametypes.MinigameType)1 GameMechanicBase (au.com.mineauz.minigames.mechanics.GameMechanicBase)1 MenuItemAddFlag (au.com.mineauz.minigames.menu.MenuItemAddFlag)1