Search in sources :

Example 1 with UpdatingBInventoryButton

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

the class VoteGUI method onChest.

@Override
public void onChest(Player player) {
    if (this.user == null) {
        user = UserManager.getInstance().getVotingPluginUser(player);
    }
    BInventory inv = new BInventory(plugin.getGui().getChestVoteGUIName());
    if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
        inv.dontClose();
    }
    if (player.getUniqueId().toString().equals(user.getUUID())) {
        inv.requirePermission("VotingPlugin.Commands.Vote.GUI");
    } else {
        inv.requirePermission("VotingPlugin.Commands.Vote.GUI.Other");
    }
    inv.addPlaceholder("points", "" + user.getPoints());
    inv.addPlaceholder("player", user.getPlayerName());
    inv.addPlaceholder("top", plugin.getConfigFile().getVoteTopDefault());
    for (String slot : plugin.getGui().getChestVoteGUISlots()) {
        ItemBuilder builder = getItemSlot(slot, player);
        inv.addButton(new UpdatingBInventoryButton(builder, 1000, 1000) {

            @Override
            public void onClick(ClickEvent event) {
                Player player = event.getWhoClicked();
                String cmd = plugin.getGui().getChestVoteGUISlotCommand(slot);
                if (cmd.equalsIgnoreCase("none")) {
                    return;
                } else if (!cmd.equals("")) {
                    event.runSync(new Runnable() {

                        @Override
                        public void run() {
                            player.performCommand(cmd);
                        }
                    });
                } else {
                    if (slot.equalsIgnoreCase("url")) {
                        new VoteURL(plugin, player, user, true).open();
                    } else if (slot.equalsIgnoreCase("next")) {
                        new VoteNext(plugin, player, user).open(GUIMethod.CHEST);
                    } else if (slot.equalsIgnoreCase("last")) {
                        new VoteLast(plugin, player, user).open(GUIMethod.CHEST);
                    } else if (slot.equalsIgnoreCase("total")) {
                        new VoteTotal(plugin, player, user).open(GUIMethod.CHEST);
                    } else if (slot.equalsIgnoreCase("top")) {
                        new VoteTopVoter(plugin, player, user, TopVoter.getDefault(), 1).open(GUIMethod.CHEST);
                    } else if (slot.equalsIgnoreCase("today")) {
                        new VoteToday(plugin, player, user, 1).open(GUIMethod.CHEST);
                    } else if (slot.equalsIgnoreCase("help")) {
                        player.performCommand("vote help");
                    } else if (slot.equalsIgnoreCase("shop")) {
                        new VoteShop(plugin, player, user).open(GUIMethod.CHEST);
                    } else if (slot.equalsIgnoreCase("lastmonth")) {
                        new VoteTopVoterLastMonth(plugin, player, user).open(GUIMethod.CHEST);
                    } else if (slot.equalsIgnoreCase("best")) {
                        new VoteBest(plugin, player, user).open(GUIMethod.CHEST);
                    } else if (slot.equalsIgnoreCase("streak")) {
                        new VoteStreak(plugin, player, user).open(GUIMethod.CHEST);
                    }
                }
                if (RewardHandler.getInstance().hasRewards(plugin.getGui().getData(), plugin.getGui().getChestVoteGUISlotRewardsPath(slot))) {
                    RewardHandler.getInstance().giveReward(UserManager.getInstance().getVotingPluginUser(player), plugin.getGui().getData(), plugin.getGui().getChestVoteGUISlotRewardsPath(slot), new RewardOptions().addPlaceholder("identifier", slot));
                }
            }

            @Override
            public ItemBuilder onUpdate(Player player) {
                ItemBuilder item = getItemSlot(slot, player);
                VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
                item.addPlaceholder("points", "" + user.getPoints());
                item.addPlaceholder("player", user.getPlayerName());
                item.addPlaceholder("top", plugin.getConfigFile().getVoteTopDefault());
                return item;
            }
        });
    }
    inv.openInventory(player);
}
Also used : UpdatingBInventoryButton(com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton) Player(org.bukkit.entity.Player) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) BInventory(com.bencodez.advancedcore.api.inventory.BInventory) RewardOptions(com.bencodez.advancedcore.api.rewards.RewardOptions) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) VotingPluginUser(com.bencodez.votingplugin.user.VotingPluginUser)

