This commit is contained in:
kento2 2026-06-03 01:30:22 +02:00
parent b091eb3377
commit 6449d95b66
5 changed files with 11 additions and 11 deletions

View file

@ -4,6 +4,7 @@ import de.kentoj.kencommandapi.api.argument.ArgumentType;
import de.kentoj.kencommandapi.api.argument.SuggestionProvider;
import de.kentoj.kencommandapi.api.argument.suggestion.NoSuggestionProvider;
import de.kentoj.kencommandapi.api.processing.CommandContext;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
@ -11,6 +12,10 @@ public class StringArgumentType<T, S extends CommandContext<T, ?>> implements Ar
private final boolean isGreedy;
public StringArgumentType() {
this(false);
}
@Override
public String parseInput(String string) {
return string;

View file

@ -1,12 +1,12 @@
package de.kentoj.kencommandapi.impl;
import de.kentoj.kencommandapi.api.KenCommandApi;
import de.kentoj.kencommandapi.api.processing.CommandContext;
import de.kentoj.kencommandapi.api.processing.CommandException;
import de.kentoj.kencommandapi.api.processing.ParsedArgument;
import de.kentoj.kencommandapi.api.argument.ArgumentType;
import de.kentoj.kencommandapi.api.argument.CommandArgument;
import de.kentoj.kencommandapi.api.nodes.CommandNode;
import de.kentoj.kencommandapi.api.processing.CommandContext;
import de.kentoj.kencommandapi.api.processing.CommandException;
import de.kentoj.kencommandapi.api.processing.ParsedArgument;
import de.kentoj.kencommandapi.impl.processing.ParsedArgumentImpl;
import de.kentoj.kencommandapi.impl.structure.CommandArgumentImpl;
import de.kentoj.kencommandapi.impl.structure.CommandNodeImpl;
@ -16,7 +16,6 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.stream.Collectors;
@RequiredArgsConstructor
public abstract class AbstractKenCommandApi<T, S extends CommandContext<T, ?>> implements KenCommandApi<T, S> {

View file

@ -62,7 +62,7 @@ public class CommandNodeImpl<T, S extends CommandContext<T, ?>> implements Comma
if (arguments.stream()
.anyMatch(arg -> arg.getId().equals(argument.getId()))
) throw new IllegalArgumentException("argument with same identifier is already added");
if (arguments.getLast().getType().isGreedy())
if (!arguments.isEmpty() && arguments.getLast().getType().isGreedy())
throw new IllegalStateException("can't append argument to a node, whose last argument type is greedy: "
+ arguments.getLast().getType().getClass().getCanonicalName());