use of gg.projecteden.nexus.framework.commands.models.annotations.TabCompleterFor in project Nexus by ProjectEdenGG.
the class HoursCommand method tabCompleteHoursTopArgument.
@TabCompleterFor(HoursTopArguments.class)
List<String> tabCompleteHoursTopArgument(String filter) {
if (filter.contains(" "))
return new ArrayList<>();
Set<String> completions = new HashSet<>();
LocalDate now = LocalDate.now();
LocalDate start = LocalDate.of(2020, 6, 1);
while (!start.isAfter(now)) {
completions.add(String.valueOf(start.getYear()));
completions.add(start.getYear() + "-" + String.format("%02d", start.getMonthValue()));
completions.add(start.getYear() + "-" + String.format("%02d", start.getMonthValue()) + "-" + String.format("%02d", start.getDayOfMonth()));
start = start.plusDays(1);
}
completions.add("daily");
completions.add("monthly");
completions.add("yearly");
completions.remove("2020");
return completions.stream().filter(completion -> completion.toLowerCase().startsWith(filter)).collect(Collectors.toList());
}
use of gg.projecteden.nexus.framework.commands.models.annotations.TabCompleterFor in project Nexus by ProjectEdenGG.
the class VoteCommand method tabCompleteYearMonth.
@TabCompleterFor(YearMonth.class)
List<String> tabCompleteYearMonth(String filter) {
List<String> completions = new ArrayList<>();
if (filter.matches("\\d{4}-.*")) {
final String[] split = filter.split("-");
for (int i = 1; i <= 12; i++) completions.add(split[0] + "-" + String.format("%02d", i));
} else {
Year year = Year.of(ServerAge.getEPOCH().getYear());
final Year stop = Year.now().plusYears(2);
while (year.isBefore(stop)) {
completions.add(String.valueOf(year.getValue()));
year = year.plusYears(1);
}
}
completions.removeIf(completion -> !completion.toLowerCase().startsWith(filter.toLowerCase()));
return completions;
}
Aggregations