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("org.spigotmc:spigot-api:1.21.11-R0.1-SNAPSHOT")
api("net.kyori:adventure-platform-bukkit:4.4.1") 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 { publishing {

View file

@ -22,7 +22,7 @@ dependencies {
implementation(project(":core-bukkit-api")) implementation(project(":core-bukkit-api"))
implementation("org.spigotmc:spigot-api:1.21.11-R0.1-SNAPSHOT") 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 { tasks {

View file

@ -1,63 +1,45 @@
package de.kentoj.scrow.bukkit.economy; package de.kentoj.scrow.bukkit.economy;
import de.kentoj.kencommandapi.BukkitKenCommandApi;
import de.kentoj.kencommandapi.api.processing.CommandContext; 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.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.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.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import reactor.core.scheduler.Schedulers; import reactor.core.scheduler.Schedulers;
import java.util.logging.Level; import java.util.logging.Level;
public class CoinsCommand { public class CoinsCommand {
private final CommandArgument<OfflinePlayer> playerArg; private final CommandArgument<CommandContext<CommandSender>, OfflinePlayer> playerArg;
private final CommandArgument<Integer> amountArg; private final CommandArgument<CommandContext<CommandSender>, Integer> amountArg;
public void create() { public CoinsCommand() {
var rootCommand = ScrowAPI.getCommandManager().createNode("coins"); 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"); var setLiteral = ScrowAPI.getCommandManager().createNode("set");
setLiteral.addArgument(amountArg);
setLiteral.setExecutor(this::setCoins);
rootCommand.addLiteral(setLiteral); rootCommand.addLiteral(setLiteral);
setLiteral.addArgument(playerArg);
setLiteral.setExecutor(this::setCoins);
} }
{ {
final var getLiteral = Commands.literal("get"); var getLiteral = ScrowAPI.getCommandManager().createNode("get");
getLiteral.setExecutor(this::getCoins);
rootCommand.addLiteral(getLiteral); rootCommand.addLiteral(getLiteral);
getLiteral.addArgument(playerArg);
getLiteral.addArgument(amountArg);
getLiteral.setExecutor(this::getCoins);
} }
} }
private void getCoins(CommandContext ctx) { private void getCoins(CommandContext<CommandSender> ctx) {
final var player = ctx.getArg(playerArg); var player = ctx.getArg(playerArg);
ScrowAPI.getEconomyService() ScrowAPI.getEconomyService()
.getCoins(player.getUniqueId()) .getCoins(player.getUniqueId())
@ -75,9 +57,9 @@ public class CoinsCommand {
}); });
} }
public void setCoins(CommandContext ctx) { public void setCoins(CommandContext<CommandSender> ctx) {
final var player = ctx.getArg(playerArg); var player = ctx.getArg(playerArg);
final int amount = ctx.getArg(amountArg); var amount = ctx.getArg(amountArg);
ScrowAPI.getEconomyService() ScrowAPI.getEconomyService()
.setCoins(player.getUniqueId(), amount) .setCoins(player.getUniqueId(), amount)