Example 2 with UpdatingBInventoryButton

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

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

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

the class VoteTotal method onChest.

@Override
public void onChest(Player player) {
    BInventory inv = new BInventory(plugin.getGui().getChestVoteTotalName());
    inv.addPlaceholder("player", user.getPlayerName());
    for (final TopVoter top : TopVoter.values()) {
        inv.addButton(new UpdatingBInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteTotalItem(top)).addPlaceholder("Total", "" + user.getTotal(top)).addPlaceholder("topvoter", top.getName()), 1000, 1000) {

            @Override
            public void onClick(ClickEvent clickEvent) {
            }

            @Override
            public ItemBuilder onUpdate(Player arg0) {
                return new ItemBuilder(plugin.getGui().getChestVoteTotalItem(top)).addPlaceholder("Total", "" + user.getTotal(top)).addPlaceholder("topvoter", top.getName()).addPlaceholder("player", user.getPlayerName());
            }
        });
    }
    if (plugin.getGui().getChestVoteTotalBackButton()) {
        inv.addButton(plugin.getCommandLoader().getBackButton(user));
    }
    inv.openInventory(player);
}
Also used : UpdatingBInventoryButton(com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) Player(org.bukkit.entity.Player) TopVoter(com.bencodez.votingplugin.topvoter.TopVoter) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) BInventory(com.bencodez.advancedcore.api.inventory.BInventory)

Example 5 with UpdatingBInventoryButton

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

the class VoteLast method onChest.

@Override
public void onChest(Player player) {
    BInventory inv = new BInventory(plugin.getGui().getChestVoteLastName());
    inv.addPlaceholder("player", user.getPlayerName());
    for (VoteSite site : plugin.getVoteSites()) {
        if (!site.isHidden()) {
            inv.addButton(inv.getNextSlot(), new UpdatingBInventoryButton(site.getItem().setName(site.getDisplayName()).setLore(user.voteCommandLastGUILine(site)).setAmountNone(1), 1000, 1000) {

                @Override
                public void onClick(ClickEvent clickEvent) {
                }

                @Override
                public ItemBuilder onUpdate(Player p) {
                    return site.getItem().setName(site.getDisplayName()).setLore(user.voteCommandLastGUILine(site)).setAmountNone(1);
                }
            });
        }
    }
    if (plugin.getGui().getChestVoteLastBackButton()) {
        inv.addButton(plugin.getCommandLoader().getBackButton(user));
    }
    inv.openInventory(player);
}
Also used : VoteSite(com.bencodez.votingplugin.objects.VoteSite) UpdatingBInventoryButton(com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton) Player(org.bukkit.entity.Player) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) BInventory(com.bencodez.advancedcore.api.inventory.BInventory)

Aggregations

BInventory (com.bencodez.advancedcore.api.inventory.BInventory)6 ClickEvent (com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent)6 UpdatingBInventoryButton (com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton)6 ItemBuilder (com.bencodez.advancedcore.api.item.ItemBuilder)6 Player (org.bukkit.entity.Player)6 VoteSite (com.bencodez.votingplugin.objects.VoteSite)4 BInventoryButton (com.bencodez.advancedcore.api.inventory.BInventoryButton)2 VotingPluginUser (com.bencodez.votingplugin.user.VotingPluginUser)2 RewardBuilder (com.bencodez.advancedcore.api.rewards.RewardBuilder)1 RewardOptions (com.bencodez.advancedcore.api.rewards.RewardOptions)1 TopVoter (com.bencodez.votingplugin.topvoter.TopVoter)1