Search in sources :

Example 1 with VoteSite

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

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

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

the class CommandLoader method loadTabComplete.

/**
 * Load tab complete.
 */
public void loadTabComplete() {
    ArrayList<String> sites = new ArrayList<String>();
    for (VoteSite site : plugin.getVoteSites()) {
        sites.add(site.getKey());
    }
    TabCompleteHandler.getInstance().addTabCompleteOption(new TabCompleteHandle("(Sitename)", sites) {

        @Override
        public void reload() {
            ArrayList<String> sites = new ArrayList<String>();
            for (VoteSite site : plugin.getVoteSites()) {
                sites.add(site.getKey());
            }
            setReplace(sites);
        }

        @Override
        public void updateReplacements() {
        }
    });
    ArrayList<String> topVoter = new ArrayList<String>();
    for (TopVoter top : TopVoter.values()) {
        topVoter.add(top.toString());
    }
    TabCompleteHandler.getInstance().addTabCompleteOption(new TabCompleteHandle("(topvoter)", topVoter) {

        @Override
        public void reload() {
            ArrayList<String> topVoter = new ArrayList<String>();
            for (TopVoter top : TopVoter.values()) {
                topVoter.add(top.toString());
            }
            setReplace(topVoter);
        }

        @Override
        public void updateReplacements() {
        }
    });
    TabCompleteHandler.getInstance().addTabCompleteOption(new TabCompleteHandle("(VoteShop)", sites) {

        @Override
        public void reload() {
            ArrayList<String> sites = new ArrayList<String>();
            for (String str : plugin.getGui().getChestShopIdentifiers()) {
                sites.add(str);
            }
            setReplace(sites);
        }

        @Override
        public void updateReplacements() {
        }
    });
}
Also used : VoteSite(com.bencodez.votingplugin.objects.VoteSite) VoteURLVoteSite(com.bencodez.votingplugin.commands.gui.player.VoteURLVoteSite) TopVoter(com.bencodez.votingplugin.topvoter.TopVoter) VoteTopVoter(com.bencodez.votingplugin.commands.gui.player.VoteTopVoter) ArrayList(java.util.ArrayList) TabCompleteHandle(com.bencodez.advancedcore.api.command.TabCompleteHandle)

Example 4 with VoteSite

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

the class VotingPluginMain method onPostLoad.

