From d936a9246ac9d422133235212ab872e1beeb51a7 Mon Sep 17 00:00:00 2001 From: kento2 Date: Wed, 15 Apr 2026 22:01:49 +0200 Subject: [PATCH] need to implement some argument types --- kencommandapi-bukkit/build.gradle.kts | 40 +++++++++++-------- .../type/PlayerArgumentType.java | 28 +++++++++++++ kencommandapi-core/build.gradle.kts | 2 +- 3 files changed, 52 insertions(+), 18 deletions(-) create mode 100644 kencommandapi-bukkit/src/main/java/de/kentoj/kencommandapi/type/PlayerArgumentType.java diff --git a/kencommandapi-bukkit/build.gradle.kts b/kencommandapi-bukkit/build.gradle.kts index 59ba338..722ada8 100644 --- a/kencommandapi-bukkit/build.gradle.kts +++ b/kencommandapi-bukkit/build.gradle.kts @@ -3,25 +3,44 @@ val scrowToken = providers.gradleProperty("scrowMavenToken") plugins { id("java") + id("java-library") id("maven-publish") id("io.freefair.lombok") version "9.2.0" } group = "de.kentoj" -version = "unspecified" +version = "1.0.0" + +fun scrowRepo(handler: RepositoryHandler) = handler.maven { + name = "scrow" + url = uri("http://forge.kentoj.de/api/packages/scrow/maven") + isAllowInsecureProtocol = true + + credentials(HttpHeaderCredentials::class) { + name = "Authorization" + value = "token $scrowToken" + } + + authentication { + create("header") + } +} repositories { mavenCentral() maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") { name = "spigotmc-repo" } + scrowRepo(this) } dependencies { - // https://mvnrepository.com/artifact/org.jetbrains/annotations +// https://mvnrepository.com/artifact/org.jetbrains/annotations implementation("org.jetbrains:annotations:26.0.2-1") - implementation(project(":kencommandapi-core")) + api("de.kentoj:kencommandapi-core:1.0.0") + + api("org.spigotmc:spigot-api:1.21.11-R0.1-SNAPSHOT") implementation("org.spigotmc:spigot-api:1.21.11-R0.1-SNAPSHOT") } @@ -35,19 +54,6 @@ publishing { } } repositories { - maven { - name = "scrow" - url = uri("http://forge.kentoj.de/api/packages/scrow/maven") - isAllowInsecureProtocol = true - - credentials(HttpHeaderCredentials::class) { - name = "Authorization" - value = "token $scrowToken" - } - - authentication { - create("header") - } - } + scrowRepo(this) } } diff --git a/kencommandapi-bukkit/src/main/java/de/kentoj/kencommandapi/type/PlayerArgumentType.java b/kencommandapi-bukkit/src/main/java/de/kentoj/kencommandapi/type/PlayerArgumentType.java new file mode 100644 index 0000000..68b5879 --- /dev/null +++ b/kencommandapi-bukkit/src/main/java/de/kentoj/kencommandapi/type/PlayerArgumentType.java @@ -0,0 +1,28 @@ +package de.kentoj.kencommandapi.type; + +import de.kentoj.kencommandapi.api.processing.CommandContext; +import de.kentoj.kencommandapi.api.structure.argument.ArgumentType; +import de.kentoj.kencommandapi.api.structure.argument.SuggestionProvider; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import java.util.Set; + +// TODO +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class PlayerArgumentType implements ArgumentType { + + @Override + public Player parseInput(String string) { + var player = Bukkit.getPlayer(string); + if (player == null) throw new RuntimeException("Player not online -- " + string); + return player; + } + + @Override + public SuggestionProvider defaultSuggestionProvider() { + return (SuggestionProvider) context -> Set.of(); + } +} diff --git a/kencommandapi-core/build.gradle.kts b/kencommandapi-core/build.gradle.kts index 2dc5d16..d267ea6 100644 --- a/kencommandapi-core/build.gradle.kts +++ b/kencommandapi-core/build.gradle.kts @@ -8,7 +8,7 @@ plugins { } group = "de.kentoj" -version = "1.0-SNAPSHOT" +version = "1.0.0" repositories { mavenCentral()