use of com.bencodez.votingplugin.commands.gui.admin.AdminVoteHelp 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);
}
Aggregations