Search in sources :

Example 46 with BInventoryButton

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

the class RewardEditItems method openEdit.

public void openEdit(Player player, RewardEditData reward) {
    EditGUI inv = new EditGUI("Edit Item Edit: " + reward.getName());
    inv.addData("Reward", reward);
    for (String key : reward.getData().getConfigurationSection("Items").getKeys(false)) {
        inv.addButton(new BInventoryButton(new ItemBuilder(reward.getData().getConfigurationSection("Items." + key)).setName("&c" + key).addLoreLine("&cClick to edit")) {

            @Override
            public void onClick(ClickEvent clickEvent) {
                String key = (String) getData("key");
                openEditItem(player, key, reward);
            }
        }.addData("key", key));
    }
    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) UpdatingBInventoryButton(com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) EditGUIValueInventory(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueInventory) EditGUIValueString(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString)

Example 47 with BInventoryButton

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

the class RewardEditItems method openEditItem.

public void openEditItem(Player player, String item, RewardEditData reward) {
    EditGUI inv = new EditGUI("Edit Item " + item + ": " + reward.getName());
    inv.addData("Reward", reward);
    inv.addData("Item", item);
    inv.addButton(new BInventoryButton(new ItemBuilder(reward.getData().getConfigurationSection("Items." + item))) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            RewardEditData reward = (RewardEditData) getInv().getData("Reward");
            String item = (String) getInv().getData("Item");
            openEditItem(player, item, reward);
        }
    });
    inv.addButton(new EditGUIButton(new EditGUIValueString("Items." + item + ".Name", reward.getValue("Items." + item + ".Name")) {

        @Override
        public void setValue(Player player, String value) {
            RewardEditData reward = (RewardEditData) getInv().getData("Reward");
            reward.setValue(getKey(), value);
            reloadAdvancedCore();
            String item = (String) getInv().getData("Item");
            openEditItem(player, item, reward);
        }
    }));
    inv.addButton(new EditGUIButton(new EditGUIValueList("Items." + item + ".Lore", reward.getValue("Items." + item + ".Lore")) {

        @Override
        public void setValue(Player player, ArrayList<String> value) {
            RewardEditData reward = (RewardEditData) getInv().getData("Reward");
            reward.setValue(getKey(), value);
            reloadAdvancedCore();
            String item = (String) getInv().getData("Item");
            openEditItem(player, item, reward);
        }
    }));
    inv.addButton(new EditGUIButton(new EditGUIValueNumber("Items." + item + ".Amount", reward.getValue("Items." + item + ".Amount")) {

        @Override
        public void setValue(Player player, Number value) {
            RewardEditData reward = (RewardEditData) getInv().getData("Reward");
            reward.setValue(getKey(), value.intValue());
            reloadAdvancedCore();
            String item = (String) getInv().getData("Item");
            openEditItem(player, item, reward);
        }
    }));
    inv.addButton(new EditGUIButton(new EditGUIValueNumber("Items." + item + ".CustomModelData", reward.getValue("Items." + item + ".CustomModelData")) {

        @Override
        public void setValue(Player player, Number value) {
            RewardEditData reward = (RewardEditData) getInv().getData("Reward");
            reward.setValue(getKey(), value.intValue());
            reloadAdvancedCore();
            String item = (String) getInv().getData("Item");
            openEditItem(player, item, reward);
        }
    }));
    ArrayList<String> flagList = new ArrayList<String>();
    for (ItemFlag flag : ItemFlag.values()) {
        flagList.add(flag.toString());
    }
    inv.addButton(new EditGUIButton(new EditGUIValueList("Items." + item + ".ItemFlags", reward.getValue("Items." + item + ".ItemFlags")) {

        @Override
        public void setValue(Player player, ArrayList<String> value) {
            RewardEditData reward = (RewardEditData) getInv().getData("Reward");
            reward.setValue(getKey(), value);
            reloadAdvancedCore();
            String item = (String) getInv().getData("Item");
            openEditItem(player, item, reward);
        }
    }).addOptions(ArrayUtils.getInstance().convert(flagList)));
    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) Player(org.bukkit.entity.Player) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) UpdatingBInventoryButton(com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) ArrayList(java.util.ArrayList) EditGUIValueString(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString) EditGUIValueString(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) EditGUIValueList(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueList) RewardEditData(com.bencodez.advancedcore.api.rewards.RewardEditData) EditGUIValueNumber(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber) EditGUIButton(com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton) EditGUIValueNumber(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber) EditGUIValueInventory(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueInventory) ItemFlag(org.bukkit.inventory.ItemFlag)

Example 48 with BInventoryButton

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

the class RewardEditItems method open.

