Search in sources :

Example 6 with VoteSite

use of com.bencodez.votingplugin.objects.VoteSite in project VotingPlugin by Ben12345rocks.

the class VoteLast method getChat.

@Override
public ArrayList<String> getChat(CommandSender sender) {
    ArrayList<String> msg = new ArrayList<String>();
    String playerName = user.getPlayerName();
    msg.add(StringParser.getInstance().replaceIgnoreCase(plugin.getConfigFile().getFormatCommandsVoteLastTitle(), "%player%", playerName));
    for (VoteSite voteSite : plugin.getVoteSites()) {
        if (!voteSite.isHidden()) {
            msg.add(user.voteCommandLastLine(voteSite));
        }
    }
    return ArrayUtils.getInstance().colorize(msg);
}
Also used : VoteSite(com.bencodez.votingplugin.objects.VoteSite) ArrayList(java.util.ArrayList)

Example 7 with VoteSite

use of com.bencodez.votingplugin.objects.VoteSite 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 8 with VoteSite

use of com.bencodez.votingplugin.objects.VoteSite in project VotingPlugin by Ben12345rocks.

the class AdminGUI method openAdminGUIVoteSiteSite.

/**
 * Open admin GUI vote site site.
 *
 * @param player   the player
 * @param voteSite the vote site
 */
