Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class GameruleCommand extends CoreCommand {

@Subcommand("set")
@CommandPermission("multiverse.core.gamerule.set")
@CommandCompletion("@gamerules true|false|@range:1-10 @mvworlds:multiple|*")
@CommandCompletion("@gamerules @gamerulesvalues @mvworlds:multiple|*")
@Syntax("<Gamerule> <Gamerule value> [World or *]")
@Description("{@@mv-core.gamerule.set.description}")
void onGameruleSetCommand(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.jvnet.hk2.annotations.Service;

import org.mvplugins.multiverse.core.config.MVCoreConfig;
import org.mvplugins.multiverse.core.configuration.functions.DefaultSuggesterProvider;
import org.mvplugins.multiverse.core.configuration.handle.PropertyModifyAction;
import org.mvplugins.multiverse.core.destination.DestinationInstance;
import org.mvplugins.multiverse.core.destination.DestinationsProvider;
Expand Down Expand Up @@ -61,6 +62,7 @@
registerAsyncCompletion("flags", this::suggestFlags);
registerStaticCompletion("gamemodes", suggestEnums(GameMode.class));
registerStaticCompletion("gamerules", this::suggestGamerules);
registerAsyncCompletion("gamerulesvalues", this::suggestGamerulesValues);
registerStaticCompletion("mvconfigs", config.getStringPropertyHandle().getAllPropertyNames());
registerAsyncCompletion("mvconfigvalues", this::suggestMVConfigValues);
registerAsyncCompletion("mvworlds", this::suggestMVWorlds);
Expand Down Expand Up @@ -139,6 +141,13 @@
return Arrays.stream(GameRule.values()).map(GameRule::getName).collect(Collectors.toList());
}

private Collection<String> suggestGamerulesValues(BukkitCommandCompletionContext context) {
return Try.of(() -> context.getContextValue(GameRule.class))

Check warning on line 145 in src/main/java/org/mvplugins/multiverse/core/commandtools/MVCommandCompletions.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 'method def' child has incorrect indentation level 7, expected level should be 8. Raw Output: /github/workspace/./src/main/java/org/mvplugins/multiverse/core/commandtools/MVCommandCompletions.java:145:8: warning: 'method def' child has incorrect indentation level 7, expected level should be 8. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
// Just use our suggester from configuration lib since gamerules are only boolean or int
.mapTry(gamerule -> DefaultSuggesterProvider.getDefaultSuggester(gamerule.getType()).suggest(context.getInput()))

Check warning on line 147 in src/main/java/org/mvplugins/multiverse/core/commandtools/MVCommandCompletions.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 Line is longer than 120 characters (found 128). Raw Output: /github/workspace/./src/main/java/org/mvplugins/multiverse/core/commandtools/MVCommandCompletions.java:147:0: warning: Line is longer than 120 characters (found 128). (com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck)
.getOrElse(Collections.emptyList());
}

private Collection<String> suggestMVConfigValues(BukkitCommandCompletionContext context) {
return Try.of(() -> context.getContextValue(String.class))
.map(propertyName -> config.getStringPropertyHandle()
Expand Down