Search in sources :

Example 1 with PlayerVoteEvent

use of com.bencodez.votingplugin.events.PlayerVoteEvent in project VotingPlugin by Ben12345rocks.

the class CommandLoader method loadAdminVoteCommand.

/**
 * Load admin vote command.
 */
private void loadAdminVoteCommand() {
    plugin.setAdminVoteCommand(new ArrayList<CommandHandler>());
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "CurrentPluginTime" }, "VotingPlugin.Commands.AdminVote.CurrentPluginTime|" + adminPerm, "Current plugin time") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern(plugin.getConfigFile().getFormatTimeFormat());
            sendMessage(sender, plugin.getTimeChecker().getTime().format(formatter));
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(player)", "SetPoints", "(number)" }, "VotingPlugin.Commands.AdminVote.SetPoints|" + adminPerm, "Set players voting points") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
            user.setPoints(Integer.parseInt(args[3]));
            sender.sendMessage(StringParser.getInstance().colorize("&cSet " + args[1] + " points to " + args[3]));
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "ResyncMilestones" }, "VotingPlugin.Commands.AdminVote.ResyncMilestones|" + adminPerm, "Resync Milestones") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            sendMessage(sender, "&cStarting...");
            for (String uuid : UserManager.getInstance().getAllUUIDs()) {
                VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
                user.dontCache();
                user.setMilestoneCount(user.getTotal(TopVoter.AllTime));
            }
            sendMessage(sender, "&cFinished sync milestonecount with all time total");
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "ResetMilestoneCount" }, "VotingPlugin.Commands.AdminVote.ResetMilestoneCount|" + adminPerm, "Resets milestone count to alltimetotal") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            sendMessage(sender, "&cStarting to clear milestonecounts...");
            plugin.getTopVoterHandler().resetMilestoneCount();
            sendMessage(sender, "&cFinished");
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "ResyncMilestonesAlreadyGiven" }, "VotingPlugin.Commands.AdminVote.ResyncMilestonesGiven|" + adminPerm, "Resync Milestones already given") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            sendMessage(sender, "&cStarting...");
            ArrayList<Integer> nums = new ArrayList<Integer>();
            for (String str : plugin.getSpecialRewardsConfig().getMilestoneVotes()) {
                try {
                    nums.add(Integer.parseInt(str));
                } catch (Exception e) {
                    plugin.getLogger().warning("Failed to get number from " + str);
                }
            }
            for (String uuid : UserManager.getInstance().getAllUUIDs()) {
                VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
                user.dontCache();
                int milestoneCount = user.getMilestoneCount();
                for (int num : nums) {
                    if (milestoneCount >= num) {
                        if (!user.hasGottenMilestone(num)) {
                            sendMessage(sender, "&cMilestone " + num + " for " + user.getPlayerName() + " not already given when it should be, Current AllTimeTotal: " + user.getTotal(TopVoter.AllTime) + ", Current MileStoneCount: " + user.getMilestoneCount());
                            user.setHasGotteMilestone(num, true);
                        }
                    } else {
                        if (user.hasGottenMilestone(num)) {
                            sendMessage(sender, "&cMilestone " + num + " for " + user.getPlayerName() + " already given when it shouldn't be, Current AllTimeTotal: " + user.getTotal(TopVoter.AllTime) + ", Current MileStoneCount: " + user.getMilestoneCount());
                            user.setHasGotteMilestone(num, false);
                        }
                    }
                }
            }
            sendMessage(sender, "&cFinished");
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "ResetPoints" }, "VotingPlugin.Commands.AdminVote.ResetPoints|" + adminPerm, "Clears all points of all players", true, false) {

        @Override
        public void execute(CommandSender sender, String[] args) {
            sendMessage(sender, "&cStarting...");
            plugin.getUserManager().removeAllKeyValues("Points", DataType.INTEGER);
            plugin.getUserManager().getDataManager().clearCache();
            sendMessage(sender, "&cFinished");
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "ResyncMilestones", "(player)" }, "VotingPlugin.Commands.AdminVote.SetResyncMilestones|" + adminPerm, "Resync Milestones to alltimetotal for player") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
            user.setMilestoneCount(user.getTotal(TopVoter.AllTime));
            sendMessage(sender, "&cResynced milestones for " + args[1]);
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(player)", "AddPoints", "(number)" }, "VotingPlugin.Commands.AdminVote.AddPoints|" + adminPerm, "Add to players voting points") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
            user.clearCache();
            synchronized (pointLock) {
                user.addPoints(Integer.parseInt(args[3]));
            }
            sender.sendMessage(StringParser.getInstance().colorize("&cGave " + args[1] + " " + args[3] + " points" + ", " + args[1] + " now has " + user.getPoints() + " points"));
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(player)", "RemovePoints", "(number)" }, "VotingPlugin.Commands.AdminVote.RemovePoints|" + adminPerm, "Remove voting points") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
            user.clearCache();
            user.removePoints(Integer.parseInt(args[3]));
            sender.sendMessage(StringParser.getInstance().colorize("&cRemoved " + args[3] + " points from " + args[1] + ", " + args[1] + " now has " + user.getPoints() + " points"));
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Help&?" }, "VotingPlugin.Commands.AdminVote.Help|" + adminPerm, "See this page") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            new AdminVoteHelp(plugin, sender, 1).open();
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "ServiceSites&Status" }, "VotingPlugin.Commands.AdminVote.ServiceSites|" + adminPerm, "See a list of all service sites the server got") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            ArrayList<String> serviceSites = plugin.getServerData().getServiceSites();
            if (!serviceSites.isEmpty()) {
                sendMessage(sender, "&cEvery service site the server has gotten from votifier:");
                for (String serviceSite : serviceSites) {
                    boolean hasSite = plugin.hasVoteSite(serviceSite);
                    if (hasSite) {
                        String siteName = plugin.getVoteSiteName(true, serviceSite);
                        sendMessage(sender, serviceSite + " : Current site = " + siteName);
                    } else {
                        sendMessage(sender, serviceSite + " : No site with this service site, did you do something wrong?");
                    }
                }
            } else {
                sendMessage(sender, "&cNo votes have been received. Please check your votifier settings.");
            }
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Help&?", "(number)" }, "VotingPlugin.Commands.AdminVote.Help|" + adminPerm, "See this page") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            int page = Integer.parseInt(args[1]);
            new AdminVoteHelp(plugin, sender, page).open();
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Edit", "BungeeSettings" }, "VotingPlugin.Commands.AdminVote.Edit.BungeeSettings", "Edit BungeeSettings.yml", false) {

        @Override
        public void execute(CommandSender sender, String[] args) {
            new AdminVoteBungeeSettings(plugin, sender).open(GUIMethod.CHEST);
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Edit", "VoteShop" }, "VotingPlugin.Commands.AdminVote.Edit.VoteShop", "Edit VoteShop", false) {

        @Override
        public void execute(CommandSender sender, String[] args) {
            new AdminVoteVoteShop(plugin, sender).open(GUIMethod.CHEST);
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Edit", "MileStones" }, "VotingPlugin.Commands.AdminVote.Edit.MileStones", "Edit milestones rewards", false) {

        @Override
        public void execute(CommandSender sender, String[] args) {
            new AdminVoteMilestones(plugin, sender).open(GUIMethod.CHEST);
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Edit", "Cumulative" }, "VotingPlugin.Commands.AdminVote.Edit.Cumulative", "Edit cumulative rewards", false) {

        @Override
        public void execute(CommandSender sender, String[] args) {
            new AdminVoteCumulative(plugin, sender).open(GUIMethod.CHEST);
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Edit", "VoteParty" }, "VotingPlugin.Commands.AdminVote.Edit.VoteParty", "Edit voteparty", false) {

        @Override
        public void execute(CommandSender sender, String[] args) {
            new AdminVoteVoteParty(plugin, sender).open(GUIMethod.CHEST);
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Perms" }, "VotingPlugin.Commands.AdminVote.Perms|" + adminPerm, "List permissions") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            new AdminVotePerms(plugin, sender, 1).open();
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Perms", "(Number)" }, "VotingPlugin.Commands.AdminVote.Perms|" + adminPerm, "List permissions") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            new AdminVotePerms(plugin, sender, Integer.parseInt(args[1])).open();
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "PermsPlayer", "(Player)" }, "VotingPlugin.Commands.AdminVote.Perms.Other|" + adminPerm, "List permissions from the plugin the player has") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            new AdminVotePerms(plugin, sender, 1, args[1]).open();
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "PermsPlayer", "(Player)", "(Number)" }, "VotingPlugin.Commands.AdminVote.Perms.Other|" + adminPerm, "List permissions from the plugin the player has") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            new AdminVotePerms(plugin, sender, Integer.parseInt(args[2]), args[1]).open();
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Perms", "(Number)", "(Player)" }, "VotingPlugin.Commands.AdminVote.Perms.Other|" + adminPerm, "List permissions from the plugin the specificed player has") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            new AdminVotePerms(plugin, sender, Integer.parseInt(args[1]), args[2]).open();
        }
    });
    if (plugin.getOptions().getDebug().equals(DebugLevel.DEV)) {
        plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "PermsDebug" }, "VotingPlugin.Commands.AdminVote.PermsDebug", "Dev permission list, generate this list, requires dev debug") {

            @Override
            public void execute(CommandSender sender, String[] args) {
                sendMessage(sender, ArrayUtils.getInstance().convert(new AdminVotePerms(plugin, sender, 0).listPermsDev(sender)));
            }
        });
    }
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Reload" }, "VotingPlugin.Commands.AdminVote.Reload|" + adminPerm, "Reload plugin, will not reload user storage") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            sendMessage(sender, "&4" + "Reloading " + plugin.getName() + "...");
            plugin.reload();
            if (plugin.isYmlError()) {
                sendMessage(sender, "&3Detected yml error, please check server log for details");
            }
            if (plugin.getProfile().equals("dev")) {
                sendMessage(sender, "&cDetected using dev build, there could be bugs, use at your own risk");
            }
            sendMessage(sender, "&4" + plugin.getName() + " v" + plugin.getDescription().getVersion() + " reloaded! Note: User storage has not been reloaded");
            if (plugin.getServerData().getServiceSites().size() == 0) {
                sendMessage(sender, "&c" + "Detected that server hasn't received any votes from votifier, please check votifier connection");
            }
            if (!plugin.getConfigFile().isDisableUpdateChecking() && plugin.getUpdater().getResult().equals(Updater.UpdateResult.UPDATE_AVAILABLE)) {
                sendMessage(sender, "&3Plugin has update available! https://www.spigotmc.org/resources/votingplugin.15358/");
            }
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "ReloadAll" }, "VotingPlugin.Commands.AdminVote.Reload|" + adminPerm, "Reload plugin, including user storage") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            sendMessage(sender, "&4" + "Reloading " + plugin.getName() + "...");
            plugin.reloadAll();
            if (plugin.isYmlError()) {
                sendMessage(sender, "&3Detected yml error, please check server log for details");
            }
            if (plugin.getProfile().equals("dev")) {
                sendMessage(sender, "&cDetected using dev build, there could be bugs, use at your own risk");
            }
            sendMessage(sender, "&4" + plugin.getName() + " v" + plugin.getDescription().getVersion() + " reloaded!");
            if (plugin.getServerData().getServiceSites().size() == 0) {
                sendMessage(sender, "&c" + "Detected that server hasn't received any votes from votifier, please check votifier connection");
            }
            if (!plugin.getConfigFile().isDisableUpdateChecking() && plugin.getUpdater().getResult().equals(Updater.UpdateResult.UPDATE_AVAILABLE)) {
                sendMessage(sender, "&3Plugin has update available! https://www.spigotmc.org/resources/votingplugin.15358/");
            }
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Version" }, "VotingPlugin.Commands.AdminVote.Version|" + adminPerm, "List version info") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            if (sender instanceof Player) {
                Player player = (Player) sender;
                Bukkit.getScheduler().runTask(plugin, new Runnable() {

                    @Override
                    public void run() {
                        player.performCommand("bukkit:version " + plugin.getName());
                    }
                });
            } else {
                Bukkit.getScheduler().runTask(plugin, new Runnable() {

                    @Override
                    public void run() {
                        Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "bukkit:version " + plugin.getName());
                    }
                });
            }
            sendMessage(sender, "Using AdvancedCore " + plugin.getVersion() + "' built on '" + plugin.getBuildTime());
            if (!plugin.getAdvancedCoreBuildNumber().equals("NOTSET")) {
                sendMessage(sender, "AdvancedCore Jenkins build number: " + plugin.getAdvancedCoreBuildNumber());
            }
            if (!plugin.getBuildNumber().equals("NOTSET")) {
                sendMessage(sender, "Using votingplugin jenkins build: " + plugin.getBuildNumber());
            }
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Sites" }, "VotingPlugin.Commands.AdminVote.Sites|" + adminPerm, "List VoteSites", false) {

        @Override
        public void execute(CommandSender sender, String[] args) {
            new AdminGUI(plugin).openAdminGUIVoteSites((Player) sender);
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "GUI" }, "VotingPlugin.Commands.AdminVote.GUI|" + adminPerm, "Admin GUI", false) {

        @Override
        public void execute(CommandSender sender, String[] args) {
            com.bencodez.advancedcore.command.gui.AdminGUI.getInstance().openGUI((Player) sender);
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Sites", "(sitename)" }, "VotingPlugin.Commands.AdminVote.Sites.Site|" + adminPerm, "View Site Info") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            if (sender instanceof Player) {
                new AdminGUI(plugin).openAdminGUIVoteSiteSite((Player) sender, plugin.getVoteSite(args[1], false));
            } else {
                sender.sendMessage("Must be a player to do this");
            }
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "UUID", "(player)" }, "VotingPlugin.Commands.AdminVote.UUID|" + adminPerm, "View UUID of player") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            sender.sendMessage(ChatColor.GREEN + "UUID of player " + ChatColor.DARK_GREEN + args[1] + ChatColor.GREEN + " is: " + PlayerUtils.getInstance().getUUID(args[1]));
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "PlayerName", "(uuid)" }, "VotingPlugin.Commands.AdminVote.PlayerName|" + adminPerm, "View PlayerName of player") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            try {
                sender.sendMessage(ChatColor.GREEN + "PlayerName of player " + ChatColor.DARK_GREEN + args[1] + ChatColor.GREEN + " is: " + PlayerUtils.getInstance().getPlayerName(UserManager.getInstance().getVotingPluginUser(UUID.fromString(args[1])), args[1]));
            } catch (IllegalArgumentException e) {
                sendMessage(sender, "&cInvalid uuid");
            }
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "ClearTotal" }, "VotingPlugin.Commands.AdminVote.ClearTotal.All|" + adminPerm, "Reset totals for all players") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            if (sender instanceof Player) {
                sender.sendMessage(StringParser.getInstance().colorize("&cThis command can not be done from ingame"));
                return;
            }
            for (TopVoter top : TopVoter.values()) {
                plugin.getUserManager().removeAllKeyValues(top.getColumnName(), DataType.INTEGER);
            }
            plugin.getUserManager().getDataManager().clearCache();
            sender.sendMessage(StringParser.getInstance().colorize("&cCleared totals for everyone"));
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "ClearOfflineVoteRewards" }, "VotingPlugin.Commands.AdminVote.ClearOfflineVoteRewards|" + adminPerm, "Reset offline votes/rewards") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            if (sender instanceof Player) {
                sender.sendMessage(StringParser.getInstance().colorize("&cThis command can not be done from ingame"));
                return;
            }
            plugin.getUserManager().removeAllKeyValues("OfflineVotes", DataType.STRING);
            plugin.getUserManager().removeAllKeyValues(plugin.getUserManager().getOfflineRewardsPath(), DataType.STRING);
            plugin.getUserManager().getDataManager().clearCache();
            sender.sendMessage(StringParser.getInstance().colorize("&cCleared offline votes/rewards"));
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(player)", "SetVoteStreak", "DAY", "(number)" }, "VotingPlugin.Commands.AdminVote.SetVoteStreak.Day|" + adminPerm, "Set votestreak for player") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            UserManager.getInstance().getVotingPluginUser(args[1]).setDayVoteStreak(Integer.parseInt(args[4]));
            sender.sendMessage(StringParser.getInstance().colorize("&cSet votestreak day for '" + args[1] + "' to " + args[4]));
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(player)", "SetVoteStreak", "WEEK", "(number)" }, "VotingPlugin.Commands.AdminVote.SetVoteStreak.Week|" + adminPerm, "Set votestreak for player") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            UserManager.getInstance().getVotingPluginUser(args[1]).setWeekVoteStreak(Integer.parseInt(args[4]));
            sender.sendMessage(StringParser.getInstance().colorize("&cSet votestreak week for '" + args[1] + "' to " + args[4]));
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(player)", "SetVoteStreak", "MONTH", "(number)" }, "VotingPlugin.Commands.AdminVote.SetVoteStreak.Month|" + adminPerm, "Set votestreak for player") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            UserManager.getInstance().getVotingPluginUser(args[1]).setMonthVoteStreak(Integer.parseInt(args[4]));
            sender.sendMessage(StringParser.getInstance().colorize("&cSet votestreak month for '" + args[1] + "' to " + args[4]));
        }
    });
    for (final TopVoter top : TopVoter.values()) {
        plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(player)", "SetTotal", top.toString(), "(number)" }, "VotingPlugin.Commands.AdminVote.SetTotal." + top.toString() + "|" + adminPerm, "Set " + top.toString() + " totals for player") {

            @Override
            public void execute(CommandSender sender, String[] args) {
                UserManager.getInstance().getVotingPluginUser(args[1]).setTotal(top, Integer.parseInt(args[4]));
                sender.sendMessage(StringParser.getInstance().colorize("&cSet " + top.toString() + " total for '" + args[1] + "' to " + args[4]));
            }
        });
        plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(player)", "AddTotal", top.toString(), "(number)" }, "VotingPlugin.Commands.AdminVote.AddTotal." + top.toString() + "|" + adminPerm, "Add " + top.toString() + " totals for player") {

            @Override
            public void execute(CommandSender sender, String[] args) {
                VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
                user.setTotal(top, user.getTotal(top) + Integer.parseInt(args[4]));
                sender.sendMessage(StringParser.getInstance().colorize("&cAdded " + top.toString() + " total for " + args[1]));
            }
        });
    }
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(player)", "ClearTotal" }, "VotingPlugin.Commands.AdminVote.ClearTotal|" + adminPerm, "Clear Totals for player") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
            user.clearTotals();
            sender.sendMessage(StringParser.getInstance().colorize("&cCleared totals for '" + args[1] + "'"));
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(player)", "AddMilestoneCount", "(number)" }, "VotingPlugin.Commands.AdminVote.AddMilestoneCount|" + adminPerm, "Add milestonecount") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
            user.setMilestoneCount(user.getMilestoneCount() + Integer.parseInt(args[3]));
            plugin.getSpecialRewards().checkMilestone(user, null, false);
            sender.sendMessage(StringParser.getInstance().colorize("&cAdded milestonecount for " + args[1]));
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(player)", "SetMilestoneCount", "(number)" }, "VotingPlugin.Commands.AdminVote.SetMilestoneCount|" + adminPerm, "Set milestonecount") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
            user.setMilestoneCount(Integer.parseInt(args[3]));
            sender.sendMessage(StringParser.getInstance().colorize("&cSet milestonecount for " + args[1] + " to " + args[3]));
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(player)", "ClearGottenMilestones" }, "VotingPlugin.Commands.AdminVote.ClearGottenMilestones|" + adminPerm, "Clears received milestones") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
            user.setHasGottenMilestone(new HashMap<String, Boolean>());
            sender.sendMessage(StringParser.getInstance().colorize("&cClearing gotten milestones for " + args[1]));
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Vote", "(player)", "All" }, "VotingPlugin.Commands.AdminVote.Vote|" + adminPerm, "Trigger manual vote") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            sendMessage(sender, "&cTriggering vote for all voting sites...");
            for (VoteSite site : plugin.getVoteSites()) {
                PlayerVoteEvent voteEvent = new PlayerVoteEvent(site, args[1], site.getServiceSite(), false);
                if (voteEvent.getVoteSite() != null) {
                    if (!voteEvent.getVoteSite().isVaidServiceSite()) {
                        sendMessage(sender, "&cPossible issue with service site, has the server gotten the vote from " + voteEvent.getServiceSite() + "?");
                    }
                }
                plugin.getServer().getPluginManager().callEvent(voteEvent);
            }
            if (plugin.isYmlError()) {
                sendMessage(sender, "&3Detected yml error, please check server log for details");
            }
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Vote", "(player)", "(Sitename)" }, "VotingPlugin.Commands.AdminVote.Vote|" + adminPerm, "Trigger manual vote") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(args[2], true), args[1], args[2], false);
            sendMessage(sender, "&cTriggering vote...");
            if (voteEvent.getVoteSite() != null) {
                if (!voteEvent.getVoteSite().isVaidServiceSite()) {
                    sendMessage(sender, "&cPossible issue with service site, has the server gotten the vote from " + voteEvent.getServiceSite() + "?");
                }
            }
            plugin.getServer().getPluginManager().callEvent(voteEvent);
            if (plugin.isYmlError()) {
                sendMessage(sender, "&3Detected yml error, please check server log for details");
            }
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Vote", "(player)" }, "VotingPlugin.Commands.AdminVote.Vote|" + adminPerm, "Trigger manual vote via GUI", false) {

        @Override
        public void execute(CommandSender sender, String[] args) {
            new AdminVoteVotePlayer(plugin, sender, args[1]).open();
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Vote" }, "VotingPlugin.Commands.AdminVote.Vote|" + adminPerm, "Manual vote syntax") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            sendMessage(sender, "&aUse /av vote (player) (site)");
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(Player)", "ForceVote", "All" }, "VotingPlugin.Commands.AdminVote.Vote|" + adminPerm, "Trigger manual vote") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            sendMessage(sender, "&cTriggering vote for all voting sites...");
            for (VoteSite site : plugin.getVoteSites()) {
                PlayerVoteEvent voteEvent = new PlayerVoteEvent(site, args[1], site.getServiceSite(), false);
                if (voteEvent.getVoteSite() != null) {
                    if (!voteEvent.getVoteSite().isVaidServiceSite()) {
                        sendMessage(sender, "&cPossible issue with service site, has the server gotten the vote from " + voteEvent.getServiceSite() + "?");
                    }
                }
                plugin.getServer().getPluginManager().callEvent(voteEvent);
            }
            if (plugin.isYmlError()) {
                sendMessage(sender, "&3Detected yml error, please check server log for details");
            }
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(Player)", "ForceVote", "(Sitename)" }, "VotingPlugin.Commands.AdminVote.Vote|" + adminPerm, "Trigger manual vote") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(args[3], true), args[1], args[3], false);
            sendMessage(sender, "&cTriggering vote...");
            if (voteEvent.getVoteSite() != null) {
                if (!voteEvent.getVoteSite().isVaidServiceSite()) {
                    sendMessage(sender, "&cPossible issue with service site, has the server gotten the vote from " + voteEvent.getServiceSite() + "?");
                }
            }
            plugin.getServer().getPluginManager().callEvent(voteEvent);
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "VoteSite", "(sitename)", "Create" }, "VotingPlugin.Commands.AdminVote.VoteSite.Edit|" + adminPerm, "Create VoteSite") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            sender.sendMessage(StringParser.getInstance().colorize("&cCreating VoteSite..." + args[1]));
            plugin.getConfigVoteSites().generateVoteSite(args[1]);
            sender.sendMessage(StringParser.getInstance().colorize("&cCreated VoteSite: &c&l" + args[1]));
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Config", "TempDebug" }, "VotingPlugin.Commands.AdminVote.Config.Edit|" + adminPerm, "Enable debug, effective until reload/restart") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            VotingPluginMain.plugin.getOptions().setDebug(DebugLevel.INFO);
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Config", "TempExtraDebug" }, "VotingPlugin.Commands.AdminVote.Config.Edit|" + adminPerm, "Enable extra debug, effective until reload/restart") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            VotingPluginMain.plugin.getOptions().setDebug(DebugLevel.EXTRA);
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "VoteSite", "(sitename)", "SetServiceSite", "(string)" }, "VotingPlugin.Commands.AdminVote.VoteSite.Edit|" + adminPerm, "Set VoteSite SerivceSite") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            String voteSite = plugin.getVoteSiteName(true, args[1]);
            String serviceSite = args[3];
            plugin.getConfigVoteSites().setServiceSite(voteSite, serviceSite);
            sender.sendMessage(StringParser.getInstance().colorize("&cSet ServiceSite to &c&l" + serviceSite + "&c on &c&l" + voteSite));
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "VoteSite", "(sitename)", "SetVoteURL", "(string)" }, "VotingPlugin.Commands.AdminVote.VoteSite.Edit|" + adminPerm, "Set VoteSite VoteURL") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            String voteSite = plugin.getVoteSiteName(true, args[1]);
            String url = args[3];
            plugin.getConfigVoteSites().setVoteURL(voteSite, url);
            sender.sendMessage(StringParser.getInstance().colorize("&cSet VoteURL to &c&l" + url + "&c on &c&l" + voteSite));
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "VoteSite", "(sitename)", "SetPriority", "(number)" }, "VotingPlugin.Commands.AdminVote.VoteSite.Edit|" + adminPerm, "Set VoteSite Priority") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            String voteSite = plugin.getVoteSiteName(true, args[1]);
            int value = Integer.parseInt(args[3]);
            plugin.getConfigVoteSites().setPriority(voteSite, value);
            sender.sendMessage(StringParser.getInstance().colorize("&cSet priortiy to &c&l" + value + "&c on &c&l" + voteSite));
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "VoteSite", "(sitename)", "SetVoteDelay", "(number)" }, "VotingPlugin.Commands.AdminVote.VoteSite.Edit|" + adminPerm, "Set VoteSite VoteDelay") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            String voteSite = plugin.getVoteSiteName(true, args[1]);
            int delay = Integer.parseInt(args[3]);
            plugin.getConfigVoteSites().setVoteDelay(voteSite, delay);
            sender.sendMessage(StringParser.getInstance().colorize("&cSet VoteDelay to &c&l" + delay + "&c on &c&l" + voteSite));
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "UpdateCheck" }, "VotingPlugin.Commands.AdminVote.UpdateCheck|" + adminPerm, "Check for update") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {

                @Override
                public void run() {
                    sender.sendMessage(StringParser.getInstance().colorize("&cChecking for update..."));
                    plugin.setUpdater(new Updater(plugin, 15358, false));
                    final Updater.UpdateResult result = plugin.getUpdater().getResult();
                    switch(result) {
                        case FAIL_SPIGOT:
                            {
                                sender.sendMessage(StringParser.getInstance().colorize("&cFailed to check for update for &c&l" + plugin.getName() + "&c!"));
                                break;
                            }
                        case NO_UPDATE:
                            {
                                sender.sendMessage(StringParser.getInstance().colorize("&c&l" + plugin.getName() + " &cis up to date! Version: &c&l" + plugin.getUpdater().getVersion()));
                                break;
                            }
                        case UPDATE_AVAILABLE:
                            {
                                sender.sendMessage(StringParser.getInstance().colorize("&c&l" + plugin.getName() + " &chas an update available! Your Version: &c&l" + plugin.getDescription().getVersion() + " &cNew Version: &c&l" + plugin.getUpdater().getVersion()));
                                break;
                            }
                        default:
                            {
                                break;
                            }
                    }
                }
            });
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "VoteSite", "(sitename)", "SetEnabled", "(boolean)" }, "VotingPlugin.Commands.AdminVote.VoteSite.Edit|" + adminPerm, "Set VoteSite Enabled") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            String voteSite = plugin.getVoteSiteName(false, args[1]);
            boolean value = Boolean.parseBoolean(args[3]);
            plugin.getConfigVoteSites().setEnabled(voteSite, value);
            sender.sendMessage(StringParser.getInstance().colorize("&cSet votesite " + voteSite + " enabled to " + value));
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "VoteSite", "(sitename)", "Check" }, "VotingPlugin.Commands.AdminVote.VoteSite.Check|" + adminPerm, "Check to see if VoteSite is valid") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            String siteName = args[1];
            if (!plugin.getConfigVoteSites().isServiceSiteGood(siteName)) {
                sender.sendMessage(StringParser.getInstance().colorize("&cServiceSite is invalid, votes may not work properly"));
            } else {
                String service = plugin.getConfigVoteSites().getServiceSite(siteName);
                if (plugin.getServerData().getServiceSites().contains(service)) {
                    sender.sendMessage(StringParser.getInstance().colorize("&aServiceSite is properly setup"));
                } else {
                    sender.sendMessage(StringParser.getInstance().colorize("&cService may not be valid, haven't recieved a vote from " + service + ", see /av servicesites"));
                }
            }
            if (!plugin.getConfigVoteSites().isVoteURLGood(siteName)) {
                sender.sendMessage(StringParser.getInstance().colorize("&cVoteURL is invalid"));
            } else {
                sender.sendMessage(StringParser.getInstance().colorize("&aVoteURL is properly setup"));
            }
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "BackgroundUpdate" }, "VotingPlugin.Commands.AdminVote.BackgroundUpdate|" + adminPerm, "Force a background update") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            plugin.setUpdate(true);
            plugin.update();
            sender.sendMessage(StringParser.getInstance().colorize("&cUpdating..."));
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "ClearOfflineVotes" }, "VotingPlugin.Commands.AdminVote.ClearOfflineVotes|" + adminPerm, "Clear all offline votes") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            plugin.getUserManager().removeAllKeyValues("OfflineVotes", DataType.STRING);
            plugin.getUserManager().getDataManager().clearCache();
            sender.sendMessage(StringParser.getInstance().colorize("&cOffline votes Cleared"));
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Test", "(Player)", "(sitename)", "(number)" }, "VotingPlugin.Commands.AdminVote.Test|" + adminPerm, "Test voting times") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            VoteTester.getInstance().testVotes(Integer.parseInt(args[3]), args[1], args[2]);
            if (isPlayer(sender)) {
                sendMessage(sender, "&cSee console for details");
            }
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "TestReward", "(Player)", "(reward)", "(number)" }, "VotingPlugin.Commands.AdminVote.TestReward|" + adminPerm, "Test reward times") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            VoteTester.getInstance().testRewards(Integer.parseInt(args[3]), args[1], args[2]);
            if (isPlayer(sender)) {
                sendMessage(sender, "&cSee console for details");
            }
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Placeholders" }, "VotingPlugin.Commands.AdminVote.Placeholders|" + adminPerm, "See possible placeholderapi placeholders") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            new AdminVotePlaceholders(plugin, sender).open();
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "VoteParty", "Force" }, "VotingPlugin.Commands.AdminVote.VoteParty.Force|" + adminPerm, "Force a voteparty reward, resets vote count") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            plugin.getVoteParty().giveRewards(plugin.getBungeeSettings().isUseBungeecoord());
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "VoteParty", "SetVoteCount", "(Number)" }, "VotingPlugin.Commands.AdminVote.VoteParty.SetVoteCount|" + adminPerm, "Set voteparty count") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            int num = Integer.parseInt(args[2]);
            if (num == 0) {
                plugin.getVoteParty().reset(true);
                sendMessage(sender, "&cVoteparty totals have been set to 0 and all been reset");
            } else {
                plugin.getVoteParty().setTotalVotes(num);
                sendMessage(sender, "&cVoteparty total votes has been set to " + args[2]);
            }
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "VoteParty", "AddVoteCount", "(Number)" }, "VotingPlugin.Commands.AdminVote.VoteParty.SetVoteCount|" + adminPerm, "Add voteparty count") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            int num = plugin.getVoteParty().getTotalVotes() + Integer.parseInt(args[2]);
            plugin.getVoteParty().setTotalVotes(num);
            sendMessage(sender, "&cVoteparty total votes has been set to " + num);
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "VoteParty", "SetExtraRequired", "(Number)" }, "VotingPlugin.Commands.AdminVote.VoteParty.SetExtraRequired|" + adminPerm, "Set VotePartyExtraRequired value") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            plugin.getServerData().setVotePartyExtraRequired(Integer.parseInt(args[1]));
            sendMessage(sender, "&cSet VotePartyExtraRequired to " + args[1]);
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(player)", "ForceVoteShop", "(VoteShop)" }, "VotingPlugin.Commands.AdminVote.ForceVoteShop|" + adminPerm, "Force a voteshop reward") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
            RewardHandler.getInstance().giveReward(user, plugin.getConfigFile().getData(), plugin.getGui().getChestShopIdentifierRewardsPath(args[3]), new RewardOptions());
            sendMessage(sender, "&cVoteShop " + args[3] + " forced");
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(player)", "ForceMilestone", "(Number)" }, "VotingPlugin.Commands.AdminVote.ForceMilestone|" + adminPerm, "Force a milestone") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
            plugin.getSpecialRewards().giveMilestoneVoteReward(user, user.isOnline(), parseInt(args[3]), plugin.getBungeeSettings().isUseBungeecoord());
            sendMessage(sender, "&cMilestone " + args[3] + " forced");
        }
    });
    for (final TopVoter top : TopVoter.valuesMinusAllTime()) {
        plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(player)", "ForceTopVoter", top.toString(), "(Number)" }, "VotingPlugin.Commands.AdminVote.ForceTopVoter." + top.toString() + "|" + adminPerm, "Force a top voter reward") {

            @Override
            public void execute(CommandSender sender, String[] args) {
                VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
                int place = parseInt(args[4]);
                switch(top) {
                    case Daily:
                        user.giveDailyTopVoterAward(place, args[4]);
                        break;
                    case Monthly:
                        user.giveMonthlyTopVoterAward(place, args[4]);
                        break;
                    case Weekly:
                        user.giveWeeklyTopVoterAward(place, args[4]);
                        break;
                    default:
                        break;
                }
                sendMessage(sender, "&cTopVoter " + top.toString() + " " + args[4] + " forced");
            }
        });
        String text = "";
        switch(top) {
            case Daily:
                text = "Day";
                break;
            case Monthly:
                text = "Month";
                break;
            case Weekly:
                text = "Week";
                break;
            default:
                break;
        }
        final String str = text;
        plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(player)", "ForceVoteStreak", str, "(Number)" }, "VotingPlugin.Commands.AdminVote.ForceVoteStreak|" + adminPerm, "Force a votestreak reward for " + str) {

            @Override
            public void execute(CommandSender sender, String[] args) {
                VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
                plugin.getSpecialRewards().giveVoteStreakReward(user, user.isOnline(), str, args[4], parseInt(args[4]), plugin.getBungeeSettings().isUseBungeecoord());
                sendMessage(sender, "&cVoteStreak " + str + " " + args[4] + " forced");
            }
        });
    }
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(player)", "ForceCumulative", "(Number)" }, "VotingPlugin.Commands.AdminVote.ForceCumulative|" + adminPerm, "Force a cumulative reward") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
            plugin.getSpecialRewards().giveCumulativeVoteReward(user, user.isOnline(), parseInt(args[3]), plugin.getBungeeSettings().isUseBungeecoord());
            sendMessage(sender, "&cCumulative " + args[3] + " forced");
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(player)", "ForceAllSites" }, "VotingPlugin.Commands.AdminVote.ForceAllSites|" + adminPerm, "Force a allsites reward") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
            plugin.getSpecialRewards().giveAllSitesRewards(user, user.isOnline(), plugin.getBungeeSettings().isUseBungeecoord());
            sendMessage(sender, "&cAllSites forced");
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(player)", "ForceFirstVote" }, "VotingPlugin.Commands.AdminVote.ForceFirstVote|" + adminPerm, "Force a firstvote reward") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
            plugin.getSpecialRewards().giveFirstVoteRewards(user, user.isOnline(), plugin.getBungeeSettings().isUseBungeecoord());
            sendMessage(sender, "&cFirstVote forced");
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(player)", "ForceFirstVoteToday" }, "VotingPlugin.Commands.AdminVote.ForceFirstVoteToday|" + adminPerm, "Force a firstvotetoday reward") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
            plugin.getSpecialRewards().giveFirstVoteTodayRewards(user, user.isOnline(), plugin.getBungeeSettings().isUseBungeecoord());
            sendMessage(sender, "&cFirstVoteToday forced");
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Placeholders", "(player)" }, "VotingPlugin.Commands.AdminVote.Placeholders.Players|" + adminPerm, "See possible placeholderapi placeholders with player values") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            new AdminVotePlaceholdersPlayer(plugin, sender, UserManager.getInstance().getVotingPluginUser(args[1])).open();
        }
    });
    plugin.getAdminVoteCommand().add(new CommandHandler(new String[] {}, "VotingPlugin.Commands.AdminVote|" + adminPerm, "Base command") {

        @Override
        public void execute(CommandSender sender, String[] args) {
            sendMessage(sender, "&cInvalid command, see /adminvote help");
        }
    });
    ArrayList<CommandHandler> avCommands = com.bencodez.advancedcore.command.CommandLoader.getInstance().getBasicAdminCommands("VotingPlugin");
    for (CommandHandler cmd : avCommands) {
        cmd.setPerm(cmd.getPerm() + "|" + adminPerm);
    }
    plugin.getAdminVoteCommand().addAll(avCommands);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CommandHandler(com.bencodez.advancedcore.api.command.CommandHandler) AdminVotePlaceholders(com.bencodez.votingplugin.commands.gui.admin.AdminVotePlaceholders) VoteSite(com.bencodez.votingplugin.objects.VoteSite) VoteURLVoteSite(com.bencodez.votingplugin.commands.gui.player.VoteURLVoteSite) RewardOptions(com.bencodez.advancedcore.api.rewards.RewardOptions) AdminVoteVoteShop(com.bencodez.votingplugin.commands.gui.admin.voteshop.AdminVoteVoteShop) AdminVoteBungeeSettings(com.bencodez.votingplugin.commands.gui.admin.AdminVoteBungeeSettings) AdminVoteMilestones(com.bencodez.votingplugin.commands.gui.admin.milestones.AdminVoteMilestones) TopVoter(com.bencodez.votingplugin.topvoter.TopVoter) VoteTopVoter(com.bencodez.votingplugin.commands.gui.player.VoteTopVoter) AdminVoteVotePlayer(com.bencodez.votingplugin.commands.gui.admin.AdminVoteVotePlayer) Updater(com.bencodez.advancedcore.api.updater.Updater) AdminVotePlaceholdersPlayer(com.bencodez.votingplugin.commands.gui.admin.AdminVotePlaceholdersPlayer) AdminGUI(com.bencodez.votingplugin.commands.gui.AdminGUI) Player(org.bukkit.entity.Player) AdminVotePlaceholdersPlayer(com.bencodez.votingplugin.commands.gui.admin.AdminVotePlaceholdersPlayer) AdminVoteVotePlayer(com.bencodez.votingplugin.commands.gui.admin.AdminVoteVotePlayer) AdminVoteCumulative(com.bencodez.votingplugin.commands.gui.admin.cumulative.AdminVoteCumulative) AdminVotePerms(com.bencodez.votingplugin.commands.gui.admin.AdminVotePerms) AdminVoteVoteParty(com.bencodez.votingplugin.commands.gui.admin.AdminVoteVoteParty) PlayerVoteEvent(com.bencodez.votingplugin.events.PlayerVoteEvent) AdminVoteHelp(com.bencodez.votingplugin.commands.gui.admin.AdminVoteHelp) CommandSender(org.bukkit.command.CommandSender) DateTimeFormatter(java.time.format.DateTimeFormatter) VotingPluginUser(com.bencodez.votingplugin.user.VotingPluginUser)