@Override
public void onPostLoad() {
    loadVersionFile();
    getOptions().setServer(bungeeSettings.getServer());
    if (bungeeSettings.isUseBungeecoord()) {
        bungeeHandler = new BungeeHandler(this);
        bungeeHandler.load();
        if (getOptions().getServer().equalsIgnoreCase("PleaseSet")) {
            getLogger().warning("Bungeecoord is true and server name is not set, bungeecoord features may not work");
        }
    }
    registerCommands();
    checkVotifier();
    registerEvents();
    loadDirectlyDefined();
    checkUpdate = new CheckUpdate(this);
    checkUpdate.startUp();
    voteReminding = new VoteReminding(this);
    voteReminding.loadRemindChecking();
    specialRewards = new SpecialRewards(this);
    signs = new Signs(this);
    coolDownCheck.checkEnabled();
    coolDownCheck.load();
    Bukkit.getScheduler().runTask(plugin, new Runnable() {

        @Override
        public void run() {
            signs.loadSigns();
        }
    });
    topVoterHandler = new TopVoterHandler(this);
    lastMonthTopVoter = new LinkedHashMap<TopVoterPlayer, Integer>();
    Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {

        @Override
        public void run() {
            topVoterHandler.loadLastMonth();
            debug("Loaded last month top voters");
        }
    });
    topVoter = new LinkedHashMap<TopVoter, LinkedHashMap<TopVoterPlayer, Integer>>();
    for (TopVoter top : TopVoter.values()) {
        topVoter.put(top, new LinkedHashMap<TopVoterPlayer, Integer>());
    }
    voteToday = new LinkedHashMap<TopVoterPlayer, HashMap<VoteSite, LocalDateTime>>();
    voteLog = new Logger(plugin, new File(plugin.getDataFolder() + File.separator + "Log", "votelog.txt"));
    new AdminGUI(this).loadHook();
    // vote party
    voteParty = new VoteParty(this);
    voteParty.register();
    topVoterHandler.register();
    metrics();
    // javascript api
    getJavascriptEngineRequests().add(new JavascriptPlaceholderRequest("User") {

        @Override
        public Object getObject(OfflinePlayer player) {
            return getVotingPluginUserManager().getVotingPluginUser(player);
        }
    });
    getJavascriptEngine().put("VotingPluginHooks", VotingPluginHooks.getInstance());
    loadTimer();
    // placeholderapi loading
    placeholders = new PlaceHolders(this);
    placeholders.load();
    if (Bukkit.getPluginManager().isPluginEnabled("MVdWPlaceholderAPI")) {
        mvdwPlaceholders = new MVdWPlaceholders(this);
        mvdwPlaceholders.loadMVdWPlaceholders();
    }
    // Add rewards
    RewardHandler.getInstance().addInjectedReward(new RewardInjectInt("Points", 0) {

        @Override
        public String onRewardRequest(Reward reward, com.bencodez.advancedcore.api.user.AdvancedCoreUser user, int num, HashMap<String, String> placeholders) {
            UserManager.getInstance().getVotingPluginUser(user).addPoints(num);
            return null;
        }
    }.synchronize().addEditButton(new EditGUIButton(new ItemBuilder(Material.PAPER), new EditGUIValueNumber("Points", null) {

        @Override
        public void setValue(Player player, Number value) {
            RewardEditData reward = (RewardEditData) getInv().getData("Reward");
            reward.setValue("Points", value.intValue());
        }
    }.addLore("Give player voting points"))).validator(new RewardInjectValidator() {

        @Override
        public void onValidate(Reward reward, RewardInject inject, ConfigurationSection data) {
            if (data.getInt(inject.getPath(), -1) == 0) {
                warning(reward, inject, "Points can not be 0");
            }
        }
    }));
    RewardHandler.getInstance().addInjectedReward(new RewardInjectConfigurationSection("VoteBossBar") {

        @Override
        public String onRewardRequested(Reward arg0, com.bencodez.advancedcore.api.user.AdvancedCoreUser user, ConfigurationSection section, HashMap<String, String> placeholders) {
            if (section.getBoolean("Enabled")) {
                user.sendBossBar(StringParser.getInstance().replacePlaceHolder(section.getString("Message", ""), placeholders), section.getString("Color", "BLUE"), section.getString("Style", "SOLID"), (double) UserManager.getInstance().getVotingPluginUser(user).getSitesVotedOn() / plugin.getVoteSites().size(), section.getInt("Delay", 30));
            }
            return null;
        }
    });
    for (final TopVoter top : TopVoter.values()) {
        RewardHandler.getInstance().addPlaceholder(new RewardPlaceholderHandle("Total_" + top.toString()) {

            @Override
            public String getValue(Reward reward, com.bencodez.advancedcore.api.user.AdvancedCoreUser user) {
                VotingPluginUser vUser = UserManager.getInstance().getVotingPluginUser(user);
                return "" + vUser.getTotal(top);
            }
        });
    }
    if (plugin.getConfigFile().isFormatAlternateBroadcastEnabled()) {
        broadcastHandler = new BroadcastHandler(plugin, plugin.getConfigFile().getFormatAlternateBroadcastDelay());
        plugin.debug("Using alternate broadcast method");
    }
    plugin.getLogger().info("Enabled VotingPlugin " + plugin.getDescription().getVersion());
    if (getProfile().contains("dev")) {
        plugin.getLogger().info("Using dev build, this is not a stable build, use at your own risk. Build number: " + buildNumber);
    }
    boolean hasRewards = RewardHandler.getInstance().hasRewards(getConfigVoteSites().getData(), getConfigVoteSites().getEverySiteRewardPath());
    boolean issues = true;
    ArrayList<String> services = serverData.getServiceSites();
    for (VoteSite site : getVoteSites()) {
        if (!site.hasRewards() && !hasRewards) {
            issues = false;
            plugin.getLogger().warning("No rewards detected for the site: " + site.getKey() + ". See https://github.com/BenCodez/VotingPlugin/wiki/Rewards");
        }
        boolean contains = false;
        for (String service : services) {
            if (service.equalsIgnoreCase(site.getServiceSite())) {
                contains = true;
            }
        }
        if (!contains) {
            issues = false;
            plugin.getLogger().warning("No vote has been recieved from " + site.getServiceSite() + ", may be an invalid service site. Please read: https://github.com/BenCodez/VotingPlugin/wiki/Votifier-Troubleshooting");
        }
    }
    if (!issues) {
        Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {

            @Override
            public void run() {
                plugin.getLogger().warning("Detected an issue with voting sites, check the server startup log for more details: https://github.com/BenCodez/VotingPlugin/wiki/Votifier-Troubleshooting");
            }
        }, 30l);
    }
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) VoteReminding(com.bencodez.votingplugin.votereminding.VoteReminding) PlaceHolders(com.bencodez.votingplugin.placeholders.PlaceHolders) LinkedHashMap(java.util.LinkedHashMap) OfflinePlayer(org.bukkit.OfflinePlayer) AdminGUI(com.bencodez.votingplugin.commands.gui.AdminGUI) RewardPlaceholderHandle(com.bencodez.advancedcore.api.rewards.RewardPlaceholderHandle) VoteParty(com.bencodez.votingplugin.voteparty.VoteParty) TopVoterPlayer(com.bencodez.votingplugin.topvoter.TopVoterPlayer) Player(org.bukkit.entity.Player) OfflinePlayer(org.bukkit.OfflinePlayer) TopVoterPlayer(com.bencodez.votingplugin.topvoter.TopVoterPlayer) RewardInjectInt(com.bencodez.advancedcore.api.rewards.injected.RewardInjectInt) MVdWPlaceholders(com.bencodez.votingplugin.placeholders.MVdWPlaceholders) ItemBuilder(com.bencodez.advancedcore.api.item.ItemBuilder) CheckUpdate(com.bencodez.votingplugin.updater.CheckUpdate) EditGUIButton(com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton) EditGUIValueNumber(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber) File(java.io.File) ConfigurationSection(org.bukkit.configuration.ConfigurationSection) RewardInjectConfigurationSection(com.bencodez.advancedcore.api.rewards.injected.RewardInjectConfigurationSection) VotingPluginUser(com.bencodez.votingplugin.user.VotingPluginUser) Logger(com.bencodez.advancedcore.logger.Logger) VoteSite(com.bencodez.votingplugin.objects.VoteSite) TopVoterHandler(com.bencodez.votingplugin.topvoter.TopVoterHandler) EditGUIValueNumber(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber) TopVoter(com.bencodez.votingplugin.topvoter.TopVoter) RewardInjectValidator(com.bencodez.advancedcore.api.rewards.injected.RewardInjectValidator) SpecialRewards(com.bencodez.votingplugin.specialrewards.SpecialRewards) JavascriptPlaceholderRequest(com.bencodez.advancedcore.api.javascript.JavascriptPlaceholderRequest) Signs(com.bencodez.votingplugin.signs.Signs) RewardEditData(com.bencodez.advancedcore.api.rewards.RewardEditData) RewardInjectConfigurationSection(com.bencodez.advancedcore.api.rewards.injected.RewardInjectConfigurationSection) RewardInject(com.bencodez.advancedcore.api.rewards.injected.RewardInject) DirectlyDefinedReward(com.bencodez.advancedcore.api.rewards.DirectlyDefinedReward) Reward(com.bencodez.advancedcore.api.rewards.Reward) BroadcastHandler(com.bencodez.votingplugin.broadcast.BroadcastHandler)

