Search in sources :

Example 1 with TabCompleterFor

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());
}
Also used : JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) BiFunction(java.util.function.BiFunction) Async(gg.projecteden.annotations.Async) Arg(gg.projecteden.nexus.framework.commands.models.annotations.Arg) ConverterFor(gg.projecteden.nexus.framework.commands.models.annotations.ConverterFor) Player(org.bukkit.entity.Player) AFK(gg.projecteden.nexus.features.afk.AFK) ArrayList(java.util.ArrayList) Hours(gg.projecteden.nexus.models.hours.Hours) HashSet(java.util.HashSet) PlayerUtils(gg.projecteden.nexus.utils.PlayerUtils) Nickname(gg.projecteden.nexus.models.nickname.Nickname) TimespanBuilder(gg.projecteden.utils.TimeUtils.Timespan.TimespanBuilder) Timespan(gg.projecteden.utils.TimeUtils.Timespan) Nexus(gg.projecteden.nexus.Nexus) Description(gg.projecteden.nexus.framework.commands.models.annotations.Description) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Nerd(gg.projecteden.nexus.models.nerd.Nerd) Rank(gg.projecteden.nexus.models.nerd.Rank) Koda(gg.projecteden.nexus.features.chat.Koda) CustomCommand(gg.projecteden.nexus.framework.commands.models.CustomCommand) Tasks(gg.projecteden.nexus.utils.Tasks) Set(java.util.Set) GroupChange(gg.projecteden.nexus.utils.LuckPermsUtils.GroupChange) Collectors(java.util.stream.Collectors) Aliases(gg.projecteden.nexus.framework.commands.models.annotations.Aliases) TickTime(gg.projecteden.utils.TimeUtils.TickTime) Switch(gg.projecteden.nexus.framework.commands.models.annotations.Switch) HoursTopArguments(gg.projecteden.nexus.models.hours.HoursService.HoursTopArguments) List(java.util.List) Jingle(gg.projecteden.nexus.utils.SoundUtils.Jingle) CommandEvent(gg.projecteden.nexus.framework.commands.models.events.CommandEvent) LocalDate(java.time.LocalDate) HoursService(gg.projecteden.nexus.models.hours.HoursService) TabCompleterFor(gg.projecteden.nexus.framework.commands.models.annotations.TabCompleterFor) OnlinePlayers(gg.projecteden.nexus.utils.PlayerUtils.OnlinePlayers) PageResult(gg.projecteden.nexus.models.hours.HoursService.PageResult) LocalDate(java.time.LocalDate) HashSet(java.util.HashSet) TabCompleterFor(gg.projecteden.nexus.framework.commands.models.annotations.TabCompleterFor)

Example 2 with TabCompleterFor

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;
}
Also used : Year(java.time.Year) ArrayList(java.util.ArrayList) TabCompleterFor(gg.projecteden.nexus.framework.commands.models.annotations.TabCompleterFor)

Aggregations

TabCompleterFor (gg.projecteden.nexus.framework.commands.models.annotations.TabCompleterFor)2 ArrayList (java.util.ArrayList)2 Async (gg.projecteden.annotations.Async)1 Nexus (gg.projecteden.nexus.Nexus)1 AFK (gg.projecteden.nexus.features.afk.AFK)1 Koda (gg.projecteden.nexus.features.chat.Koda)1 CustomCommand (gg.projecteden.nexus.framework.commands.models.CustomCommand)1 Aliases (gg.projecteden.nexus.framework.commands.models.annotations.Aliases)1 Arg (gg.projecteden.nexus.framework.commands.models.annotations.Arg)1 ConverterFor (gg.projecteden.nexus.framework.commands.models.annotations.ConverterFor)1 Description (gg.projecteden.nexus.framework.commands.models.annotations.Description)1 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)1 Switch (gg.projecteden.nexus.framework.commands.models.annotations.Switch)1 CommandEvent (gg.projecteden.nexus.framework.commands.models.events.CommandEvent)1 Hours (gg.projecteden.nexus.models.hours.Hours)1 HoursService (gg.projecteden.nexus.models.hours.HoursService)1 HoursTopArguments (gg.projecteden.nexus.models.hours.HoursService.HoursTopArguments)1 PageResult (gg.projecteden.nexus.models.hours.HoursService.PageResult)1 Nerd (gg.projecteden.nexus.models.nerd.Nerd)1 Rank (gg.projecteden.nexus.models.nerd.Rank)1