mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-22 10:36:09 +01:00
Properly display command usage
This commit is contained in:
parent
67b8018f93
commit
baf377e304
@ -185,6 +185,7 @@ public class QuestadminCommandHandler {
|
||||
|
||||
private String getAdminCommandUsage(final String cmd) {
|
||||
return ChatColor.RED + Lang.get("usage") + ": " + ChatColor.YELLOW + "/questadmin "
|
||||
+ Lang.get(Lang.getKeyFromPrefix("COMMAND_QUESTADMIN_", cmd) + "_HELP");
|
||||
+ Lang.get(Lang.getKeyFromPrefix("COMMAND_QUESTADMIN_", cmd) + "_HELP")
|
||||
.replace("<command>", cmd.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public class QuestadminFinishCommand extends QuestsSubCommand {
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 1) {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_FINISH_HELP"));
|
||||
// Shows command usage
|
||||
return;
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.finish")) {
|
||||
|
@ -69,7 +69,7 @@ public class QuestadminGiveCommand extends QuestsSubCommand {
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 1) {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_GIVE_HELP"));
|
||||
// Shows command usage
|
||||
return;
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.give")) {
|
||||
|
@ -67,7 +67,7 @@ public class QuestadminGivepointsCommand extends QuestsSubCommand {
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 1) {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_GIVEPOINTS_HELP"));
|
||||
// Shows command usage
|
||||
return;
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.givepoints")) {
|
||||
|
@ -70,7 +70,7 @@ public class QuestadminNextstageCommand extends QuestsSubCommand {
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 1) {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_NEXTSTAGE_HELP"));
|
||||
// Shows command usage
|
||||
return;
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.nextstage")) {
|
||||
|
@ -67,7 +67,7 @@ public class QuestadminPointsCommand extends QuestsSubCommand {
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 1) {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_POINTS_HELP"));
|
||||
// Shows command usage
|
||||
return;
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.points")) {
|
||||
|
@ -67,7 +67,7 @@ public class QuestadminPointsallCommand extends QuestsSubCommand {
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 1) {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_POINTSALL_HELP"));
|
||||
// Shows command usage
|
||||
return;
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.pointsall")) {
|
||||
|
@ -70,7 +70,7 @@ public class QuestadminQuitCommand extends QuestsSubCommand {
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 1) {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_QUIT_HELP"));
|
||||
// Shows command usage
|
||||
return;
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.quit")) {
|
||||
|
@ -70,7 +70,7 @@ public class QuestadminRemoveCommand extends QuestsSubCommand {
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 1) {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_REMOVE_HELP"));
|
||||
// Shows command usage
|
||||
return;
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") && cs.hasPermission("quests.admin.remove")) {
|
||||
|
@ -69,7 +69,7 @@ public class QuestadminResetCommand extends QuestsSubCommand {
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 1) {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_RESET_HELP"));
|
||||
// Shows command usage
|
||||
return;
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.reset")) {
|
||||
|
@ -71,7 +71,7 @@ public class QuestadminSetstageCommand extends QuestsSubCommand {
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 1) {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_SETSTAGE_HELP"));
|
||||
// Shows command usage
|
||||
return;
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.setstage")) {
|
||||
@ -85,14 +85,10 @@ public class QuestadminSetstageCommand extends QuestsSubCommand {
|
||||
}
|
||||
}
|
||||
int stage = -1;
|
||||
if (args.length > 3) {
|
||||
try {
|
||||
stage = Integer.parseInt(args[args.length - 1]);
|
||||
} catch (final NumberFormatException e) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("inputNum"));
|
||||
}
|
||||
} else {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("COMMAND_QUESTADMIN_SETSTAGE_USAGE"));
|
||||
return;
|
||||
}
|
||||
final IQuester quester = plugin.getQuester(target.getUniqueId());
|
||||
|
@ -68,7 +68,7 @@ public class QuestadminStatsCommand extends QuestsSubCommand {
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 1) {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_STATS_HELP"));
|
||||
// Shows command usage
|
||||
return;
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") && cs.hasPermission("quests.admin.stats")) {
|
||||
|
@ -67,7 +67,7 @@ public class QuestadminTakepointsCommand extends QuestsSubCommand {
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 1) {
|
||||
cs.sendMessage(ChatColor.RED + Lang.get("COMMAND_QUESTADMIN_TAKEPOINTS_HELP"));
|
||||
// Shows command usage
|
||||
return;
|
||||
}
|
||||
if (cs.hasPermission("quests.admin.*") || cs.hasPermission("quests.admin.takepoints")) {
|
||||
|
@ -120,6 +120,6 @@ public class QuestsCommandHandler {
|
||||
|
||||
private String getCommandUsage(final String cmd) {
|
||||
return ChatColor.RED + Lang.get("usage") + ": " + ChatColor.YELLOW + "/quests "
|
||||
+ Lang.get(Lang.getKeyFromPrefix("COMMAND_", cmd) + "_HELP");
|
||||
+ Lang.get(Lang.getKeyFromPrefix("COMMAND_", cmd) + "_HELP").replace("<command>", cmd.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
@ -58,12 +58,10 @@ public class QuestsInfoCommand extends QuestsSubCommand {
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (cs.hasPermission("quests.info")) {
|
||||
cs.sendMessage(ChatColor.YELLOW + "Quests " + ChatColor.GOLD
|
||||
+ plugin.getDescription().getVersion());
|
||||
cs.sendMessage(ChatColor.YELLOW + "Quests " + ChatColor.GOLD + plugin.getDescription().getVersion());
|
||||
cs.sendMessage(ChatColor.GOLD + Lang.get("createdBy") + " " + ChatColor.RED + "Blackvein"
|
||||
+ ChatColor.GOLD + " " + Lang.get("continuedBy") + " " + ChatColor.RED + "PikaMug & contributors");
|
||||
cs.sendMessage(ChatColor.DARK_AQUA + "" + ChatColor.UNDERLINE
|
||||
+ "https://github.com/PikaMug/Quests");
|
||||
cs.sendMessage(ChatColor.DARK_AQUA + "" + ChatColor.UNDERLINE + "https://github.com/PikaMug/Quests");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,15 +66,15 @@ public class QuestsQuitCommand extends QuestsSubCommand {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 1) {
|
||||
// Shows command usage
|
||||
return;
|
||||
}
|
||||
if (assertNonPlayer(cs)) {
|
||||
return;
|
||||
}
|
||||
final Player player = (Player) cs;
|
||||
if (player.hasPermission(getPermission())) {
|
||||
if (args.length == 1) {
|
||||
Lang.send(player, ChatColor.RED + Lang.get(player, "COMMAND_QUIT_HELP"));
|
||||
return;
|
||||
}
|
||||
final IQuester quester = plugin.getQuester(player.getUniqueId());
|
||||
if (!quester.getCurrentQuestsTemp().isEmpty()) {
|
||||
final IQuest quest = plugin.getQuestTemp(concatArgArray(args, 1, args.length - 1, ' '));
|
||||
|
@ -65,15 +65,16 @@ public class QuestsTakeCommand extends QuestsSubCommand {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 1) {
|
||||
// Shows command usage
|
||||
return;
|
||||
}
|
||||
if (assertNonPlayer(cs)) {
|
||||
return;
|
||||
}
|
||||
final Player player = (Player) cs;
|
||||
if (plugin.getSettings().canAllowCommands()) {
|
||||
if (player.hasPermission(getPermission())) {
|
||||
if (args.length == 1) {
|
||||
Lang.send(player, ChatColor.YELLOW + Lang.get(player, "COMMAND_TAKE_USAGE"));
|
||||
} else {
|
||||
final IQuest questToFind = plugin.getQuestTemp(concatArgArray(args, 1, args.length - 1, ' '));
|
||||
final IQuester quester = plugin.getQuester(player.getUniqueId());
|
||||
if (questToFind != null) {
|
||||
@ -87,7 +88,6 @@ public class QuestsTakeCommand extends QuestsSubCommand {
|
||||
} else {
|
||||
Lang.send(player, ChatColor.YELLOW + Lang.get(player, "questNotFound"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Lang.send(player, ChatColor.RED + Lang.get(player, "noPermission"));
|
||||
}
|
||||
|
@ -63,15 +63,12 @@ public class QuestsTopCommand extends QuestsSubCommand {
|
||||
|
||||
@Override
|
||||
public int getMaxArguments() {
|
||||
return 2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender cs, String[] args) {
|
||||
if (cs.hasPermission(getPermission())) {
|
||||
if (args.length > 2) {
|
||||
cs.sendMessage(ChatColor.YELLOW + Lang.get("COMMAND_TOP_USAGE"));
|
||||
} else {
|
||||
final int topNumber;
|
||||
if (args.length == 1) {
|
||||
topNumber = 5; // default
|
||||
@ -124,4 +121,3 @@ public class QuestsTopCommand extends QuestsSubCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ COMMAND_LIST: "list"
|
||||
COMMAND_LIST_HELP: "<command> [page] - List available quests"
|
||||
COMMAND_TAKE: "take"
|
||||
COMMAND_TAKE_HELP: "<command> [quest] - Accept a quest via command"
|
||||
COMMAND_TAKE_USAGE: "Usage: /quests take [quest]"
|
||||
COMMAND_QUIT: "quit"
|
||||
COMMAND_QUIT_HELP: "<command> [quest] - Quit a current quest"
|
||||
COMMAND_JOURNAL: "journal"
|
||||
@ -17,7 +16,6 @@ COMMAND_STATS: "stats"
|
||||
COMMAND_STATS_HELP: "<command> - View quest statistics"
|
||||
COMMAND_TOP: "top"
|
||||
COMMAND_TOP_HELP: "<command> [number] - View plugin leaderboards"
|
||||
COMMAND_TOP_USAGE: "Usage: /quests top [number]"
|
||||
COMMAND_INFO: "info"
|
||||
COMMAND_INFO_HELP: "<command> - View plugin information"
|
||||
COMMAND_QUEST_HELP: "- View current quest objectives"
|
||||
@ -43,7 +41,6 @@ COMMAND_QUESTADMIN_NEXTSTAGE: "nextstage"
|
||||
COMMAND_QUESTADMIN_NEXTSTAGE_HELP: "<command> [player] [quest] - Force a player to complete current stage"
|
||||
COMMAND_QUESTADMIN_SETSTAGE: "setstage"
|
||||
COMMAND_QUESTADMIN_SETSTAGE_HELP: "<command> [player] [quest] [stage] - Set the current stage for a player"
|
||||
COMMAND_QUESTADMIN_SETSTAGE_USAGE: 'Usage: /questadmin setstage [player] [quest] [stage]'
|
||||
COMMAND_QUESTADMIN_RESET: "reset"
|
||||
COMMAND_QUESTADMIN_RESET_HELP: "<command> [player] - Clear all questing data of a player"
|
||||
COMMAND_QUESTADMIN_REMOVE: "remove"
|
||||
|
Loading…
Reference in New Issue
Block a user