Search in sources :

Example 1 with ItemBuilder

use of com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder in project VotingPlugin by Ben12345rocks.

the class PlayerGUIs method openVoteStreak.

public void openVoteStreak(Player player, User user) {
    setSelectedPlayer(player, user);
    BInventory inv = new BInventory(StringUtils.getInstance().replacePlaceHolder(Config.getInstance().getGUIVoteStreakName(), "player", user.getPlayerName()));
    inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteStreakCurrentDayStreakItem()).addPlaceholder("Streak", "" + user.getDayVoteStreak())) {

        @Override
        public void onClick(ClickEvent clickEvent) {
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteStreakCurrentWeekStreakItem()).addPlaceholder("Streak", "" + user.getWeekVoteStreak())) {

        @Override
        public void onClick(ClickEvent clickEvent) {
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteStreakCurrentMonthStreakItem()).addPlaceholder("Streak", "" + user.getMonthVoteStreak())) {

        @Override
        public void onClick(ClickEvent clickEvent) {
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteStreakHighestDayStreakItem()).addPlaceholder("Streak", "" + user.getBestDayVoteStreak())) {

        @Override
        public void onClick(ClickEvent clickEvent) {
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteStreakHighestWeekStreakItem()).addPlaceholder("Streak", "" + user.getBestWeekVoteStreak())) {

        @Override
        public void onClick(ClickEvent clickEvent) {
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteStreakHighestMonthStreakItem()).addPlaceholder("Streak", "" + user.getBestMonthVoteStreak())) {

        @Override
        public void onClick(ClickEvent clickEvent) {
        }
    });
    if (Config.getInstance().getGUIVoteStreakBackButton()) {
        inv.addButton(new BInventoryButton(getBackButton()) {

            @Override
            public void onClick(ClickEvent event) {
                openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
            }
        });
    }
    inv.openInventory(player);
}
Also used : ItemBuilder(com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder) BInventoryButton(com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton) ClickEvent(com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory.ClickEvent) BInventory(com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory)

Example 2 with ItemBuilder

use of com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder in project VotingPlugin by Ben12345rocks.

the class PlayerGUIs method openVoteTop.

public void openVoteTop(Player player, TopVoter top) {
    if (top == null) {
        top = TopVoter.getDefault();
    }
    BInventory inv = null;
    Set<Entry<User, Integer>> users = null;
    String topVoter = "";
    if (top.equals(TopVoter.Monthly)) {
        topVoter = Config.getInstance().getFormatTopVoterMonthly();
        users = plugin.topVoterMonthly.entrySet();
    } else if (top.equals(TopVoter.Weekly)) {
        topVoter = Config.getInstance().getFormatTopVoterWeekly();
        users = plugin.topVoterWeekly.entrySet();
    } else if (top.equals(TopVoter.Daily)) {
        topVoter = Config.getInstance().getFormatTopVoterDaily();
        users = plugin.topVoterDaily.entrySet();
    } else {
        topVoter = Config.getInstance().getFormatTopVoterAllTime();
        users = plugin.topVoterAllTime.entrySet();
    }
    inv = new BInventory(StringUtils.getInstance().replacePlaceHolder(Config.getInstance().getGUIVoteTopName(), "topvoter", topVoter));
    int pos = 1;
    for (Entry<User, Integer> entry : users) {
        inv.addButton(new BInventoryButton(new ItemBuilder(MiscUtils.getInstance().setSkullOwner(entry.getKey().getOfflinePlayer())).setName(Config.getInstance().getGUIVoteTopItemName()).addLoreLine(Config.getInstance().getGUIVoteTopItemLore()).addPlaceholder("position", "" + pos).addPlaceholder("player", entry.getKey().getPlayerName()).addPlaceholder("votes", "" + entry.getValue())) {

            @Override
            public void onClick(ClickEvent clickEvent) {
                // ItemBuilder item = new ItemBuilder(clickEvent.getClickedItem());
                // String name = ChatColor.stripColor(item.getName()).split(":")[1].trim();
                String name = (String) clickEvent.getButton().getData("player");
                User user = UserManager.getInstance().getVotingPluginUser(name);
                openVoteGUI(player, user);
            }
        }.addData("player", entry.getKey().getPlayerName()));
        pos++;
    }
    final TopVoter cur = top;
    inv.getPageButtons().add(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteTopSwitchItem()).addPlaceholder("Top", topVoter)) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            if (!clickEvent.getClick().equals(ClickType.RIGHT)) {
                openVoteTop(player, cur.next());
            } else {
                openVoteTop(player, cur.prev());
            }
        }
    });
    if (Config.getInstance().getGUIVoteTopBackButton()) {
        inv.getPageButtons().add(new BInventoryButton(getBackButton().setSlot(1)) {

            @Override
            public void onClick(ClickEvent event) {
                openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
            }
        });
    }
    inv.setPages(true);
    inv.setMaxInvSize(Config.getInstance().getGUIVoteTopSize());
    inv.openInventory(player);
}
Also used : User(com.Ben12345rocks.VotingPlugin.Objects.User) BInventoryButton(com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton) ClickEvent(com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory.ClickEvent) BInventory(com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory) Entry(java.util.Map.Entry) ItemBuilder(com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder) TopVoter(com.Ben12345rocks.VotingPlugin.Objects.TopVoter)

Example 3 with ItemBuilder

use of com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder in project VotingPlugin by Ben12345rocks.

the class PlayerGUIs method openVoteURL.

/**
 * Vote URL.
 *
 * @param player
 *            the player
 */
public void openVoteURL(Player player) {
    setSelectedPlayer(player, null);
    BInventory inv = new BInventory(Config.getInstance().getGUIVoteURLName());
    User user = UserManager.getInstance().getVotingPluginUser(player);
    int count = 0;
    if (Config.getInstance().getVoteURLViewAllUrlsButtonEnabled()) {
        ItemBuilder builderAll = new ItemBuilder(Config.getInstance().getVoteURLAlreadyVotedAllUrlsButtonItemSection());
        if (user.canVoteAll()) {
            builderAll = new ItemBuilder(Config.getInstance().getVoteURLCanVoteAllUrlsButtonItemSection());
        }
        if (!builderAll.hasCustomDisplayName()) {
            builderAll.setName("&4All Voting Sites");
        }
        if (!builderAll.hasCustomLore()) {
            builderAll.setLore("&cClick Me");
        }
        inv.addButton(count, new BInventoryButton(builderAll) {

            @Override
            public void onClick(ClickEvent event) {
                User user = UserManager.getInstance().getVotingPluginUser(event.getPlayer());
                Player player = event.getWhoClicked();
                player.closeInventory();
                user.sendMessage(Commands.getInstance().voteURLs(user));
            }
        });
        count++;
    }
    for (VoteSite voteSite : plugin.getVoteSites()) {
        ItemBuilder builder = new ItemBuilder(Config.getInstance().getVoteURLAlreadyVotedItemSection());
        if (user.canVoteSite(voteSite)) {
            builder = new ItemBuilder(Config.getInstance().getVoteURLCanVoteItemSection());
        } else {
            builder.addLoreLine(Config.getInstance().getVoteURLNextVote().replace("%Info%", Commands.getInstance().voteCommandNextInfo(user, voteSite)));
        }
        builder.setName(Config.getInstance().getVoteURLSiteName().replace("%Name%", voteSite.getDisplayName()));
        inv.addButton(count, new BInventoryButton(builder) {

            @Override
            public void onClick(ClickEvent event) {
                Player player = event.getWhoClicked();
                if (player != null) {
                    player.closeInventory();
                    User user = UserManager.getInstance().getVotingPluginUser(player);
                    user.sendMessage(StringUtils.getInstance().replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(Config.getInstance().getGUIVoteURLURLText(), "voteurl", voteSite.getVoteURL()), "sitename", voteSite.getDisplayName()), "player", player.getName()));
                }
            }
        });
        count++;
    }
    if (Config.getInstance().getGUIVoteURLBackButton()) {
        inv.addButton(new BInventoryButton(getBackButton()) {

            @Override
            public void onClick(ClickEvent event) {
                openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
            }
        });
    }
    inv.openInventory(player);
}
Also used : VoteSite(com.Ben12345rocks.VotingPlugin.Objects.VoteSite) ItemBuilder(com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder) Player(org.bukkit.entity.Player) User(com.Ben12345rocks.VotingPlugin.Objects.User) BInventoryButton(com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton) ClickEvent(com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory.ClickEvent) BInventory(com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory)

Example 4 with ItemBuilder

use of com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder in project VotingPlugin by Ben12345rocks.

the class PlayerGUIs method openVoteTotal.

