Search in sources :

Example 31 with EditGUIValueInventory

use of com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueInventory 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 32 with EditGUIValueInventory

use of com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueInventory 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 33 with EditGUIValueInventory

use of com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueInventory 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 34 with EditGUIValueInventory

use of com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueInventory in project AdvancedCore by BenCodez.

the class RewardEditJavascript method open.

@Override
public void open(Player player, RewardEditData reward) {
    EditGUI inv = new EditGUI("Edit Javascript: " + reward.getName());
    inv.addData("Reward", reward);
    inv.addButton(getBooleanButton("Javascript.Enabled", reward));
    inv.addButton(getStringButton("Javascript.Expression", reward));
    inv.addButton(new EditGUIButton(new EditGUIValueInventory("Javascript.TrueRewards") {

        @Override
        public void openInventory(ClickEvent clickEvent) {
            RewardEditData reward = (RewardEditData) getInv().getData("Reward");
            if (reward.hasPath("AdvancedRandomReward")) {
                openSubReward(player, "Javascript.TrueRewards", reward);
            }
        }
    }).setName("&aEdit true rewards"));
    inv.addButton(new EditGUIButton(new EditGUIValueInventory("Javascript.FalseRewards") {

        @Override
        public void openInventory(ClickEvent clickEvent) {
            RewardEditData reward = (RewardEditData) getInv().getData("Reward");
            if (reward.hasPath("AdvancedRandomReward")) {
                openSubReward(player, "Javascript.FalseRewards", reward);
            }
        }
    }).setName("&aEdit false rewards"));
    inv.addButton(getBackButton(reward));
    inv.openInventory(player);
}
Also used : EditGUI(com.bencodez.advancedcore.api.inventory.editgui.EditGUI) RewardEditData(com.bencodez.advancedcore.api.rewards.RewardEditData) EditGUIButton(com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) EditGUIValueInventory(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueInventory)

Example 35 with EditGUIValueInventory

use of com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueInventory 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

EditGUIValueInventory (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueInventory)39 ClickEvent (com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent)38 EditGUI (com.bencodez.advancedcore.api.inventory.editgui.EditGUI)35 RewardEditData (com.bencodez.advancedcore.api.rewards.RewardEditData)35 ItemBuilder (com.bencodez.advancedcore.api.item.ItemBuilder)30 BInventoryButton (com.bencodez.advancedcore.api.inventory.BInventoryButton)26 Player (org.bukkit.entity.Player)18 EditGUIButton (com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton)14 ValueRequestBuilder (com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder)13 StringListener (com.bencodez.advancedcore.api.valuerequest.listeners.StringListener)9 EditGUIValueString (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString)6 UpdatingBInventoryButton (com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton)5 ArrayList (java.util.ArrayList)5 EditGUIValueList (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueList)4 NumberListener (com.bencodez.advancedcore.api.valuerequest.listeners.NumberListener)4 FileDirectoryException (com.bencodez.advancedcore.api.exceptions.FileDirectoryException)2 EditGUIValueBoolean (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueBoolean)2 EditGUIValueNumber (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber)2 JavascriptEngine (com.bencodez.advancedcore.api.javascript.JavascriptEngine)2 RewardEditAdvancedRandomReward (com.bencodez.advancedcore.api.rewards.editbuttons.RewardEditAdvancedRandomReward)2