Search in sources :

Example 16 with BInventoryButton

use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project AdvancedCore by BenCodez.

the class RewardEditGUI method openRewardGUIRequirements.

public void openRewardGUIRequirements(Player player, RewardEditData rewardEditData, String rewardName) {
    EditGUI inv = new EditGUI("Requirements: " + rewardName);
    inv.requirePermission(AdvancedCorePlugin.getInstance().getOptions().getPermPrefix() + ".RewardEdit");
    inv.addData("Reward", rewardEditData);
    inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER), new EditGUIValueBoolean("ForceOffline", rewardEditData.getValue("ForceOffline")) {

        @Override
        public void setValue(Player player, boolean value) {
            RewardEditData reward = (RewardEditData) getInv().getData("Reward");
            reward.setValue(getKey(), value);
            plugin.reloadAdvancedCore(false);
        }
    }.addLore("Force reward to execute to run while player is offline")));
    inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER), new EditGUIValueInventory("Delayed") {

        @Override
        public void openInventory(ClickEvent clickEvent) {
            RewardEditData reward = (RewardEditData) getInv().getData("Reward");
            new RewardEditDelayed() {

                @Override
                public void setVal(String key, Object value) {
                    RewardEditData reward = (RewardEditData) getInv().getData("Reward");
                    reward.setValue(key, value);
                    plugin.reloadAdvancedCore(false);
                }
            }.open(clickEvent.getPlayer(), reward);
        }
    }.addLore("Delay reward from being executed")));
    inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER), new EditGUIValueInventory("Timed") {

        @Override
        public void openInventory(ClickEvent clickEvent) {
            RewardEditData reward = (RewardEditData) getInv().getData("Reward");
            new RewardEditTimed() {

                @Override
                public void setVal(String key, Object value) {
                    RewardEditData reward = (RewardEditData) getInv().getData("Reward");
                    reward.setValue(key, value);
                    plugin.reloadAdvancedCore(false);
                }
            }.open(clickEvent.getPlayer(), reward);
        }
    }.addLore("Execute reward at certain time")));
    for (RequirementInject injectReward : plugin.getRewardHandler().getInjectedRequirements()) {
        if (injectReward.isEditable()) {
            for (BInventoryButton b : injectReward.getEditButtons()) {
                if (b instanceof EditGUIButton) {
                    EditGUIButton eb = (EditGUIButton) b;
                    if (eb.getEditor().isCanGetValue()) {
                        eb.getEditor().setCurrentValue(rewardEditData.getValue(eb.getEditor().getKey()));
                    }
                    inv.addButton(eb);
                } else {
                    inv.addButton(b);
                }
            }
        }
    }
    inv.sort();
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cGo back")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            openRewardGUI(clickEvent.getPlayer(), rewardEditData, rewardName);
        }
    });
    inv.openInventory(player);
}
Also used : EditGUI(com.bencodez.advancedcore.api.inventory.editgui.EditGUI) EditGUIValueBoolean(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueBoolean) Player(org.bukkit.entity.Player) RewardEditDelayed(com.bencodez.advancedcore.api.rewards.editbuttons.RewardEditDelayed) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) RewardEditData(com.bencodez.advancedcore.api.rewards.RewardEditData) EditGUIButton(com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton) EditGUIValueInventory(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueInventory) RewardEditTimed(com.bencodez.advancedcore.api.rewards.editbuttons.RewardEditTimed) RequirementInject(com.bencodez.advancedcore.api.rewards.injectedrequirement.RequirementInject)

Example 17 with BInventoryButton

use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project AdvancedCore by BenCodez.

the class RewardEditGUI method openRewardsGUICopy.

public void openRewardsGUICopy(Player player, RewardEditData rewardEditData, String rewardName) {
    if (!player.hasPermission(AdvancedCorePlugin.getInstance().getOptions().getPermPrefix() + ".RewardEdit")) {
        player.sendMessage("You do not have enough permission to do this");
        return;
    }
    BInventory inv = new BInventory("CopyRewards");
    inv.addData("masterreward", rewardEditData);
    for (Reward reward : plugin.getRewardHandler().getRewards()) {
        if (!reward.getConfig().isDirectlyDefinedReward()) {
            ArrayList<String> lore = new ArrayList<String>();
            if (reward.getConfig().isDirectlyDefinedReward()) {
                lore.add("&cReward is directly defined");
            }
            inv.addButton(new BInventoryButton(reward.getRewardName(), ArrayUtils.getInstance().convert(lore), new ItemStack(Material.STONE)) {

                @Override
                public void onClick(ClickEvent event) {
                    new RewardGUIConfirmation(plugin, player, "Confirm copy reward?") {

                        @Override
                        public void onDeny(Player p) {
                            RewardEditData rewardEditData = (RewardEditData) getInv().getData("masterreward");
                            rewardEditData.reOpenEditGUI(player);
                        }

                        @Override
                        public void onConfirm(Player p) {
                            Reward reward = (Reward) getButton().getData("Reward");
                            RewardEditData rewardEditData = (RewardEditData) getInv().getData("masterreward");
                            for (Entry<String, Object> entry : getAllValues(reward.getConfig().getConfigData()).entrySet()) {
                                rewardEditData.setValue(entry.getKey(), entry.getValue());
                            }
                        }
                    }.open();
                }
            }.addData("Reward", reward));
        }
    }
    inv.openInventory(player);
}
Also used : Player(org.bukkit.entity.Player) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) ArrayList(java.util.ArrayList) BInventory(com.bencodez.advancedcore.api.inventory.BInventory) Entry(java.util.Map.Entry) RewardEditData(com.bencodez.advancedcore.api.rewards.RewardEditData) DirectlyDefinedReward(com.bencodez.advancedcore.api.rewards.DirectlyDefinedReward) Reward(com.bencodez.advancedcore.api.rewards.Reward) ItemStack(org.bukkit.inventory.ItemStack)

Example 18 with BInventoryButton

use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project AdvancedCore by BenCodez.

the class RewardEditGUI method openRewardGUI.

public void openRewardGUI(Player player, RewardEditData rewardEditData, String rewardName) {
    EditGUI inv = new EditGUI("Reward: " + rewardName);
    inv.requirePermission(AdvancedCorePlugin.getInstance().getOptions().getPermPrefix() + ".RewardEdit");
    inv.addData("Reward", rewardEditData);
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.REDSTONE).setName("&cRequirements")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            openRewardGUIRequirements(clickEvent.getPlayer(), rewardEditData, rewardName);
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.DIAMOND).setName("&cRewards").addLoreLine("&cOnly shows current set values for Rewards")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            openRewardGUIRewards(clickEvent.getPlayer(), rewardEditData, rewardName, false);
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.DIAMOND).setName("&cAll Rewards").addLoreLine("&cShows all possible settings")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            openRewardGUIRewards(clickEvent.getPlayer(), rewardEditData, rewardName, true);
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.ANVIL).setName("&cCopy from existing reward").addLoreLine("&cDoes not remove existing rewards currently set, unless they overlap")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            openRewardsGUICopy(clickEvent.getPlayer(), rewardEditData, rewardName);
        }
    });
    if (rewardEditData.getParent() != null) {
        inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cOpen parent reward edit GUI")) {

            @Override
            public void onClick(ClickEvent clickEvent) {
                RewardEditData rewardEditData = (RewardEditData) getInv().getData("Reward");
                rewardEditData.getParent().reOpenEditGUI(clickEvent.getPlayer());
            }
        }.setSlot(-2));
    }
    inv.openInventory(player);
}
Also used : EditGUI(com.bencodez.advancedcore.api.inventory.editgui.EditGUI) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) RewardEditData(com.bencodez.advancedcore.api.rewards.RewardEditData) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent)

Example 19 with BInventoryButton

use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project AdvancedCore by BenCodez.

