Search in sources :

Example 21 with ItemBuilder

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

the class UserGUI method openUserGUI.

/**
 * Open user GUI.
 *
 * @param player     the player
 * @param playerName the player name
 */
public void openUserGUI(Player player, final String playerName) {
    if (!player.hasPermission("AdvancedCore.UserEdit")) {
        player.sendMessage("Not enough permissions");
        return;
    }
    BInventory inv = new BInventory("UserGUI: " + playerName);
    inv.addData("player", playerName);
    inv.addButton(new BInventoryButton("Give Reward File", new String[] {}, new ItemStack(Material.STONE)) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            ArrayList<String> rewards = new ArrayList<String>();
            for (Reward reward : plugin.getRewardHandler().getRewards()) {
                rewards.add(reward.getRewardName());
            }
            new ValueRequest().requestString(clickEvent.getPlayer(), "", ArrayUtils.getInstance().convert(rewards), true, new StringListener() {

                @Override
                public void onInput(Player player, String value) {
                    AdvancedCoreUser user = plugin.getUserManager().getUser(UserGUI.getInstance().getCurrentPlayer(player));
                    plugin.getRewardHandler().giveReward(user, value, new RewardOptions());
                    player.sendMessage("Given " + user.getPlayerName() + " reward file " + value);
                }
            });
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder("WRITABLE_BOOK").setName("Edit Data")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            Player player = clickEvent.getPlayer();
            EditGUI inv = new EditGUI("Edit Data, click to change");
            final AdvancedCoreUser user = plugin.getUserManager().getUser(playerName);
            for (final String key : user.getData().getKeys()) {
                String value = user.getData().getValue(key);
                inv.addButton(new EditGUIButton(new ItemBuilder(Material.STONE).setName(key + " = " + value), new EditGUIValueString(key, value) {

                    @Override
                    public void setValue(Player player, String value) {
                        if (value.equals("\"\"")) {
                            value = "";
                        }
                        user.getData().setString(key, value);
                        openUserGUI(player, playerName);
                    }
                }));
            }
            inv.openInventory(player);
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&cView player data")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            AdvancedCoreUser user = plugin.getUserManager().getUser(playerName);
            for (String key : user.getData().getKeys()) {
                String str = user.getData().getValue(key);
                user.sendMessage("&c&l" + key + " &c" + str);
            }
        }
    });
    for (BInventoryButton button : extraButtons.values()) {
        inv.addButton(button);
    }
    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) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) ArrayList(java.util.ArrayList) EditGUIValueString(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString) BInventory(com.bencodez.advancedcore.api.inventory.BInventory) EditGUIValueString(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString) ValueRequest(com.bencodez.advancedcore.api.valuerequest.ValueRequest) AdvancedCoreUser(com.bencodez.advancedcore.api.user.AdvancedCoreUser) RewardOptions(com.bencodez.advancedcore.api.rewards.RewardOptions) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) EditGUIButton(com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton) Reward(com.bencodez.advancedcore.api.rewards.Reward) StringListener(com.bencodez.advancedcore.api.valuerequest.listeners.StringListener) ItemStack(org.bukkit.inventory.ItemStack)

Example 22 with ItemBuilder

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

the class RewardEditLucky method openRename.

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

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

the class RewardEditLucky method openEditSub.

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

Example 24 with ItemBuilder

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

the class RewardEditPotions method openEditSub.

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

Example 25 with ItemBuilder

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

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