Search in sources :

Example 1 with MenuItemToolMode

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

the class MinigameTool method openMenu.

public void openMenu(MinigamePlayer player) {
    Menu men = new Menu(2, "Set Tool Mode", player);
    final MenuItemCustom miselect = new MenuItemCustom("Select", MinigameUtils.stringToList("Selects and area;or points visually"), Material.DIAMOND_BLOCK);
    final MenuItemCustom mideselect = new MenuItemCustom("Deselect", MinigameUtils.stringToList("Deselects an;area or points"), Material.GLASS);
    final MinigamePlayer fply = player;
    miselect.setClick(new InteractionInterface() {

        @Override
        public Object interact(Object object) {
            if (mode != null) {
                mode.select(fply, minigame, TeamsModule.getMinigameModule(minigame).getTeam(team));
            }
            return miselect.getItem();
        }
    });
    mideselect.setClick(new InteractionInterface() {

        @Override
        public Object interact(Object object) {
            if (mode != null) {
                mode.deselect(fply, minigame, TeamsModule.getMinigameModule(minigame).getTeam(team));
            }
            return mideselect.getItem();
        }
    });
    men.addItem(mideselect, men.getSize() - 1);
    men.addItem(miselect, men.getSize() - 2);
    List<String> teams = new ArrayList<String>(TeamColor.values().length + 1);
    for (TeamColor col : TeamColor.values()) teams.add(MinigameUtils.capitalize(col.toString().replace("_", " ")));
    teams.add("None");
    men.addItem(new MenuItemToolTeam("Team", Material.PAPER, new Callback<String>() {

        @Override
        public void setValue(String value) {
            setTeam(TeamColor.matchColor(value.replace(" ", "_")));
        }

        @Override
        public String getValue() {
            if (getTeam() != null)
                return MinigameUtils.capitalize(getTeam().toString().replace("_", " "));
            return "None";
        }
    }, teams), men.getSize() - 3);
    for (ToolMode m : ToolModes.getToolModes()) {
        men.addItem(new MenuItemToolMode(m.getDisplayName(), MinigameUtils.stringToList(m.getDescription()), m.getIcon(), m));
    }
    men.displayMenu(player);
}
Also used : MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) ArrayList(java.util.ArrayList) TeamColor(au.com.mineauz.minigames.minigame.TeamColor) MenuItemCustom(au.com.mineauz.minigames.menu.MenuItemCustom) MenuItemToolMode(au.com.mineauz.minigames.menu.MenuItemToolMode) MenuItemToolMode(au.com.mineauz.minigames.menu.MenuItemToolMode) Callback(au.com.mineauz.minigames.menu.Callback) InteractionInterface(au.com.mineauz.minigames.menu.InteractionInterface) MenuItemToolTeam(au.com.mineauz.minigames.menu.MenuItemToolTeam) Menu(au.com.mineauz.minigames.menu.Menu)

Aggregations

MinigamePlayer (au.com.mineauz.minigames.MinigamePlayer)1 Callback (au.com.mineauz.minigames.menu.Callback)1 InteractionInterface (au.com.mineauz.minigames.menu.InteractionInterface)1 Menu (au.com.mineauz.minigames.menu.Menu)1 MenuItemCustom (au.com.mineauz.minigames.menu.MenuItemCustom)1 MenuItemToolMode (au.com.mineauz.minigames.menu.MenuItemToolMode)1 MenuItemToolTeam (au.com.mineauz.minigames.menu.MenuItemToolTeam)1 TeamColor (au.com.mineauz.minigames.minigame.TeamColor)1 ArrayList (java.util.ArrayList)1