From b6aff8497fd6b542cd66c2ac1cf1a95999d892d3 Mon Sep 17 00:00:00 2001 From: kento2 Date: Thu, 16 Apr 2026 10:32:45 +0200 Subject: [PATCH] . --- core-bukkit-api/build.gradle.kts | 2 +- core-bukkit-impl/build.gradle.kts | 2 +- .../scrow/bukkit/economy/CoinsCommand.java | 58 +++++++------------ 3 files changed, 22 insertions(+), 40 deletions(-) diff --git a/core-bukkit-api/build.gradle.kts b/core-bukkit-api/build.gradle.kts index 24048c8..a604487 100644 --- a/core-bukkit-api/build.gradle.kts +++ b/core-bukkit-api/build.gradle.kts @@ -36,7 +36,7 @@ dependencies { api("org.spigotmc:spigot-api:1.21.11-R0.1-SNAPSHOT") api("net.kyori:adventure-platform-bukkit:4.4.1") - api("de.kentoj:kencommandapi-core:1.0.0") + api("de.kentoj:kencommandapi-core:1.2.0") } publishing { diff --git a/core-bukkit-impl/build.gradle.kts b/core-bukkit-impl/build.gradle.kts index 04e7941..fa19958 100644 --- a/core-bukkit-impl/build.gradle.kts +++ b/core-bukkit-impl/build.gradle.kts @@ -22,7 +22,7 @@ dependencies { implementation(project(":core-bukkit-api")) implementation("org.spigotmc:spigot-api:1.21.11-R0.1-SNAPSHOT") - implementation("de.kentoj:kencommandapi-bukkit:1.0.0") + implementation("de.kentoj:kencommandapi-bukkit:1.2.0") } tasks { diff --git a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/economy/CoinsCommand.java b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/economy/CoinsCommand.java index 130eb08..e253a5e 100644 --- a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/economy/CoinsCommand.java +++ b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/economy/CoinsCommand.java @@ -1,63 +1,45 @@ package de.kentoj.scrow.bukkit.economy; -import de.kentoj.kencommandapi.BukkitKenCommandApi; import de.kentoj.kencommandapi.api.processing.CommandContext; +import de.kentoj.kencommandapi.api.structure.argument.CommandArgument; import de.kentoj.kencommandapi.api.structure.argument.types.IntegerArgumentType; -import de.kentoj.kencommandapi.api.structure.node.CommandNode; +import de.kentoj.kencommandapi.type.OfflinePlayerArgumentType; import de.kentoj.scrow.bukkit.ScrowAPI; -import de.kentoj.scrow.bukkit.command.Commands; -import de.kentoj.scrow.bukkit.command.execution.CommandContext; -import de.kentoj.scrow.bukkit.command.literal.CommandArgument; -import de.kentoj.scrow.bukkit.command.literal.RootLiteral; -import de.kentoj.scrow.bukkit.command.type.NumberArgumentType; -import de.kentoj.scrow.bukkit.command.type.PlayerArgumentType; -import lombok.var; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; import reactor.core.scheduler.Schedulers; import java.util.logging.Level; public class CoinsCommand { - private final CommandArgument playerArg; - private final CommandArgument amountArg; + private final CommandArgument, OfflinePlayer> playerArg; + private final CommandArgument, Integer> amountArg; - public void create() { + public CoinsCommand() { var rootCommand = ScrowAPI.getCommandManager().createNode("coins"); + this.playerArg = ScrowAPI.getCommandManager().createArgument("player", OfflinePlayerArgumentType.getInstance()); + this.amountArg = ScrowAPI.getCommandManager().createArgument("amount", IntegerArgumentType.getInstance()); - var playerArg = ScrowAPI.getCommandManager().createArgument("player", ) - } - - /* - /coins steve - /coins steve set 0 - /coins steve get - */ - public CoinsCommand(BukkitKenCommandApi commandManager) { - playerArg = Commands.argument0("player", PlayerArgumentType.offlinePlayer(), CommandContext::getSenderPlayer); - - amountArg = Commands.argument0("amount", NumberArgumentType.integer(0, Integer.MAX_VALUE)); - - rootCommand = Commands.root("coins"); - rootCommand.addArgument(playerArg); - rootCommand.setExecutor(this::getCoins); { - final var setLiteral = Commands.literal("set"); - setLiteral.addArgument(amountArg); - setLiteral.setExecutor(this::setCoins); + var setLiteral = ScrowAPI.getCommandManager().createNode("set"); rootCommand.addLiteral(setLiteral); + setLiteral.addArgument(playerArg); + setLiteral.setExecutor(this::setCoins); } { - final var getLiteral = Commands.literal("get"); - getLiteral.setExecutor(this::getCoins); + var getLiteral = ScrowAPI.getCommandManager().createNode("get"); rootCommand.addLiteral(getLiteral); + getLiteral.addArgument(playerArg); + getLiteral.addArgument(amountArg); + getLiteral.setExecutor(this::getCoins); } } - private void getCoins(CommandContext ctx) { - final var player = ctx.getArg(playerArg); + private void getCoins(CommandContext ctx) { + var player = ctx.getArg(playerArg); ScrowAPI.getEconomyService() .getCoins(player.getUniqueId()) @@ -75,9 +57,9 @@ public class CoinsCommand { }); } - public void setCoins(CommandContext ctx) { - final var player = ctx.getArg(playerArg); - final int amount = ctx.getArg(amountArg); + public void setCoins(CommandContext ctx) { + var player = ctx.getArg(playerArg); + var amount = ctx.getArg(amountArg); ScrowAPI.getEconomyService() .setCoins(player.getUniqueId(), amount)