use of com.bencodez.votingplugin.commands.gui.player.VoteHelp in project VotingPlugin by Ben12345rocks.
the class CommandLoader method loadVoteCommand.
/**
* Load vote command.
*/
private void loadVoteCommand() {
plugin.setVoteCommand(new ArrayList<CommandHandler>());
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders()) {
plugin.getVoteCommand().add(new CommandHandler(new String[] { "SetPrimaryAccount", "(player)" }, "VotingPlugin.Commands.Vote.SetPrimaryAccount|" + modPerm, "Set primary account", false) {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(sender.getName());
if (args[1].equals("none")) {
user.setPrimaryAccount(null);
sendMessage(sender, "&cRemoved primary account");
} else {
try {
user.setPrimaryAccount(java.util.UUID.fromString(PlayerUtils.getInstance().getUUID(args[1])));
sendMessage(sender, "&cPrimary account set");
} catch (Exception e) {
e.printStackTrace();
sendMessage(sender, "Failed to set primary account: " + e.getMessage());
}
}
}
});
}
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Help&?" }, "VotingPlugin.Commands.Vote.Help|" + playerPerm, "View help page") {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteHelp(plugin, sender, 1).open();
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Help&?", "(number)" }, "VotingPlugin.Commands.Vote.Help|" + playerPerm, "View help page") {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteHelp(plugin, sender, Integer.parseInt(args[1])).open();
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "ToggleReminders" }, "VotingPlugin.Commands.Vote.ToggleReminders", "Enable/disable vote reminders", false) {
@Override
public void execute(CommandSender sender, String[] args) {
Player p = (Player) sender;
boolean value = false;
if (plugin.getVoteReminding().getRemindersEnabled().containsKey(p.getUniqueId())) {
value = !plugin.getVoteReminding().getRemindersEnabled().get(p.getUniqueId());
}
plugin.getVoteReminding().getRemindersEnabled().put(p.getUniqueId(), value);
if (value) {
sendMessage(sender, plugin.getConfigFile().getFormatCommandsVoteToggleRemindersEnabled());
} else {
sendMessage(sender, plugin.getConfigFile().getFormatCommandsVoteToggleRemindersDisabled());
}
}
});
if (plugin.getGui().getChestVoteShopEnabled()) {
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Shop" }, "VotingPlugin.Commands.Vote.Shop|" + playerPerm, "Open VoteShop GUI", false) {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteShop(plugin, sender, UserManager.getInstance().getVotingPluginUser((Player) sender)).open();
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Shop", "(Text)" }, "VotingPlugin.Commands.Vote.Shop|" + playerPerm, "Open VoteShop GUI", false) {
@Override
public void execute(CommandSender sender, String[] args) {
if (!plugin.getGui().getChestVoteShopEnabled()) {
sender.sendMessage(StringParser.getInstance().colorize("&cVote shop disabled"));
return;
}
String identifier = args[1];
Set<String> identifiers = plugin.getGui().getChestShopIdentifiers();
if (ArrayUtils.getInstance().containsIgnoreCase(identifiers, identifier)) {
for (String ident : identifiers) {
if (ident.equalsIgnoreCase(args[1])) {
identifier = ident;
}
}
String perm = plugin.getGui().getChestVoteShopPermission(identifier);
boolean hasPerm = false;
if (perm.isEmpty()) {
hasPerm = true;
} else {
hasPerm = sender.hasPermission(perm);
}
int limit = plugin.getGui().getChestShopIdentifierLimit(identifier);
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(sender.getName());
boolean limitPass = true;
if (limit > 0) {
if (user.getVoteShopIdentifierLimit(identifier) >= limit) {
limitPass = false;
}
}
if (!plugin.getGui().getChestVoteShopNotBuyable(identifier)) {
if (hasPerm) {
user.clearCache();
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
if (identifier != null) {
if (limitPass) {
HashMap<String, String> placeholders = new HashMap<String, String>();
placeholders.put("identifier", identifier);
placeholders.put("points", "" + points);
placeholders.put("limit", "" + limit);
if (user.removePoints(points)) {
RewardHandler.getInstance().giveReward(user, plugin.getGui().getData(), plugin.getGui().getChestShopIdentifierRewardsPath(identifier), new RewardOptions().setPlaceholders(placeholders));
user.sendMessage(StringParser.getInstance().replacePlaceHolder(plugin.getConfigFile().getFormatShopPurchaseMsg(), placeholders));
if (limit > 0) {
user.setVoteShopIdentifierLimit(identifier, user.getVoteShopIdentifierLimit(identifier) + 1);
}
} else {
user.sendMessage(StringParser.getInstance().replacePlaceHolder(plugin.getConfigFile().getFormatShopFailedMsg(), placeholders));
}
} else {
user.sendMessage(plugin.getGui().getChestVoteShopLimitReached());
}
}
}
}
} else {
sendMessage(sender, "&cWrong voteshop item");
}
}
});
}
plugin.getVoteCommand().add(new CommandHandler(new String[] { "URL", "(SiteName)" }, "VotingPlugin.Commands.Vote.URL.VoteSite", "Open VoteURL GUI for VoteSite", false) {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteURLVoteSite(plugin, sender, UserManager.getInstance().getVotingPluginUser((Player) sender), args[1]).open();
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "URL" }, "VotingPlugin.Commands.Vote.URL|" + playerPerm, "Open VoteURL GUI", false) {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteURL(plugin, sender, UserManager.getInstance().getVotingPluginUser((Player) sender), true).open();
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Last", "(player)" }, "VotingPlugin.Commands.Vote.Last.Other|" + modPerm, "See other players last votes") {
@Override
public void execute(CommandSender sender, String[] args) {
if (plugin.getUserManager().userExist(args[1])) {
new VoteLast(plugin, sender, UserManager.getInstance().getVotingPluginUser(args[1])).open();
} else {
sendMessage(sender, StringParser.getInstance().replacePlaceHolder(plugin.getConfigFile().getFormatUserNotExist(), "player", args[1]));
}
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Last" }, "VotingPlugin.Commands.Vote.Last|" + playerPerm, "See your last votes", false) {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteLast(plugin, sender, UserManager.getInstance().getVotingPluginUser((Player) sender)).open();
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "ToggleBroadcast" }, "VotingPlugin.Commands.Vote.ToggleBroadcast|" + playerPerm, "Toggle whether or not you will recieve vote broadcasts", false) {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser((Player) sender);
boolean value = !user.getDisableBroadcast();
user.setDisableBroadcast(value);
if (!value) {
sendMessage(sender, plugin.getConfigFile().getFormatCommandsVoteToggleBroadcastEnabled());
} else {
sendMessage(sender, plugin.getConfigFile().getFormatCommandsVoteToggleBroadcastDisabled());
}
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Next", "(player)" }, "VotingPlugin.Commands.Vote.Next.Other|" + modPerm, "See other players next votes") {
@Override
public void execute(CommandSender sender, String[] args) {
if (plugin.getUserManager().userExist(args[1])) {
new VoteNext(plugin, sender, UserManager.getInstance().getVotingPluginUser(args[1])).open();
} else {
sendMessage(sender, StringParser.getInstance().replacePlaceHolder(plugin.getConfigFile().getFormatUserNotExist(), "player", args[1]));
}
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Points", "(player)" }, "VotingPlugin.Commands.Vote.Points.Other|" + modPerm, "View pints of other player") {
@Override
public void execute(CommandSender sender, String[] args) {
if (plugin.getUserManager().userExist(args[1])) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
String msg = plugin.getConfigFile().getFormatCommandVotePoints().replace("%Player%", user.getPlayerName()).replace("%Points%", "" + user.getPoints());
if (sender instanceof Player) {
UserManager.getInstance().getVotingPluginUser((Player) sender).sendMessage(msg);
} else {
sender.sendMessage(StringParser.getInstance().colorize(msg));
}
} else {
sendMessage(sender, StringParser.getInstance().replacePlaceHolder(plugin.getConfigFile().getFormatUserNotExist(), "player", args[1]));
}
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Points" }, "VotingPlugin.Commands.Vote.Points|" + playerPerm, "View your points", false) {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser((Player) sender);
String msg = plugin.getConfigFile().getFormatCommandVotePoints().replace("%Player%", user.getPlayerName()).replace("%Points%", "" + user.getPoints());
user.sendMessage(msg);
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Next" }, "VotingPlugin.Commands.Vote.Next|" + playerPerm, "See your next votes", false) {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteNext(plugin, sender, UserManager.getInstance().getVotingPluginUser((Player) sender)).open();
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "GUI", "(player)" }, "VotingPlugin.Commands.Vote.GUI.Other|" + modPerm, "Open VoteGUI", false) {
@Override
public void execute(CommandSender sender, String[] args) {
if (plugin.getUserManager().userExist(args[1])) {
new VoteGUI(plugin, sender, UserManager.getInstance().getVotingPluginUser(args[1])).open();
} else {
sendMessage(sender, StringParser.getInstance().replacePlaceHolder(plugin.getConfigFile().getFormatUserNotExist(), "player", args[1]));
}
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "GUI" }, "VotingPlugin.Commands.Vote.GUI|" + playerPerm, "Open VoteGUI", false) {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteGUI(plugin, sender, UserManager.getInstance().getVotingPluginUser((Player) sender)).open();
}
});
if (plugin.getGui().isLastMonthGUI()) {
plugin.getVoteCommand().add(new CommandHandler(new String[] { "LastMonthTop" }, "VotingPlugin.Commands.Vote.LastMonthTop|" + playerPerm, "Open list of Top Voters from last month") {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteTopVoterLastMonth(plugin, sender, UserManager.getInstance().getVotingPluginUser((Player) sender)).open();
}
});
}
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Top" }, "VotingPlugin.Commands.Vote.Top|" + playerPerm, "Open list of Top Voters") {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteTopVoter(plugin, sender, null, TopVoter.getDefault(), 1).open(GUIMethod.valueOf(plugin.getGui().getGuiMethodTopVoter().toUpperCase()));
}
});
for (final TopVoter top : TopVoter.values()) {
String argName = top.toString();
String perm = top.toString();
if (argName.equals(TopVoter.AllTime.toString())) {
argName = "All";
perm = "All";
}
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Top", argName }, "VotingPlugin.Commands.Vote.Top." + perm + "|" + playerPerm, "Open page of Top Voters") {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteTopVoter(plugin, sender, null, top, 1).open(GUIMethod.valueOf(plugin.getGui().getGuiMethodTopVoter().toUpperCase()));
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Top", argName, "(number)" }, "VotingPlugin.Commands.Vote.Top." + perm + "|" + playerPerm, "Open page of Top Voters") {
@Override
public void execute(CommandSender sender, String[] args) {
int page = Integer.parseInt(args[2]);
new VoteTopVoter(plugin, sender, null, top, page).open(GUIMethod.valueOf(plugin.getGui().getGuiMethodTopVoter().toUpperCase()));
}
});
}
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Top", "(number)" }, "VotingPlugin.Commands.Vote.Top|" + playerPerm, "Open page of Top Voters") {
@Override
public void execute(CommandSender sender, String[] args) {
int page = Integer.parseInt(args[1]);
new VoteTopVoter(plugin, sender, null, TopVoter.getDefault(), page).open(GUIMethod.valueOf(plugin.getGui().getGuiMethodTopVoter().toUpperCase()));
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Party" }, "VotingPlugin.Commands.Vote.Party|" + playerPerm, "View current amount of votes and how many more needed") {
@Override
public void execute(CommandSender sender, String[] args) {
plugin.getVoteParty().commandVoteParty(sender);
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Today", "(number)" }, "VotingPlugin.Commands.Vote.Today|" + playerPerm, "Open page of who Voted Today") {
@Override
public void execute(CommandSender sender, String[] args) {
int page = Integer.parseInt(args[1]);
new VoteToday(plugin, sender, null, page).open();
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Today" }, "VotingPlugin.Commands.Vote.Today|" + playerPerm, "View who list of who voted today") {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteToday(plugin, sender, null, 1).open();
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Total", "All" }, "VotingPlugin.Commands.Vote.Total.All|" + playerPerm, "View server total votes") {
@Override
public void execute(CommandSender sender, String[] args) {
ArrayList<String> msg = new ArrayList<String>();
ArrayList<String> uuids = UserManager.getInstance().getAllUUIDs();
int daily = 0;
int weekly = 0;
int month = 0;
int all = 0;
for (String uuid : uuids) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
user.dontCache();
daily += user.getTotal(TopVoter.Daily);
weekly += user.getTotal(TopVoter.Weekly);
month += user.getTotal(TopVoter.Monthly);
all += user.getTotal(TopVoter.AllTime);
}
for (String s : plugin.getConfigFile().getFormatCommandsVoteTotalAll()) {
String str = StringParser.getInstance().replaceIgnoreCase(s, "%DailyTotal%", "" + daily);
str = StringParser.getInstance().replaceIgnoreCase(str, "%WeeklyTotal%", "" + weekly);
str = StringParser.getInstance().replaceIgnoreCase(str, "%MonthlyTotal%", "" + month);
str = StringParser.getInstance().replaceIgnoreCase(str, "%AllTimeTotal%", "" + all);
msg.add(str);
}
msg = ArrayUtils.getInstance().colorize(msg);
sendMessage(sender, msg);
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Total", "(player)" }, "VotingPlugin.Commands.Vote.Total.Other|" + modPerm, "View other players total votes") {
@Override
public void execute(CommandSender sender, String[] args) {
if (plugin.getUserManager().userExist(args[1])) {
new VoteTotal(plugin, sender, UserManager.getInstance().getVotingPluginUser(args[1])).open();
} else {
sendMessage(sender, StringParser.getInstance().replacePlaceHolder(plugin.getConfigFile().getFormatUserNotExist(), "player", args[1]));
}
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Total" }, "VotingPlugin.Commands.Vote.Total|" + playerPerm, "View your total votes", false) {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteTotal(plugin, sender, UserManager.getInstance().getVotingPluginUser((Player) sender)).open();
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Best" }, "VotingPlugin.Commands.Vote.Best|" + playerPerm, "View your best voting", false) {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteBest(plugin, sender, UserManager.getInstance().getVotingPluginUser((Player) sender)).open();
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Best", "(player)" }, "VotingPlugin.Commands.Vote.Best.Other|" + modPerm, "View someone's best voting") {
@Override
public void execute(CommandSender sender, String[] args) {
if (plugin.getUserManager().userExist(args[1])) {
new VoteBest(plugin, sender, UserManager.getInstance().getVotingPluginUser(args[1])).open();
} else {
sendMessage(sender, StringParser.getInstance().replacePlaceHolder(plugin.getConfigFile().getFormatUserNotExist(), "player", args[1]));
}
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Streak" }, "VotingPlugin.Commands.Vote.Streak|" + playerPerm, "View your voting streak", false) {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteStreak(plugin, sender, UserManager.getInstance().getVotingPluginUser((Player) sender)).open();
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Streak", "(player)" }, "VotingPlugin.Commands.Vote.Streak.Other|" + modPerm, "View someone's voting streak") {
@Override
public void execute(CommandSender sender, String[] args) {
if (plugin.getUserManager().userExist(args[1])) {
new VoteStreak(plugin, sender, UserManager.getInstance().getVotingPluginUser(args[1])).open();
} else {
sendMessage(sender, StringParser.getInstance().replacePlaceHolder(plugin.getConfigFile().getFormatUserNotExist(), "player", args[1]));
}
}
});
if (plugin.getConfigFile().isAllowVotePointTransfers()) {
plugin.getVoteCommand().add(new CommandHandler(new String[] { "GivePoints", "(player)", "(number)" }, "VotingPlugin.Commands.Vote.GivePoints", "Give someone points from your points", false) {
@Override
public void execute(CommandSender sender, String[] args) {
if (plugin.getConfigFile().isAllowVotePointTransfers()) {
VotingPluginUser cPlayer = UserManager.getInstance().getVotingPluginUser((Player) sender);
cPlayer.cache();
if (plugin.getUserManager().userExist(args[1])) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
user.dontCache();
int pointsToGive = Integer.parseInt(args[2]);
if (pointsToGive > 0) {
if (cPlayer.getPoints() >= pointsToGive) {
user.addPoints(pointsToGive);
cPlayer.removePoints(pointsToGive);
sendMessage(sender, "&c" + pointsToGive + " points given to " + user.getPlayerName());
user.sendMessage("&cYou received " + pointsToGive + " points from " + cPlayer.getPlayerName());
} else {
sendMessage(sender, "&cNot enough points");
}
} else {
sendMessage(sender, "&cNumber of points needs to be greater than 0");
}
} else {
sendMessage(sender, "&c" + args[1] + " has not joined the server");
}
}
}
});
}
plugin.getVoteCommand().add(new CommandHandler(new String[] {}, "VotingPlugin.Commands.Vote|" + playerPerm, "See voting URLs") {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = null;
if (sender instanceof Player) {
user = UserManager.getInstance().getVotingPluginUser((Player) sender);
}
if (plugin.getConfigFile().isUseVoteGUIMainCommand() && sender instanceof Player) {
// vote gui command
new VoteGUI(plugin, sender, user).open();
} else {
new VoteURL(plugin, sender, user, true).open();
}
}
});
plugin.getVoteCommand().add(new CommandHandler(new String[] { "List&All" }, "VotingPlugin.Commands.Vote.List|" + playerPerm, "See voting URLs") {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteURL(plugin, sender, null, true).open(GUIMethod.CHAT);
}
});
if (plugin.getConfigFile().isAddCustomCommands()) {
for (String ident : plugin.getConfigFile().getCustomCommands()) {
ConfigurationSection section = plugin.getConfigFile().getCustomCommands(ident);
@SuppressWarnings("unchecked") String[] args = ArrayUtils.getInstance().convert((ArrayList<String>) section.getList("Args", new ArrayList<String>()));
plugin.getVoteCommand().add(new CommandHandler(args, section.getString("Permission", ""), section.getString("HelpMessage", "")) {
@SuppressWarnings("unchecked")
@Override
public void execute(CommandSender sender, String[] args) {
sendMessage(sender, section.getString("Message", ""));
for (String str : (ArrayList<String>) section.getList("Commands", new ArrayList<String>())) {
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
Bukkit.getServer().dispatchCommand(sender, str);
}
});
}
}
});
}
}
ArrayList<CommandHandler> avCommands = com.bencodez.advancedcore.command.CommandLoader.getInstance().getBasicCommands("VotingPlugin");
for (CommandHandler cmd : avCommands) {
cmd.setPerm(cmd.getPerm() + "|" + playerPerm);
}
plugin.getVoteCommand().addAll(avCommands);
ArrayList<CommandHandler> list = plugin.getVoteCommand();
ArrayList<String> disabledCommands = plugin.getConfigFile().getDisabledCommands();
for (int i = list.size() - 1; i >= 0; i--) {
boolean remove = false;
for (String disabled : disabledCommands) {
CommandHandler handle = list.get(i);
if (handle.getPerm().contains(disabled)) {
remove = true;
}
}
if (remove) {
plugin.debug("Disabling: " + ArrayUtils.getInstance().makeStringList(ArrayUtils.getInstance().convert(list.get(i).getArgs())));
list.remove(i);
}
}
ArrayList<String> disabledDefaultPerms = plugin.getConfigFile().getDisabledDefaultPermissions();
for (CommandHandler cmd : list) {
boolean contains = false;
for (String dis : disabledDefaultPerms) {
if (cmd.getPerm().contains(dis + "|")) {
contains = true;
}
}
if (contains) {
cmd.setPerm(cmd.getPerm().replace("|" + playerPerm, ""));
plugin.debug("Disabling VotingPlugin.Player permission on " + cmd.getPerm());
}
}
}
Aggregations