Search in sources :

Example 11 with MenuItemBack

use of au.com.mineauz.minigames.menu.MenuItemBack 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 12 with MenuItemBack

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

the class GiveItemAction method displayMenu.

@Override
public boolean displayMenu(final MinigamePlayer player, Menu previous) {
    Menu m = new Menu(3, "Give Item", player);
    m.addItem(new MenuItemBack(previous), m.getSize() - 9);
    MenuItemString n = (MenuItemString) name.getMenuItem("Name", Material.NAME_TAG);
    n.setAllowNull(true);
    m.addItem(n);
    MenuItemString l = (MenuItemString) lore.getMenuItem("Lore", Material.PAPER, MinigameUtils.stringToList("Separate with semi-colons;for new lines"));
    l.setAllowNull(true);
    m.addItem(l);
    m.addItem(new MenuItemString("Type", Material.STONE, new Callback<String>() {

        @Override
        public void setValue(String value) {
            if (Material.getMaterial(value.toUpperCase()) != null) {
                type.setFlag(value.toUpperCase());
            } else
                player.sendMessage("Invalid item type!", "error");
        }

        @Override
        public String getValue() {
            return type.getFlag();
        }
    }));
    m.addItem(count.getMenuItem("Count", Material.STEP, 1, 64));
    m.addItem(damage.getMenuItem("Damage", Material.COBBLESTONE, 0, null));
    m.displayMenu(player);
    return true;
}
Also used : Callback(au.com.mineauz.minigames.menu.Callback) MenuItemBack(au.com.mineauz.minigames.menu.MenuItemBack) Menu(au.com.mineauz.minigames.menu.Menu) MenuItemString(au.com.mineauz.minigames.menu.MenuItemString) MenuItemString(au.com.mineauz.minigames.menu.MenuItemString)

Example 13 with MenuItemBack

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

the class SetEnabledAction method displayMenu.

@Override
public boolean displayMenu(MinigamePlayer player, Menu previous) {
    Menu m = new Menu(3, "Set Enabled", player);
    m.addItem(new MenuItemBack(previous), m.getSize() - 9);
    m.addItem(state.getMenuItem("Set Enabled", Material.ENDER_PEARL));
    m.displayMenu(player);
    return true;
}
Also used : MenuItemBack(au.com.mineauz.minigames.menu.MenuItemBack) Menu(au.com.mineauz.minigames.menu.Menu)

Aggregations

Menu (au.com.mineauz.minigames.menu.Menu)13 MenuItemBack (au.com.mineauz.minigames.menu.MenuItemBack)13 Callback (au.com.mineauz.minigames.menu.Callback)3 InteractionInterface (au.com.mineauz.minigames.menu.InteractionInterface)2 MenuItemCustom (au.com.mineauz.minigames.menu.MenuItemCustom)2 MenuItemString (au.com.mineauz.minigames.menu.MenuItemString)2 ArrayList (java.util.ArrayList)2 RewardScheme (au.com.mineauz.minigames.minigame.reward.scheme.RewardScheme)1 StandardRewardScheme (au.com.mineauz.minigames.minigame.reward.scheme.StandardRewardScheme)1