Search in sources :

Example 6 with BInventory

use of com.bencodez.advancedcore.api.inventory.BInventory in project VotingPlugin by Ben12345rocks.

the class VoteURLVoteSite method onChest.

@Override
public void onChest(Player player) {
    if (!plugin.isVoteSite(voteSite)) {
        player.sendMessage("Not a valid votesite");
        return;
    }
    VoteSite site = plugin.getVoteSite(voteSite, true);
    BInventory inv = new BInventory(plugin.getGui().getChestVoteURLSiteName());
    inv.addPlaceholder("site", site.getDisplayName());
    inv.setMeta(player, "VoteSite", site);
    if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
        inv.dontClose();
    }
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.BOW).setName("&4URL").addLoreLine("Click to see URL")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            VoteSite site = (VoteSite) clickEvent.getMeta("VoteSite");
            clickEvent.getWhoClicked().sendMessage(site.getVoteURL());
        }
    });
    inv.addButton(new UpdatingBInventoryButton(new ItemBuilder(Material.COMPASS).setName("&4Next Vote").addLoreLine(user.voteCommandNextInfo(site)), 1000, 1000) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            new VoteURL(plugin, clickEvent.getPlayer(), user, true).open();
        }

        @Override
        public ItemBuilder onUpdate(Player arg0) {
            return new ItemBuilder(Material.COMPASS).setName("&4Next Vote").addLoreLine(user.voteCommandNextInfo(site));
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.CLOCK).setName("&4Last Vote").addLoreLine(user.voteCommandLastLine(site))) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            new VoteURL(plugin, clickEvent.getPlayer(), user, true).open();
        }
    });
    if (plugin.getGui().getChestVoteURLBackButton()) {
        inv.addButton(plugin.getCommandLoader().getBackButton(user));
    }
    inv.openInventory(player);
}
Also used : VoteSite(com.bencodez.votingplugin.objects.VoteSite) UpdatingBInventoryButton(com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) 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) BInventory(com.bencodez.advancedcore.api.inventory.BInventory)

Example 7 with BInventory

use of com.bencodez.advancedcore.api.inventory.BInventory in project VotingPlugin by Ben12345rocks.

the class AdminVoteCumulative method onChest.

@Override
public void onChest(Player player) {
    BInventory inv = new BInventory("Edit Cumulative");
    inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.Cumulative");
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&cEdit existing cumulative rewards")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            ArrayList<Integer> nums = new ArrayList<Integer>();
            for (String num : plugin.getSpecialRewardsConfig().getCumulativeVotes()) {
                if (StringParser.getInstance().isInt(num)) {
                    nums.add(Integer.parseInt(num));
                }
            }
            Number[] options = new Number[nums.size()];
            for (int i = 0; i < nums.size(); i++) {
                options[i] = nums.get(i);
            }
            new ValueRequestBuilder(new NumberListener() {

                @Override
                public void onInput(Player player, Number value) {
                    RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(), RewardHandler.getInstance().getDirectlyDefined("Cumulative." + value.intValue() + ".Rewards"));
                }
            }, options).allowCustomOption(false).usingMethod(InputMethod.INVENTORY).request(clickEvent.getPlayer());
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.EMERALD_BLOCK).setName("&aAdd cumulative reward")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            new ValueRequest().requestNumber(player, new NumberListener() {

                @Override
                public void onInput(Player player, Number value) {
                    plugin.getSpecialRewardsConfig().setCumulative(value.intValue());
                    plugin.reload();
                }
            });
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.REDSTONE_BLOCK).setName("&cRemove cumulative")) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            new AdminVoteCumulativeRemove(plugin, clickEvent.getPlayer()).open();
        }
    });
    inv.openInventory(player);
}
Also used : Player(org.bukkit.entity.Player) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) ArrayList(java.util.ArrayList) BInventory(com.bencodez.advancedcore.api.inventory.BInventory) ValueRequest(com.bencodez.advancedcore.api.valuerequest.ValueRequest) ValueRequestBuilder(com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) NumberListener(com.bencodez.advancedcore.api.valuerequest.listeners.NumberListener)

Example 8 with BInventory

use of com.bencodez.advancedcore.api.inventory.BInventory 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 9 with BInventory

use of com.bencodez.advancedcore.api.inventory.BInventory 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 10 with BInventory

use of com.bencodez.advancedcore.api.inventory.BInventory in project VotingPlugin by Ben12345rocks.

the class AdminGUI method openAdminGUIVoteSites.

/**
 * Open admin GUI vote sites.
 *
 * @param player the player
 */
public void openAdminGUIVoteSites(Player player) {
    BInventory inv = new BInventory("VoteSites");
    int count = 0;
    for (VoteSite voteSite : plugin.getVoteSites()) {
        ArrayList<String> lore = new ArrayList<String>();
        lore.add("Priority: " + voteSite.getPriority());
        lore.add("Name: " + voteSite.getDisplayName());
        lore.add("ServiceSite: " + voteSite.getServiceSite());
        lore.add("VoteURL: " + voteSite.getVoteURL());
        lore.add("VoteDelay: " + voteSite.getVoteDelay());
        lore.add("VoteDelayMin: " + voteSite.getVoteDelayMin());
        inv.addButton(count, new BInventoryButton(voteSite.getKey(), ArrayUtils.getInstance().convert(lore), new ItemStack(Material.STONE)) {

            @Override
            public void onClick(ClickEvent event) {
                Player player = event.getWhoClicked();
                openAdminGUIVoteSiteSite(player, voteSite);
            }
        });
        count++;
    }
    inv.openInventory(player);
}
Also used : VoteSite(com.bencodez.votingplugin.objects.VoteSite) Player(org.bukkit.entity.Player) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) ArrayList(java.util.ArrayList) BInventory(com.bencodez.advancedcore.api.inventory.BInventory) EditGUIValueString(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString) ItemStack(org.bukkit.inventory.ItemStack)

Aggregations

BInventory (com.bencodez.advancedcore.api.inventory.BInventory)23 ClickEvent (com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent)23 ItemBuilder (com.bencodez.advancedcore.api.item.ItemBuilder)21 BInventoryButton (com.bencodez.advancedcore.api.inventory.BInventoryButton)19 Player (org.bukkit.entity.Player)15 VoteSite (com.bencodez.votingplugin.objects.VoteSite)7 UpdatingBInventoryButton (com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton)6 VotingPluginUser (com.bencodez.votingplugin.user.VotingPluginUser)5 ValueRequest (com.bencodez.advancedcore.api.valuerequest.ValueRequest)4 ArrayList (java.util.ArrayList)4 RewardOptions (com.bencodez.advancedcore.api.rewards.RewardOptions)3 AdminVoteConfirmation (com.bencodez.votingplugin.commands.gui.admin.AdminVoteConfirmation)3 TopVoterPlayer (com.bencodez.votingplugin.topvoter.TopVoterPlayer)3 HashMap (java.util.HashMap)3 ValueRequestBuilder (com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder)2 NumberListener (com.bencodez.advancedcore.api.valuerequest.listeners.NumberListener)2 StringListener (com.bencodez.advancedcore.api.valuerequest.listeners.StringListener)2 TopVoter (com.bencodez.votingplugin.topvoter.TopVoter)2 Entry (java.util.Map.Entry)2 ItemStack (org.bukkit.inventory.ItemStack)2