Skip to content

Commit 83aaf8c

Browse files
authored
Fix /exp command usages & tab complete (#6607)
1 parent 966bc99 commit 83aaf8c

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

‎Essentials/src/main/java/com/earth2me/essentials/commands/Commandexp.java‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,21 @@ protected List<String> getTabCompleteOptions(final Server server, final User use
147147
}
148148
return options;
149149
} else if (args.length == 2) {
150-
if ((args[0].equalsIgnoreCase("set") && user.isAuthorized("essentials.exp.set")) || (args[0].equalsIgnoreCase("give") && user.isAuthorized("essentials.exp.give")) || (args[0].equalsIgnoreCase("take") && user.isAuthorized("essentials.exp.take"))) {
150+
final ExpCommands cmd;
151+
try {
152+
cmd = ExpCommands.valueOf(args[0].toUpperCase(Locale.ENGLISH));
153+
} catch (final IllegalArgumentException e) {
154+
return Collections.emptyList();
155+
}
156+
if (cmd.hasOtherPermission(user)) {
157+
return getPlayers(user);
158+
}
159+
if (cmd.hasPermission(user) && cmd != ExpCommands.SHOW && cmd != ExpCommands.RESET) {
151160
final String levellessArg = args[1].toLowerCase(Locale.ENGLISH).replaceAll("l", "");
152161
if (NumberUtil.isInt(levellessArg)) {
153162
return Lists.newArrayList(levellessArg + "l");
154163
}
155164
}
156-
if (user.isAuthorized("essentials.exp.others")) {
157-
return getPlayers(user);
158-
}
159165
} else if (args.length == 3 && !(args[0].equalsIgnoreCase("show") || args[0].equalsIgnoreCase("reset"))) {
160166
final String levellessArg = args[2].toLowerCase(Locale.ENGLISH).replaceAll("l", "");
161167
if (NumberUtil.isInt(levellessArg)) {

‎Essentials/src/main/resources/messages.properties‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,9 @@ expCommandUsage1Description=Gives the target player the specified amount of xp
375375
expCommandUsage2=/<command> set <playername> <amount>
376376
expCommandUsage2Description=Sets the target player's xp the specified amount
377377
expCommandUsage3=/<command> show <playername>
378-
expCommandUsage4Description=Displays the amount of xp the target player has
379-
expCommandUsage5=/<command> reset <playername>
380-
expCommandUsage5Description=Resets the target player's xp to 0
378+
expCommandUsage3Description=Displays the amount of xp the target player has
379+
expCommandUsage4=/<command> reset <playername>
380+
expCommandUsage4Description=Resets the target player's xp to 0
381381
expSet=<secondary>{0} <primary>now has<secondary> {1} <primary>exp.
382382
extCommandDescription=Extinguish players.
383383
extCommandUsage=/<command> [player]

0 commit comments

Comments
 (0)