Search in sources :

Example 6 with MenuItemList

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

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

the class TeamsModule method addEditMenuOptions.

@Override
public void addEditMenuOptions(Menu menu) {
    Menu m = new Menu(6, "Teams", menu.getViewer());
    m.setPreviousPage(menu);
    List<MenuItem> items = new ArrayList<MenuItem>();
    List<String> teams = new ArrayList<String>(this.teams.size() + 1);
    for (TeamColor t : this.teams.keySet()) {
        teams.add(MinigameUtils.capitalize(t.toString().replace("_", " ")));
    }
    teams.add("None");
    items.add(new MenuItemList("Default Winning Team", Material.PAPER, getDefaultWinnerCallback(), teams));
    items.add(new MenuItemNewLine());
    for (Team t : this.teams.values()) {
        items.add(new MenuItemTeam(t.getChatColor() + t.getDisplayName(), t));
    }
    m.addItem(new MenuItemAddTeam("Add Team", getMinigame()), m.getSize() - 1);
    m.addItems(items);
    m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, menu), m.getSize() - 9);
    MenuItemPage p = new MenuItemPage("Team Options", Material.CHEST, m);
    menu.addItem(p);
}
Also used : MenuItemTeam(au.com.mineauz.minigames.menu.MenuItemTeam) MenuItemPage(au.com.mineauz.minigames.menu.MenuItemPage) ArrayList(java.util.ArrayList) MenuItemNewLine(au.com.mineauz.minigames.menu.MenuItemNewLine) MenuItem(au.com.mineauz.minigames.menu.MenuItem) TeamColor(au.com.mineauz.minigames.minigame.TeamColor) MenuItemAddTeam(au.com.mineauz.minigames.menu.MenuItemAddTeam) MenuItemList(au.com.mineauz.minigames.menu.MenuItemList) MenuItemAddTeam(au.com.mineauz.minigames.menu.MenuItemAddTeam) MenuItemTeam(au.com.mineauz.minigames.menu.MenuItemTeam) Team(au.com.mineauz.minigames.minigame.Team) Menu(au.com.mineauz.minigames.menu.Menu)

Example 8 with MenuItemList

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

use of au.com.mineauz.minigames.menu.MenuItemList 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)

Example 10 with MenuItemList

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

the class MatchTeamCondition method displayMenu.

@Override
public boolean displayMenu(MinigamePlayer player, Menu prev) {
    Menu m = new Menu(3, "Match Team", player);
    m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, prev), m.getSize() - 9);
    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));
    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)

Aggregations

MenuItemList (au.com.mineauz.minigames.menu.MenuItemList)13 Menu (au.com.mineauz.minigames.menu.Menu)12 Callback (au.com.mineauz.minigames.menu.Callback)11 MenuItemPage (au.com.mineauz.minigames.menu.MenuItemPage)11 ArrayList (java.util.ArrayList)10 MenuItemNewLine (au.com.mineauz.minigames.menu.MenuItemNewLine)5 TeamColor (au.com.mineauz.minigames.minigame.TeamColor)5 InteractionInterface (au.com.mineauz.minigames.menu.InteractionInterface)4 MenuItemCustom (au.com.mineauz.minigames.menu.MenuItemCustom)4 MenuItemInteger (au.com.mineauz.minigames.menu.MenuItemInteger)4 MenuItemString (au.com.mineauz.minigames.menu.MenuItemString)3 MinigamePlayer (au.com.mineauz.minigames.MinigamePlayer)2 MenuItem (au.com.mineauz.minigames.menu.MenuItem)2 MenuItemBoolean (au.com.mineauz.minigames.menu.MenuItemBoolean)2 MenuItemDecimal (au.com.mineauz.minigames.menu.MenuItemDecimal)2 MenuItemTime (au.com.mineauz.minigames.menu.MenuItemTime)2 FutureCallback (com.google.common.util.concurrent.FutureCallback)2 MinigameType (au.com.mineauz.minigames.gametypes.MinigameType)1 GameMechanicBase (au.com.mineauz.minigames.mechanics.GameMechanicBase)1 MenuItemAddFlag (au.com.mineauz.minigames.menu.MenuItemAddFlag)1