Search in sources :

Example 6 with ItemBuilder

use of com.bencodez.advancedcore.api.item.ItemBuilder in project VotingPlugin by Ben12345rocks.

the class VoteTopVoter method onChest.

@Override
public void onChest(Player player) {
    try {
        if (top == null) {
            top = TopVoter.getDefault();
        }
        Set<Entry<TopVoterPlayer, Integer>> users = null;
        String topVoter = top.getName();
        @SuppressWarnings("unchecked") LinkedHashMap<TopVoterPlayer, Integer> topVotes = (LinkedHashMap<TopVoterPlayer, Integer>) plugin.getTopVoter(top).clone();
        users = topVotes.entrySet();
        BInventory inv = new BInventory(plugin.getGui().getChestVoteTopName());
        inv.addPlaceholder("topvoter", topVoter);
        if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
            inv.dontClose();
        }
        int pos = 1;
        for (Entry<TopVoterPlayer, Integer> entry : users) {
            ItemBuilder playerItem = new ItemBuilder(Material.PAPER);
            if (plugin.getGui().isChestVoteTopUseSkull()) {
                playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
            } else {
                playerItem = new ItemBuilder(Material.valueOf(plugin.getGui().getChestVoteTopPlayerItemMaterial()));
            }
            playerItem.setLore(new ArrayList<String>());
            inv.addButton(new BInventoryButton(playerItem.setName(plugin.getGui().getChestVoteTopItemName()).addLoreLine(plugin.getGui().getChestVoteTopItemLore()).addPlaceholder("position", "" + pos).addPlaceholder("player", entry.getKey().getPlayerName()).addPlaceholder("votes", "" + entry.getValue())) {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    if (plugin.getGui().getChestVoteTopOpenMainGUIOnClick()) {
                        TopVoterPlayer user = (TopVoterPlayer) getData("User");
                        new VoteGUI(plugin, player, user.getUser()).open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
                    } else {
                        getInv().forceClose(clickEvent.getPlayer());
                    }
                }
            }.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey()));
            pos++;
        }
        final TopVoter cur = top;
        inv.getPageButtons().add(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteTopSwitchItem()).addPlaceholder("Top", topVoter)) {

            @Override
            public void onClick(ClickEvent clickEvent) {
                if (!clickEvent.getClick().equals(ClickType.RIGHT)) {
                    new VoteTopVoter(plugin, player, user, cur.next(), 0).open(GUIMethod.CHEST);
                } else {
                    new VoteTopVoter(plugin, player, user, cur.prev(), 0).open(GUIMethod.CHEST);
                }
            }
        });
        if (plugin.getGui().getChestVoteTopBackButton()) {
            inv.getPageButtons().add(plugin.getCommandLoader().getBackButton(user).setSlot(1));
        }
        inv.setPages(true);
        inv.setMaxInvSize(plugin.getGui().getChestVoteTopSize());
        inv.openInventory(player);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) TopVoterPlayer(com.bencodez.votingplugin.topvoter.TopVoterPlayer) BInventory(com.bencodez.advancedcore.api.inventory.BInventory) LinkedHashMap(java.util.LinkedHashMap) Entry(java.util.Map.Entry) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) TopVoter(com.bencodez.votingplugin.topvoter.TopVoter)

Example 7 with ItemBuilder

use of com.bencodez.advancedcore.api.item.ItemBuilder in project VotingPlugin by Ben12345rocks.

the class VoteTopVoterLastMonth method onChest.

