Search in sources :

Example 36 with EditGUIValueInventory

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

the class RewardEditPotions method open.

@Override
public void open(Player player, RewardEditData reward) {
    EditGUI inv = new EditGUI("Edit Potions: " + reward.getName());
    inv.addData("Reward", reward);
    ArrayList<String> potionEffects = new ArrayList<String>();
    for (PotionEffectType effect : PotionEffectType.values()) {
        potionEffects.add(effect.toString());
    }
    inv.addButton(new EditGUIButton(new EditGUIValueInventory("Potions") {

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

                @Override
                public void onInput(Player player, String value) {
                    RewardEditData reward = (RewardEditData) getInv().getData("Reward");
                    reward.createSection("Potions." + value);
                    reloadAdvancedCore();
                    open(player, reward);
                }
            }, ArrayUtils.getInstance().convert(potionEffects)).usingMethod(InputMethod.INVENTORY).request(clickEvent.getPlayer());
        }
    }).setName("&aAdd potion effect"));
    inv.addButton(new EditGUIButton(new EditGUIValueInventory("Potions") {

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

        @Override
        public void openInventory(ClickEvent clickEvent) {
            RewardEditData reward = (RewardEditData) getInv().getData("Reward");
            if (reward.hasPath("Potions")) {
                openEditSub(player, reward);
            }
        }
    }).setName("&aEdit potion effect"));
    inv.addButton(getBackButton(reward));
    inv.openInventory(player);
}
Also used : EditGUI(com.bencodez.advancedcore.api.inventory.editgui.EditGUI) Player(org.bukkit.entity.Player) PotionEffectType(org.bukkit.potion.PotionEffectType) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) ArrayList(java.util.ArrayList) ValueRequestBuilder(com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder) RewardEditData(com.bencodez.advancedcore.api.rewards.RewardEditData) EditGUIButton(com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton) EditGUIValueInventory(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueInventory) StringListener(com.bencodez.advancedcore.api.valuerequest.listeners.StringListener)

Example 37 with EditGUIValueInventory

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

the class RewardEditPotions method openEditSub.

public void openEditSub(Player player, RewardEditData reward, String potion) {
    EditGUI inv = new EditGUI("Edit Potions Edit " + potion + ": " + reward.getName());
    inv.addData("Reward", reward);
    inv.addButton(getIntButton("Potions." + potion + ".Duration", reward));
    inv.addButton(getIntButton("Potions." + potion + ".Amplifier", 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) RewardEditData(com.bencodez.advancedcore.api.rewards.RewardEditData) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) EditGUIValueInventory(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueInventory)

Example 38 with EditGUIValueInventory

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

the class RewardEditSpecialChance method openRename.

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

                    @Override
                    public void onInput(Player player, Number value) {
                        RewardEditData reward = (RewardEditData) getInv().getData("Reward");
                        reward.setValue("SpecialChance." + value.intValue(), reward.getData().getConfigurationSection("SpecialChance." + key));
                        reward.setValue("SpecialChance." + key, null);
                        reloadAdvancedCore();
                        open(player, reward);
                    }
                }, new Number[] {}).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) NumberListener(com.bencodez.advancedcore.api.valuerequest.listeners.NumberListener) 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) ValueRequestBuilder(com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder)

Example 39 with EditGUIValueInventory

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

the class RewardEditSpecialChance method openEditSub.

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

            @Override
            public void onClick(ClickEvent clickEvent) {
                RewardEditData reward = (RewardEditData) getInv().getData("Reward");
                openSubReward(clickEvent.getPlayer(), "SpecialChance." + key, 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