Search in sources :

Example 16 with ItemBuilder

use of com.bencodez.advancedcore.api.item.ItemBuilder in project AdvancedCore by BenCodez.

the class ChoiceGUI method openPreferenceReward.

public void openPreferenceReward(Player player, String rewardName) {
    Reward reward = plugin.getRewardHandler().getReward(rewardName);
    if (!reward.getConfig().getEnableChoices()) {
        player.sendMessage("Choice rewards not enabled");
        return;
    }
    AdvancedCoreUser user = plugin.getUserManager().getUser(player);
    BInventory inv = new BInventory("Select Preference");
    for (String choice : reward.getConfig().getChoices()) {
        ItemBuilder builder = new ItemBuilder(reward.getConfig().getChoicesItem(choice));
        if (user.getChoicePreference(rewardName).equalsIgnoreCase(choice)) {
            builder.addLoreLine("&cCurrent preference");
            builder.addLoreLine("&c&lClick to remove");
        } else {
            builder.addLoreLine("&aClick to set as preference");
        }
        builder.setName("&a" + choice);
        inv.addButton(new BInventoryButton(builder) {

            @Override
            public void onClick(ClickEvent clickEvent) {
                AdvancedCoreUser user = (AdvancedCoreUser) getInv().getData("User");
                String rewardName = (String) getInv().getData("Reward");
                String choice = (String) getData("Choice");
                if (user.getChoicePreference(rewardName).equals(choice)) {
                    choice = "none";
                }
                user.setChoicePreference(rewardName, choice);
                user.sendMessage(plugin.getOptions().getFormatChoiceRewardsPreferenceSet(), "choice", choice);
            }
        }.addData("Choice", choice));
    }
    inv.addData("User", user);
    inv.addData("Reward", rewardName);
    inv.openInventory(player);
}
Also used : AdvancedCoreUser(com.bencodez.advancedcore.api.user.AdvancedCoreUser) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) Reward(com.bencodez.advancedcore.api.rewards.Reward) BInventory(com.bencodez.advancedcore.api.inventory.BInventory)

Example 17 with ItemBuilder

use of com.bencodez.advancedcore.api.item.ItemBuilder in project AdvancedCore by BenCodez.

the class ChoiceGUI method openClaimChoices.

public void openClaimChoices(Player player, Reward reward) {
    if (!reward.getConfig().getEnableChoices()) {
        player.sendMessage("Choice rewards not enabled");
        return;
    }
    AdvancedCoreUser user = plugin.getUserManager().getUser(player);
    BInventory inv = new BInventory("Pick reward");
    inv.dontClose();
    for (String choice : reward.getConfig().getChoices()) {
        ItemBuilder builder = new ItemBuilder(reward.getConfig().getChoicesItem(choice)).setNameIfNotExist("&a" + choice);
        inv.addButton(new BInventoryButton(builder) {

            @Override
            public void onClick(ClickEvent clickEvent) {
                Reward reward = (Reward) getInv().getData("Reward");
                AdvancedCoreUser user = (AdvancedCoreUser) getInv().getData("User");
                String choice = (String) getData("Choice");
                user.removeUnClaimedChoiceReward(reward.getName());
                plugin.getRewardHandler().giveChoicesReward(reward, user, choice);
                if (user.getUnClaimedChoices().size() > 0) {
                    openClaimChoices(clickEvent.getPlayer());
                } else {
                    Bukkit.getScheduler().runTask(plugin, new Runnable() {

                        @Override
                        public void run() {
                            clickEvent.getPlayer().closeInventory();
                        }
                    });
                }
            }
        }.addData("Choice", choice));
    }
    inv.addData("User", user);
    inv.addData("Reward", reward);
    inv.openInventory(player);
}
Also used : AdvancedCoreUser(com.bencodez.advancedcore.api.user.AdvancedCoreUser) 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) Reward(com.bencodez.advancedcore.api.rewards.Reward)

Example 18 with ItemBuilder

use of com.bencodez.advancedcore.api.item.ItemBuilder 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 19 with ItemBuilder

use of com.bencodez.advancedcore.api.item.ItemBuilder 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 20 with ItemBuilder

use of com.bencodez.advancedcore.api.item.ItemBuilder 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

ItemBuilder (com.bencodez.advancedcore.api.item.ItemBuilder)71 ClickEvent (com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent)64 BInventoryButton (com.bencodez.advancedcore.api.inventory.BInventoryButton)57 EditGUI (com.bencodez.advancedcore.api.inventory.editgui.EditGUI)32 Player (org.bukkit.entity.Player)32 EditGUIValueInventory (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueInventory)30 BInventory (com.bencodez.advancedcore.api.inventory.BInventory)28 RewardEditData (com.bencodez.advancedcore.api.rewards.RewardEditData)28 EditGUIButton (com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton)13 ArrayList (java.util.ArrayList)13 UpdatingBInventoryButton (com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton)11 EditGUIValueString (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString)11 ValueRequestBuilder (com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder)11 StringListener (com.bencodez.advancedcore.api.valuerequest.listeners.StringListener)9 EditGUIValueList (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueList)7 VoteSite (com.bencodez.votingplugin.objects.VoteSite)7 EditGUIValueNumber (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber)6 Reward (com.bencodez.advancedcore.api.rewards.Reward)6 AdvancedCoreUser (com.bencodez.advancedcore.api.user.AdvancedCoreUser)6 ValueRequest (com.bencodez.advancedcore.api.valuerequest.ValueRequest)6