Search in sources :

Example 11 with InteractionInterface

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

the class MatchBlockCondition method displayMenu.

@Override
public boolean displayMenu(MinigamePlayer player, Menu prev) {
    Menu m = new Menu(3, "Match Block", player);
    m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, prev), m.getSize() - 9);
    final MenuItemCustom c = new MenuItemCustom("Auto Set Block", MinigameUtils.stringToList("Click here with a;block you wish to;match to."), Material.ITEM_FRAME);
    m.addItem(c, m.getSize() - 1);
    final MinigamePlayer ply = m.getViewer();
    final MenuItemString btype = new MenuItemString("Block Type", Material.STONE, new Callback<String>() {

        @Override
        public void setValue(String value) {
            if (Material.matchMaterial(value.toUpperCase()) != null)
                type.setFlag(value.toUpperCase());
            else
                ply.sendMessage("No block found by that name!", "error");
        }

        @Override
        public String getValue() {
            return type.getFlag();
        }
    });
    m.addItem(btype);
    final MenuItemBoolean busedur = (MenuItemBoolean) useDur.getMenuItem("Use Data Values", Material.ENDER_PEARL);
    m.addItem(busedur);
    final MenuItemInteger bdur = (MenuItemInteger) dur.getMenuItem("Data Value", Material.PAPER, 0, 16);
    m.addItem(bdur);
    c.setClickItem(new InteractionInterface() {

        @Override
        public Object interact(Object object) {
            ItemStack i = (ItemStack) object;
            type.setFlag(i.getType().toString());
            useDur.setFlag(true);
            dur.setFlag(((Short) i.getDurability()).intValue());
            bdur.updateDescription();
            busedur.updateDescription();
            btype.updateDescription();
            return c.getItem();
        }
    });
    addInvertMenuItem(m);
    m.displayMenu(player);
    return true;
}
Also used : MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) MenuItemInteger(au.com.mineauz.minigames.menu.MenuItemInteger) MenuItemPage(au.com.mineauz.minigames.menu.MenuItemPage) MenuItemString(au.com.mineauz.minigames.menu.MenuItemString) MenuItemCustom(au.com.mineauz.minigames.menu.MenuItemCustom) MenuItemString(au.com.mineauz.minigames.menu.MenuItemString) InteractionInterface(au.com.mineauz.minigames.menu.InteractionInterface) MenuItemBoolean(au.com.mineauz.minigames.menu.MenuItemBoolean) Menu(au.com.mineauz.minigames.menu.Menu) ItemStack(org.bukkit.inventory.ItemStack)

Example 12 with InteractionInterface

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

the class MenuItemConditionAdd method onClick.

@Override
public ItemStack onClick() {
    Menu m = new Menu(6, "Conditions", getContainer().getViewer());
    m.setPreviousPage(getContainer());
    Map<String, Menu> cats = new HashMap<String, Menu>();
    List<String> cons = new ArrayList<String>(Conditions.getAllConditionNames());
    Collections.sort(cons);
    for (String con : cons) {
        if ((Conditions.getConditionByName(con).useInNodes() && nexec != null) || (Conditions.getConditionByName(con).useInRegions() && rexec != null)) {
            String catname = Conditions.getConditionByName(con).getCategory();
            if (catname == null)
                catname = "misc conditions";
            catname.toLowerCase();
            Menu cat = null;
            if (!cats.containsKey(catname)) {
                cat = new Menu(6, MinigameUtils.capitalize(catname), getContainer().getViewer());
                cats.put(catname, cat);
                m.addItem(new MenuItemPage(MinigameUtils.capitalize(catname), Material.CHEST, cat));
                cat.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, m), cat.getSize() - 9);
            } else
                cat = cats.get(catname);
            MenuItemCustom c = new MenuItemCustom(MinigameUtils.capitalize(con), Material.PAPER);
            final String fcon = con;
            c.setClick(new InteractionInterface() {

                @Override
                public Object interact(Object object) {
                    ConditionInterface condition = Conditions.getConditionByName(fcon);
                    if (rexec != null) {
                        rexec.addCondition(condition);
                        getContainer().addItem(new MenuItemCondition(MinigameUtils.capitalize(fcon), Material.PAPER, rexec, condition));
                    } else {
                        nexec.addCondition(condition);
                        getContainer().addItem(new MenuItemCondition(MinigameUtils.capitalize(fcon), Material.PAPER, nexec, condition));
                    }
                    getContainer().displayMenu(getContainer().getViewer());
                    return null;
                }
            });
            cat.addItem(c);
        }
    }
    m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, getContainer()), m.getSize() - 9);
    m.displayMenu(getContainer().getViewer());
    return null;
}
Also used : HashMap(java.util.HashMap) MenuItemPage(au.com.mineauz.minigames.menu.MenuItemPage) ArrayList(java.util.ArrayList) MenuItemCustom(au.com.mineauz.minigames.menu.MenuItemCustom) InteractionInterface(au.com.mineauz.minigames.menu.InteractionInterface) ConditionInterface(au.com.mineauz.minigamesregions.conditions.ConditionInterface) Menu(au.com.mineauz.minigames.menu.Menu)

Example 13 with InteractionInterface

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

the class MenuItemNodeExecutor 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)

Example 14 with InteractionInterface

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

the class MinigameStats method createStatSelectMenu.

/**
	 * Creates a menu that allows you to select a statistic
	 * @param parent The parent menu
	 * @param statCallback The callback to be invoked when the statistic is chosen. Note: only the setValue() method will be called.
	 * @return The menu to display
	 */
public static Menu createStatSelectMenu(final Menu parent, final Callback<MinigameStat> statCallback) {
    final Menu submenu = new Menu(6, "Select Statistic", parent.getViewer());
    for (final MinigameStat stat : getAllStats().values()) {
        MenuItemCustom item = new MenuItemCustom(WordUtils.capitalizeFully(stat.getDisplayName()), Material.BOOK_AND_QUILL);
        item.setClick(new InteractionInterface() {

            @Override
            public Object interact(Object object) {
                statCallback.setValue(stat);
                parent.displayMenu(submenu.getViewer());
                return null;
            }
        });
        submenu.addItem(item);
    }
    submenu.addItem(new MenuItemBack(parent), submenu.getSize() - 9);
    return submenu;
}
Also used : InteractionInterface(au.com.mineauz.minigames.menu.InteractionInterface) MenuItemBack(au.com.mineauz.minigames.menu.MenuItemBack) Menu(au.com.mineauz.minigames.menu.Menu) MenuItemCustom(au.com.mineauz.minigames.menu.MenuItemCustom)

Example 15 with InteractionInterface

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

the class RegionModule method addEditMenuOptions.

@Override
public void addEditMenuOptions(Menu menu) {
    final MenuItemCustom c = new MenuItemCustom("Regions and Nodes", Material.DIAMOND_BLOCK);
    final Menu fmenu = menu;
    c.setClick(new InteractionInterface() {

        @Override
        public Object interact(Object object) {
            displayMenu(c.getContainer().getViewer(), fmenu);
            return null;
        }
    });
    menu.addItem(c);
}
Also used : InteractionInterface(au.com.mineauz.minigames.menu.InteractionInterface) 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