first commit
This commit is contained in:
parent
72da8e063b
commit
76784dba7e
20 changed files with 588 additions and 0 deletions
|
|
@ -0,0 +1,27 @@
|
|||
package de.kencommand.impl.structure.argument;
|
||||
|
||||
import de.kencommand.api.processing.CommandContext;
|
||||
import de.kencommand.api.structure.argument.ArgumentType;
|
||||
import de.kencommand.api.structure.argument.CommandArgument;
|
||||
import de.kencommand.api.structure.argument.SuggestionProvider;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class CommandArgumentImpl<T, S extends CommandContext<T>, V> implements CommandArgument<T, S, V> {
|
||||
|
||||
@Getter
|
||||
private final String id;
|
||||
@Getter
|
||||
private final ArgumentType<V> type;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private @Nullable T defaultValue;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private @Nullable SuggestionProvider<T, S> suggestionProvider;
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package de.kencommand.impl.structure.node;
|
||||
|
||||
import de.kencommand.api.processing.CommandContext;
|
||||
import de.kencommand.api.structure.node.CommandNode;
|
||||
import de.kencommand.api.structure.node.LiteralNode;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class LiteralNodeImpl<T, S extends CommandContext<T>> implements LiteralNode<T, S> {
|
||||
|
||||
@Getter
|
||||
private final Set<CommandNode<? extends T, ? extends S>> literals = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public void addLiteral(@NotNull CommandNode<? extends T, ? extends S> commandNode) {
|
||||
for (String name : commandNode.getNames()) {
|
||||
if (getLiteral(name) != null) throw new IllegalArgumentException("literal with same name is already added");
|
||||
}
|
||||
literals.add(commandNode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandNode<? extends T, ? extends S> getLiteral(@NotNull String name) {
|
||||
for (var literal : literals) {
|
||||
for (String literalName : literal.getNames()) {
|
||||
if (literalName.equalsIgnoreCase(name)) return literal;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue