Search in sources :

Example 1 with InteractionInterface

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

the class RewardSign method signUse.

@Override
public boolean signUse(Sign sign, MinigamePlayer player) {
    Location loc = sign.getLocation();
    if (!MinigameUtils.isMinigameTool(player.getPlayer().getInventory().getItemInMainHand())) {
        String label = sign.getLine(2).toLowerCase();
        if (player.isInMinigame()) {
            if (!player.hasTempClaimedReward(label)) {
                if (mdata.hasRewardSign(loc)) {
                    Rewards rew = mdata.getRewardSign(loc);
                    for (RewardType r : rew.getReward()) {
                        r.giveReward(player);
                    }
                }
                player.addTempClaimedReward(label);
            }
        } else {
            if (!player.hasClaimedReward(label)) {
                if (mdata.hasRewardSign(loc)) {
                    Rewards rew = mdata.getRewardSign(loc);
                    for (RewardType r : rew.getReward()) {
                        r.giveReward(player);
                    }
                    player.updateInventory();
                }
                player.addClaimedReward(label);
            }
        }
    } else if (player.getPlayer().hasPermission("minigame.tool")) {
        Rewards rew = null;
        if (!mdata.hasRewardSign(loc)) {
            mdata.addRewardSign(loc);
        }
        rew = mdata.getRewardSign(loc);
        Menu rewardMenu = new Menu(5, getName(), player);
        rewardMenu.addItem(new MenuItemRewardGroupAdd("Add Group", Material.ITEM_FRAME, rew), 42);
        rewardMenu.addItem(new MenuItemRewardAdd("Add Item", Material.ITEM_FRAME, rew), 43);
        final MenuItemCustom mic = new MenuItemCustom("Save Rewards", Material.REDSTONE_TORCH_ON);
        final Location floc = loc;
        mic.setClick(new InteractionInterface() {

            @Override
            public Object interact(Object object) {
                mdata.saveRewardSign(MinigameUtils.createLocationID(floc), true);
                mic.getContainer().getViewer().sendMessage("Saved rewards for this sign.", null);
                mic.getContainer().getViewer().getPlayer().closeInventory();
                return null;
            }
        });
        rewardMenu.addItem(mic, 44);
        List<String> list = new ArrayList<String>();
        for (RewardRarity r : RewardRarity.values()) {
            list.add(r.toString());
        }
        List<MenuItem> mi = new ArrayList<MenuItem>();
        for (RewardType item : rew.getRewards()) {
            mi.add(item.getMenuItem());
        }
        List<String> des = new ArrayList<String>();
        des.add("Double Click to edit");
        for (RewardGroup group : rew.getGroups()) {
            MenuItemRewardGroup rwg = new MenuItemRewardGroup(group.getName() + " Group", des, Material.CHEST, group, rew);
            mi.add(rwg);
        }
        rewardMenu.addItems(mi);
        rewardMenu.displayMenu(player);
    }
    return true;
}
Also used : MenuItemRewardAdd(au.com.mineauz.minigames.menu.MenuItemRewardAdd) MenuItem(au.com.mineauz.minigames.menu.MenuItem) MenuItemCustom(au.com.mineauz.minigames.menu.MenuItemCustom) InteractionInterface(au.com.mineauz.minigames.menu.InteractionInterface) MenuItemRewardGroup(au.com.mineauz.minigames.menu.MenuItemRewardGroup) RewardGroup(au.com.mineauz.minigames.minigame.reward.RewardGroup) RewardType(au.com.mineauz.minigames.minigame.reward.RewardType) MenuItemRewardGroupAdd(au.com.mineauz.minigames.menu.MenuItemRewardGroupAdd) Rewards(au.com.mineauz.minigames.minigame.reward.Rewards) ArrayList(java.util.ArrayList) List(java.util.List) Menu(au.com.mineauz.minigames.menu.Menu) RewardRarity(au.com.mineauz.minigames.minigame.reward.RewardRarity) MenuItemRewardGroup(au.com.mineauz.minigames.menu.MenuItemRewardGroup) Location(org.bukkit.Location)

Example 2 with InteractionInterface

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

the class HierarchyRewardScheme method addMenuItems.