public void openVoteTotal(Player player, User user) {
    setSelectedPlayer(player, user);
    BInventory inv = new BInventory(StringUtils.getInstance().replacePlaceHolder(Config.getInstance().getGUIVoteTotalName(), "player", user.getPlayerName()));
    inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteTotalDayTotalItem()).addPlaceholder("Total", "" + user.getDailyTotal())) {

        @Override
        public void onClick(ClickEvent clickEvent) {
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteTotalWeekTotalItem()).addPlaceholder("Total", "" + user.getWeeklyTotal())) {

        @Override
        public void onClick(ClickEvent clickEvent) {
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteTotalMonthTotalItem()).addPlaceholder("Total", "" + user.getMonthTotal())) {

        @Override
        public void onClick(ClickEvent clickEvent) {
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteTotalAllTimeTotalItem()).addPlaceholder("Total", "" + user.getAllTimeTotal())) {

        @Override
        public void onClick(ClickEvent clickEvent) {
        }
    });
    if (Config.getInstance().getGUIVoteTotalBackButton()) {
        inv.addButton(new BInventoryButton(getBackButton()) {

            @Override
            public void onClick(ClickEvent event) {
                openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
            }
        });
    }
    inv.openInventory(player);
}
Also used : ItemBuilder(com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder) BInventoryButton(com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton) ClickEvent(com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory.ClickEvent) BInventory(com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory)

Example 5 with ItemBuilder

use of com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder in project VotingPlugin by Ben12345rocks.

the class CommandLoader method loadCommands.

/**
 * Load commands.
 */
public void loadCommands() {
    loadAdminVoteCommand();
    loadVoteCommand();
    Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {

        @Override
        public void run() {
            com.Ben12345rocks.AdvancedCore.Thread.Thread.getInstance().run(new Runnable() {

                @Override
                public void run() {
                    loadTabComplete();
                    UserGUI.getInstance().addPluginButton(plugin, new BInventoryButton("Force Vote", new String[] {}, new ItemStack(Material.STONE)) {

                        @Override
                        public void onClick(ClickEvent clickEvent) {
                            Player player = clickEvent.getPlayer();
                            ArrayList<String> voteSites = new ArrayList<String>();
                            for (VoteSite voteSite : plugin.getVoteSites()) {
                                voteSites.add(voteSite.getKey());
                            }
                            new ValueRequest().requestString(player, "", ArrayUtils.getInstance().convert(voteSites), true, new StringListener() {

                                @Override
                                public void onInput(Player player, String value) {
                                    VotiferEvent.playerVote(UserGUI.getInstance().getCurrentPlayer(player), value, false);
                                    player.sendMessage("Forced vote for " + UserGUI.getInstance().getCurrentPlayer(player) + " on " + value);
                                }
                            });
                        }
                    });
                    UserGUI.getInstance().addPluginButton(plugin, new BInventoryButton("Set Vote Points", new String[] {}, new ItemStack(Material.STONE)) {

                        @Override
                        public void onClick(ClickEvent clickEvent) {
                            Player player = clickEvent.getPlayer();
                            User user = UserManager.getInstance().getVotingPluginUser(UserGUI.getInstance().getCurrentPlayer(player));
                            new ValueRequest().requestNumber(player, "" + user.getPoints(), new Number[] { 0, 5, 100 }, true, new NumberListener() {

                                @Override
                                public void onInput(Player player, Number value) {
                                    User user = UserManager.getInstance().getVotingPluginUser(UserGUI.getInstance().getCurrentPlayer(player));
                                    user.setPoints(value.intValue());
                                    player.sendMessage("Points set to " + value.intValue() + " for " + user.getPlayerName());
                                }
                            });
                        }
                    });
                    UserGUI.getInstance().addPluginButton(plugin, new BInventoryButton(new ItemBuilder(Material.BOOK).setName("Set Month Total")) {

                        @Override
                        public void onClick(ClickEvent clickEvent) {
                            String playerName = (String) clickEvent.getMeta(clickEvent.getPlayer(), "Player");
                            User user = UserManager.getInstance().getVotingPluginUser(playerName);
                            new ValueRequest().requestNumber(clickEvent.getPlayer(), "" + user.getMonthTotal(), new Number[] { 0, 10, 50, 100 }, new NumberListener() {

                                @Override
                                public void onInput(Player player, Number value) {
                                    String playerName = (String) clickEvent.getMeta(clickEvent.getPlayer(), "Player");
                                    User user = UserManager.getInstance().getVotingPluginUser(playerName);
                                    user.setMonthTotal(value.intValue());
                                    player.sendMessage(StringUtils.getInstance().colorize("&cTotal set"));
                                }
                            });
                        }
                    });
                    UserGUI.getInstance().addPluginButton(plugin, new BInventoryButton("MileStones", new String[0], new ItemStack(Material.STONE)) {

                        @Override
                        public void onClick(ClickEvent event) {
                            Player player = event.getWhoClicked();
                            String playerName = (String) event.getMeta(player, "Player");
                            BInventory inv = new BInventory("MileStones: " + playerName);
                            for (String mileStoneName : Config.getInstance().getMilestoneVotes()) {
                                if (StringUtils.getInstance().isInt(mileStoneName)) {
                                    int mileStone = Integer.parseInt(mileStoneName);
                                    inv.addButton(inv.getNextSlot(), new BInventoryButton("" + mileStone, new String[] { "Enabled: " + Config.getInstance().getMilestoneRewardEnabled(mileStone), "&cClick to set wether this has been completed or not" }, new ItemStack(Material.STONE)) {

                                        @Override
                                        public void onClick(ClickEvent clickEvent) {
                                            if (StringUtils.getInstance().isInt(clickEvent.getClickedItem().getItemMeta().getDisplayName())) {
                                                Player player = clickEvent.getPlayer();
                                                int mileStone = Integer.parseInt(clickEvent.getClickedItem().getItemMeta().getDisplayName());
                                                String playerName = (String) event.getMeta(player, "Player");
                                                User user = UserManager.getInstance().getVotingPluginUser(playerName);
                                                new ValueRequest().requestBoolean(player, "" + user.hasGottenMilestone(mileStone), new BooleanListener() {

                                                    @Override
                                                    public void onInput(Player player, boolean value) {
                                                        String playerName = UserGUI.getInstance().getCurrentPlayer(player);
                                                        User user = UserManager.getInstance().getVotingPluginUser(playerName);
                                                        user.setHasGotteMilestone(mileStone, value);
                                                        player.sendMessage("Set milestone completetion to " + value + " on " + mileStone);
                                                    }
                                                });
                                            }
                                        }
                                    });
                                }
                            }
                        }
                    });
                }
            });
        }
    });
}
Also used : Player(org.bukkit.entity.Player) OfflinePlayer(org.bukkit.OfflinePlayer) User(com.Ben12345rocks.VotingPlugin.Objects.User) BInventoryButton(com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton) ClickEvent(com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory.ClickEvent) ArrayList(java.util.ArrayList) ValueRequest(com.Ben12345rocks.AdvancedCore.Util.ValueRequest.ValueRequest) BInventory(com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory) VoteSite(com.Ben12345rocks.VotingPlugin.Objects.VoteSite) NumberListener(com.Ben12345rocks.AdvancedCore.Util.ValueRequest.Listeners.NumberListener) ItemBuilder(com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder) BooleanListener(com.Ben12345rocks.AdvancedCore.Util.ValueRequest.Listeners.BooleanListener) StringListener(com.Ben12345rocks.AdvancedCore.Util.ValueRequest.Listeners.StringListener) ItemStack(org.bukkit.inventory.ItemStack)

Aggregations

BInventory (com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory)10 ClickEvent (com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory.ClickEvent)10 BInventoryButton (com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton)10 ItemBuilder (com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder)10 User (com.Ben12345rocks.VotingPlugin.Objects.User)6 Player (org.bukkit.entity.Player)5 VoteSite (com.Ben12345rocks.VotingPlugin.Objects.VoteSite)4 BooleanListener (com.Ben12345rocks.AdvancedCore.Util.ValueRequest.Listeners.BooleanListener)1 NumberListener (com.Ben12345rocks.AdvancedCore.Util.ValueRequest.Listeners.NumberListener)1 StringListener (com.Ben12345rocks.AdvancedCore.Util.ValueRequest.Listeners.StringListener)1 ValueRequest (com.Ben12345rocks.AdvancedCore.Util.ValueRequest.ValueRequest)1 TopVoter (com.Ben12345rocks.VotingPlugin.Objects.TopVoter)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Entry (java.util.Map.Entry)1 OfflinePlayer (org.bukkit.OfflinePlayer)1 ItemStack (org.bukkit.inventory.ItemStack)1