Search in sources :

Example 6 with MenuItemBack

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

the class MinigameStats method createStatFieldSelectMenu.

/**
	 * Creates a menu that allows you to select a statistic field
	 * @param parent The parent menu
	 * @param format The format to define the fields available
	 * @param callback The callback to be invoked when the field is chosen. Note: only the setValue() method will be called.
	 * @return The menu to display
	 */
public static Menu createStatFieldSelectMenu(final Menu parent, StatFormat format, final Callback<StatValueField> callback) {
    final Menu submenu = new Menu(6, "Select Statistic Field", parent.getViewer());
    for (final StatValueField field : format.getFields()) {
        MenuItemCustom item = new MenuItemCustom(WordUtils.capitalizeFully(field.name()), Material.PAPER);
        item.setClick(new InteractionInterface() {

            @Override
            public Object interact(Object object) {
                callback.setValue(field);
                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 7 with MenuItemBack

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

the class HierarchyRewardScheme method showRewardsMenu.

private void showRewardsMenu(TreeMap<T, Rewards> rewards, MinigamePlayer player, Menu parent) {
    Menu submenu = new Menu(6, "Rewards", player);
    for (T key : rewards.keySet()) {
        submenu.addItem(new MenuItemRewardPair(rewards, key, Material.CHEST));
    }
    submenu.addItem(new MenuItemAddReward(rewards, "Add Reward Set", Material.ITEM_FRAME), submenu.getSize() - 2);
    submenu.addItem(new MenuItemBack(parent), submenu.getSize() - 1);
    submenu.setPreviousPage(parent);
    submenu.displayMenu(player);
}
Also used : MenuItemBack(au.com.mineauz.minigames.menu.MenuItemBack) Menu(au.com.mineauz.minigames.menu.Menu)

Example 8 with MenuItemBack

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

the class MenuItemRegionExecutorAdd method onClick.

@Override
public ItemStack onClick() {
    Menu m = new Menu(6, "Select Trigger", getContainer().getViewer());
    List<String> triggers = new ArrayList<String>(Triggers.getAllRegionTriggers());
    Collections.sort(triggers);
    for (String trig : triggers) {
        m.addItem(new MenuItemTrigger(Triggers.getTrigger(trig), region, getContainer()));
    }
    m.addItem(new MenuItemBack(getContainer()), m.getSize() - 9);
    m.displayMenu(getContainer().getViewer());
    return null;
}
Also used : ArrayList(java.util.ArrayList) MenuItemBack(au.com.mineauz.minigames.menu.MenuItemBack) Menu(au.com.mineauz.minigames.menu.Menu)

Example 9 with MenuItemBack

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

the class RewardsModule method createSubMenu.

private Menu createSubMenu(final Menu parent) {
    final Menu submenu = new Menu(6, "Reward Settings", parent.getViewer());
    scheme.addMenuItems(submenu);
    submenu.addItem(RewardSchemes.newMenuItem("Reward Scheme", Material.PAPER, new Callback<Class<? extends RewardScheme>>() {

        @Override
        public void setValue(Class<? extends RewardScheme> value) {
            scheme = RewardSchemes.createScheme(value);
            // Update the menu
            Menu menu = createSubMenu(parent);
            menu.displayMenu(submenu.getViewer());
        }

        @Override
        public Class<? extends RewardScheme> getValue() {
            return scheme.getClass();
        }
    }), submenu.getSize() - 1);
    submenu.addItem(new MenuItemBack(parent), submenu.getSize() - 9);
    return submenu;
}
Also used : Callback(au.com.mineauz.minigames.menu.Callback) MenuItemBack(au.com.mineauz.minigames.menu.MenuItemBack) RewardScheme(au.com.mineauz.minigames.minigame.reward.scheme.RewardScheme) StandardRewardScheme(au.com.mineauz.minigames.minigame.reward.scheme.StandardRewardScheme) Menu(au.com.mineauz.minigames.menu.Menu)

Example 10 with MenuItemBack

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

the class MenuItemNodeExecutorAdd method onClick.

@Override
public ItemStack onClick() {
    Menu m = new Menu(6, "Select Trigger", getContainer().getViewer());
    List<String> triggers = new ArrayList<String>(Triggers.getAllNodeTriggers());
    Collections.sort(triggers);
    for (String trig : triggers) {
        m.addItem(new MenuItemTrigger(Triggers.getTrigger(trig), node, getContainer()));
    }
    m.addItem(new MenuItemBack(getContainer()), m.getSize() - 9);
    m.displayMenu(getContainer().getViewer());
    return null;
}
Also used : ArrayList(java.util.ArrayList) 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