This commit is contained in:
kento2 2026-04-16 10:32:45 +02:00
parent 3345595146
commit b6aff8497f
3 changed files with 22 additions and 40 deletions

View file

@ -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 {

View file

@ -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 {

View file

@ -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<OfflinePlayer> playerArg;
private final CommandArgument<Integer> amountArg;
private final CommandArgument<CommandContext<CommandSender>, OfflinePlayer> playerArg;
private final CommandArgument<CommandContext<CommandSender>, 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<CommandSender> 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<CommandSender> ctx) {
var player = ctx.getArg(playerArg);
var amount = ctx.getArg(amountArg);
ScrowAPI.getEconomyService()
.setCoins(player.getUniqueId(), amount)