This commit is contained in:
kento2 2026-04-16 10:32:51 +02:00
parent dc5dd62b6e
commit bcce74a050
6 changed files with 18 additions and 9 deletions

View file

@ -9,7 +9,7 @@ plugins {
} }
group = "de.kentoj" group = "de.kentoj"
version = "1.0.0" version = "1.2.0"
fun scrowRepo(handler: RepositoryHandler) = handler.maven { fun scrowRepo(handler: RepositoryHandler) = handler.maven {
name = "scrow" name = "scrow"
@ -38,7 +38,7 @@ dependencies {
// https://mvnrepository.com/artifact/org.jetbrains/annotations // https://mvnrepository.com/artifact/org.jetbrains/annotations
implementation("org.jetbrains:annotations:26.0.2-1") implementation("org.jetbrains:annotations:26.0.2-1")
api("de.kentoj:kencommandapi-core:1.0.0") api("de.kentoj:kencommandapi-core:1.2.0")
api("org.spigotmc:spigot-api:1.21.11-R0.1-SNAPSHOT") api("org.spigotmc:spigot-api:1.21.11-R0.1-SNAPSHOT")
implementation("org.spigotmc:spigot-api:1.21.11-R0.1-SNAPSHOT") implementation("org.spigotmc:spigot-api:1.21.11-R0.1-SNAPSHOT")

View file

@ -12,7 +12,6 @@ import org.bukkit.OfflinePlayer;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
// TODO
@NoArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PRIVATE)
public class OfflinePlayerArgumentType implements ArgumentType<OfflinePlayer> { public class OfflinePlayerArgumentType implements ArgumentType<OfflinePlayer> {

View file

@ -8,7 +8,7 @@ plugins {
} }
group = "de.kentoj" group = "de.kentoj"
version = "1.0.0" version = "1.2.0"
repositories { repositories {
mavenCentral() mavenCentral()

View file

@ -28,7 +28,7 @@ public class Main {
ctx.getSender().println("adding " + amount + "$ to your balance"); ctx.getSender().println("adding " + amount + "$ to your balance");
}); });
addNode.addArgument(api.createArgument("amount", IntegerArgumentType.create())); addNode.addArgument(api.createArgument("amount", IntegerArgumentType.getInstance()));
root.addLiteral(addNode); root.addLiteral(addNode);
api.invoke(root, System.out, new String[]{"add", "100"}); api.invoke(root, System.out, new String[]{"add", "100"});
} }

View file

@ -1,5 +1,7 @@
package de.kentoj.kencommandapi.api.processing; package de.kentoj.kencommandapi.api.processing;
import de.kentoj.kencommandapi.api.structure.argument.CommandArgument;
public interface CommandContext<T> { public interface CommandContext<T> {
T getSender(); T getSender();
@ -14,4 +16,12 @@ public interface CommandContext<T> {
default <V> V getArg(String name) { default <V> V getArg(String name) {
return (V) getParsedArgument(name).getValue(); return (V) getParsedArgument(name).getValue();
} }
default <V> V getArg(CommandArgument<CommandContext<T>, V> arg) {
return getArg(arg.getId());
}
default <V> ParsedArgument<CommandContext<T>, V> getParsedArgument(CommandArgument<CommandContext<T>, V> arg) {
return getParsedArgument(arg.getId());
}
} }

View file

@ -4,11 +4,15 @@ import de.kentoj.kencommandapi.api.structure.argument.ArgumentType;
import de.kentoj.kencommandapi.api.structure.argument.SuggestionProvider; import de.kentoj.kencommandapi.api.structure.argument.SuggestionProvider;
import de.kentoj.kencommandapi.api.structure.argument.suggestion.NoSuggestionProvider; import de.kentoj.kencommandapi.api.structure.argument.suggestion.NoSuggestionProvider;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@NoArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PRIVATE)
public class IntegerArgumentType implements ArgumentType<Integer> { public class IntegerArgumentType implements ArgumentType<Integer> {
@Getter(lazy = true)
private static final IntegerArgumentType instance = new IntegerArgumentType();
@Override @Override
public Integer parseInput(String string) { public Integer parseInput(String string) {
return Integer.parseInt(string); return Integer.parseInt(string);
@ -18,8 +22,4 @@ public class IntegerArgumentType implements ArgumentType<Integer> {
public SuggestionProvider<?> defaultSuggestionProvider() { public SuggestionProvider<?> defaultSuggestionProvider() {
return NoSuggestionProvider.create(); return NoSuggestionProvider.create();
} }
public static IntegerArgumentType create() {
return new IntegerArgumentType();
}
} }