mirror of https://github.com/GeyserMC/Geyser.git
2.0 command arguments
This commit is contained in:
parent
dc1826c5f9
commit
f2a3feac05
|
@ -316,6 +316,7 @@ public class CommandRegistry {
|
|||
E e = (E) exception;
|
||||
// if cloud has a registered exception handler for this type, use it, otherwise use this handler.
|
||||
// we register all the exception handlers to cloud, so it will likely just be cloud invoking this same handler.
|
||||
cloud.exceptionController().handleException(,exception);
|
||||
cloud.handleException(source, type, e, handler);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,9 @@ import java.nio.charset.StandardCharsets;
|
|||
import java.util.Random;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import static org.incendo.cloud.parser.standard.IntegerParser.integerParser;
|
||||
import static org.incendo.cloud.parser.standard.StringParser.stringParser;
|
||||
|
||||
public class ConnectionTestCommand extends GeyserCommand {
|
||||
|
||||
/*
|
||||
|
@ -63,11 +66,8 @@ public class ConnectionTestCommand extends GeyserCommand {
|
|||
@Override
|
||||
public void register(CommandManager<GeyserCommandSource> manager) {
|
||||
manager.command(baseBuilder(manager)
|
||||
.argument(StringArgument.of(ADDRESS))
|
||||
.argument(IntegerArgument.<GeyserCommandSource>builder(PORT)
|
||||
.withMax(65535).withMin(0)
|
||||
.asOptional()
|
||||
.build())
|
||||
.required(ADDRESS, stringParser())
|
||||
.optional(PORT, integerParser(0, 65535))
|
||||
.handler(this::execute));
|
||||
}
|
||||
|
||||
|
|
|
@ -37,13 +37,14 @@ import org.geysermc.geyser.command.GeyserCommand;
|
|||
import org.geysermc.geyser.command.GeyserCommandSource;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.incendo.cloud.CommandManager;
|
||||
import org.incendo.cloud.annotation.specifier.Greedy;
|
||||
import org.incendo.cloud.context.CommandContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.incendo.cloud.parser.standard.StringParser.greedyStringParser;
|
||||
|
||||
public abstract class GeyserExtensionCommand extends GeyserCommand {
|
||||
|
||||
private final Extension extension;
|
||||
|
@ -190,7 +191,7 @@ public abstract class GeyserExtensionCommand extends GeyserCommand {
|
|||
// todo: if we don't find a way to expose cloud in the api, we should implement a way
|
||||
// to not have the [args] if its not necessary for this command. and maybe tab completion.
|
||||
manager.command(baseBuilder(manager)
|
||||
.argument(StringArgument.optional("args", StringArgument.StringMode.GREEDY))
|
||||
.optional("args", greedyStringParser())
|
||||
.handler(this::execute));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue