Search in sources :

Example 11 with BInventoryButton

use of com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton in project VotingPlugin by Ben12345rocks.

the class PlayerGUIs method openVoteBest.

public void openVoteBest(Player player, User user) {
    setSelectedPlayer(player, user);
    BInventory inv = new BInventory(StringUtils.getInstance().replacePlaceHolder(Config.getInstance().getGUIVoteBestName(), "player", user.getPlayerName()));
    inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteBestDayBestItem()).addPlaceholder("Best", "" + user.getBestDayVoteStreak())) {

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

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

        @Override
        public void onClick(ClickEvent clickEvent) {
        }
    });
    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 12 with BInventoryButton

use of com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton in project VotingPlugin by Ben12345rocks.

the class PlayerGUIs method openVoteURL.

public void openVoteURL(Player player, String voteSite) {
    User user = UserManager.getInstance().getVotingPluginUser(player);
    VoteSite site = plugin.getVoteSite(voteSite);
    BInventory inv = new BInventory(StringUtils.getInstance().replacePlaceHolder(Config.getInstance().getGUIVoteURLSiteName(), "site", site.getDisplayName()));
    inv.setMeta(player, "VoteSite", site);
    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 BInventoryButton(new ItemBuilder(Material.COMPASS).setName("&4Next Vote").addLoreLine(Commands.getInstance().voteCommandNextInfo(user, site))) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            openVoteURL(clickEvent.getPlayer());
        }
    });
    inv.addButton(new BInventoryButton(new ItemBuilder(Material.WATCH).setName("&4Last Vote").addLoreLine(Commands.getInstance().voteCommandLastLine(user, site))) {

        @Override
        public void onClick(ClickEvent clickEvent) {
            openVoteURL(clickEvent.getPlayer());
        }
    });
    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) 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 13 with BInventoryButton

use of com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton in project VotingPlugin by Ben12345rocks.

the class PlayerGUIs method openVoteGUI.

public void openVoteGUI(Player player, User user) {
    if (user == null) {
        user = UserManager.getInstance().getVotingPluginUser(player);
        setSelectedPlayer(player, user);
    }
    if ((!player.getName().equals(user.getPlayerName()) && !player.hasPermission("VotingPlugin.Commands.Vote.GUI.Other") && !player.hasPermission("VotingPlugin.Mod")) || (!player.hasPermission("VotingPlugin.Commands.Vote.GUI") && !player.hasPermission("VotingPlugin.Player"))) {
        player.sendMessage(StringUtils.getInstance().colorize(AdvancedCoreHook.getInstance().getFormatNoPerms()));
        return;
    }
    setSelectedPlayer(player, user);
    BInventory inv = new BInventory(StringUtils.getInstance().replacePlaceHolder(Config.getInstance().getGUIVoteGUIName(), "player", user.getPlayerName()));
    for (String slot : Config.getInstance().getVoteGUISlots()) {
        ItemBuilder builder = new ItemBuilder(Config.getInstance().getVoteGUISlotSection(slot));
        String[] lore = new String[1];
        lore = ArrayUtils.getInstance().convert(Config.getInstance().getVoteGUISlotLore(slot));
        if (lore.length == 0) {
            if (slot.equalsIgnoreCase("url")) {
                lore = Commands.getInstance().voteURLs(user);
            } else if (slot.equalsIgnoreCase("next")) {
                lore = Commands.getInstance().voteCommandNext(user);
            } else if (slot.equalsIgnoreCase("last")) {
                lore = Commands.getInstance().voteCommandLast(user);
            } else if (slot.equalsIgnoreCase("total")) {
                lore = Commands.getInstance().voteCommandTotal(user);
            } else if (slot.equalsIgnoreCase("top")) {
                String str = Config.getInstance().getVoteTopDefault();
                if (str.equalsIgnoreCase("monthly")) {
                    lore = TopVoterHandler.getInstance().topVoterMonthly(1);
                } else if (str.equalsIgnoreCase("weekly")) {
                    lore = TopVoterHandler.getInstance().topVoterWeekly(1);
                } else if (str.equalsIgnoreCase("daily")) {
                    lore = TopVoterHandler.getInstance().topVoterDaily(1);
                } else {
                    lore = TopVoterHandler.getInstance().topVoterAllTime(1);
                }
            } else if (slot.equalsIgnoreCase("today")) {
                lore = Commands.getInstance().voteToday();
            } else if (slot.equalsIgnoreCase("help")) {
                lore = new String[] { "Click to view help" };
            }
        }
        HashMap<String, String> placeholders = new HashMap<String, String>();
        placeholders.put("points", "" + user.getPoints());
        builder.setPlaceholders(placeholders);
        builder.setLore(ArrayUtils.getInstance().convert(lore));
        inv.addButton(Config.getInstance().getVoteGUISlotSlot(slot), new BInventoryButton(builder) {

            @Override
            public void onClick(ClickEvent event) {
                Player player = event.getWhoClicked();
                String cmd = Config.getInstance().getVoteGUISlotCommand(slot);
                User user = getSelectedPlayer(player);
                if (!cmd.equals("")) {
                    player.performCommand(cmd);
                } else {
                    if (slot.equalsIgnoreCase("url")) {
                        openVoteURL(player);
                    } else if (slot.equalsIgnoreCase("next")) {
                        openVoteNext(player, user);
                    } else if (slot.equalsIgnoreCase("last")) {
                        openVoteLast(player, user);
                    } else if (slot.equalsIgnoreCase("total")) {
                        openVoteTotal(player, user);
                    } else if (slot.equalsIgnoreCase("top")) {
                        openVoteTop(player, null);
                    } else if (slot.equalsIgnoreCase("today")) {
                        openVoteToday(player);
                    } else if (slot.equalsIgnoreCase("help")) {
                        player.performCommand("vote help");
                    } else if (slot.equalsIgnoreCase("shop")) {
                        VoteShop.getInstance().voteShop(player);
                    }
                }
            }
        });
    }
    inv.openInventory(player);
}
Also used : ItemBuilder(com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder) Player(org.bukkit.entity.Player) User(com.Ben12345rocks.VotingPlugin.Objects.User) HashMap(java.util.HashMap) BInventoryButton(com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton) ClickEvent(com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory.ClickEvent) BInventory(com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory)

