This commit is contained in:
kento2 2026-06-03 01:30:08 +02:00
parent e85228e717
commit 0cda14e3cc
34 changed files with 316 additions and 333 deletions

View file

@ -3,7 +3,6 @@ plugins {
id("java")
id("com.gradleup.shadow") version "9.2.0"
id("xyz.jpenilla.run-paper") version "2.3.1"
kotlin("jvm")
}
group = "de.kentoj.scrow"
@ -14,21 +13,16 @@ repositories {
}
dependencies {
testImplementation(platform("org.junit:junit-bom:5.10.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
implementation(kotlin("stdlib-jdk8"))
implementation(project(":core-bukkit-api"))
implementation("org.spigotmc:spigot-api:1.21.11-R0.1-SNAPSHOT")
implementation("de.kentoj.scrow:kencommandapi-bukkit:0.4")
implementation(project(":core-lib"))
implementation(kotlin("stdlib-jdk8"))
//implementation("org.spigotmc:spigot-api:1.21.11-R0.1-SNAPSHOT")
//implementation("de.kentoj.scrow:kencommandapi-bukkit:0.8")
}
tasks {
runServer {
minecraftVersion("1.21.11")
downloadPlugins {
url("https://hangarcdn.papermc.io/plugins/ViaVersion/ViaVersion/versions/5.7.1/PAPER/ViaVersion-5.7.1.jar")
@ -40,10 +34,3 @@ tasks {
tasks.build {
dependsOn("shadowJar")
}
tasks.test {
useJUnitPlatform()
}
kotlin {
jvmToolchain(21)
}

View file

@ -17,11 +17,11 @@ public class CoreImplPlugin extends JavaPlugin {
ScrowAPISurface.initScrowAPI(this, ENABLE_DATABASE);
{
ScrowAPI.getCommandManager().register(new FriendCommand().getRootNode());
ScrowAPI.getCommandManager().register(new CoinsCommand().getRootNode());
ScrowAPI.getCommandManager().register(new CrownCommand().getRootNode());
ScrowAPI.getCommandManager().register(new PlayCommand().getRootNode());
ScrowAPI.getCommandManager().register(new LobbyCommand().getRootNode());
ScrowAPI.getCommandApi().register(new FriendCommand().getRootNode());
ScrowAPI.getCommandApi().register(new CoinsCommand().getRootNode());
ScrowAPI.getCommandApi().register(new CrownCommand().getRootNode());
ScrowAPI.getCommandApi().register(new PlayCommand().getRootNode());
ScrowAPI.getCommandApi().register(new LobbyCommand().getRootNode());
}
registerServer();

View file

@ -26,7 +26,7 @@ import reactor.core.scheduler.Schedulers;
import java.io.IOException;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@NoArgsConstructor(access = AccessLevel.NONE)
public class ScrowAPISurface {
private static @Nullable MongoClient mongoClient;
@ -75,7 +75,7 @@ public class ScrowAPISurface {
ScrowAPI.setFriendshipService(ScrowAPI.getDatabase() != null ?
new MongoFriendshipService(ScrowAPI.getDatabase()) : new InMemoryFriendshipService());
ScrowAPI.setCommandManager(new BukkitKenCommandApi());
ScrowAPI.setCommandApi(new BukkitKenCommandApi());
}
public static void destroyScrowAPI() {

View file

@ -1,7 +1,7 @@
package de.kentoj.scrow.bukkit.crown;
import de.kentoj.kencommandapi.BukkitCommandContext;
import de.kentoj.kencommandapi.api.structure.node.CommandNode;
import de.kentoj.kencommandapi.api.nodes.CommandNode;
import de.kentoj.scrow.bukkit.ScrowAPI;
import lombok.Getter;
import org.bukkit.command.CommandSender;
@ -12,9 +12,9 @@ public class CrownCommand {
private final CommandNode<CommandSender, BukkitCommandContext> rootNode;
public CrownCommand() {
this.rootNode = ScrowAPI.getCommandManager().createNode("crown", "server-manager");
this.rootNode.addLiteral(new CrownListServersLiteral().getNode());
this.rootNode.addLiteral(new CrownDeployServerLiteral().getNode());
this.rootNode.addLiteral(new CrownDestroyServerLiteral().getNode());
this.rootNode = ScrowAPI.getCommandApi().createNode("crown", "server-manager");
this.rootNode.addLiteral(new CrownListServersLiteral().getRootNode());
this.rootNode.addLiteral(new CrownDeployServerLiteral().getRootNode());
this.rootNode.addLiteral(new CrownDestroyServerLiteral().getRootNode());
}
}

View file

@ -1,10 +1,10 @@
package de.kentoj.scrow.bukkit.crown;
import de.kentoj.kencommandapi.BukkitCommandContext;
import de.kentoj.kencommandapi.api.argument.CommandArgument;
import de.kentoj.kencommandapi.api.nodes.CommandNode;
import de.kentoj.kencommandapi.api.processing.CommandExecutor;
import de.kentoj.kencommandapi.api.structure.argument.CommandArgument;
import de.kentoj.kencommandapi.api.structure.argument.types.StringArgumentType;
import de.kentoj.kencommandapi.api.structure.node.CommandNode;
import de.kentoj.kencommandapi.api.types.StringArgumentType;
import de.kentoj.scrow.bukkit.ScrowAPI;
import lombok.Getter;
import org.bukkit.command.CommandSender;
@ -12,15 +12,15 @@ import org.bukkit.command.CommandSender;
public class CrownDeployServerLiteral implements CommandExecutor<CommandSender, BukkitCommandContext> {
@Getter
private final CommandNode<CommandSender, BukkitCommandContext> node;
private final CommandNode<CommandSender, BukkitCommandContext> rootNode;
private final CommandArgument<CommandSender, BukkitCommandContext, String> templateArg;
public CrownDeployServerLiteral() {
this.node = ScrowAPI.getCommandManager().createNode("deploy-server");
this.node.setExecutor(this);
this.rootNode = ScrowAPI.getCommandApi().createNode("deploy-server");
this.rootNode.setExecutor(this);
{
this.templateArg = ScrowAPI.getCommandManager().createArgument("template", new StringArgumentType<>());
this.node.addArgument(templateArg);
this.templateArg = ScrowAPI.getCommandApi().createArgument("template", new StringArgumentType<>());
this.rootNode.addArgument(templateArg);
}
}

View file

@ -1,10 +1,10 @@
package de.kentoj.scrow.bukkit.crown;
import de.kentoj.kencommandapi.BukkitCommandContext;
import de.kentoj.kencommandapi.api.argument.CommandArgument;
import de.kentoj.kencommandapi.api.nodes.CommandNode;
import de.kentoj.kencommandapi.api.processing.CommandExecutor;
import de.kentoj.kencommandapi.api.structure.argument.CommandArgument;
import de.kentoj.kencommandapi.api.structure.argument.types.StringArgumentType;
import de.kentoj.kencommandapi.api.structure.node.CommandNode;
import de.kentoj.kencommandapi.api.types.StringArgumentType;
import de.kentoj.scrow.bukkit.ScrowAPI;
import de.kentoj.scrowlib.servermanager.ServerInstance;
import lombok.Getter;
@ -15,14 +15,14 @@ import java.util.stream.Collectors;
public class CrownDestroyServerLiteral implements CommandExecutor<CommandSender, BukkitCommandContext> {
@Getter
private final CommandNode<CommandSender, BukkitCommandContext> node;
private final CommandNode<CommandSender, BukkitCommandContext> rootNode;
private final CommandArgument<CommandSender, BukkitCommandContext, String> handleArg;
public CrownDestroyServerLiteral() {
this.node = ScrowAPI.getCommandManager().createNode("destroy-server");
this.node.setExecutor(this);
this.rootNode = ScrowAPI.getCommandApi().createNode("destroy-server");
this.rootNode.setExecutor(this);
{
this.handleArg = ScrowAPI.getCommandManager().createArgument("template", new StringArgumentType<>());
this.handleArg = ScrowAPI.getCommandApi().createArgument("template", new StringArgumentType<>());
this.handleArg.setSuggestionProvider(ctx -> {
//noinspection CodeBlock2Expr
return ScrowAPI.getServerManager().getRunningServers()
@ -30,7 +30,7 @@ public class CrownDestroyServerLiteral implements CommandExecutor<CommandSender,
.collect(Collectors.toSet())
.toFuture();
});
this.node.addArgument(handleArg);
this.rootNode.addArgument(handleArg);
}
}

View file

@ -1,8 +1,8 @@
package de.kentoj.scrow.bukkit.crown;
import de.kentoj.kencommandapi.BukkitCommandContext;
import de.kentoj.kencommandapi.api.nodes.CommandNode;
import de.kentoj.kencommandapi.api.processing.CommandExecutor;
import de.kentoj.kencommandapi.api.structure.node.CommandNode;
import de.kentoj.scrow.bukkit.ScrowAPI;
import lombok.Getter;
import org.bukkit.command.CommandSender;
@ -10,11 +10,11 @@ import org.bukkit.command.CommandSender;
public class CrownListServersLiteral implements CommandExecutor<CommandSender, BukkitCommandContext> {
@Getter
private final CommandNode<CommandSender, BukkitCommandContext> node;
private final CommandNode<CommandSender, BukkitCommandContext> rootNode;
public CrownListServersLiteral() {
this.node = ScrowAPI.getCommandManager().createNode("list-servers");
this.node.setExecutor(this);
this.rootNode = ScrowAPI.getCommandApi().createNode("list-servers");
this.rootNode.setExecutor(this);
}
@Override

View file

@ -1,10 +1,9 @@
package de.kentoj.scrow.bukkit.economy;
import de.kentoj.kencommandapi.BukkitCommandContext;
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.api.argument.CommandArgument;
import de.kentoj.kencommandapi.api.nodes.CommandNode;
import de.kentoj.kencommandapi.api.types.IntegerArgumentType;
import de.kentoj.kencommandapi.type.OfflinePlayerArgumentType;
import de.kentoj.scrow.bukkit.ScrowAPI;
import lombok.Getter;
@ -23,19 +22,19 @@ public class CoinsCommand {
private final CommandArgument<CommandSender, BukkitCommandContext, Integer> amountArg;
public CoinsCommand() {
this.rootNode = ScrowAPI.getCommandManager().createNode("coins", "eco");
this.playerArg = ScrowAPI.getCommandManager().createArgument("player", OfflinePlayerArgumentType.getInstance());
this.amountArg = ScrowAPI.getCommandManager().createArgument("amount", new IntegerArgumentType<>());
this.rootNode = ScrowAPI.getCommandApi().createNode("coins", "eco");
this.playerArg = ScrowAPI.getCommandApi().createArgument("player", OfflinePlayerArgumentType.getInstance());
this.amountArg = ScrowAPI.getCommandApi().createArgument("amount", new IntegerArgumentType<>());
{
var setLiteral = ScrowAPI.getCommandManager().createNode("set");
var setLiteral = ScrowAPI.getCommandApi().createNode("set");
rootNode.addLiteral(setLiteral);
setLiteral.addArgument(playerArg);
setLiteral.addArgument(amountArg);
setLiteral.setExecutor(this::setCoins);
}
{
var getLiteral = ScrowAPI.getCommandManager().createNode("get");
var getLiteral = ScrowAPI.getCommandApi().createNode("get");
rootNode.addLiteral(getLiteral);
getLiteral.addArgument(playerArg);
getLiteral.setExecutor(this::getCoins);

View file

@ -1,27 +1,34 @@
package de.kentoj.scrow.bukkit.friends.command;
import de.kentoj.kencommandapi.BukkitCommandContext;
import de.kentoj.kencommandapi.api.structure.node.CommandNode;
import de.kentoj.kencommandapi.api.argument.CommandArgument;
import de.kentoj.kencommandapi.api.nodes.CommandNode;
import de.kentoj.kencommandapi.api.processing.CommandExecutor;
import de.kentoj.kencommandapi.type.OfflinePlayerArgumentType;
import de.kentoj.scrow.bukkit.ScrowAPI;
import de.kentoj.scrow.bukkit.friends.handler.FriendAddHandler;
import lombok.Getter;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
public class FriendAddLiteral {
public class FriendAddLiteral implements CommandExecutor<CommandSender, BukkitCommandContext> {
@Getter
private final CommandNode<CommandSender, BukkitCommandContext> node;
private final CommandNode<CommandSender, BukkitCommandContext> rootNode;
private final CommandArgument<CommandSender, BukkitCommandContext, OfflinePlayer> playerArg;
public FriendAddLiteral() {
var cmdManager = ScrowAPI.getCommandManager();
var playerArg = cmdManager.createArgument("player", OfflinePlayerArgumentType.getInstance());
var cmds = ScrowAPI.getCommandApi();
this.node = cmdManager.createNode("add");
this.node.addArgument(playerArg);
this.node.setExecutor(ctx -> {
var handler = new FriendAddHandler(ctx.getPlayerSender(), ctx.getArg(playerArg));
handler.handle();
});
this.playerArg = cmds.createArgument("player", OfflinePlayerArgumentType.getInstance());
this.rootNode = cmds.createNode("add");
this.rootNode.addArgument(playerArg);
this.rootNode.setExecutor(this);
}
@Override
public void execute(BukkitCommandContext ctx) {
var handler = new FriendAddHandler(ctx.getPlayerSender(), ctx.getArg(playerArg));
handler.handle();
}
}

View file

@ -1,7 +1,7 @@
package de.kentoj.scrow.bukkit.friends.command;
import de.kentoj.kencommandapi.BukkitCommandContext;
import de.kentoj.kencommandapi.api.structure.node.CommandNode;
import de.kentoj.kencommandapi.api.nodes.CommandNode;
import de.kentoj.scrow.bukkit.ScrowAPI;
import lombok.Getter;
import org.bukkit.command.CommandSender;
@ -12,10 +12,10 @@ public class FriendCommand {
private final CommandNode<CommandSender, BukkitCommandContext> rootNode;
public FriendCommand() {
this.rootNode = ScrowAPI.getCommandManager().createNode("friends", "f", "friend");
rootNode.addLiteral(new FriendListLiteral().getNode());
rootNode.addLiteral(new FriendAddLiteral().getNode());
rootNode.addLiteral(new FriendRemoveLiteral().getNode());
rootNode.addLiteral(new FriendRequestsLiteral().getNode());
this.rootNode = ScrowAPI.getCommandApi().createNode("friends", "f", "friend");
rootNode.addLiteral(new FriendListLiteral().getRootNode());
rootNode.addLiteral(new FriendAddLiteral().getRootNode());
rootNode.addLiteral(new FriendRemoveLiteral().getRootNode());
rootNode.addLiteral(new FriendRequestsLiteral().getRootNode());
}
}

View file

@ -1,23 +1,21 @@
package de.kentoj.scrow.bukkit.friends.command;
import de.kentoj.kencommandapi.BukkitCommandContext;
import de.kentoj.kencommandapi.api.structure.node.CommandNode;
import de.kentoj.kencommandapi.api.nodes.CommandNode;
import de.kentoj.scrow.bukkit.ScrowAPI;
import de.kentoj.scrow.bukkit.friends.FriendshipService;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import reactor.core.scheduler.Schedulers;
public class FriendListLiteral {
@Getter
private final CommandNode<CommandSender, BukkitCommandContext> node;
private final CommandNode<CommandSender, BukkitCommandContext> rootNode;
public FriendListLiteral() {
this.node = ScrowAPI.getCommandManager().createNode("list");
node.setExecutor(this::friendList);
this.rootNode = ScrowAPI.getCommandApi().createNode("list");
rootNode.setExecutor(this::friendList);
}
private void friendList(BukkitCommandContext ctx) {

View file

@ -1,26 +1,25 @@
package de.kentoj.scrow.bukkit.friends.command;
import de.kentoj.kencommandapi.BukkitCommandContext;
import de.kentoj.kencommandapi.api.structure.argument.CommandArgument;
import de.kentoj.kencommandapi.api.structure.node.CommandNode;
import de.kentoj.kencommandapi.api.argument.CommandArgument;
import de.kentoj.kencommandapi.api.nodes.CommandNode;
import de.kentoj.kencommandapi.type.OfflinePlayerArgumentType;
import de.kentoj.scrow.bukkit.ScrowAPI;
import lombok.Getter;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import reactor.core.publisher.Mono;
public class FriendRemoveLiteral {
@Getter
private final CommandNode<CommandSender, BukkitCommandContext> node;
private final CommandNode<CommandSender, BukkitCommandContext> rootNode;
private final CommandArgument<CommandSender, BukkitCommandContext, OfflinePlayer> playerArg;
public FriendRemoveLiteral() {
this.node = ScrowAPI.getCommandManager().createNode("remove");
this.playerArg = ScrowAPI.getCommandManager().createArgument("player", OfflinePlayerArgumentType.getInstance());
this.node.addArgument(playerArg);
this.node.setExecutor(this::removeFriend);
this.playerArg = ScrowAPI.getCommandApi().createArgument("player", OfflinePlayerArgumentType.getInstance());
this.rootNode = ScrowAPI.getCommandApi().createNode("remove");
this.rootNode.addArgument(playerArg);
this.rootNode.setExecutor(this::removeFriend);
}
private void removeFriend(BukkitCommandContext ctx) {

View file

@ -1,7 +1,7 @@
package de.kentoj.scrow.bukkit.friends.command;
import de.kentoj.kencommandapi.BukkitCommandContext;
import de.kentoj.kencommandapi.api.structure.node.CommandNode;
import de.kentoj.kencommandapi.api.nodes.CommandNode;
import de.kentoj.scrow.bukkit.ScrowAPI;
import lombok.Getter;
import org.bukkit.Bukkit;
@ -10,11 +10,11 @@ import org.bukkit.command.CommandSender;
public class FriendRequestsLiteral {
@Getter
private final CommandNode<CommandSender, BukkitCommandContext> node;
private final CommandNode<CommandSender, BukkitCommandContext> rootNode;
public FriendRequestsLiteral() {
this.node = ScrowAPI.getCommandManager().createNode("requests", "list-requests");
node.setExecutor(this::friendRequestsList);
this.rootNode = ScrowAPI.getCommandApi().createNode("requests", "list-requests");
rootNode.setExecutor(this::friendRequestsList);
}
private void friendRequestsList(BukkitCommandContext ctx) {

View file

@ -22,7 +22,7 @@ public class FriendAddHandler {
findAction()
.flatMap(this::executeAction)
.doOnError(CommandException.class, e -> {
ScrowAPI.getCommandManager().sendErrorMessage(self, e);
ScrowAPI.getCommandApi().sendErrorMessage(self, e);
})
.onErrorComplete(CommandException.class)
.subscribe();

View file

@ -1,8 +1,8 @@
package de.kentoj.scrow.bukkit.server;
import de.kentoj.kencommandapi.BukkitCommandContext;
import de.kentoj.kencommandapi.api.nodes.CommandNode;
import de.kentoj.kencommandapi.api.processing.CommandExecutor;
import de.kentoj.kencommandapi.api.structure.node.CommandNode;
import de.kentoj.scrow.bukkit.ScrowAPI;
import lombok.Getter;
import org.bukkit.Bukkit;
@ -14,7 +14,7 @@ public class LobbyCommand implements CommandExecutor<CommandSender, BukkitComman
private final CommandNode<CommandSender, BukkitCommandContext> rootNode;
public LobbyCommand() {
var cmds = ScrowAPI.getCommandManager();
var cmds = ScrowAPI.getCommandApi();
this.rootNode = cmds.createNode("lobby", "l", "hub");
this.rootNode.setExecutor(this);
}

View file

@ -1,10 +1,10 @@
package de.kentoj.scrow.bukkit.server;
import de.kentoj.kencommandapi.BukkitCommandContext;
import de.kentoj.kencommandapi.api.argument.CommandArgument;
import de.kentoj.kencommandapi.api.nodes.CommandNode;
import de.kentoj.kencommandapi.api.processing.CommandExecutor;
import de.kentoj.kencommandapi.api.structure.argument.CommandArgument;
import de.kentoj.kencommandapi.api.structure.argument.types.StringArgumentType;
import de.kentoj.kencommandapi.api.structure.node.CommandNode;
import de.kentoj.kencommandapi.api.types.StringArgumentType;
import de.kentoj.scrow.bukkit.ScrowAPI;
import de.kentoj.scrowlib.servermanager.ServerInstance;
import lombok.Getter;
@ -18,8 +18,8 @@ public class PlayCommand implements CommandExecutor<CommandSender, BukkitCommand
private final CommandArgument<CommandSender, BukkitCommandContext, String> gamemodeArg;
public PlayCommand() {
this.rootNode = ScrowAPI.getCommandManager().createNode("play", "queue");
this.gamemodeArg = ScrowAPI.getCommandManager().createArgument("gamemode", new StringArgumentType<>());
this.rootNode = ScrowAPI.getCommandApi().createNode("play", "queue");
this.gamemodeArg = ScrowAPI.getCommandApi().createArgument("gamemode", new StringArgumentType<>());
this.rootNode.addArgument(this.gamemodeArg);
this.rootNode.setExecutor(this);
}