.
This commit is contained in:
parent
dc5dd62b6e
commit
bcce74a050
6 changed files with 18 additions and 9 deletions
|
|
@ -9,7 +9,7 @@ plugins {
|
|||
}
|
||||
|
||||
group = "de.kentoj"
|
||||
version = "1.0.0"
|
||||
version = "1.2.0"
|
||||
|
||||
fun scrowRepo(handler: RepositoryHandler) = handler.maven {
|
||||
name = "scrow"
|
||||
|
|
@ -38,7 +38,7 @@ dependencies {
|
|||
// https://mvnrepository.com/artifact/org.jetbrains/annotations
|
||||
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")
|
||||
implementation("org.spigotmc:spigot-api:1.21.11-R0.1-SNAPSHOT")
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import org.bukkit.OfflinePlayer;
|
|||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
// TODO
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class OfflinePlayerArgumentType implements ArgumentType<OfflinePlayer> {
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ plugins {
|
|||
}
|
||||
|
||||
group = "de.kentoj"
|
||||
version = "1.0.0"
|
||||
version = "1.2.0"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class Main {
|
|||
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);
|
||||
api.invoke(root, System.out, new String[]{"add", "100"});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package de.kentoj.kencommandapi.api.processing;
|
||||
|
||||
import de.kentoj.kencommandapi.api.structure.argument.CommandArgument;
|
||||
|
||||
public interface CommandContext<T> {
|
||||
|
||||
T getSender();
|
||||
|
|
@ -14,4 +16,12 @@ public interface CommandContext<T> {
|
|||
default <V> V getArg(String name) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.suggestion.NoSuggestionProvider;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class IntegerArgumentType implements ArgumentType<Integer> {
|
||||
|
||||
@Getter(lazy = true)
|
||||
private static final IntegerArgumentType instance = new IntegerArgumentType();
|
||||
|
||||
@Override
|
||||
public Integer parseInput(String string) {
|
||||
return Integer.parseInt(string);
|
||||
|
|
@ -18,8 +22,4 @@ public class IntegerArgumentType implements ArgumentType<Integer> {
|
|||
public SuggestionProvider<?> defaultSuggestionProvider() {
|
||||
return NoSuggestionProvider.create();
|
||||
}
|
||||
|
||||
public static IntegerArgumentType create() {
|
||||
return new IntegerArgumentType();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue