Search in sources :

Example 11 with Callback

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

the class TeamScoreRangeCondition method displayMenu.

@Override
public boolean displayMenu(MinigamePlayer player, Menu prev) {
    Menu m = new Menu(3, "Team Score Range", player);
    m.addItem(min.getMenuItem("Minimum Score", Material.STEP, 0, null));
    m.addItem(max.getMenuItem("Maximum Score", Material.STONE, 0, null));
    List<String> teams = new ArrayList<String>();
    for (TeamColor t : TeamColor.values()) teams.add(MinigameUtils.capitalize(t.toString().replace("_", " ")));
    m.addItem(new MenuItemList("Team Color", Material.WOOL, new Callback<String>() {

        @Override
        public void setValue(String value) {
            team.setFlag(value.toUpperCase().replace(" ", "_"));
        }

        @Override
        public String getValue() {
            return MinigameUtils.capitalize(team.getFlag().replace("_", " "));
        }
    }, teams));
    m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, prev), m.getSize() - 9);
    addInvertMenuItem(m);
    m.displayMenu(player);
    return true;
}
Also used : Callback(au.com.mineauz.minigames.menu.Callback) MenuItemList(au.com.mineauz.minigames.menu.MenuItemList) MenuItemPage(au.com.mineauz.minigames.menu.MenuItemPage) ArrayList(java.util.ArrayList) TeamColor(au.com.mineauz.minigames.minigame.TeamColor) Menu(au.com.mineauz.minigames.menu.Menu)

Example 12 with Callback

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

the class ScoreboardDisplay method displayMenu.

public void displayMenu(MinigamePlayer player) {
    final Menu setupMenu = new Menu(3, "Setup Scoreboard", player);
    StatSettings settings = minigame.getSettings(stat);
    final MenuItemCustom statisticChoice = new MenuItemCustom("Statistic", Material.BOOK_AND_QUILL);
    statisticChoice.setDescription(Arrays.asList(ChatColor.GREEN + settings.getDisplayName()));
    final MenuItemCustom fieldChoice = new MenuItemCustom("Statistic Field", Material.PAPER);
    fieldChoice.setDescription(Arrays.asList(ChatColor.GREEN + field.getTitle()));
    statisticChoice.setClick(new InteractionInterface() {

        @Override
        public Object interact(Object object) {
            Menu childMenu = MinigameStats.createStatSelectMenu(setupMenu, new Callback<MinigameStat>() {

                @Override
                public MinigameStat getValue() {
                    throw new UnsupportedOperationException();
                }

                @Override
                public void setValue(MinigameStat value) {
                    stat = value;
                    StatSettings settings = minigame.getSettings(stat);
                    statisticChoice.setDescription(Arrays.asList(ChatColor.GREEN + settings.getDisplayName()));
                    // Check that the field is valid
                    StatValueField first = null;
                    boolean valid = false;
                    for (StatValueField sfield : settings.getFormat().getFields()) {
                        if (first == null) {
                            first = sfield;
                        }
                        if (sfield == field) {
                            valid = true;
                            break;
                        }
                    }
                    // Update the field
                    if (!valid) {
                        field = first;
                        fieldChoice.setDescription(Arrays.asList(ChatColor.GREEN + value.toString()));
                    }
                }
            });
            childMenu.displayMenu(setupMenu.getViewer());
            return null;
        }
    });
    fieldChoice.setClick(new InteractionInterface() {

        @Override
        public Object interact(Object object) {
            StatSettings settings = minigame.getSettings(stat);
            Menu childMenu = MinigameStats.createStatFieldSelectMenu(setupMenu, settings.getFormat(), new Callback<StatValueField>() {

                @Override
                public StatValueField getValue() {
                    throw new UnsupportedOperationException();
                }

                @Override
                public void setValue(StatValueField value) {
                    field = value;
                    fieldChoice.setDescription(Arrays.asList(ChatColor.GREEN + value.getTitle()));
                }
            });
            childMenu.displayMenu(setupMenu.getViewer());
            return null;
        }
    });
    setupMenu.addItem(statisticChoice);
    setupMenu.addItem(fieldChoice);
    List<String> sbotypes = new ArrayList<String>();
    for (ScoreboardOrder o : ScoreboardOrder.values()) {
        sbotypes.add(o.toString().toLowerCase());
    }
    setupMenu.addItem(new MenuItemList("Scoreboard Order", Material.ENDER_PEARL, new Callback<String>() {

        @Override
        public void setValue(String value) {
            order = ScoreboardOrder.valueOf(value.toUpperCase());
        }

        @Override
        public String getValue() {
            return order.toString().toLowerCase();
        }
    }, sbotypes));
    setupMenu.addItem(new MenuItemScoreboardSave("Create Scoreboard", Material.REDSTONE_TORCH_ON, this), setupMenu.getSize() - 1);
    setupMenu.displayMenu(player);
}
Also used : ArrayList(java.util.ArrayList) MenuItemCustom(au.com.mineauz.minigames.menu.MenuItemCustom) MenuItemScoreboardSave(au.com.mineauz.minigames.menu.MenuItemScoreboardSave) StatValueField(au.com.mineauz.minigames.stats.StatValueField) FutureCallback(com.google.common.util.concurrent.FutureCallback) Callback(au.com.mineauz.minigames.menu.Callback) InteractionInterface(au.com.mineauz.minigames.menu.InteractionInterface) MenuItemList(au.com.mineauz.minigames.menu.MenuItemList) MinigameStat(au.com.mineauz.minigames.stats.MinigameStat) Menu(au.com.mineauz.minigames.menu.Menu) StatSettings(au.com.mineauz.minigames.stats.StatSettings)

Example 13 with Callback

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

the class WeatherTimeModule method addEditMenuOptions.

@Override
public void addEditMenuOptions(Menu menu) {
    Menu m = new Menu(6, "Time and Weather", menu.getViewer());
    m.addItem(new MenuItemBoolean("Use Custom Time", Material.WATCH, new Callback<Boolean>() {

        @Override
        public void setValue(Boolean value) {
            useCustomTime.setFlag(value);
        }

        @Override
        public Boolean getValue() {
            return useCustomTime.getFlag();
        }
    }));
    m.addItem(new MenuItemInteger("Time of Day", Material.WATCH, new Callback<Integer>() {

        @Override
        public void setValue(Integer value) {
            time.setFlag(value.longValue());
        }

        @Override
        public Integer getValue() {
            return time.getFlag().intValue();
        }
    }, 0, 24000));
    m.addItem(new MenuItemBoolean("Use Custom Weather", Material.WATER_BUCKET, new Callback<Boolean>() {

        @Override
        public void setValue(Boolean value) {
            useCustomWeather.setFlag(value);
        }

        @Override
        public Boolean getValue() {
            return useCustomWeather.getFlag();
        }
    }));
    m.addItem(new MenuItemList("Weather Type", Material.WATER_BUCKET, new Callback<String>() {

        @Override
        public void setValue(String value) {
            weather.setFlag(WeatherType.valueOf(value.toUpperCase()));
        }

        @Override
        public String getValue() {
            return MinigameUtils.capitalize(weather.getFlag().toString());
        }
    }, MinigameUtils.stringToList("Clear;Downfall")));
    m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, menu), m.getSize() - 9);
    menu.addItem(new MenuItemPage("Time and Weather Settings", Material.CHEST, m));
}
Also used : MenuItemInteger(au.com.mineauz.minigames.menu.MenuItemInteger) Callback(au.com.mineauz.minigames.menu.Callback) MenuItemList(au.com.mineauz.minigames.menu.MenuItemList) MenuItemInteger(au.com.mineauz.minigames.menu.MenuItemInteger) MenuItemPage(au.com.mineauz.minigames.menu.MenuItemPage) MenuItemBoolean(au.com.mineauz.minigames.menu.MenuItemBoolean) Menu(au.com.mineauz.minigames.menu.Menu) MenuItemBoolean(au.com.mineauz.minigames.menu.MenuItemBoolean)

Example 14 with Callback

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

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

the class PlayerHasItemCondition method displayMenu.

@Override
public boolean displayMenu(MinigamePlayer player, Menu prev) {
    Menu m = new Menu(3, "Player Has Item", player);
    m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, prev), m.getSize() - 9);
    final MinigamePlayer fply = player;
    m.addItem(new MenuItemString("Item", Material.STONE, new Callback<String>() {

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

        @Override
        public String getValue() {
            return type.getFlag();
        }
    }));
    m.addItem(useData.getMenuItem("Match Item Data", Material.ENDER_PEARL));
    m.addItem(data.getMenuItem("Data Value", Material.EYE_OF_ENDER, 0, null));
    m.addItem(new MenuItemList("Search Where", Material.COMPASS, new Callback<String>() {

        @Override
        public void setValue(String value) {
            where.setFlag(value.toUpperCase());
        }

        @Override
        public String getValue() {
            return WordUtils.capitalizeFully(where.getFlag());
        }
    }, Arrays.asList("Anywhere", "Hotbar", "Main", "Armor", "Slot")));
    m.addItem(slot.getMenuItem("Slot", Material.DIAMOND, 0, 35));
    m.addItem(new MenuItemNewLine());
    m.addItem(matchName.getMenuItem("Match Display Name", Material.NAME_TAG));
    MenuItemString menuItem = (MenuItemString) name.getMenuItem("Display Name", Material.NAME_TAG, MinigameUtils.stringToList("The name to match.;Use % to do a wildcard match"));
    menuItem.setAllowNull(true);
    m.addItem(menuItem);
    m.addItem(matchLore.getMenuItem("Match Lore", Material.BOOK));
    menuItem = (MenuItemString) lore.getMenuItem("Lore", Material.BOOK, MinigameUtils.stringToList("The lore to match. Separate;with semi-colons;for new lines.;Use % to do a wildcard match"));
    menuItem.setAllowNull(true);
    m.addItem(menuItem);
    addInvertMenuItem(m);
    m.displayMenu(player);
    return true;
}
Also used : MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) Callback(au.com.mineauz.minigames.menu.Callback) MenuItemList(au.com.mineauz.minigames.menu.MenuItemList) MenuItemPage(au.com.mineauz.minigames.menu.MenuItemPage) MenuItemNewLine(au.com.mineauz.minigames.menu.MenuItemNewLine) Menu(au.com.mineauz.minigames.menu.Menu) MenuItemString(au.com.mineauz.minigames.menu.MenuItemString) MenuItemString(au.com.mineauz.minigames.menu.MenuItemString)

Aggregations

Callback (au.com.mineauz.minigames.menu.Callback)23 Menu (au.com.mineauz.minigames.menu.Menu)22 MenuItemPage (au.com.mineauz.minigames.menu.MenuItemPage)17 MenuItemString (au.com.mineauz.minigames.menu.MenuItemString)12 ArrayList (java.util.ArrayList)12 MenuItemList (au.com.mineauz.minigames.menu.MenuItemList)11 InteractionInterface (au.com.mineauz.minigames.menu.InteractionInterface)6 MenuItemCustom (au.com.mineauz.minigames.menu.MenuItemCustom)6 MinigamePlayer (au.com.mineauz.minigames.MinigamePlayer)5 MenuItemInteger (au.com.mineauz.minigames.menu.MenuItemInteger)5 TeamColor (au.com.mineauz.minigames.minigame.TeamColor)5 MenuItemNewLine (au.com.mineauz.minigames.menu.MenuItemNewLine)4 MenuItem (au.com.mineauz.minigames.menu.MenuItem)3 MenuItemBack (au.com.mineauz.minigames.menu.MenuItemBack)3 MenuItemBoolean (au.com.mineauz.minigames.menu.MenuItemBoolean)3 MenuItemDecimal (au.com.mineauz.minigames.menu.MenuItemDecimal)2 MenuItemTime (au.com.mineauz.minigames.menu.MenuItemTime)2 MinigameTool (au.com.mineauz.minigames.tool.MinigameTool)2 FutureCallback (com.google.common.util.concurrent.FutureCallback)2 MinigameType (au.com.mineauz.minigames.gametypes.MinigameType)1