Example 2 with PlayerVoteEvent

use of com.bencodez.votingplugin.events.PlayerVoteEvent 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.bencodez.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) {
                                    PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(value, true), UserGUI.getInstance().getCurrentPlayer(player), plugin.getVoteSiteServiceSite(value), false);
                                    plugin.getServer().getPluginManager().callEvent(voteEvent);
                                    player.sendMessage("Forced vote for " + UserGUI.getInstance().getCurrentPlayer(player) + " on " + value);
                                }
                            });
                        }
                    });
                    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 : plugin.getSpecialRewardsConfig().getMilestoneVotes()) {
                                if (StringParser.getInstance().isInt(mileStoneName)) {
                                    int mileStone = Integer.parseInt(mileStoneName);
                                    inv.addButton(inv.getNextSlot(), new BInventoryButton("" + mileStone, new String[] { "Enabled: " + plugin.getSpecialRewardsConfig().getMilestoneRewardEnabled(mileStone), "&cClick to set wether this has been completed or not" }, new ItemStack(Material.STONE)) {

                                        @Override
                                        public void onClick(ClickEvent clickEvent) {
                                            if (StringParser.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");
                                                VotingPluginUser 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);
                                                        VotingPluginUser 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) AdminVotePlaceholdersPlayer(com.bencodez.votingplugin.commands.gui.admin.AdminVotePlaceholdersPlayer) AdminVoteVotePlayer(com.bencodez.votingplugin.commands.gui.admin.AdminVoteVotePlayer) BInventoryButton(com.bencodez.advancedcore.api.inventory.BInventoryButton) ClickEvent(com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent) ArrayList(java.util.ArrayList) ValueRequest(com.bencodez.advancedcore.api.valuerequest.ValueRequest) BInventory(com.bencodez.advancedcore.api.inventory.BInventory) VoteSite(com.bencodez.votingplugin.objects.VoteSite) VoteURLVoteSite(com.bencodez.votingplugin.commands.gui.player.VoteURLVoteSite) PlayerVoteEvent(com.bencodez.votingplugin.events.PlayerVoteEvent) BooleanListener(com.bencodez.advancedcore.api.valuerequest.listeners.BooleanListener) StringListener(com.bencodez.advancedcore.api.valuerequest.listeners.StringListener) ItemStack(org.bukkit.inventory.ItemStack) VotingPluginUser(com.bencodez.votingplugin.user.VotingPluginUser)

Example 3 with PlayerVoteEvent

use of com.bencodez.votingplugin.events.PlayerVoteEvent 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 4 with PlayerVoteEvent

use of com.bencodez.votingplugin.events.PlayerVoteEvent 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 5 with PlayerVoteEvent

use of com.bencodez.votingplugin.events.PlayerVoteEvent in project VotingPlugin by Ben12345rocks.

the class VotingPluginUser method bungeeVote.

public void bungeeVote(String service, BungeeMessageData text, boolean setTotals) {
    if (plugin.getBungeeSettings().isUseBungeecoord()) {
        plugin.debug("Bungee vote for " + getPlayerName() + " on " + service);
        PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(service, true), getPlayerName(), service, true);
        voteEvent.setBungee(true);
        voteEvent.setForceBungee(true);
        voteEvent.setAddTotals(setTotals);
        voteEvent.setBungeeTextTotals(text);
        voteEvent.setVotingPluginUser(this);
        Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {

            @Override
            public void run() {
                plugin.getServer().getPluginManager().callEvent(voteEvent);
            }
        });
    }
}
Also used : PlayerVoteEvent(com.bencodez.votingplugin.events.PlayerVoteEvent)

Aggregations

PlayerVoteEvent (com.bencodez.votingplugin.events.PlayerVoteEvent)9 ArrayList (java.util.ArrayList)5 VoteSite (com.bencodez.votingplugin.objects.VoteSite)4 ClickEvent (com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent)3 BInventoryButton (com.bencodez.advancedcore.api.inventory.BInventoryButton)3 Player (org.bukkit.entity.Player)3 EditGUI (com.bencodez.advancedcore.api.inventory.editgui.EditGUI)2 StringListener (com.bencodez.advancedcore.api.valuerequest.listeners.StringListener)2 AdminVotePlaceholdersPlayer (com.bencodez.votingplugin.commands.gui.admin.AdminVotePlaceholdersPlayer)2 AdminVoteVotePlayer (com.bencodez.votingplugin.commands.gui.admin.AdminVoteVotePlayer)2 VoteURLVoteSite (com.bencodez.votingplugin.commands.gui.player.VoteURLVoteSite)2 VotingPluginUser (com.bencodez.votingplugin.user.VotingPluginUser)2 CommandHandler (com.bencodez.advancedcore.api.command.CommandHandler)1 BInventory (com.bencodez.advancedcore.api.inventory.BInventory)1 EditGUIButton (com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton)1 EditGUIValueBoolean (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueBoolean)1 EditGUIValueList (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueList)1 EditGUIValueNumber (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber)1 EditGUIValueString (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString)1 ItemBuilder (com.bencodez.advancedcore.api.item.ItemBuilder)1