Skip to content

Commit

Permalink
Fix possible null issue with gamerule completion
Browse files Browse the repository at this point in the history
  • Loading branch information
benwoo1110 committed Feb 28, 2025
1 parent 54ebdcb commit f46449f
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

import co.aikar.commands.BukkitCommandCompletionContext;
Expand All @@ -16,6 +15,7 @@
import co.aikar.commands.RegisteredCommand;
import co.aikar.commands.RootCommand;
import com.dumptruckman.minecraft.util.Logging;
import io.vavr.control.Option;
import io.vavr.control.Try;
import jakarta.inject.Inject;
import org.apache.commons.lang.Validate;
Expand Down Expand Up @@ -215,7 +215,8 @@ private Collection<String> suggestGamerules() {
private Collection<String> suggestGamerulesValues(BukkitCommandCompletionContext context) {
return Try.of(() -> context.getContextValue(GameRule.class))
// Just use our suggester from configuration lib since gamerules are only boolean or int
.mapTry(gamerule -> DefaultSuggesterProvider.getDefaultSuggester(gamerule.getType()).suggest(context.getInput()))
.mapTry(gamerule -> Option.of(DefaultSuggesterProvider.getDefaultSuggester(gamerule.getType()))
.map(s -> s.suggest(context.getInput())).getOrElse(Collections.emptyList()))
.getOrElse(Collections.emptyList());
}

Expand Down

0 comments on commit f46449f

Please sign in to comment.