mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-22 18:47:20 +01:00
Implement lowercased enum completion and fix some checkstyles
This commit is contained in:
parent
bbfc1a05e8
commit
6ba51fa573
@ -71,7 +71,7 @@ class CreateCommand extends MultiverseCommand {
|
|||||||
|
|
||||||
@Subcommand("create")
|
@Subcommand("create")
|
||||||
@CommandPermission("multiverse.core.create")
|
@CommandPermission("multiverse.core.create")
|
||||||
@CommandCompletion("@empty @flags:groupName=mvcreatecommand")
|
@CommandCompletion("@empty @environments @flags:groupName=mvcreatecommand")
|
||||||
@Syntax("<name> <environment> --seed [seed] --generator [generator[:id]] --world-type [worldtype] --adjust-spawn --no-structures")
|
@Syntax("<name> <environment> --seed [seed] --generator [generator[:id]] --world-type [worldtype] --adjust-spawn --no-structures")
|
||||||
@Description("{@@mv-core.create.description}")
|
@Description("{@@mv-core.create.description}")
|
||||||
void onCreateCommand(
|
void onCreateCommand(
|
||||||
|
@ -54,7 +54,7 @@ class ImportCommand extends MultiverseCommand {
|
|||||||
|
|
||||||
@Subcommand("import")
|
@Subcommand("import")
|
||||||
@CommandPermission("multiverse.core.import")
|
@CommandPermission("multiverse.core.import")
|
||||||
@CommandCompletion("@mvworlds:scope=potential @flags:groupName=mvimportcommand")
|
@CommandCompletion("@mvworlds:scope=potential @environments @flags:groupName=mvimportcommand")
|
||||||
@Syntax("<name> <env> --generator [generator[:id]] --adjust-spawn")
|
@Syntax("<name> <env> --generator [generator[:id]] --adjust-spawn")
|
||||||
@Description("{@@mv-core.import.description")
|
@Description("{@@mv-core.import.description")
|
||||||
void onImportCommand(
|
void onImportCommand(
|
||||||
|
@ -3,6 +3,7 @@ package org.mvplugins.multiverse.core.commandtools;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -18,7 +19,10 @@ import com.dumptruckman.minecraft.util.Logging;
|
|||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import io.vavr.control.Try;
|
import io.vavr.control.Try;
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
|
import org.bukkit.Difficulty;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.GameRule;
|
import org.bukkit.GameRule;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jvnet.hk2.annotations.Service;
|
import org.jvnet.hk2.annotations.Service;
|
||||||
|
|
||||||
@ -30,19 +34,18 @@ import org.mvplugins.multiverse.core.world.MultiverseWorld;
|
|||||||
import org.mvplugins.multiverse.core.world.WorldManager;
|
import org.mvplugins.multiverse.core.world.WorldManager;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class MVCommandCompletions extends PaperCommandCompletions {
|
class MVCommandCompletions extends PaperCommandCompletions {
|
||||||
|
|
||||||
protected final MVCommandManager commandManager;
|
private final MVCommandManager commandManager;
|
||||||
private final WorldManager worldManager;
|
private final WorldManager worldManager;
|
||||||
private final DestinationsProvider destinationsProvider;
|
private final DestinationsProvider destinationsProvider;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public MVCommandCompletions(
|
MVCommandCompletions(
|
||||||
@NotNull MVCommandManager mvCommandManager,
|
@NotNull MVCommandManager mvCommandManager,
|
||||||
@NotNull WorldManager worldManager,
|
@NotNull WorldManager worldManager,
|
||||||
@NotNull DestinationsProvider destinationsProvider,
|
@NotNull DestinationsProvider destinationsProvider,
|
||||||
@NotNull MVCoreConfig config
|
@NotNull MVCoreConfig config) {
|
||||||
) {
|
|
||||||
super(mvCommandManager);
|
super(mvCommandManager);
|
||||||
this.commandManager = mvCommandManager;
|
this.commandManager = mvCommandManager;
|
||||||
this.worldManager = worldManager;
|
this.worldManager = worldManager;
|
||||||
@ -50,13 +53,19 @@ public class MVCommandCompletions extends PaperCommandCompletions {
|
|||||||
|
|
||||||
registerAsyncCompletion("commands", this::suggestCommands);
|
registerAsyncCompletion("commands", this::suggestCommands);
|
||||||
registerAsyncCompletion("destinations", this::suggestDestinations);
|
registerAsyncCompletion("destinations", this::suggestDestinations);
|
||||||
|
registerStaticCompletion("difficulties", suggestEnums(Difficulty.class));
|
||||||
|
registerStaticCompletion("environments", suggestEnums(World.Environment.class));
|
||||||
registerAsyncCompletion("flags", this::suggestFlags);
|
registerAsyncCompletion("flags", this::suggestFlags);
|
||||||
|
registerStaticCompletion("gamemodes", suggestEnums(GameMode.class));
|
||||||
registerStaticCompletion("gamerules", this::suggestGamerules);
|
registerStaticCompletion("gamerules", this::suggestGamerules);
|
||||||
registerStaticCompletion("mvconfigs", config.getNodes().getNames());
|
registerStaticCompletion("mvconfigs", config.getNodes().getNames());
|
||||||
registerAsyncCompletion("mvworlds", this::suggestMVWorlds);
|
registerAsyncCompletion("mvworlds", this::suggestMVWorlds);
|
||||||
|
|
||||||
setDefaultCompletion("destinations", ParsedDestination.class);
|
setDefaultCompletion("destinations", ParsedDestination.class);
|
||||||
|
setDefaultCompletion("difficulties", Difficulty.class);
|
||||||
|
setDefaultCompletion("environments", World.Environment.class);
|
||||||
setDefaultCompletion("flags", String[].class);
|
setDefaultCompletion("flags", String[].class);
|
||||||
|
setDefaultCompletion("gamemodes", GameMode.class);
|
||||||
setDefaultCompletion("gamerules", GameRule.class);
|
setDefaultCompletion("gamerules", GameRule.class);
|
||||||
setDefaultCompletion("mvworlds", LoadedMultiverseWorld.class);
|
setDefaultCompletion("mvworlds", LoadedMultiverseWorld.class);
|
||||||
}
|
}
|
||||||
@ -152,4 +161,11 @@ public class MVCommandCompletions extends PaperCommandCompletions {
|
|||||||
Logging.severe("Invalid MVWorld scope: " + scope);
|
Logging.severe("Invalid MVWorld scope: " + scope);
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private <T extends Enum<T>> Collection<String> suggestEnums(Class<T> enumClass) {
|
||||||
|
return EnumSet.allOf(enumClass).stream()
|
||||||
|
.map(Enum::name)
|
||||||
|
.map(String::toLowerCase)
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user