@Override
public void onChest(Player player) {
    Set<Entry<TopVoterPlayer, Integer>> users = null;
    users = plugin.getLastMonthTopVoter().entrySet();
    BInventory inv = new BInventory(plugin.getGui().getChestVoteTopName());
    inv.addPlaceholder("topvoter", "Last Month");
    if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
        inv.dontClose();
    }
    int pos = 1;
    for (Entry<TopVoterPlayer, Integer> entry : users) {
        ItemBuilder playerItem;
        if (plugin.getGui().isChestVoteTopUseSkull()) {
            playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
        } else {
            playerItem = new ItemBuilder(Material.valueOf(plugin.getGui().getChestVoteTopPlayerItemMaterial()));
        }
        playerItem.setLore(new ArrayList<String>());
        inv.addButton(new BInventoryButton(playerItem.setName(plugin.getGui().getChestVoteTopItemName()).addLoreLine(plugin.getGui().getChestVoteTopItemLore()).addPlaceholder("position", "" + pos).addPlaceholder("player", entry.getKey().getPlayerName()).addPlaceholder("votes", "" + entry.getValue())) {

            @Override
            public void onClick(ClickEvent clickEvent) {
                TopVoterPlayer user = (TopVoterPlayer) getData("User");
                new VoteGUI(plugin, player, user.getUser()).open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
            }
        }.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey()));
        pos++;
    }
    if (plugin.getGui().getChestVoteTopBackButton()) {
        inv.getPageButtons().add(plugin.getCommandLoader().getBackButton(user).setSlot(1));
    }
    inv.setPages(true);
    inv.setMaxInvSize(plugin.getGui().getChestVoteTopSize());
    inv.openInventory(player);
}
Also used : BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) TopVoterPlayer(com.bencodez.votingplugin.topvoter.TopVoterPlayer) BInventory(com.bencodez.advancedcore.api.inventory.BInventory) Entry(java.util.Map.Entry) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder)

Example 8 with ItemBuilder

use of com.bencodez.advancedcore.api.item.ItemBuilder in project VotingPlugin by Ben12345rocks.

the class VoteURL method onChest.

@Override
public void onChest(Player player) {
    // normal GUI
    BInventory inv = new BInventory(plugin.getGui().getChestVoteURLName());
    if (plugin.getGui().getChestVoteURLViewAllUrlsButtonEnabled()) {
        ItemBuilder builderAll = getItemAll();
        inv.addButton(new UpdatingBInventoryButton(builderAll, 5000, 5000) {

            @Override
            public void onClick(ClickEvent event) {
                VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(event.getPlayer());
                json = true;
                user.sendMessage(getChat(player));
            }

            @Override
            public ItemBuilder onUpdate(Player player) {
                return getItemAll();
            }
        });
    }
    int startSlot = plugin.getGui().getChestVoteURLAllUrlsButtonStartSlot();
    for (final VoteSite voteSite : plugin.getVoteSites()) {
        if (!voteSite.isHidden()) {
            ItemBuilder builder = getItemVoteSite(voteSite);
            if (startSlot >= 0) {
                builder.setSlot(startSlot);
                startSlot++;
            }
            inv.addButton(new UpdatingBInventoryButton(builder, 5000, 5000) {

                @Override
                public void onClick(ClickEvent event) {
                    Player player = event.getPlayer();
                    if (player != null) {
                        VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
                        user.sendMessage(StringParser.getInstance().replacePlaceHolder(StringParser.getInstance().replacePlaceHolder(StringParser.getInstance().replacePlaceHolder(plugin.getGui().getChestVoteURLURLText(), "voteurl", voteSite.getVoteURL()), "sitename", voteSite.getDisplayName()), "player", player.getName()));
                    }
                }

                @Override
                public ItemBuilder onUpdate(Player player) {
                    return getItemVoteSite(voteSite);
                }
            });
        }
    }
    for (final String str : plugin.getGui().getChestVoteURLExtraItems()) {
        inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteURLExtraItemsItem(str))) {

            @Override
            public void onClick(ClickEvent clickEvent) {
                new RewardBuilder(plugin.getGui().getData(), "CHEST.VoteURL.ExtraItems." + str + ".Rewards").setGiveOffline(false).send(clickEvent.getPlayer());
            }
        });
    }
    if (plugin.getGui().getChestVoteURLBackButton()) {
        inv.addButton(plugin.getCommandLoader().getBackButton(user));
    }
    inv.openInventory(player);
}
Also used : VoteSite(com.bencodez.votingplugin.objects.VoteSite) RewardBuilder(com.bencodez.advancedcore.api.rewards.RewardBuilder) UpdatingBInventoryButton(com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) Player(org.bukkit.entity.Player) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) UpdatingBInventoryButton(com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) BInventory(com.bencodez.advancedcore.api.inventory.BInventory) VotingPluginUser(com.bencodez.votingplugin.user.VotingPluginUser)

Example 9 with ItemBuilder