@Override
public void addMenuItems(final Menu menu) {
    menu.addItem(new MenuItemList("Comparison Type", Material.REDSTONE_COMPARATOR, getConfigurationTypeCallback(), Lists.transform(Arrays.asList(Comparison.values()), Functions.toStringFunction())));
    menu.addItem(enableRewardsOnLoss.getMenuItem("Award On Loss", Material.LEVER, MinigameUtils.stringToList("When on, awards will still;be given to losing;players")));
    menu.addItem(lossUsesSecondary.getMenuItem("Losers Get Secondary", Material.LEVER, MinigameUtils.stringToList("When on, the losers;will only get the;secondary reward")));
    menu.addItem(new MenuItemNewLine());
    MenuItemCustom primary = new MenuItemCustom("Primary Rewards", Material.CHEST);
    primary.setClick(new InteractionInterface() {

        @Override
        public Object interact(Object object) {
            showRewardsMenu(primaryRewards, menu.getViewer(), menu);
            return null;
        }
    });
    MenuItemCustom secondary = new MenuItemCustom("Secondary Rewards", Material.CHEST);
    secondary.setClick(new InteractionInterface() {

        @Override
        public Object interact(Object object) {
            showRewardsMenu(secondaryRewards, menu.getViewer(), menu);
            return null;
        }
    });
    menu.addItem(primary);
    menu.addItem(secondary);
}
Also used : MenuItemList(au.com.mineauz.minigames.menu.MenuItemList) InteractionInterface(au.com.mineauz.minigames.menu.InteractionInterface) MenuItemNewLine(au.com.mineauz.minigames.menu.MenuItemNewLine) MenuItemCustom(au.com.mineauz.minigames.menu.MenuItemCustom)

Example 3 with InteractionInterface

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

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

Example 5 with InteractionInterface

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

the class NodeToolMode method onSetMode.

@Override
public void onSetMode(final MinigamePlayer player, MinigameTool tool) {
    tool.addSetting("Node", "None");
    final Menu m = new Menu(2, "Node Selection", player);
    if (player.isInMenu()) {
        m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, player.getMenu()), m.getSize() - 9);
    }
    final MinigameTool ftool = tool;
    m.addItem(new MenuItemString("Node Name", Material.PAPER, new Callback<String>() {

        @Override
        public void setValue(String value) {
            ftool.changeSetting("Node", value);
        }

        @Override
        public String getValue() {
            return ftool.getSetting("Node");
        }
    }));
    if (tool.getMinigame() != null) {
        // Node selection menu
        RegionModule module = RegionModule.getMinigameModule(tool.getMinigame());
        Menu nodeMenu = new Menu(6, "Nodes", player);
        List<MenuItem> items = new ArrayList<MenuItem>();
        for (final Node node : module.getNodes()) {
            MenuItemCustom item = new MenuItemCustom(node.getName(), Material.STONE_BUTTON);
            // Set the node and go back to the main menu
            item.setClick(new InteractionInterface() {

                @Override
                public Object interact(Object object) {
                    ftool.changeSetting("Node", node.getName());
                    m.displayMenu(player);
                    return object;
                }
            });
            items.add(item);
        }
        nodeMenu.addItems(items);
        nodeMenu.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, m), nodeMenu.getSize() - 9);
        m.addItem(new MenuItemPage("Edit Node", Material.STONE_BUTTON, nodeMenu));
    }
    m.displayMenu(player);
}
Also used : MenuItemPage(au.com.mineauz.minigames.menu.MenuItemPage) MinigameTool(au.com.mineauz.minigames.tool.MinigameTool) ArrayList(java.util.ArrayList) MenuItem(au.com.mineauz.minigames.menu.MenuItem) MenuItemString(au.com.mineauz.minigames.menu.MenuItemString) MenuItemCustom(au.com.mineauz.minigames.menu.MenuItemCustom) MenuItemString(au.com.mineauz.minigames.menu.MenuItemString) Callback(au.com.mineauz.minigames.menu.Callback) InteractionInterface(au.com.mineauz.minigames.menu.InteractionInterface) Menu(au.com.mineauz.minigames.menu.Menu)

Aggregations

InteractionInterface (au.com.mineauz.minigames.menu.InteractionInterface)18 MenuItemCustom (au.com.mineauz.minigames.menu.MenuItemCustom)18 Menu (au.com.mineauz.minigames.menu.Menu)17 ArrayList (java.util.ArrayList)10 MenuItemPage (au.com.mineauz.minigames.menu.MenuItemPage)9 MinigamePlayer (au.com.mineauz.minigames.MinigamePlayer)6 Callback (au.com.mineauz.minigames.menu.Callback)6 MenuItemNewLine (au.com.mineauz.minigames.menu.MenuItemNewLine)5 MenuItemString (au.com.mineauz.minigames.menu.MenuItemString)5 MenuItem (au.com.mineauz.minigames.menu.MenuItem)4 MenuItemBoolean (au.com.mineauz.minigames.menu.MenuItemBoolean)4 MenuItemInteger (au.com.mineauz.minigames.menu.MenuItemInteger)4 MenuItemList (au.com.mineauz.minigames.menu.MenuItemList)4 MenuItemBack (au.com.mineauz.minigames.menu.MenuItemBack)2 MinigameTool (au.com.mineauz.minigames.tool.MinigameTool)2 FutureCallback (com.google.common.util.concurrent.FutureCallback)2 PlayerLoadout (au.com.mineauz.minigames.PlayerLoadout)1 MinigameType (au.com.mineauz.minigames.gametypes.MinigameType)1 GameMechanicBase (au.com.mineauz.minigames.mechanics.GameMechanicBase)1 MenuItemAddFlag (au.com.mineauz.minigames.menu.MenuItemAddFlag)1