@Override
public void open(Player player, RewardEditData reward) {
    EditGUI inv = new EditGUI("Edit Items: " + reward.getName());
    inv.addData("Reward", reward);
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&cView current items").addLoreLine("&aDisplaying all current items on next slot").addLoreLine("&aThis doesn't support adding conditional items")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
        }
    });
    UpdatingBInventoryButton b = new UpdatingBInventoryButton(new ItemBuilder(Material.PAPER).setName("&cView current items").addLoreLine("&aDisplaying all current items").addLoreLine("This doesn't support adding conditional items"), 750, 750) {

        public ItemBuilder nextItem() {
            RewardEditData reward = (RewardEditData) getInv().getData("Reward");
            if (reward.hasPath("Items")) {
                try {
                    int num = (int) getData("CurrentItem");
                    @SuppressWarnings("unchecked") ArrayList<String> set = (ArrayList<String>) getData("ItemsKeys");
                    num++;
                    if (num >= set.size()) {
                        num = 0;
                    }
                    addData("CurrentItem", num);
                    return new ItemBuilder(reward.getData().getConfigurationSection("Items." + set.get(num))).addLoreLine("&cDisplaying: " + set.get(num));
                } catch (Exception e) {
                    e.printStackTrace();
                    return new ItemBuilder(Material.STONE).setName("Error");
                }
            }
            return new ItemBuilder(Material.PAPER).setName("&cNo Items");
        }

        @Override
        public void onClick(ClickEvent clickEvent) {
            RewardEditData reward = (RewardEditData) getInv().getData("Reward");
            open(player, reward);
        }

        @Override
        public ItemBuilder onUpdate(Player player) {
            return nextItem();
        }
    };
    if (reward.hasPath("Items")) {
        b.addData("ItemsKeys", ArrayUtils.getInstance().convert(reward.getData().getConfigurationSection("Items").getKeys(false)));
    } else {
        b.addData("ItemsKeys", new ArrayList<String>());
    }
    b.addData("CurrentItem", 0);
    inv.addButton(b);
    inv.addButton(new EditGUIButton(new EditGUIValueInventory("Items") {

        @Override
        public void openInventory(ClickEvent clickEvent) {
            RewardEditData reward = (RewardEditData) getInv().getData("Reward");
            if (reward.hasPath("Items")) {
                openRemove(player, reward);
            }
        }
    }).setName("&aRemove item"));
    inv.addButton(new EditGUIButton(new EditGUIValueInventory("Items") {

        @Override
        public void openInventory(ClickEvent clickEvent) {
            RewardEditData reward = (RewardEditData) getInv().getData("Reward");
            if (reward.hasPath("Items")) {
                openEdit(player, reward);
            }
        }
    }).setName("&aEdit existing item"));
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&aAdd current item in hand to reward")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            RewardEditData reward = (RewardEditData) getInv().getData("Reward");
            openAdd(clickEvent.getPlayer(), reward);
        }
    });
    inv.addButton(getBackButton(reward));
    inv.openInventory(player);
}
Also used : EditGUI(com.bencodez.advancedcore.api.inventory.editgui.EditGUI) UpdatingBInventoryButton(com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton) Player(org.bukkit.entity.Player) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) UpdatingBInventoryButton(com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) ArrayList(java.util.ArrayList) EditGUIValueString(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString) 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)

Example 49 with BInventoryButton

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

the class RewardEditItems method openAdd.

@SuppressWarnings("deprecation")
public void openAdd(Player player, RewardEditData reward) {
    EditGUI inv = new EditGUI("Edit Item Add: " + reward.getName());
    inv.addData("Reward", reward);
    inv.addButton(new BInventoryButton(new ItemBuilder(player.getItemInHand().clone()).addLoreLine("&cClick to add")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            ItemBuilder item = new ItemBuilder(clickEvent.getPlayer().getItemInHand().clone());
            HashMap<String, Object> map = item.getConfiguration();
            for (Entry<String, Object> entry : map.entrySet()) {
                reward.setValue("Items." + item.getType().toString() + "." + entry.getKey(), entry.getValue());
            }
            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) Entry(java.util.Map.Entry) RewardEditData(com.bencodez.advancedcore.api.rewards.RewardEditData) HashMap(java.util.HashMap) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) UpdatingBInventoryButton(com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) EditGUIValueInventory(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueInventory)

Example 50 with BInventoryButton

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

the class RewardEditLucky method openRemove.

public void openRemove(Player player, RewardEditData reward) {
    EditGUI inv = new EditGUI("Edit Lucky Remove: " + reward.getName());
    inv.addData("Reward", reward);
    for (String key : reward.getData().getConfigurationSection("Lucky").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("Lucky." + 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)

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