Search in sources :

Example 16 with VoteSite

use of com.Ben12345rocks.VotingPlugin.Objects.VoteSite 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 17 with VoteSite

use of com.Ben12345rocks.VotingPlugin.Objects.VoteSite 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 18 with VoteSite

use of com.Ben12345rocks.VotingPlugin.Objects.VoteSite 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)

Example 19 with VoteSite

use of com.Ben12345rocks.VotingPlugin.Objects.VoteSite in project VotingPlugin by Ben12345rocks.

the class ConfigVoteSites method getVoteSitesLoad.

/**
 * Gets the vote sites load.
 *
 * @return the vote sites load
 */
public ArrayList<VoteSite> getVoteSitesLoad() {
    ArrayList<VoteSite> voteSites = new ArrayList<VoteSite>();
    ArrayList<String> voteSiteNames = getVoteSitesNames();
    if (voteSiteNames != null) {
        for (String site : voteSiteNames) {
            if (getVoteSiteEnabled(site) && !site.equalsIgnoreCase("null")) {
                if (!siteCheck(site)) {
                    plugin.getLogger().warning("Failed to load site " + site + ", see above");
                } else {
                    voteSites.add(new VoteSite(site));
                }
            }
        }
    }
    Collections.sort(voteSites, new Comparator<VoteSite>() {

        @Override
        public int compare(VoteSite v1, VoteSite v2) {
            int v1P = v1.getPriority();
            int v2P = v2.getPriority();
            if (v1P < v2P) {
                return 1;
            }
            if (v1P > v2P) {
                return -1;
            }
            return 0;
        }
    });
    return voteSites;
}
Also used : VoteSite(com.Ben12345rocks.VotingPlugin.Objects.VoteSite) ArrayList(java.util.ArrayList)

Aggregations

VoteSite (com.Ben12345rocks.VotingPlugin.Objects.VoteSite)19 ArrayList (java.util.ArrayList)11 BInventory (com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory)9 ClickEvent (com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory.ClickEvent)9 BInventoryButton (com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton)9 User (com.Ben12345rocks.VotingPlugin.Objects.User)9 Player (org.bukkit.entity.Player)6 ItemBuilder (com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder)4 HashMap (java.util.HashMap)3 OfflinePlayer (org.bukkit.OfflinePlayer)3 ItemStack (org.bukkit.inventory.ItemStack)3 BooleanListener (com.Ben12345rocks.AdvancedCore.Util.ValueRequest.Listeners.BooleanListener)2 NumberListener (com.Ben12345rocks.AdvancedCore.Util.ValueRequest.Listeners.NumberListener)2 StringListener (com.Ben12345rocks.AdvancedCore.Util.ValueRequest.Listeners.StringListener)2 ValueRequest (com.Ben12345rocks.AdvancedCore.Util.ValueRequest.ValueRequest)2 DateTimeFormatter (java.time.format.DateTimeFormatter)2 CommandHandler (com.Ben12345rocks.AdvancedCore.Objects.CommandHandler)1 TabCompleteHandle (com.Ben12345rocks.AdvancedCore.Objects.TabCompleteHandle)1 UUID (com.Ben12345rocks.AdvancedCore.Objects.UUID)1 UserStorage (com.Ben12345rocks.AdvancedCore.Objects.UserStorage)1