public void openAdminGUIVoteSiteSite(Player player, VoteSite voteSite) {
    EditGUI inv = new EditGUI("VoteSite: " + voteSite.getDisplayName());
    inv.setMeta(player, "VoteSite", voteSite);
    inv.addButton(new BInventoryButton(voteSite.getItem().setName("&cForce vote")) {

        @Override
        public void onClick(ClickEvent event) {
            ArrayList<String> playerNames = new ArrayList<String>();
            for (Player p : Bukkit.getOnlinePlayers()) {
                playerNames.add(p.getName());
            }
            new ValueRequestBuilder(new StringListener() {

                @Override
                public void onInput(Player player, String value) {
                    Object ob = PlayerUtils.getInstance().getPlayerMeta(player, "VoteSite");
                    if (ob != null) {
                        VoteSite site = (VoteSite) ob;
                        PlayerVoteEvent voteEvent = new PlayerVoteEvent(site, value, site.getServiceSite(), false);
                        plugin.getServer().getPluginManager().callEvent(voteEvent);
                    }
                }
            }, ArrayUtils.getInstance().convert(playerNames)).usingMethod(InputMethod.INVENTORY).allowCustomOption(true).request(event.getWhoClicked());
        }
    });
    inv.addButton(new EditGUIButton(new EditGUIValueNumber("Priority", voteSite.getPriority()) {

        @Override
        public void setValue(Player player, Number num) {
            VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
            plugin.getConfigVoteSites().setPriority(voteSite.getKey(), num.intValue());
            plugin.reload();
        }
    }));
    inv.addButton(new EditGUIButton(new EditGUIValueString("ServiceSite", voteSite.getServiceSite()) {

        @Override
        public void setValue(Player player, String value) {
            VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
            String siteName = voteSite.getKey();
            plugin.getConfigVoteSites().setServiceSite(siteName, value);
            plugin.reload();
        }
    }));
    inv.addButton(new EditGUIButton(new EditGUIValueString("Name", voteSite.getDisplayName()) {

        @Override
        public void setValue(Player player, String value) {
            VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
            plugin.getConfigVoteSites().setDisplayName(voteSite.getKey(), value);
            plugin.reload();
        }
    }));
    inv.addButton(new EditGUIButton(new EditGUIValueString("VoteURL", voteSite.getVoteURL()) {

        @Override
        public void setValue(Player player, String value) {
            VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
            String siteName = voteSite.getKey();
            plugin.getConfigVoteSites().setVoteURL(siteName, value);
            plugin.reload();
        }
    }));
    inv.addButton(new EditGUIButton(new EditGUIValueNumber("VoteDelay", voteSite.getVoteDelay()) {

        @Override
        public void setValue(Player player, Number num) {
            VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
            String siteName = voteSite.getKey();
            plugin.getConfigVoteSites().setVoteDelay(siteName, num.intValue());
            plugin.reload();
        }
    }));
    inv.addButton(new EditGUIButton(new EditGUIValueNumber("VoteDelayMin", voteSite.getVoteDelay()) {

        @Override
        public void setValue(Player player, Number num) {
            VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
            String siteName = voteSite.getKey();
            plugin.getConfigVoteSites().setVoteDelay(siteName, num.intValue());
            plugin.reload();
        }
    }));
    inv.addButton(new EditGUIButton(new EditGUIValueBoolean("Enabled", voteSite.isEnabled()) {

        @Override
        public void setValue(Player player, boolean value) {
            VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
            String siteName = voteSite.getKey();
            plugin.getConfigVoteSites().setEnabled(siteName, value);
            plugin.reload();
        }
    }));
    inv.addButton(new EditGUIButton(new EditGUIValueBoolean("ForceOffline", voteSite.isGiveOffline()) {

        @Override
        public void setValue(Player player, boolean value) {
            VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
            String siteName = voteSite.getKey();
            plugin.getConfigVoteSites().setForceOffline(siteName, value);
            plugin.reload();
        }
    }));
    inv.addButton(new EditGUIButton(new EditGUIValueBoolean("VoteDelayDaily", voteSite.isVoteDelayDaily()) {

        @Override
        public void setValue(Player player, boolean value) {
            VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
            String siteName = voteSite.getKey();
            plugin.getConfigVoteSites().setVoteDelayDaily(siteName, value);
            plugin.reload();
        }
    }));
    if (voteSite.getSiteData().isList("Rewards")) {
        inv.addButton(new EditGUIButton(new EditGUIValueList("Rewards", voteSite.getSiteData().getStringList("Rewards")) {

            @Override
            public void setValue(Player p, ArrayList<String> rewards) {
                VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
                plugin.getConfigVoteSites().set(voteSite.getKey(), "Rewards", rewards);
                plugin.reload();
            }
        }));
    } else {
        inv.addButton(new BInventoryButton(new ItemBuilder(Material.DISPENSER, 1).setName("&cRewards")) {

            @Override
            public void onClick(ClickEvent clickEvent) {
                RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(), RewardHandler.getInstance().getDirectlyDefined("VoteSites." + voteSite.getKey() + ".Rewards"));
            }
        });
    }
    inv.openInventory(player);
}
Also used : EditGUI(com.bencodez.advancedcore.api.inventory.editgui.EditGUI) RewardEditGUI(com.bencodez.advancedcore.command.gui.RewardEditGUI) Player(org.bukkit.entity.Player) EditGUIValueBoolean(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueBoolean) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) ArrayList(java.util.ArrayList) EditGUIValueString(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString) EditGUIValueString(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString) ValueRequestBuilder(com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder) VoteSite(com.bencodez.votingplugin.objects.VoteSite) PlayerVoteEvent(com.bencodez.votingplugin.events.PlayerVoteEvent) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) EditGUIValueList(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueList) EditGUIValueNumber(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber) EditGUIButton(com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton) EditGUIValueNumber(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber) StringListener(com.bencodez.advancedcore.api.valuerequest.listeners.StringListener)

Example 9 with VoteSite

use of com.bencodez.votingplugin.objects.VoteSite in project VotingPlugin by Ben12345rocks.

the class AdminVoteVotePlayer method onChest.

@Override
public void onChest(Player player) {
    EditGUI inv = new EditGUI("Trigger vote for " + playerName);
    inv.requirePermission("VotingPlugin.Commands.AdminVote.Vote|VotingPlugin.Admin");
    for (VoteSite site : plugin.getVoteSites()) {
        inv.addButton(new BInventoryButton(site.getItem().setName(site.getKey())) {

            @Override
            public void onClick(ClickEvent clickEvent) {
                VoteSite site = (VoteSite) getData("site");
                PlayerVoteEvent voteEvent = new PlayerVoteEvent(site, playerName, site.getServiceSite(), false);
                sendMessage(clickEvent.getPlayer(), "&cTriggering vote...");
                if (voteEvent.getVoteSite() != null) {
                    if (!voteEvent.getVoteSite().isVaidServiceSite()) {
                        sendMessage(clickEvent.getPlayer(), "&cPossible issue with service site, has the server gotten the vote from " + voteEvent.getServiceSite() + "?");
                    }
                }
                plugin.getServer().getPluginManager().callEvent(voteEvent);
                if (plugin.isYmlError()) {
                    sendMessage(clickEvent.getPlayer(), "&3Detected yml error, please check server log for details");
                }
            }
        }.addData("site", site));
    }
    inv.openInventory(player);
}
Also used : VoteSite(com.bencodez.votingplugin.objects.VoteSite) EditGUI(com.bencodez.advancedcore.api.inventory.editgui.EditGUI) PlayerVoteEvent(com.bencodez.votingplugin.events.PlayerVoteEvent) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent)

Example 10 with VoteSite

use of com.bencodez.votingplugin.objects.VoteSite in project VotingPlugin by Ben12345rocks.

the class VoteToday method voteToday.

public String[] voteToday() {
    ArrayList<String> msg = new ArrayList<String>();
    for (TopVoterPlayer user : plugin.getVoteToday().keySet()) {
        for (VoteSite voteSite : plugin.getVoteToday().get(user).keySet()) {
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern(plugin.getConfigFile().getFormatTimeFormat());
            String timeString = plugin.getVoteToday().get(user).get(voteSite).format(formatter);
            HashMap<String, String> placeholders = new HashMap<String, String>();
            placeholders.put("player", user.getPlayerName());
            placeholders.put("votesite", voteSite.getKey());
            placeholders.put("time", timeString);
            msg.add(StringParser.getInstance().replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(), placeholders));
        // msg.add("&6" + user.getPlayerName() + " : " + voteSite.getKey() + " : " +
        // timeString);
        }
    }
    msg = ArrayUtils.getInstance().colorize(msg);
    return ArrayUtils.getInstance().convert(msg);
}
Also used : VoteSite(com.bencodez.votingplugin.objects.VoteSite) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TopVoterPlayer(com.bencodez.votingplugin.topvoter.TopVoterPlayer) DateTimeFormatter(java.time.format.DateTimeFormatter)

Aggregations

VoteSite (com.bencodez.votingplugin.objects.VoteSite)28 ArrayList (java.util.ArrayList)15 Player (org.bukkit.entity.Player)10 ClickEvent (com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent)9 VotingPluginUser (com.bencodez.votingplugin.user.VotingPluginUser)9 HashMap (java.util.HashMap)9 BInventory (com.bencodez.advancedcore.api.inventory.BInventory)7 BInventoryButton (com.bencodez.advancedcore.api.inventory.BInventoryButton)7 ItemBuilder (com.bencodez.advancedcore.api.item.ItemBuilder)7 TopVoterPlayer (com.bencodez.votingplugin.topvoter.TopVoterPlayer)6 TopVoter (com.bencodez.votingplugin.topvoter.TopVoter)5 UpdatingBInventoryButton (com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton)4 PlayerVoteEvent (com.bencodez.votingplugin.events.PlayerVoteEvent)4 DateTimeFormatter (java.time.format.DateTimeFormatter)4 LinkedHashMap (java.util.LinkedHashMap)4 VoteURLVoteSite (com.bencodez.votingplugin.commands.gui.player.VoteURLVoteSite)3 LocalDateTime (java.time.LocalDateTime)3 BookWrapper (com.bencodez.advancedcore.api.bookgui.BookWrapper)2 Layout (com.bencodez.advancedcore.api.bookgui.Layout)2 EditGUI (com.bencodez.advancedcore.api.inventory.editgui.EditGUI)2