Example 14 with BInventoryButton

use of com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton in project VotingPlugin by Ben12345rocks.

the class PlayerGUIs method openVoteLast.

public void openVoteLast(Player player, User user) {
    setSelectedPlayer(player, user);
    BInventory inv = new BInventory(StringUtils.getInstance().replacePlaceHolder(Config.getInstance().getGUIVoteLastName(), "player", user.getPlayerName()));
    for (VoteSite site : plugin.getVoteSites()) {
        inv.addButton(inv.getNextSlot(), new BInventoryButton(site.getItem().setName(site.getDisplayName()).setLore(Commands.getInstance().voteCommandLastLine(user, site)).setAmountNone(1)) {

            @Override
            public void onClick(ClickEvent clickEvent) {
            }
        });
    }
    if (Config.getInstance().getGUIVoteLastBackButton()) {
        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) BInventoryButton(com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton) ClickEvent(com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory.ClickEvent) BInventory(com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory)

Example 15 with BInventoryButton

use of com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton in project VotingPlugin by Ben12345rocks.

the class PlayerGUIs method openVoteToday.

public void openVoteToday(Player player) {
    setSelectedPlayer(player, null);
    BInventory inv = new BInventory(Config.getInstance().getGUIVoteTodayName());
    for (User user : plugin.voteToday.keySet()) {
        for (VoteSite voteSite : plugin.voteToday.get(user).keySet()) {
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern(Config.getInstance().getFormatTimeFormat());
            String timeString = plugin.voteToday.get(user).get(voteSite).format(formatter);
            String msg = "&6" + user.getPlayerName() + " : " + voteSite.getDisplayName() + " : " + timeString;
            inv.addButton(inv.getNextSlot(), new BInventoryButton(user.getPlayerName(), new String[] { msg }, MiscUtils.getInstance().setSkullOwner(user.getOfflinePlayer())) {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    User user = UserManager.getInstance().getVotingPluginUser(clickEvent.getClickedItem().getItemMeta().getDisplayName());
                    openVoteGUI(player, user);
                }
            });
        }
    }
    if (Config.getInstance().getGUIVoteTodayBackButton()) {
        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) 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) DateTimeFormatter(java.time.format.DateTimeFormatter)

Aggregations

ClickEvent (com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory.ClickEvent)16 BInventoryButton (com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton)16 BInventory (com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory)15 ItemBuilder (com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder)10 VoteSite (com.Ben12345rocks.VotingPlugin.Objects.VoteSite)9 Player (org.bukkit.entity.Player)8 User (com.Ben12345rocks.VotingPlugin.Objects.User)7 ArrayList (java.util.ArrayList)4 ItemStack (org.bukkit.inventory.ItemStack)4 StringListener (com.Ben12345rocks.AdvancedCore.Util.ValueRequest.Listeners.StringListener)3 ValueRequest (com.Ben12345rocks.AdvancedCore.Util.ValueRequest.ValueRequest)3 BooleanListener (com.Ben12345rocks.AdvancedCore.Util.ValueRequest.Listeners.BooleanListener)2 NumberListener (com.Ben12345rocks.AdvancedCore.Util.ValueRequest.Listeners.NumberListener)2 ValueRequestBuilder (com.Ben12345rocks.AdvancedCore.Util.ValueRequest.ValueRequestBuilder)1 TopVoter (com.Ben12345rocks.VotingPlugin.Objects.TopVoter)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 HashMap (java.util.HashMap)1 Entry (java.util.Map.Entry)1 OfflinePlayer (org.bukkit.OfflinePlayer)1