Search in sources :

Example 26 with BInventoryButton

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

the class RewardEditPotions method openRemove.

public void openRemove(Player player, RewardEditData reward) {
    EditGUI inv = new EditGUI("Edit Potions Remove: " + reward.getName());
    inv.addData("Reward", reward);
    for (String key : reward.getData().getConfigurationSection("Potions").getKeys(false)) {
        inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&c" + key).addLoreLine("&cClick to remove")) {

            @Override
            public void onClick(ClickEvent clickEvent) {
                RewardEditData reward = (RewardEditData) getInv().getData("Reward");
                reward.setValue("Potions." + key, null);
                reloadAdvancedCore();
                open(player, reward);
            }
        });
    }
    inv.addButton(getBackButtonCustom(reward, new EditGUIValueInventory("") {

        @Override
        public void openInventory(ClickEvent clickEvent) {
            RewardEditData reward = (RewardEditData) getInv().getData("Reward");
            open(player, reward);
        }
    }));
    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) EditGUIValueInventory(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueInventory)

Example 27 with BInventoryButton

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

the class RewardEditSpecialChance method openRemove.

public void openRemove(Player player, RewardEditData reward) {
    EditGUI inv = new EditGUI("Edit SpecialChance Remove: " + reward.getName());
    inv.addData("Reward", reward);
    for (String key : reward.getData().getConfigurationSection("SpecialChance").getKeys(false)) {
        inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&c" + key).addLoreLine("&cClick to remove")) {

            @Override
            public void onClick(ClickEvent clickEvent) {
                RewardEditData reward = (RewardEditData) getInv().getData("Reward");
                reward.setValue("SpecialChance." + key, null);
                reloadAdvancedCore();
                open(player, reward);
            }
        });
    }
    inv.addButton(getBackButtonCustom(reward, new EditGUIValueInventory("") {

        @Override
        public void openInventory(ClickEvent clickEvent) {
            RewardEditData reward = (RewardEditData) getInv().getData("Reward");
            open(player, reward);
        }
    }));
    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) EditGUIValueInventory(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueInventory)

Example 28 with BInventoryButton

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

the class EditGUI method sort.

public void sort() {
    Map<Integer, BInventoryButton> map = getButtons();
    setButtons(new HashMap<Integer, BInventoryButton>());
    LinkedHashMap<String, EditGUIButton> buttons = new LinkedHashMap<String, EditGUIButton>();
    ArrayList<String> sortedList = new ArrayList<String>();
    for (BInventoryButton button : map.values()) {
        if (button instanceof EditGUIButton) {
            EditGUIButton b = (EditGUIButton) button;
            String key = b.getEditor().getKey();
            sortedList.add(key);
            b.setSlot(-1);
            buttons.put(key, b);
        } else {
            addButton(button);
        }
    }
    sortedList.sort(Comparator.naturalOrder());
    for (String key : sortedList) {
        addButton(buttons.get(key));
    }
}
Also used : BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap)

Example 29 with BInventoryButton

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

the class RewardEditAdvancedRandomReward method openRename.

public void openRename(Player player, RewardEditData reward) {
    EditGUI inv = new EditGUI("Edit AdvancedRandomReward Rename: " + reward.getName());
    inv.addData("Reward", reward);
    for (String key : reward.getData().getConfigurationSection("AdvancedRandomReward").getKeys(false)) {
        inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&a" + key).addLoreLine("&aClick to rename")) {

            @Override
            public void onClick(ClickEvent clickEvent) {
                new ValueRequestBuilder(new StringListener() {

                    @Override
                    public void onInput(Player player, String value) {
                        RewardEditData reward = (RewardEditData) getInv().getData("Reward");
                        reward.setValue("AdvancedRandomReward." + value, reward.getData().getConfigurationSection("AdvancedRandomReward." + key));
                        reward.setValue("AdvancedRandomReward." + key, null);
                        reloadAdvancedCore();
                        open(player, reward);
                    }
                }, new String[] {}).usingMethod(InputMethod.CHAT).request(clickEvent.getPlayer());
            }
        });
    }
    inv.addButton(getBackButtonCustom(reward, new EditGUIValueInventory("") {

        @Override
        public void openInventory(ClickEvent clickEvent) {
            RewardEditData reward = (RewardEditData) getInv().getData("Reward");
            open(player, reward);
        }
    }));
    inv.openInventory(player);
}
Also used : EditGUI(com.bencodez.advancedcore.api.inventory.editgui.EditGUI) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) 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) EditGUIValueInventory(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueInventory) StringListener(com.bencodez.advancedcore.api.valuerequest.listeners.StringListener) ValueRequestBuilder(com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder)

Example 30 with BInventoryButton

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

the class RewardEditAdvancedWorld method openRename.

public void openRename(Player player, RewardEditData reward) {
    EditGUI inv = new EditGUI("Edit AdvancedWorld Rename: " + reward.getName());
    inv.addData("Reward", reward);
    for (String key : reward.getData().getConfigurationSection("AdvancedWorld").getKeys(false)) {
        inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&a" + key).addLoreLine("&aClick to rename")) {

            @Override
            public void onClick(ClickEvent clickEvent) {
                new ValueRequestBuilder(new StringListener() {

                    @Override
                    public void onInput(Player player, String value) {
                        RewardEditData reward = (RewardEditData) getInv().getData("Reward");
                        reward.setValue("AdvancedWorld." + value, reward.getData().getConfigurationSection("AdvancedWorld." + key));
                        reward.setValue("AdvancedWorld." + key, null);
                        reloadAdvancedCore();
                        open(player, reward);
                    }
                }, new String[] {}).usingMethod(InputMethod.CHAT).request(clickEvent.getPlayer());
            }
        });
    }
    inv.addButton(getBackButtonCustom(reward, new EditGUIValueInventory("") {

        @Override
        public void openInventory(ClickEvent clickEvent) {
            RewardEditData reward = (RewardEditData) getInv().getData("Reward");
            open(player, reward);
        }
    }));
    inv.openInventory(player);
}
Also used : EditGUI(com.bencodez.advancedcore.api.inventory.editgui.EditGUI) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) 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) EditGUIValueInventory(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueInventory) StringListener(com.bencodez.advancedcore.api.valuerequest.listeners.StringListener) ValueRequestBuilder(com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder)

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