Example 5 with VoteSite

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

the class VotingPluginMain method loadDirectlyDefined.

public void loadDirectlyDefined() {
    RewardHandler.getInstance().getDirectlyDefinedRewards().clear();
    // AllSites reward
    addDirectlyDefinedRewards(new DirectlyDefinedReward("AllSites") {

        @Override
        public void createSection(String key) {
            getSpecialRewardsConfig().createSection(key);
        }

        @Override
        public ConfigurationSection getFileData() {
            return getSpecialRewardsConfig().getData();
        }

        @Override
        public void save() {
            getSpecialRewardsConfig().saveData();
        }

        @Override
        public void setData(String path, Object value) {
            getSpecialRewardsConfig().setValue(path, value);
        }
    });
    // FirstVote
    addDirectlyDefinedRewards(new DirectlyDefinedReward("FirstVote") {

        @Override
        public void createSection(String key) {
            getSpecialRewardsConfig().createSection(key);
        }

        @Override
        public ConfigurationSection getFileData() {
            return getSpecialRewardsConfig().getData();
        }

        @Override
        public void save() {
            getSpecialRewardsConfig().saveData();
        }

        @Override
        public void setData(String path, Object value) {
            getSpecialRewardsConfig().setValue(path, value);
        }
    });
    addDirectlyDefinedRewards(new DirectlyDefinedReward("FirstVoteToday") {

        @Override
        public void createSection(String key) {
            getSpecialRewardsConfig().createSection(key);
        }

        @Override
        public ConfigurationSection getFileData() {
            return getSpecialRewardsConfig().getData();
        }

        @Override
        public void save() {
            getSpecialRewardsConfig().saveData();
        }

        @Override
        public void setData(String path, Object value) {
            getSpecialRewardsConfig().setValue(path, value);
        }
    });
    addDirectlyDefinedRewards(new DirectlyDefinedReward("VoteReminding.Rewards") {

        @Override
        public void createSection(String key) {
            getConfigFile().saveData();
        }

        @Override
        public ConfigurationSection getFileData() {
            return getConfigFile().getData();
        }

        @Override
        public void save() {
            getConfigFile().saveData();
        }

        @Override
        public void setData(String path, Object value) {
            getConfigFile().setValue(path, value);
        }
    });
    // vote cooldown ended
    addDirectlyDefinedRewards(new DirectlyDefinedReward("VoteCoolDownEndedReward") {

        @Override
        public void createSection(String key) {
            getSpecialRewardsConfig().createSection(key);
        }

        @Override
        public ConfigurationSection getFileData() {
            return getSpecialRewardsConfig().getData();
        }

        @Override
        public void save() {
            getSpecialRewardsConfig().saveData();
        }

        @Override
        public void setData(String path, Object value) {
            getSpecialRewardsConfig().setValue(path, value);
        }
    });
    // any site rewards
    addDirectlyDefinedRewards(new DirectlyDefinedReward("AnySiteRewards") {

        @Override
        public void createSection(String key) {
            getSpecialRewardsConfig().createSection(key);
        }

        @Override
        public ConfigurationSection getFileData() {
            return getSpecialRewardsConfig().getData();
        }

        @Override
        public void save() {
            getSpecialRewardsConfig().saveData();
        }

        @Override
        public void setData(String path, Object value) {
            getSpecialRewardsConfig().setValue(path, value);
        }
    });
    addDirectlyDefinedRewards(new DirectlyDefinedReward("EverySiteReward") {

        @Override
        public void createSection(String key) {
            getConfigVoteSites().createSection(key);
        }

        @Override
        public ConfigurationSection getFileData() {
            return getConfigVoteSites().getData();
        }

        @Override
        public void save() {
            getConfigVoteSites().saveData();
        }

        @Override
        public void setData(String path, Object value) {
            getConfigVoteSites().setValue(path, value);
        }
    });
    // login rewards
    addDirectlyDefinedRewards(new DirectlyDefinedReward("LoginRewards") {

        @Override
        public void createSection(String key) {
            getSpecialRewardsConfig().createSection(key);
        }

        @Override
        public ConfigurationSection getFileData() {
            return getSpecialRewardsConfig().getData();
        }

        @Override
        public void save() {
            getSpecialRewardsConfig().saveData();
        }

        @Override
        public void setData(String path, Object value) {
            getSpecialRewardsConfig().setValue(path, value);
        }
    });
    // logout rewards
    addDirectlyDefinedRewards(new DirectlyDefinedReward("LogoutRewards") {

        @Override
        public void createSection(String key) {
            getSpecialRewardsConfig().createSection(key);
        }

        @Override
        public ConfigurationSection getFileData() {
            return getSpecialRewardsConfig().getData();
        }

        @Override
        public void save() {
            getSpecialRewardsConfig().saveData();
        }

        @Override
        public void setData(String path, Object value) {
            getSpecialRewardsConfig().setValue(path, value);
        }
    });
    // VoteParty
    addDirectlyDefinedRewards(new DirectlyDefinedReward("VoteParty.Rewards") {

        @Override
        public void createSection(String key) {
            getSpecialRewardsConfig().createSection(key);
        }

        @Override
        public ConfigurationSection getFileData() {
            return getSpecialRewardsConfig().getData();
        }

        @Override
        public void save() {
            getSpecialRewardsConfig().saveData();
        }

        @Override
        public void setData(String path, Object value) {
            getSpecialRewardsConfig().setValue(path, value);
        }
    });
    // Cumulative rewards
    for (String num : getSpecialRewardsConfig().getCumulativeVotes()) {
        addDirectlyDefinedRewards(new DirectlyDefinedReward("Cumulative." + num + ".Rewards") {

            @Override
            public void createSection(String key) {
                getSpecialRewardsConfig().createSection(key);
            }

            @Override
            public ConfigurationSection getFileData() {
                return getSpecialRewardsConfig().getData();
            }

            @Override
            public void save() {
                getSpecialRewardsConfig().saveData();
            }

            @Override
            public void setData(String path, Object value) {
                getSpecialRewardsConfig().setValue(path, value);
            }
        });
    }
    // Milestones rewards
    for (String num : getSpecialRewardsConfig().getMilestoneVotes()) {
        addDirectlyDefinedRewards(new DirectlyDefinedReward("MileStones." + num + ".Rewards") {

            @Override
            public void createSection(String key) {
                getSpecialRewardsConfig().createSection(key);
            }

            @Override
            public ConfigurationSection getFileData() {
                return getSpecialRewardsConfig().getData();
            }

            @Override
            public void save() {
                getSpecialRewardsConfig().saveData();
            }

            @Override
            public void setData(String path, Object value) {
                getSpecialRewardsConfig().setValue(path, value);
            }
        });
    }
    // VoteSites
    for (VoteSite site : plugin.getVoteSites()) {
        addDirectlyDefinedRewards(new DirectlyDefinedReward("VoteSites." + site.getKey() + ".Rewards") {

            @Override
            public void createSection(String key) {
                getConfigVoteSites().createSection(key);
            }

            @Override
            public ConfigurationSection getFileData() {
                return getConfigVoteSites().getData();
            }

            @Override
            public void save() {
                getConfigVoteSites().saveData();
            }

            @Override
            public void setData(String path, Object value) {
                getConfigVoteSites().setValue(path, value);
            }
        });
    }
    // vote streaks
    String[] types = new String[] { "Day", "Week", "Month" };
    for (String type : types) {
        for (String str : plugin.getSpecialRewardsConfig().getVoteStreakVotes(type)) {
            addDirectlyDefinedRewards(new DirectlyDefinedReward("VoteStreak." + type + "." + str + ".Rewards") {

                @Override
                public void createSection(String key) {
                    getSpecialRewardsConfig().createSection(key);
                }

                @Override
                public ConfigurationSection getFileData() {
                    return getSpecialRewardsConfig().getData();
                }

                @Override
                public void save() {
                    getSpecialRewardsConfig().saveData();
                }

                @Override
                public void setData(String path, Object value) {
                    getSpecialRewardsConfig().setValue(path, value);
                }
            });
        }
    }
    for (String path : plugin.getSpecialRewardsConfig().getMonthlyPossibleRewardPlaces()) {
        addDirectlyDefinedRewards(new DirectlyDefinedReward(plugin.getSpecialRewardsConfig().getMonthlyAwardRewardsPath(path)) {

            @Override
            public void createSection(String key) {
                getSpecialRewardsConfig().createSection(key);
            }

            @Override
            public ConfigurationSection getFileData() {
                return getSpecialRewardsConfig().getData();
            }

            @Override
            public void save() {
                getSpecialRewardsConfig().saveData();
            }

            @Override
            public void setData(String path, Object value) {
                getSpecialRewardsConfig().setValue(path, value);
            }
        });
    }
    for (String path : plugin.getSpecialRewardsConfig().getWeeklyPossibleRewardPlaces()) {
        addDirectlyDefinedRewards(new DirectlyDefinedReward(plugin.getSpecialRewardsConfig().getWeeklyAwardRewardsPath(path)) {

            @Override
            public void createSection(String key) {
                getSpecialRewardsConfig().createSection(key);
            }

            @Override
            public ConfigurationSection getFileData() {
                return getSpecialRewardsConfig().getData();
            }

            @Override
            public void save() {
                getSpecialRewardsConfig().saveData();
            }

            @Override
            public void setData(String path, Object value) {
                getSpecialRewardsConfig().setValue(path, value);
            }
        });
    }
    for (String path : plugin.getSpecialRewardsConfig().getDailyPossibleRewardPlaces()) {
        addDirectlyDefinedRewards(new DirectlyDefinedReward(plugin.getSpecialRewardsConfig().getDailyAwardRewardsPath(path)) {

            @Override
            public void createSection(String key) {
                getSpecialRewardsConfig().createSection(key);
            }

            @Override
            public ConfigurationSection getFileData() {
                return getSpecialRewardsConfig().getData();
            }

            @Override
            public void save() {
                getSpecialRewardsConfig().saveData();
            }

            @Override
            public void setData(String path, Object value) {
                getSpecialRewardsConfig().setValue(path, value);
            }
        });
    }
    for (String identifier : plugin.getGui().getChestShopIdentifiers()) {
        addDirectlyDefinedRewards(new DirectlyDefinedReward("CHEST.Shop." + identifier + ".Rewards") {

            @Override
            public void createSection(String key) {
                getGui().createSection(key);
            }

            @Override
            public ConfigurationSection getFileData() {
                return getGui().getData();
            }

            @Override
            public void save() {
                getGui().saveData();
            }

            @Override
            public void setData(String path, Object value) {
                getGui().setValue(path, value);
            }
        });
    }
    addDirectlyDefinedRewards(new DirectlyDefinedReward("BungeeVotePartyRewards") {

        @Override
        public void createSection(String key) {
            getBungeeSettings().createSection(key);
        }

        @Override
        public ConfigurationSection getFileData() {
            return getBungeeSettings().getData();
        }

        @Override
        public void save() {
            getBungeeSettings().saveData();
        }

        @Override
        public void setData(String path, Object value) {
            getBungeeSettings().setValue(path, value);
        }
    });
}
Also used : DirectlyDefinedReward(com.bencodez.advancedcore.api.rewards.DirectlyDefinedReward) VoteSite(com.bencodez.votingplugin.objects.VoteSite) ConfigurationSection(org.bukkit.configuration.ConfigurationSection) RewardInjectConfigurationSection(com.bencodez.advancedcore.api.rewards.injected.RewardInjectConfigurationSection)

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