Search in sources :

Example 1 with RewardGroup

use of au.com.mineauz.minigames.minigame.reward.RewardGroup in project Minigames by AddstarMC.

the class MenuItemRewardGroupAdd method checkValidEntry.

@Override
public void checkValidEntry(String entry) {
    entry = entry.replace(" ", "_");
    for (RewardGroup group : rewards.getGroups()) {
        if (group.getName().equals(entry)) {
            getContainer().getViewer().sendMessage("A reward group already exists by the name \"" + entry + "\"!", "error");
            getContainer().cancelReopenTimer();
            getContainer().displayMenu(getContainer().getViewer());
            return;
        }
    }
    RewardGroup group = rewards.addGroup(entry, RewardRarity.NORMAL);
    MenuItemRewardGroup mrg = new MenuItemRewardGroup(entry + " Group", Material.CHEST, group, rewards);
    getContainer().addItem(mrg);
    getContainer().cancelReopenTimer();
    getContainer().displayMenu(getContainer().getViewer());
}
Also used : RewardGroup(au.com.mineauz.minigames.minigame.reward.RewardGroup)

Example 2 with RewardGroup

use of au.com.mineauz.minigames.minigame.reward.RewardGroup 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)

Aggregations

RewardGroup (au.com.mineauz.minigames.minigame.reward.RewardGroup)2 InteractionInterface (au.com.mineauz.minigames.menu.InteractionInterface)1 Menu (au.com.mineauz.minigames.menu.Menu)1 MenuItem (au.com.mineauz.minigames.menu.MenuItem)1 MenuItemCustom (au.com.mineauz.minigames.menu.MenuItemCustom)1 MenuItemRewardAdd (au.com.mineauz.minigames.menu.MenuItemRewardAdd)1 MenuItemRewardGroup (au.com.mineauz.minigames.menu.MenuItemRewardGroup)1 MenuItemRewardGroupAdd (au.com.mineauz.minigames.menu.MenuItemRewardGroupAdd)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 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Location (org.bukkit.Location)1