the class RewardEditGUI method openRewardsGUI.

/**
 * Open rewards GUI.
 *
 * @param player the player
 */
public void openRewardsGUI(Player player) {
    if (!player.hasPermission(AdvancedCorePlugin.getInstance().getOptions().getPermPrefix() + ".RewardEdit")) {
        player.sendMessage("You do not have enough permission to do this");
        return;
    }
    BInventory inv = new BInventory("Rewards");
    for (Reward reward : plugin.getRewardHandler().getRewards()) {
        if (!reward.getConfig().isDirectlyDefinedReward()) {
            ArrayList<String> lore = new ArrayList<String>();
            if (reward.getConfig().isDirectlyDefinedReward()) {
                lore.add("&cReward is not directly defined, can not edit in GUI");
            }
            inv.addButton(new BInventoryButton(reward.getRewardName(), ArrayUtils.getInstance().convert(lore), new ItemStack(Material.STONE)) {

                @Override
                public void onClick(ClickEvent event) {
                    Player player = event.getWhoClicked();
                    Reward reward = (Reward) getData("Reward");
                    if (!reward.getConfig().isDirectlyDefinedReward()) {
                        openRewardGUI(player, new RewardEditData(reward), reward.getRewardName());
                    } else {
                        player.sendMessage("Can't edit this reward, directly defined reward");
                    }
                }
            }.addData("Reward", reward));
        }
    }
    inv.openInventory(player);
}
Also used : Player(org.bukkit.entity.Player) RewardEditData(com.bencodez.advancedcore.api.rewards.RewardEditData) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) ArrayList(java.util.ArrayList) BInventory(com.bencodez.advancedcore.api.inventory.BInventory) DirectlyDefinedReward(com.bencodez.advancedcore.api.rewards.DirectlyDefinedReward) Reward(com.bencodez.advancedcore.api.rewards.Reward) ItemStack(org.bukkit.inventory.ItemStack)

Example 20 with BInventoryButton

use of com.bencodez.advancedcore.api.inventory.BInventoryButton in project AdvancedCore by BenCodez.

the class RewardGUIConfirmation method onChest.

@Override
public void onChest(Player player) {
    BInventory inv = new BInventory(title);
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.EMERALD_BLOCK).setName("&aConfirm")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            onConfirm(clickEvent.getPlayer());
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.REDSTONE_BLOCK).setName("&aCancel")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            onDeny(clickEvent.getPlayer());
        }
    });
    inv.openInventory(player);
}
Also used : ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) BInventory(com.bencodez.advancedcore.api.inventory.BInventory)

Aggregations

BInventoryButton (com.bencodez.advancedcore.api.inventory.BInventoryButton)66 ClickEvent (com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent)65 ItemBuilder (com.bencodez.advancedcore.api.item.ItemBuilder)57 EditGUI (com.bencodez.advancedcore.api.inventory.editgui.EditGUI)33 Player (org.bukkit.entity.Player)32 BInventory (com.bencodez.advancedcore.api.inventory.BInventory)31 RewardEditData (com.bencodez.advancedcore.api.rewards.RewardEditData)29 EditGUIValueInventory (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueInventory)26 ArrayList (java.util.ArrayList)15 ValueRequestBuilder (com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder)11 EditGUIValueString (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString)10 StringListener (com.bencodez.advancedcore.api.valuerequest.listeners.StringListener)10 ItemStack (org.bukkit.inventory.ItemStack)10 ValueRequest (com.bencodez.advancedcore.api.valuerequest.ValueRequest)9 EditGUIButton (com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton)8 UpdatingBInventoryButton (com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton)7 Reward (com.bencodez.advancedcore.api.rewards.Reward)7 AdvancedCoreUser (com.bencodez.advancedcore.api.user.AdvancedCoreUser)7 VoteSite (com.bencodez.votingplugin.objects.VoteSite)7 NumberListener (com.bencodez.advancedcore.api.valuerequest.listeners.NumberListener)5