Search in sources :

Example 1 with RewardEditTimed

use of com.bencodez.advancedcore.api.rewards.editbuttons.RewardEditTimed 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)

Aggregations

ClickEvent (com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent)1 BInventoryButton (com.bencodez.advancedcore.api.inventory.BInventoryButton)1 EditGUI (com.bencodez.advancedcore.api.inventory.editgui.EditGUI)1 EditGUIButton (com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton)1 EditGUIValueBoolean (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueBoolean)1 EditGUIValueInventory (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueInventory)1 ItemBuilder (com.bencodez.advancedcore.api.item.ItemBuilder)1 RewardEditData (com.bencodez.advancedcore.api.rewards.RewardEditData)1 RewardEditDelayed (com.bencodez.advancedcore.api.rewards.editbuttons.RewardEditDelayed)1 RewardEditTimed (com.bencodez.advancedcore.api.rewards.editbuttons.RewardEditTimed)1 RequirementInject (com.bencodez.advancedcore.api.rewards.injectedrequirement.RequirementInject)1 Player (org.bukkit.entity.Player)1