use of com.bencodez.advancedcore.api.item.ItemBuilder in project VotingPlugin by Ben12345rocks.

the class VoteURL method getItemAll.

private ItemBuilder getItemAll() {
    ItemBuilder builderAll = new ItemBuilder(plugin.getGui().getChestVoteURLAlreadyVotedAllUrlsButtonItemSection());
    if (plugin.getGui().isChestVoteURLAllUrlsButtonrequireAllSitesVoted()) {
        if (user.canVoteAny()) {
            builderAll = new ItemBuilder(plugin.getGui().getChestVoteURLCanVoteAllUrlsButtonItemSection());
        }
    } else {
        if (user.canVoteAll()) {
            builderAll = new ItemBuilder(plugin.getGui().getChestVoteURLCanVoteAllUrlsButtonItemSection());
        }
    }
    if (!builderAll.hasCustomDisplayName()) {
        builderAll.setName("&4All Voting Sites");
    }
    if (!builderAll.hasCustomLore()) {
        builderAll.setLore("&cClick Me");
    }
    int slot = plugin.getGui().getChestVoteURLAllUrlsButtonSlot();
    if (slot >= 0) {
        builderAll.setSlot(slot);
    }
    return builderAll;
}
Also used : ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder)

Example 10 with ItemBuilder

use of com.bencodez.advancedcore.api.item.ItemBuilder in project VotingPlugin by Ben12345rocks.

the class AdminVoteVoteShopItem method onChest.

@Override
public void onChest(Player player) {
    EditGUI inv = new EditGUI("Edit VoteShop Item: " + identifier);
    inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.VoteShop");
    // to add
    inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueString("Identifier_Name", plugin.getGui().getChestShopIdentifierIdentifierName(identifier)) {

        @Override
        public void setValue(Player player, String name) {
            setPathData(getKey(), name);
        }
    }));
    inv.addButton(new EditGUIButton(new ItemBuilder(Material.OAK_DOOR, 1), new EditGUIValueString("Permission", plugin.getGui().getChestVoteShopPermission(identifier)) {

        @Override
        public void setValue(Player player, String name) {
            setPathData(getKey(), name);
        }
    }));
    inv.addButton(new EditGUIButton(new ItemBuilder(Material.EMERALD, 1), new EditGUIValueNumber("Cost", plugin.getGui().getChestShopIdentifierCost(identifier)) {

        @Override
        public void setValue(Player player, Number num) {
            setPathData(getKey(), num.intValue());
        }
    }));
    inv.addButton(new EditGUIButton(new ItemBuilder(Material.BARRIER, 1), new EditGUIValueNumber("Limit", plugin.getGui().getChestShopIdentifierLimit(identifier)) {

        @Override
        public void setValue(Player player, Number num) {
            setPathData(getKey(), num.intValue());
        }
    }));
    // display item
    ConfigurationSection displayItemData = plugin.getGui().getChestShopIdentifierSection(identifier);
    inv.addButton(new EditGUIButton(new ItemBuilder(Material.valueOf(displayItemData.getString("Material")), 1), new EditGUIValueString("Material", displayItemData.getString("Material")) {

        @Override
        public void setValue(Player player, String name) {
            setPathData(getKey(), name);
        }
    }));
    inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueString("Name", displayItemData.getString("Name")) {

        @Override
        public void setValue(Player player, String name) {
            setPathData(getKey(), name);
        }
    }));
    inv.addButton(new EditGUIButton(new ItemBuilder(Material.BOOK, 1), new EditGUIValueList("Lore", displayItemData.getStringList("Lore")) {

        @Override
        public void setValue(Player player, ArrayList<String> value) {
            setPathData(getKey(), value);
        }
    }));
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.DISPENSER, 1).setName("&cRewards")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(), plugin.getRewardHandler().getDirectlyDefined("CHEST.Shop." + identifier + ".Rewards"));
        }
    });
    // implement item reward?
    inv.openInventory(player);
}
Also used : EditGUI(com.bencodez.advancedcore.api.inventory.editgui.EditGUI) RewardEditGUI(com.bencodez.advancedcore.command.gui.RewardEditGUI) 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) 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) 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) ConfigurationSection(org.bukkit.configuration.ConfigurationSection)

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