Skip to content

Commit da354fb

Browse files
authored
Auto complete /mail clear indices (EssentialsX#5132)
1 parent 4cc2cf0 commit da354fb

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

Essentials/src/main/java/com/earth2me/essentials/commands/Commandmail.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,21 @@ protected List<String> getTabCompleteOptions(final Server server, final User use
298298
if (pages == 0) {
299299
return Lists.newArrayList("0");
300300
} else {
301-
final List<String> options = Lists.newArrayList("1");
302-
if (pages > 1) {
303-
options.add(String.valueOf(pages));
301+
final List<String> options = new ArrayList<>();
302+
for (int i = 0; i < pages; i++) {
303+
options.add(String.valueOf(i + 1));
304+
}
305+
return options;
306+
}
307+
} else if (args[0].equalsIgnoreCase("clear")) {
308+
final ArrayList<MailMessage> mail = user.getMailMessages();
309+
// We show up to 9 mails on a page, we don't need to autocomplete more than that...
310+
if (mail.size() >= 9) {
311+
return Lists.newArrayList("1", "2", "3", "4", "5", "6", "7", "8", "9");
312+
} else {
313+
final List<String> options = new ArrayList<>();
314+
for (int i = 0; i < mail.size(); i++) {
315+
options.add(String.valueOf(i + 1));
304316
}
305317
return options;
306318
}

0 commit comments

Comments
 (0)