From 767185ec32e5048f2c1db2b794ce214960aa2352 Mon Sep 17 00:00:00 2001 From: Josh Roy <10731363+JRoy@users.noreply.github.com> Date: Fri, 14 Oct 2022 20:32:47 -0400 Subject: [PATCH] Auto complete /mail clear indices (#5132) --- .../essentials/commands/Commandmail.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandmail.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandmail.java index 747f03629..59d8b2775 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandmail.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandmail.java @@ -298,9 +298,21 @@ public class Commandmail extends EssentialsCommand { if (pages == 0) { return Lists.newArrayList("0"); } else { - final List options = Lists.newArrayList("1"); - if (pages > 1) { - options.add(String.valueOf(pages)); + final List options = new ArrayList<>(); + for (int i = 0; i < pages; i++) { + options.add(String.valueOf(i + 1)); + } + return options; + } + } else if (args[0].equalsIgnoreCase("clear")) { + final ArrayList mail = user.getMailMessages(); + // We show up to 9 mails on a page, we don't need to autocomplete more than that... + if (mail.size() >= 9) { + return Lists.newArrayList("1", "2", "3", "4", "5", "6", "7", "8", "9"); + } else { + final List options = new ArrayList<>(); + for (int i = 0; i < mail.size(); i++) { + options.add(String.valueOf(i + 1)); } return options; }