Search in sources :

Example 1 with MenuItemRewardGroup

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

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

the class Rewards method createMenu.

public Menu createMenu(String name, MinigamePlayer player, Menu parent) {
    Menu rewardMenu = new Menu(5, name, player);
    rewardMenu.setPreviousPage(parent);
    rewardMenu.addItem(new MenuItemRewardGroupAdd("Add Group", Material.ITEM_FRAME, this), 42);
    rewardMenu.addItem(new MenuItemRewardAdd("Add Item", Material.ITEM_FRAME, this), 43);
    rewardMenu.addItem(new MenuItemPage("Save " + name, Material.REDSTONE_TORCH_ON, parent), 44);
    List<MenuItem> mi = new ArrayList<MenuItem>();
    for (RewardType item : items) {
        mi.add(item.getMenuItem());
    }
    List<String> des = new ArrayList<String>();
    des.add("Double Click to edit");
    for (RewardGroup group : groups) {
        MenuItemRewardGroup rwg = new MenuItemRewardGroup(group.getName() + " Group", des, Material.CHEST, group, this);
        mi.add(rwg);
    }
    rewardMenu.addItems(mi);
    return rewardMenu;
}
Also used : MenuItemRewardGroup(au.com.mineauz.minigames.menu.MenuItemRewardGroup) MenuItemRewardGroupAdd(au.com.mineauz.minigames.menu.MenuItemRewardGroupAdd) MenuItemRewardAdd(au.com.mineauz.minigames.menu.MenuItemRewardAdd) MenuItemPage(au.com.mineauz.minigames.menu.MenuItemPage) ArrayList(java.util.ArrayList) MenuItem(au.com.mineauz.minigames.menu.MenuItem) Menu(au.com.mineauz.minigames.menu.Menu) MenuItemRewardGroup(au.com.mineauz.minigames.menu.MenuItemRewardGroup)

Aggregations

Menu (au.com.mineauz.minigames.menu.Menu)2 MenuItem (au.com.mineauz.minigames.menu.MenuItem)2 MenuItemRewardAdd (au.com.mineauz.minigames.menu.MenuItemRewardAdd)2 MenuItemRewardGroup (au.com.mineauz.minigames.menu.MenuItemRewardGroup)2 MenuItemRewardGroupAdd (au.com.mineauz.minigames.menu.MenuItemRewardGroupAdd)2 ArrayList (java.util.ArrayList)2 InteractionInterface (au.com.mineauz.minigames.menu.InteractionInterface)1 MenuItemCustom (au.com.mineauz.minigames.menu.MenuItemCustom)1 MenuItemPage (au.com.mineauz.minigames.menu.MenuItemPage)1 RewardGroup (au.com.mineauz.minigames.minigame.reward.RewardGroup)1 RewardRarity (au.com.mineauz.minigames.minigame.reward.RewardRarity)1 RewardType (au.com.mineauz.minigames.minigame.reward.RewardType)1 Rewards (au.com.mineauz.minigames.minigame.reward.Rewards)1 List (java.util.List)1 Location (org.bukkit.Location)1