mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-01-10 10:17:41 +01:00
Fix some regression on command flag registering and completion
This commit is contained in:
parent
c71bdd83d6
commit
95a1fddbe5
@ -21,6 +21,7 @@ import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
|||||||
import com.onarandombox.MultiverseCore.config.MVCoreConfig;
|
import com.onarandombox.MultiverseCore.config.MVCoreConfig;
|
||||||
import com.onarandombox.MultiverseCore.destination.DestinationsProvider;
|
import com.onarandombox.MultiverseCore.destination.DestinationsProvider;
|
||||||
import com.onarandombox.MultiverseCore.destination.ParsedDestination;
|
import com.onarandombox.MultiverseCore.destination.ParsedDestination;
|
||||||
|
import io.vavr.control.Try;
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import org.bukkit.GameRule;
|
import org.bukkit.GameRule;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -95,8 +96,11 @@ public class MVCommandCompletions extends PaperCommandCompletions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Collection<String> suggestFlags(@NotNull BukkitCommandCompletionContext context) {
|
private Collection<String> suggestFlags(@NotNull BukkitCommandCompletionContext context) {
|
||||||
return this.commandManager.getFlagsManager().suggest(
|
String groupName = context.getConfig("groupName", "");
|
||||||
context.getConfig("groupName", ""), context.getContextValue(String[].class));
|
|
||||||
|
return Try.of(() -> context.getContextValue(String[].class))
|
||||||
|
.map(flags -> commandManager.getFlagsManager().suggest(groupName, flags))
|
||||||
|
.getOrElse(Collections.emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Collection<String> suggestGamerules() {
|
private Collection<String> suggestGamerules() {
|
||||||
|
@ -33,11 +33,12 @@ public abstract class MultiverseCommand extends BaseCommand {
|
|||||||
return commandManager.getFlagsManager();
|
return commandManager.getFlagsManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CommandFlag flag(CommandFlag flag) {
|
protected <T extends CommandFlag> T flag(T flag) {
|
||||||
if (flagGroupBuilder == null) {
|
if (flagGroupBuilder == null) {
|
||||||
flagGroupBuilder = CommandFlagGroup.builder("mv" + getClass().getSimpleName().toLowerCase());
|
flagGroupBuilder = CommandFlagGroup.builder("mv" + getClass().getSimpleName().toLowerCase());
|
||||||
}
|
}
|
||||||
flagGroupBuilder.add(flag);
|
flagGroupBuilder.add(flag);
|
||||||
|
Logging.finest("Registered flag: " + flag);
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,17 @@ public class CommandFlag {
|
|||||||
return aliases;
|
return aliases;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Builder{"
|
||||||
|
+ "key='" + key + '\''
|
||||||
|
+ ", aliases=" + aliases
|
||||||
|
+ '}';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A builder for a flag.
|
* A builder for a flag.
|
||||||
*
|
*
|
||||||
|
@ -191,7 +191,7 @@ public class CommandValueFlag<T> extends CommandFlag {
|
|||||||
* @return The flag.
|
* @return The flag.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public @NotNull CommandFlag build() {
|
public @NotNull CommandValueFlag<T> build() {
|
||||||
if (context == null && !String.class.equals(type)) {
|
if (context == null && !String.class.equals(type)) {
|
||||||
throw new IllegalStateException("Context is required for none-string value flags");
|
throw new IllegalStateException("Context is required for none-string value flags");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user