diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 0000000..e5211ad --- /dev/null +++ b/.bazelrc @@ -0,0 +1,5 @@ +build --java_language_version=25 +build --java_runtime_version=25 +build --tool_java_language_version=25 +build --tool_java_runtime_version=25 +build --define=maven_repo=https://repo.lab0x13.site/snapshots \ No newline at end of file diff --git a/.gitignore b/.gitignore index bdabe5b..d47fcbf 100644 --- a/.gitignore +++ b/.gitignore @@ -43,4 +43,11 @@ bin/ .vscode/ ### Mac OS ### -.DS_Store \ No newline at end of file +.DS_Store + +/.bazelbsp +/bazel-bin +/bazel-core +/bazel-out +/bazel-testlogs +/MODULE.bazel.lock \ No newline at end of file diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000..49ac758 --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,46 @@ +bazel_dep(name = "rules_java", version = "9.7.0") +bazel_dep(name = "rules_jvm_external", version = "7.1") +bazel_dep(name = "bazel_jar_jar", version = "0.1.15") + +git_override( + module_name = "rules_jvm_external", + remote = "http://forge.kentoj.de/scrow/rules_jvm_external.git", +) + +maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") +maven.install( + name = "maven", + artifacts = [ + "com.leakyabstractions:result:1.0.2.0", + "com.leakyabstractions:result-api:1.0.1.0", + "org.jetbrains:annotations:26.0.2-1", + "com.google.guava:guava:33.5.0-jre", + "org.projectlombok:lombok:1.18.46", + "org.slf4j:slf4j-api:2.0.18", + "org.slf4j:slf4j-simple:2.0.18", + "net.kyori:adventure-api:5.2.0", + "net.kyori:adventure-text-minimessage:5.2.0", + "io.papermc.paper:paper-api:[26.2.build,)", + "com.velocitypowered:velocity-api:4.1.0-20260802.091736-8", + "org.jdbi:jdbi3-core:3.53.0", + "org.jdbi:jdbi3-postgres:3.53.0", + "org.mongodb:bson:5.8.0", + "io.nats:jnats:2.25.2", + "de.kentoj.scrow:kencommandapi-core:0.34-SNAPSHOT", + "de.kentoj.scrow:kencommandapi-bukkit:0.34-SNAPSHOT", + "de.kentoj.scrow:kencommandapi-velocity:0.34-SNAPSHOT", + "io.papermc.paper:paper-api:[26.2.build,)", + "net.luckperms:api:5.5", + ], + repositories = [ + "https://repo.papermc.io/repository/maven-public/", + "https://repo.lab0x13.site/snapshots", + ], + known_contributing_modules = ["protobuf"], + fail_on_missing_checksum = False, # for kencommandapi +) + +# luckperms is provided at runtime +maven.amend_artifact(coordinates = "net.luckperms:api", neverlink = "true") + +use_repo(maven, "maven") \ No newline at end of file diff --git a/README.md b/README.md index 7a02d17..fed2ff1 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,30 @@ -TODO -- make core-lib-impl: a library -> avoid shading massive core-lib +# TODO + +## BUILD +- turn structure into +```text +//core-bukkit:api +//core-bukkit:plugin +//core-velocity:api +//core-velocity:plugin +//core-lib +``` +- MAKE THIS A MONOREPO +- make sure it doesn't break when using postgres/nats (i only tested with dummies) +- lwk make sure velocity plugin works at runtime +- runServer target: + - start papermc server + - start PostgreSQL server + - maybe also have some map loaded +- refactor BUILD files: MODULES.bazel +- debate use of third_party; deduplicate + +## bukkit - notification: Friend is now offline/online - /ignore command +# Project + modules ------- @@ -10,4 +32,14 @@ modules - **core-bukkit-api** stateful api, for minecraft development, depends on core-lib - **core-bukkit-api** stateful plugin, same as core-bukkit-api but implements it - **core-velocity-api** stateful api, for proxy development, depends on core-lib -- **core-velocity-impl** stateful plugin, same as core-velocity-api but implements it \ No newline at end of file +- **core-velocity-impl** stateful plugin, same as core-velocity-api but implements it + +Building +-------- + +compile the bukkit-impl plugin: +```shell +bazel build //core-bukkit-impl:bukkit-impl_deploy.jar +``` +This produces `bazel-bin/core-bukkit-impl/bukkit-impl.jar` with all dependencies built-in except for +LuckPerms. \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts deleted file mode 100644 index be94b45..0000000 --- a/build.gradle.kts +++ /dev/null @@ -1,10 +0,0 @@ -group = "de.kentoj.scrow" -version = "1.0.0-SNAPSHOT" - -subprojects { - version = rootProject.version - - configurations.configureEach { - resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS) - } -} \ No newline at end of file diff --git a/core-bukkit-api/BUILD b/core-bukkit-api/BUILD new file mode 100644 index 0000000..83af843 --- /dev/null +++ b/core-bukkit-api/BUILD @@ -0,0 +1,20 @@ +load("@rules_jvm_external//:defs.bzl", "artifact") +load("@rules_java//java:java_library.bzl", "java_library") + +java_library( + name = "core-bukkit-api", + srcs = glob(["src/main/**/*.java"]), + visibility = ["//visibility:public"], + deps = [ + "//core-lib:core", + artifact("io.papermc.paper:paper-api"), + artifact("org.projectlombok:lombok"), + artifact("de.kentoj.scrow:kencommandapi-bukkit"), + ], + exports = [ + "//core-lib:core", + artifact("de.kentoj.scrow:kencommandapi-bukkit"), + artifact("org.mongodb:bson"), + ], + plugins = [ "//third_party:lombok_plugin" ], +) \ No newline at end of file diff --git a/core-bukkit-api/build.gradle.kts b/core-bukkit-api/build.gradle.kts deleted file mode 100644 index 60f8761..0000000 --- a/core-bukkit-api/build.gradle.kts +++ /dev/null @@ -1,30 +0,0 @@ -plugins { - id("java") - alias(libs.plugins.scrow.publish) - alias(libs.plugins.scrow.database) - alias(libs.plugins.scrow.basedependencies) - alias(libs.plugins.scrow.javalibrary) -} - -group = "de.kentoj.scrow" - -dependencies { - api(project(":core-lib")) - compileOnly(libs.papermc.api) - - api(libs.nats) - api(libs.scrow.commandapi.bukkit) { - isChanging = true - } -} - -publishing { - publications { - create("ScrowBukkitApi") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - from(components["java"]) - } - } -} \ No newline at end of file diff --git a/core-bukkit-api/src/main/java/de/kentoj/scrow/bukkit/ScrowAPI.java b/core-bukkit-api/src/main/java/de/kentoj/scrow/bukkit/ScrowAPI.java index 34eb5a9..005f9fc 100644 --- a/core-bukkit-api/src/main/java/de/kentoj/scrow/bukkit/ScrowAPI.java +++ b/core-bukkit-api/src/main/java/de/kentoj/scrow/bukkit/ScrowAPI.java @@ -15,6 +15,8 @@ import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; import org.bukkit.OfflinePlayer; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import org.jdbi.v3.core.Jdbi; import org.jetbrains.annotations.ApiStatus; @@ -45,7 +47,9 @@ public class ScrowAPI { @Getter private static RegionManager regionManager; @Getter - private static CommandAPI commandApi; + private static CommandAPI playerCommands; + @Getter + private static CommandAPI commands; @Getter private static PlayerPrefixProvider playerPrefixProvider; @Getter @@ -100,11 +104,6 @@ public class ScrowAPI { ScrowAPI.regionManager = regionManager; } - @ApiStatus.Internal - public static void setCommandApi(CommandAPI commandApi) { - ScrowAPI.commandApi = commandApi; - } - @ApiStatus.Internal public static void setPlayerFactory(NetworkPlayerFactory playerFactory) { ScrowAPI.playerFactory = playerFactory; @@ -114,5 +113,15 @@ public class ScrowAPI { public static void setPlayerPrefixProvider(PlayerPrefixProvider playerPrefixProvider) { ScrowAPI.playerPrefixProvider = playerPrefixProvider; } + + @ApiStatus.Internal + public static void setPlayerCommands(CommandAPI playerCommands) { + ScrowAPI.playerCommands = playerCommands; + } + + @ApiStatus.Internal + public static void setCommands(CommandAPI commands) { + ScrowAPI.commands = commands; + } } diff --git a/core-bukkit-api/src/main/java/de/kentoj/scrow/bukkit/minigame/phase/Phase.java b/core-bukkit-api/src/main/java/de/kentoj/scrow/bukkit/minigame/phase/Phase.java index 9ad19eb..62f0741 100644 --- a/core-bukkit-api/src/main/java/de/kentoj/scrow/bukkit/minigame/phase/Phase.java +++ b/core-bukkit-api/src/main/java/de/kentoj/scrow/bukkit/minigame/phase/Phase.java @@ -1,6 +1,5 @@ package de.kentoj.scrow.bukkit.minigame.phase; -import com.google.errorprone.annotations.ForOverride; import de.kentoj.scrow.bukkit.ScrowAPI; import de.kentoj.scrow.bukkit.minigame.Minigame; import de.kentoj.scrow.bukkit.minigame.phaseflow.PhaseContext; @@ -25,11 +24,9 @@ public abstract class Phase implements IPhase { */ protected abstract void onCancel(); - @ForOverride protected void onEnd() { } - @ForOverride protected void onTick(int tick) { } diff --git a/core-bukkit-api/src/main/java/de/kentoj/scrow/bukkit/minigame/phaseflow/LinearPhaseFlow.java b/core-bukkit-api/src/main/java/de/kentoj/scrow/bukkit/minigame/phaseflow/LinearPhaseFlow.java index 9a6b2ac..2a380ed 100644 --- a/core-bukkit-api/src/main/java/de/kentoj/scrow/bukkit/minigame/phaseflow/LinearPhaseFlow.java +++ b/core-bukkit-api/src/main/java/de/kentoj/scrow/bukkit/minigame/phaseflow/LinearPhaseFlow.java @@ -6,7 +6,7 @@ import de.kentoj.scrow.bukkit.minigame.phase.PhaseFlow; import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.jspecify.annotations.Nullable; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.List; diff --git a/core-bukkit-impl/BUILD b/core-bukkit-impl/BUILD new file mode 100644 index 0000000..19b8396 --- /dev/null +++ b/core-bukkit-impl/BUILD @@ -0,0 +1,17 @@ +load("@rules_java//java:java_binary.bzl", "java_binary") +load("@rules_jvm_external//:defs.bzl", "artifact") + +java_binary( + name = "core-bukkit-plugin", + srcs = glob(["src/main/**/*.java"]), + main_class = "none", + resources = glob(["src/main/resources/**"], allow_empty = True), + deps = [ + "//core-bukkit-api:core-bukkit-api", + artifact("net.luckperms:api"), + artifact("io.papermc.paper:paper-api"), + artifact("io.nats:jnats"), + artifact("net.kyori:adventure-key:5.2.0"), + ], + plugins = [ "//third_party:lombok_plugin" ], +) \ No newline at end of file diff --git a/core-bukkit-impl/build.gradle.kts b/core-bukkit-impl/build.gradle.kts deleted file mode 100644 index ad76397..0000000 --- a/core-bukkit-impl/build.gradle.kts +++ /dev/null @@ -1,38 +0,0 @@ -plugins { - id("java") - alias(libs.plugins.scrow.publish) - alias(libs.plugins.scrow.runserver) - alias(libs.plugins.shadow) - alias(libs.plugins.scrow.basedependencies) - alias(libs.plugins.scrow.database) -} - -group = "de.kentoj.scrow" - -dependencies { - implementation(project(":core-bukkit-api")) - compileOnly(libs.papermc.api) - - implementation(libs.bson) - implementation(libs.nats) - implementation(libs.scrow.commandapi.bukkit) { - isChanging = true - } - implementation(libs.postgres) - compileOnly(libs.luckperms) -} - -tasks.processResources { - filesMatching("plugin.yml") { - expand( - mapOf("version" to project.version.toString()) - ) - } -} - -tasks.build { - dependsOn("shadowJar") -} -tasks.shadowJar { - archiveClassifier = "" -} \ No newline at end of file diff --git a/core-bukkit-impl/run/eula.txt b/core-bukkit-impl/run/eula.txt deleted file mode 100644 index 2ceee4f..0000000 --- a/core-bukkit-impl/run/eula.txt +++ /dev/null @@ -1,3 +0,0 @@ -#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA). -#Mon Jul 06 16:35:59 CEST 2026 -eula=true \ No newline at end of file diff --git a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/CoreImplPlugin.java b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/CoreImplPlugin.java index f5a0226..c588009 100644 --- a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/CoreImplPlugin.java +++ b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/CoreImplPlugin.java @@ -26,12 +26,12 @@ public final class CoreImplPlugin extends JavaPlugin { var cachedPrefixProvider = new CachedPrefixProvider(); ScrowAPISurface.initScrowAPI(this, cachedPrefixProvider); - ScrowAPI.getCommandApi().register(new CoinsCommand().getRootLiteral()); - ScrowAPI.getCommandApi().register(FriendCommand.create()); + ScrowAPI.getPlayerCommands().register(new CoinsCommand().getRootLiteral()); + ScrowAPI.getPlayerCommands().register(FriendCommand.create()); var instanceCache = new InstanceCache(); - ScrowAPI.getCommandApi().register(InstanceCommand.create(instanceCache)); - ScrowAPI.getCommandApi().register(new PlayCommand().getRootLiteral()); - ScrowAPI.getCommandApi().register(new LobbyCommand().getRootLiteral()); + ScrowAPI.getCommands().register(InstanceCommand.create(instanceCache)); + ScrowAPI.getPlayerCommands().register(new PlayCommand().getRootLiteral()); + ScrowAPI.getPlayerCommands().register(new LobbyCommand().getRootLiteral()); var luckperms = LuckPermsProvider.get(); new LuckPermsPrefixSetter(luckperms, cachedPrefixProvider).init(this); diff --git a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/ScrowAPISurface.java b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/ScrowAPISurface.java index 24199ba..923b7bb 100644 --- a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/ScrowAPISurface.java +++ b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/ScrowAPISurface.java @@ -22,6 +22,8 @@ import io.nats.client.Options; import lombok.AccessLevel; import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import org.jdbi.v3.core.Jdbi; @@ -67,7 +69,8 @@ public class ScrowAPISurface { ScrowAPI.setPlayerFactory(playerId -> new NetworkPlayerImpl(ScrowAPI.getMessageBroker(), playerId)); ScrowAPI.setRegionManager(new RegionManagerImpl()); - ScrowAPI.setCommandApi(new CommandAPI(plugin)); + ScrowAPI.setCommands(new CommandAPI<>(plugin, CommandSender.class)); + ScrowAPI.setPlayerCommands(new CommandAPI<>(plugin, Player.class)); ScrowAPI.setInstanceManager(new InstanceManagerImpl(ScrowAPI.getMessageBroker())); ScrowAPI.setEconomyService(ScrowAPI.getJdbi() != null ? new PostgresEconomyService(ScrowAPI.getJdbi()) : new InMemoryEconomyService()); diff --git a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsCommand.java b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsCommand.java index a3044f7..f8fb4b3 100644 --- a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsCommand.java +++ b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsCommand.java @@ -3,7 +3,6 @@ package de.kentoj.scrow.bukkit.command.economy; import com.leakyabstractions.result.api.Result; import com.leakyabstractions.result.core.Results; import de.kentoj.kencommandapi.api.invocation.CommandContext; -import de.kentoj.kencommandapi.api.invocation.CommandExecutor; import de.kentoj.kencommandapi.api.literal.Literal; import de.kentoj.kencommandapi.api.literal.RootLiteral; import de.kentoj.kencommandapi.api.platform.MessageStyle; @@ -11,34 +10,27 @@ import de.kentoj.scrow.bukkit.ScrowAPI; import de.kentoj.scrow.bukkit.scheduler.Tasks; import de.kentoj.scrowlib.convention.ScrowMessageStyle; import lombok.Getter; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import java.util.concurrent.CompletableFuture; -public class CoinsCommand implements CommandExecutor { +public final class CoinsCommand { @Getter - private final RootLiteral rootLiteral; + private final RootLiteral rootLiteral; private final MessageStyle style; public CoinsCommand() { style = ScrowMessageStyle.GENERIC; - rootLiteral = Literal.rootLiteral(style, "coins", "bal", "balance"); - rootLiteral.setPermission("command.coins.get.self"); - rootLiteral.setExecutor(this); - - var setLiteral = new CoinsSetLiteral(style).getLiteral(); - setLiteral.setPermission("command.coins.set"); - rootLiteral.addLiteral(setLiteral); - - var getLiteral = new CoinsGetLiteral(style).getLiteral(); - getLiteral.setPermission("command.coins.get.others"); - rootLiteral.addLiteral(getLiteral); + rootLiteral = Literal.builder("coins", "bal", "balance") + .withPermission("command.coins.get.self") + .withExecutor(this::execute) + .withLiteral(new CoinsSetLiteral(style).getLiteral()) + .withLiteral(new CoinsGetLiteral(style).getLiteral()) + .asRootLiteral(style); } - @Override - public CompletableFuture> execute(CommandContext ctx) { - var player = ((Player) ctx.getSender()); + public CompletableFuture> execute(CommandContext ctx) { + var player = ctx.getSender(); return Tasks.supplyAsync(() -> ScrowAPI.getEconomyService().getCoins(player.getUniqueId())) .>mapSync(amount -> { diff --git a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsGetLiteral.java b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsGetLiteral.java index 5213511..ee54749 100644 --- a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsGetLiteral.java +++ b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsGetLiteral.java @@ -2,9 +2,8 @@ package de.kentoj.scrow.bukkit.command.economy; import com.leakyabstractions.result.api.Result; import com.leakyabstractions.result.core.Results; -import de.kentoj.kencommandapi.api.argument.CommandArgument; +import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec; import de.kentoj.kencommandapi.api.invocation.CommandContext; -import de.kentoj.kencommandapi.api.invocation.CommandExecutor; import de.kentoj.kencommandapi.api.literal.Literal; import de.kentoj.kencommandapi.api.platform.MessageStyle; import de.kentoj.kencommandapi.type.OfflinePlayerArgumentType; @@ -13,30 +12,31 @@ import de.kentoj.scrow.bukkit.scheduler.Tasks; import lombok.Getter; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; import java.util.concurrent.CompletableFuture; -public class CoinsGetLiteral implements CommandExecutor { +public final class CoinsGetLiteral { @Getter - private final Literal literal; - + private final Literal literal; private final MessageStyle style; - private final CommandArgument playerArg; + private final CommandArgumentSpec playerArg; public CoinsGetLiteral(MessageStyle style) { this.style = style; - playerArg = CommandArgument.arg("player", OfflinePlayerArgumentType.getInstance()); - playerArg.setDefaultValueProvider(sender -> (OfflinePlayer) sender); - - literal = Literal.literal("get"); - literal.addArgument(playerArg); - literal.setExecutor(this); + playerArg = CommandArgumentSpec.builder("player", new OfflinePlayerArgumentType()) + .withDefaultValue(CommandContext::getSender) + .build(); + literal = Literal.builder("get") + .withPermission("command.coins.get.others") + .withArgument(playerArg) + .withExecutor(this::execute) + .build(); } - @Override - public CompletableFuture> execute(CommandContext ctx) { + private CompletableFuture> execute(CommandContext ctx) { var player = ctx.getArg(playerArg); return Tasks.supplyAsync(() -> ScrowAPI.getEconomyService().getCoins(player.getUniqueId())) @@ -45,5 +45,4 @@ public class CoinsGetLiteral implements CommandExecutor { return Results.success(new Object()); }).toFuture(); } - } diff --git a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsSetLiteral.java b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsSetLiteral.java index 2adb899..c6ad3dd 100644 --- a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsSetLiteral.java +++ b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsSetLiteral.java @@ -2,11 +2,11 @@ package de.kentoj.scrow.bukkit.command.economy; import com.leakyabstractions.result.api.Result; import com.leakyabstractions.result.core.Results; -import de.kentoj.kencommandapi.api.argument.CommandArgument; +import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec; import de.kentoj.kencommandapi.api.argument.types.IntegerArgumentType; import de.kentoj.kencommandapi.api.invocation.CommandContext; -import de.kentoj.kencommandapi.api.invocation.CommandExecutor; import de.kentoj.kencommandapi.api.literal.Literal; +import de.kentoj.kencommandapi.api.literal.LiteralBuilder; import de.kentoj.kencommandapi.api.platform.MessageStyle; import de.kentoj.kencommandapi.type.OfflinePlayerArgumentType; import de.kentoj.scrow.bukkit.ScrowAPI; @@ -14,32 +14,35 @@ import de.kentoj.scrow.bukkit.scheduler.Tasks; import lombok.Getter; import org.bukkit.OfflinePlayer; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; import java.util.concurrent.CompletableFuture; -public class CoinsSetLiteral implements CommandExecutor { +public final class CoinsSetLiteral { @Getter - private final Literal literal; + private final Literal literal; private final MessageStyle style; - private final CommandArgument playerArg; - private final CommandArgument amountArg; + private final CommandArgumentSpec playerArg; + private final CommandArgumentSpec amountArg; public CoinsSetLiteral(MessageStyle style) { this.style = style; - - playerArg = CommandArgument.arg("player", OfflinePlayerArgumentType.getInstance()); - amountArg = CommandArgument.arg("amount", new IntegerArgumentType<>()); - - literal = Literal.literal("set"); - literal.addArgument(playerArg); - literal.addArgument(amountArg); - literal.setExecutor(this); + playerArg = CommandArgumentSpec.builder("player", new OfflinePlayerArgumentType()) + .withDefaultValue(CommandContext::getSender) + .build(); + amountArg = CommandArgumentSpec.builder("amount", new IntegerArgumentType()) + .build(); + literal = Literal.builder("set") + .withPermission("command.coins.set") + .withArgument(playerArg) + .withArgument(amountArg) + .withExecutor(this::execute) + .build(); } - @Override - public CompletableFuture> execute(CommandContext ctx) { + private CompletableFuture> execute(CommandContext ctx) { var player = ctx.getArg(playerArg); var amount = ctx.getArg(amountArg); return Tasks.runAsync(() -> diff --git a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/friends/FriendAddLiteral.java b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/friends/FriendAddLiteral.java index baf0ad3..7d64056 100644 --- a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/friends/FriendAddLiteral.java +++ b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/friends/FriendAddLiteral.java @@ -2,24 +2,21 @@ package de.kentoj.scrow.bukkit.command.friends; import com.leakyabstractions.result.api.Result; import com.leakyabstractions.result.core.Results; -import de.kentoj.kencommandapi.api.argument.CommandArgument; +import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec; import de.kentoj.kencommandapi.api.invocation.CommandContext; -import de.kentoj.kencommandapi.api.invocation.CommandExecutor; import de.kentoj.kencommandapi.api.literal.Literal; import de.kentoj.kencommandapi.type.OfflinePlayerArgumentType; import de.kentoj.scrow.bukkit.ScrowAPI; +import de.kentoj.scrow.bukkit.scheduler.Task; +import de.kentoj.scrow.bukkit.scheduler.Tasks; +import de.kentoj.scrowlib.convention.ScrowMessageStyle; import de.kentoj.scrowlib.friends.FriendRequestService; import de.kentoj.scrowlib.friends.FriendshipService; import de.kentoj.scrowlib.friends.friendship.FriendshipImpl; import de.kentoj.scrowlib.friends.request.FriendRequestImpl; -import de.kentoj.scrow.bukkit.scheduler.Task; -import de.kentoj.scrow.bukkit.scheduler.Tasks; -import de.kentoj.scrowlib.convention.ScrowMessageStyle; import lombok.Getter; -import lombok.RequiredArgsConstructor; import net.kyori.adventure.text.Component; import org.bukkit.OfflinePlayer; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import java.time.Instant; @@ -27,27 +24,28 @@ import java.util.Objects; import java.util.UUID; import java.util.concurrent.CompletableFuture; -@RequiredArgsConstructor -public class FriendAddLiteral implements CommandExecutor { +public class FriendAddLiteral { @Getter - private final Literal literal; - private final CommandArgument playerArg; + private final Literal literal; + private final CommandArgumentSpec playerArg; private final ScrowMessageStyle style; + private final FriendRequestService requestService = ScrowAPI.getFriendRequestService(); private final FriendshipService friendsService = ScrowAPI.getFriendshipService(); public FriendAddLiteral(ScrowMessageStyle style) { this.style = style; - playerArg = CommandArgument.arg("player", OfflinePlayerArgumentType.getInstance()); - literal = Literal.literal("add"); - literal.addArgument(playerArg); - literal.setExecutor(this); + playerArg = CommandArgumentSpec.builder("player", new OfflinePlayerArgumentType()) + .build(); + literal = Literal.builder("add") + .withArgument(playerArg) + .withExecutor(this::execute) + .build(); } - @Override - public CompletableFuture> execute(CommandContext ctx) { - var self = (Player) ctx.getSender(); + private CompletableFuture> execute(CommandContext ctx) { + var self = ctx.getSender(); var other = ctx.getArg(playerArg); return Tasks.supplyAsync(() -> findAction(self, other) .mapSuccess(action -> { diff --git a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/friends/FriendCommand.java b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/friends/FriendCommand.java index 2f8af5f..5c1b13a 100644 --- a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/friends/FriendCommand.java +++ b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/friends/FriendCommand.java @@ -9,19 +9,20 @@ import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.HoverEvent; import net.kyori.adventure.text.format.NamedTextColor; -import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; @NoArgsConstructor(access = AccessLevel.NONE) public class FriendCommand { - public static RootLiteral create() { + + public static RootLiteral create() { var style = new ScrowMessageStyle("Friends", NamedTextColor.AQUA); - RootLiteral rootLiteral = Literal.rootLiteral(style, "f", "friend"); - rootLiteral.addLiteral(new FriendListLiteral(style).getLiteral()); - rootLiteral.addLiteral(new FriendAddLiteral(style).getLiteral()); - rootLiteral.addLiteral(new FriendRemoveLiteral(style).getLiteral()); - rootLiteral.addLiteral(new FriendRequestDeclineLiteral(style).getLiteral()); - rootLiteral.addLiteral(new FriendRequestsLiteral(style).getLiteral()); - return rootLiteral; + return Literal.builder("f", "friend") + .withLiteral(new FriendListLiteral(style).getLiteral()) + .withLiteral(new FriendAddLiteral(style).getLiteral()) + .withLiteral(new FriendRemoveLiteral(style).getLiteral()) + .withLiteral(new FriendRequestDeclineLiteral(style).getLiteral()) + .withLiteral(new FriendRequestsLiteral(style).getLiteral()) + .asRootLiteral(style); } public static Component friendRequestOptions(String requestSenderName, boolean runInstantly) { diff --git a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/friends/FriendListLiteral.java b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/friends/FriendListLiteral.java index 301a062..1e2b241 100644 --- a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/friends/FriendListLiteral.java +++ b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/friends/FriendListLiteral.java @@ -3,18 +3,17 @@ package de.kentoj.scrow.bukkit.command.friends; import com.leakyabstractions.result.api.Result; import com.leakyabstractions.result.core.Results; import de.kentoj.kencommandapi.api.invocation.CommandContext; -import de.kentoj.kencommandapi.api.invocation.CommandExecutor; import de.kentoj.kencommandapi.api.literal.Literal; import de.kentoj.scrow.bukkit.ScrowAPI; import de.kentoj.scrow.bukkit.scheduler.Tasks; import de.kentoj.scrowlib.convention.ScrowMessageStyle; import lombok.Getter; +import lombok.RequiredArgsConstructor; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.minimessage.MiniMessage; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import java.util.List; @@ -23,21 +22,17 @@ import java.util.concurrent.CompletableFuture; import static java.util.Objects.requireNonNull; import static net.kyori.adventure.text.Component.text; -public class FriendListLiteral implements CommandExecutor { +@RequiredArgsConstructor +public final class FriendListLiteral { @Getter - private final Literal literal; + private final Literal literal = Literal.builder("list") + .withExecutor(this::displayFriendList) + .build(); private final ScrowMessageStyle style; - public FriendListLiteral(ScrowMessageStyle style) { - this.style = style; - this.literal = Literal.literal("list"); - literal.setExecutor(this); - } - - @Override - public CompletableFuture> execute(CommandContext ctx) { - var sender = (Player) ctx.getSender(); + private CompletableFuture> displayFriendList(CommandContext ctx) { + var sender = ctx.getSender(); return Tasks.supplyAsync(() -> ScrowAPI.getFriendshipService().getFriendships(sender.getUniqueId())) .>mapSync(friendships -> { diff --git a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/friends/FriendRemoveLiteral.java b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/friends/FriendRemoveLiteral.java index 090715c..9da6d6b 100644 --- a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/friends/FriendRemoveLiteral.java +++ b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/friends/FriendRemoveLiteral.java @@ -2,9 +2,8 @@ package de.kentoj.scrow.bukkit.command.friends; import com.leakyabstractions.result.api.Result; import com.leakyabstractions.result.core.Results; -import de.kentoj.kencommandapi.api.argument.CommandArgument; +import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec; import de.kentoj.kencommandapi.api.invocation.CommandContext; -import de.kentoj.kencommandapi.api.invocation.CommandExecutor; import de.kentoj.kencommandapi.api.literal.Literal; import de.kentoj.kencommandapi.type.OfflinePlayerArgumentType; import de.kentoj.scrow.bukkit.ScrowAPI; @@ -12,31 +11,31 @@ import de.kentoj.scrow.bukkit.scheduler.Tasks; import de.kentoj.scrowlib.convention.ScrowMessageStyle; import lombok.Getter; import org.bukkit.OfflinePlayer; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import java.util.concurrent.CompletableFuture; -public class FriendRemoveLiteral implements CommandExecutor { +public class FriendRemoveLiteral { + @Getter - private final Literal literal; - private final CommandArgument playerArg; + private final Literal literal; + private final CommandArgumentSpec playerArg; private final ScrowMessageStyle style; - public FriendRemoveLiteral(ScrowMessageStyle style) { + FriendRemoveLiteral(ScrowMessageStyle style) { this.style = style; - this.playerArg = CommandArgument.arg("player", OfflinePlayerArgumentType.getInstance()); - this.literal = Literal.literal("remove"); - this.literal.addArgument(playerArg); - this.literal.setExecutor(this); + playerArg = CommandArgumentSpec.builder("player", new OfflinePlayerArgumentType<>()) + .build(); + literal = Literal.builder("remove") + .withArgument(playerArg) + .withExecutor(this::removeFriend) + .build(); } - @Override - public CompletableFuture> execute(CommandContext ctx) { + private CompletableFuture> removeFriend(CommandContext ctx) { var friend = ctx.getArg(playerArg); - var player = (Player) ctx.getSender(); return Tasks.supplyAsync(() -> - ScrowAPI.getFriendshipService().deleteFriendship(friend.getUniqueId(), player.getUniqueId())) + ScrowAPI.getFriendshipService().deleteFriendship(friend.getUniqueId(), ctx.getSender().getUniqueId())) .>mapSync(deleted -> { if (!deleted) return Results.failure("You are not friends with " + friend.getName() + "."); diff --git a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/friends/FriendRequestDeclineLiteral.java b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/friends/FriendRequestDeclineLiteral.java index d3b82fd..3c22a95 100644 --- a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/friends/FriendRequestDeclineLiteral.java +++ b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/friends/FriendRequestDeclineLiteral.java @@ -2,43 +2,42 @@ package de.kentoj.scrow.bukkit.command.friends; import com.leakyabstractions.result.api.Result; import com.leakyabstractions.result.core.Results; -import de.kentoj.kencommandapi.api.argument.CommandArgument; +import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec; import de.kentoj.kencommandapi.api.invocation.CommandContext; -import de.kentoj.kencommandapi.api.invocation.CommandExecutor; import de.kentoj.kencommandapi.api.literal.Literal; import de.kentoj.kencommandapi.type.OfflinePlayerArgumentType; import de.kentoj.scrow.bukkit.ScrowAPI; -import de.kentoj.scrowlib.friends.FriendRequestService; import de.kentoj.scrow.bukkit.scheduler.Tasks; import de.kentoj.scrowlib.convention.ScrowMessageStyle; +import de.kentoj.scrowlib.friends.FriendRequestService; import lombok.Getter; import lombok.RequiredArgsConstructor; import org.bukkit.OfflinePlayer; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import java.util.concurrent.CompletableFuture; @RequiredArgsConstructor -public class FriendRequestDeclineLiteral implements CommandExecutor { +public class FriendRequestDeclineLiteral { @Getter - private final Literal literal; - private final CommandArgument playerArg; + private final Literal literal; + private final CommandArgumentSpec playerArg; private final ScrowMessageStyle style; private final FriendRequestService requestService = ScrowAPI.getFriendRequestService(); - public FriendRequestDeclineLiteral(ScrowMessageStyle style) { + FriendRequestDeclineLiteral(ScrowMessageStyle style) { this.style = style; - playerArg = CommandArgument.arg("player", OfflinePlayerArgumentType.getInstance()); - literal = Literal.literal("reject", "decline"); - literal.addArgument(playerArg); - literal.setExecutor(this); + playerArg = CommandArgumentSpec.builder("player", new OfflinePlayerArgumentType()) + .build(); + literal = Literal.builder("reject", "decline") + .withArgument(playerArg) + .withExecutor(this::declineFriendRequest) + .build(); } - @Override - public CompletableFuture> execute(CommandContext ctx) { - var self = (Player) ctx.getSender(); + private CompletableFuture> declineFriendRequest(CommandContext ctx) { + var self = ctx.getSender(); var other = ctx.getArg(playerArg); return Tasks.supplyAsync(() -> requestService.deleteFriendRequest(other.getUniqueId(), self.getUniqueId())) diff --git a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/friends/FriendRequestsLiteral.java b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/friends/FriendRequestsLiteral.java index d8ef55b..18a6053 100644 --- a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/friends/FriendRequestsLiteral.java +++ b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/friends/FriendRequestsLiteral.java @@ -3,18 +3,18 @@ package de.kentoj.scrow.bukkit.command.friends; import com.leakyabstractions.result.api.Result; import com.leakyabstractions.result.core.Results; import de.kentoj.kencommandapi.api.invocation.CommandContext; -import de.kentoj.kencommandapi.api.invocation.CommandExecutor; import de.kentoj.kencommandapi.api.literal.Literal; import de.kentoj.scrow.bukkit.ScrowAPI; import de.kentoj.scrowlib.friends.FriendRequest; import de.kentoj.scrow.bukkit.scheduler.Tasks; import de.kentoj.scrowlib.convention.ScrowMessageStyle; +import lombok.AccessLevel; import lombok.Getter; +import lombok.RequiredArgsConstructor; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.minimessage.MiniMessage; import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import java.util.List; @@ -22,28 +22,23 @@ import java.util.concurrent.CompletableFuture; import static net.kyori.adventure.text.Component.text; -public class FriendRequestsLiteral implements CommandExecutor { +@RequiredArgsConstructor(access = AccessLevel.PACKAGE) +public class FriendRequestsLiteral { @Getter - private final Literal literal; + private final Literal literal = Literal.builder("requests") + .withExecutor(this::displayFriendRequests) + .build(); private final ScrowMessageStyle style; - public FriendRequestsLiteral(ScrowMessageStyle style) { - this.style = style; - literal = Literal.literal("requests"); - literal.setExecutor(this); - } - - @Override - public CompletableFuture> execute(CommandContext ctx) { - var sender = (Player) ctx.getSender(); + private CompletableFuture> displayFriendRequests(CommandContext ctx) { return Tasks.supplyAsync(() -> - ScrowAPI.getFriendRequestService().getFriendRequestsTo(sender.getUniqueId())) + ScrowAPI.getFriendRequestService().getFriendRequestsTo(ctx.getSender().getUniqueId())) .>mapAsync(list -> { if (list.isEmpty()) return Results.failure("You have no friend requests."); var requesters = list.stream().sorted(this::compareByAge).map(fr -> Bukkit.getOfflinePlayer(fr.getFrom()).getName()); - sender.sendMessage(formatList(requesters.toList())); + ctx.getSender().sendMessage(formatList(requesters.toList())); return Results.success(new Object()); }).toFuture(); } diff --git a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/instance/InstanceCommand.java b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/instance/InstanceCommand.java index 5103e9e..5226f95 100644 --- a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/instance/InstanceCommand.java +++ b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/instance/InstanceCommand.java @@ -12,10 +12,10 @@ import org.bukkit.command.CommandSender; public class InstanceCommand { public static RootLiteral create(InstanceCache instanceCache) { var style = new ScrowMessageStyle("server-manager", NamedTextColor.RED); - RootLiteral rootLiteral = Literal.rootLiteral(style, "instance", "server-manager"); - rootLiteral.addLiteral(new InstanceListLiteral(style).getNode()); - rootLiteral.addLiteral(new InstanceDeployLiteral(style).getLiteral()); - rootLiteral.addLiteral(new InstanceDestroyLiteral(instanceCache, style).getLiteral()); - return rootLiteral; + return Literal.builder("instance", "server-manager") + .withLiteral(new InstanceListLiteral(style).getLiteral()) + .withLiteral(new InstanceDeployLiteral(style).getLiteral()) + .withLiteral(new InstanceDestroyLiteral(instanceCache, style).getLiteral()) + .asRootLiteral(style); } } diff --git a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/instance/InstanceDeployLiteral.java b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/instance/InstanceDeployLiteral.java index 50d0f95..bc9c8a6 100644 --- a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/instance/InstanceDeployLiteral.java +++ b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/instance/InstanceDeployLiteral.java @@ -2,10 +2,9 @@ package de.kentoj.scrow.bukkit.command.instance; import com.leakyabstractions.result.api.Result; import com.leakyabstractions.result.core.Results; -import de.kentoj.kencommandapi.api.argument.CommandArgument; +import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec; import de.kentoj.kencommandapi.api.argument.types.StringArgumentType; import de.kentoj.kencommandapi.api.invocation.CommandContext; -import de.kentoj.kencommandapi.api.invocation.CommandExecutor; import de.kentoj.kencommandapi.api.literal.Literal; import de.kentoj.scrow.bukkit.ScrowAPI; import de.kentoj.scrow.bukkit.scheduler.Tasks; @@ -15,25 +14,25 @@ import org.bukkit.command.CommandSender; import java.util.concurrent.CompletableFuture; -public class InstanceDeployLiteral implements CommandExecutor { +public class InstanceDeployLiteral { @Getter private final Literal literal; - private final CommandArgument templateArg; + private final CommandArgumentSpec templateArg; private final ScrowMessageStyle style; - public InstanceDeployLiteral(ScrowMessageStyle style) { + InstanceDeployLiteral(ScrowMessageStyle style) { this.style = style; - templateArg = CommandArgument.arg("template", new StringArgumentType<>()); - - literal = Literal.literal("deploy"); - literal.addArgument(templateArg); - literal.setExecutor(this); + templateArg = CommandArgumentSpec.builder("template", new StringArgumentType()) + .build(); + literal = Literal.builder("deploy") + .withArgument(templateArg) + .withExecutor(this::deployInstance) + .build(); } - @Override - public CompletableFuture> execute(CommandContext ctx) { + private CompletableFuture> deployInstance(CommandContext ctx) { var template = ctx.getArg(templateArg); ctx.getSender().sendMessage(style.ok("Deploying instance... this may take a while.")); return Tasks.supplyAsync(() -> diff --git a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/instance/InstanceDestroyLiteral.java b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/instance/InstanceDestroyLiteral.java index f21e132..224403e 100644 --- a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/instance/InstanceDestroyLiteral.java +++ b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/instance/InstanceDestroyLiteral.java @@ -2,10 +2,9 @@ package de.kentoj.scrow.bukkit.command.instance; import com.leakyabstractions.result.api.Result; import com.leakyabstractions.result.core.Results; -import de.kentoj.kencommandapi.api.argument.CommandArgument; +import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec; import de.kentoj.kencommandapi.api.argument.types.StringArgumentType; import de.kentoj.kencommandapi.api.invocation.CommandContext; -import de.kentoj.kencommandapi.api.invocation.CommandExecutor; import de.kentoj.kencommandapi.api.literal.Literal; import de.kentoj.scrow.bukkit.ScrowAPI; import de.kentoj.scrow.bukkit.scheduler.Tasks; @@ -16,27 +15,29 @@ import org.bukkit.command.CommandSender; import java.util.concurrent.CompletableFuture; -public class InstanceDestroyLiteral implements CommandExecutor { +public class InstanceDestroyLiteral { @Getter private final Literal literal; - private final CommandArgument handleArg; + private final CommandArgumentSpec handleArg; private final ScrowMessageStyle style; - public InstanceDestroyLiteral(InstanceCache cache, ScrowMessageStyle style) { + InstanceDestroyLiteral(InstanceCache cache, ScrowMessageStyle style) { this.style = style; - handleArg = CommandArgument.arg("handle", new StringArgumentType<>()); - handleArg.setSuggestionProvider(ctx -> cache.getInstances().stream() - .map(ServerInstance::getHandle) - .toList()); - literal = Literal.literal("destroy"); - literal.addArgument(handleArg); - literal.setExecutor(this); + handleArg = CommandArgumentSpec.builder("handle", new StringArgumentType()) + .withSuggestionProvider(_ -> + cache.getInstances().stream() + .map(ServerInstance::getHandle) + .toList()) + .build(); + literal = Literal.builder("destroy") + .withArgument(handleArg) + .withExecutor(this::destroyInstance) + .build(); } - @Override - public CompletableFuture> execute(CommandContext ctx) { + private CompletableFuture> destroyInstance(CommandContext ctx) { var handle = ctx.getArg(handleArg); return Tasks.supplyAsync(() -> ScrowAPI.getInstanceManager().destroyInstance(handle)) .>mapSync(found -> { diff --git a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/instance/InstanceListLiteral.java b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/instance/InstanceListLiteral.java index aa5b54b..b8beef4 100644 --- a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/instance/InstanceListLiteral.java +++ b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/instance/InstanceListLiteral.java @@ -3,7 +3,6 @@ package de.kentoj.scrow.bukkit.command.instance; import com.leakyabstractions.result.api.Result; import com.leakyabstractions.result.core.Results; import de.kentoj.kencommandapi.api.invocation.CommandContext; -import de.kentoj.kencommandapi.api.invocation.CommandExecutor; import de.kentoj.kencommandapi.api.literal.Literal; import de.kentoj.scrow.bukkit.ScrowAPI; import de.kentoj.scrow.bukkit.scheduler.Tasks; @@ -14,20 +13,20 @@ import org.bukkit.command.CommandSender; import java.util.concurrent.CompletableFuture; -public class InstanceListLiteral implements CommandExecutor { +public class InstanceListLiteral { @Getter - private final Literal node; + private final Literal literal; private final ScrowMessageStyle style; - public InstanceListLiteral(ScrowMessageStyle style) { + InstanceListLiteral(ScrowMessageStyle style) { this.style = style; - this.node = Literal.literal("list"); - this.node.setExecutor(this); + this.literal = Literal.builder("list") + .withExecutor(this::displayInstanceList) + .build(); } - @Override - public CompletableFuture> execute(CommandContext ctx) { + private CompletableFuture> displayInstanceList(CommandContext ctx) { return Tasks.supplyAsync(() -> ScrowAPI.getInstanceManager().getInstances()) .>mapSync(instances -> { diff --git a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/instance/LobbyCommand.java b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/instance/LobbyCommand.java index 17e5e0d..eacc4f7 100644 --- a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/instance/LobbyCommand.java +++ b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/instance/LobbyCommand.java @@ -3,26 +3,22 @@ package de.kentoj.scrow.bukkit.command.instance; import com.leakyabstractions.result.api.Result; import com.leakyabstractions.result.core.Results; import de.kentoj.kencommandapi.api.invocation.CommandContext; -import de.kentoj.kencommandapi.api.invocation.SyncCommandExecutor; import de.kentoj.kencommandapi.api.literal.Literal; import de.kentoj.kencommandapi.api.literal.RootLiteral; -import de.kentoj.kencommandapi.api.platform.MessageStyle; +import de.kentoj.scrowlib.convention.ScrowMessageStyle; import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; -public class LobbyCommand implements SyncCommandExecutor { +public class LobbyCommand { @Getter - private final RootLiteral rootLiteral; + private final RootLiteral rootLiteral = Literal.builder("lobby", "l", "hub") + .withSyncExecutor(this::sendToLobby) + .asRootLiteral(ScrowMessageStyle.GENERIC); - public LobbyCommand() { - this.rootLiteral = Literal.rootLiteral(MessageStyle.PLAIN, "lobby", "l", "hub"); - this.rootLiteral.setExecutor(this); - } - - @Override - public Result executeSync(CommandContext ctx) { + private Result sendToLobby(CommandContext ctx) { Bukkit.dispatchCommand(ctx.getSender(), "play lobby"); return Results.success(new Object()); } diff --git a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/instance/PlayCommand.java b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/instance/PlayCommand.java index b720ec2..73384f3 100644 --- a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/instance/PlayCommand.java +++ b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/command/instance/PlayCommand.java @@ -2,7 +2,7 @@ package de.kentoj.scrow.bukkit.command.instance; import com.leakyabstractions.result.api.Result; import com.leakyabstractions.result.core.Results; -import de.kentoj.kencommandapi.api.argument.CommandArgument; +import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec; import de.kentoj.kencommandapi.api.argument.types.StringArgumentType; import de.kentoj.kencommandapi.api.invocation.CommandContext; import de.kentoj.kencommandapi.api.invocation.CommandExecutor; @@ -17,26 +17,23 @@ import org.bukkit.entity.Player; import java.util.concurrent.CompletableFuture; -public class PlayCommand implements CommandExecutor { +public class PlayCommand { @Getter - private final RootLiteral rootLiteral; - private final CommandArgument gamemodeArg; + private final RootLiteral rootLiteral; + private final CommandArgumentSpec gamemodeArg; public PlayCommand() { var style = ScrowMessageStyle.GENERIC; - - gamemodeArg = CommandArgument.arg("gamemode", new StringArgumentType<>()); - - rootLiteral = Literal.rootLiteral(style, "play", "queue"); - rootLiteral.addArgument(this.gamemodeArg); - rootLiteral.setExecutor(this); + gamemodeArg = CommandArgumentSpec.builder("gamemode", new StringArgumentType()).build(); + rootLiteral = Literal.builder("play", "queue") + .withArgument(gamemodeArg) + .withExecutor(this::execute) + .asRootLiteral(style); } - @Override - public CompletableFuture> execute(CommandContext ctx) { + private CompletableFuture> execute(CommandContext ctx) { var gamemode = ctx.getArg(gamemodeArg); - var player = (Player) ctx.getSender(); return Tasks.supplyAsync(() -> ScrowAPI.getInstanceManager().getInstances()) .mapAsync(instances -> { var instance = instances.stream() @@ -47,7 +44,7 @@ public class PlayCommand implements CommandExecutor { return Results.failure("No instance for " + gamemode + " found."); return Results.ofCallable(() -> { - ScrowAPI.getPlayer(player).sendToInstance(instance.getHandle()); + ScrowAPI.getPlayer(ctx.getSender()).sendToInstance(instance.getHandle()); return new Object(); }).mapFailure(Exception::getMessage); }).toFuture(); diff --git a/core-bukkit-impl/src/main/resources/plugin.yml b/core-bukkit-impl/src/main/resources/plugin.yml index 8e79abd..973ef1c 100644 --- a/core-bukkit-impl/src/main/resources/plugin.yml +++ b/core-bukkit-impl/src/main/resources/plugin.yml @@ -1,5 +1,6 @@ name: "CoreBukkit" version: "${version}" +depend: [ "LuckPerms" ] main: "de.kentoj.scrow.bukkit.CoreImplPlugin" api-version: "1.21" author: "Kento2" \ No newline at end of file diff --git a/core-lib/BUILD b/core-lib/BUILD new file mode 100644 index 0000000..acc6aa9 --- /dev/null +++ b/core-lib/BUILD @@ -0,0 +1,23 @@ +load("@rules_jvm_external//:defs.bzl", "artifact") +load("@rules_java//java:java_library.bzl", "java_library") + +shared_deps = [ + "//third_party:common_deps", + artifact("de.kentoj.scrow:kencommandapi-core"), + artifact("net.kyori:adventure-api"), + artifact("net.kyori:adventure-text-minimessage"), + artifact("org.jdbi:jdbi3-core"), + artifact("org.mongodb:bson"), +] + +java_library( + name = "core", + srcs = glob(["src/main/**/*.java"]), + visibility = ["//visibility:public"], + deps = shared_deps + [ + artifact("org.jdbi:jdbi3-postgres"), + artifact("io.nats:jnats"), + ], + exports = shared_deps, + plugins = [ "//third_party:lombok_plugin" ], +) \ No newline at end of file diff --git a/core-lib/src/main/java/de/kentoj/scrowlib/instancemanager/InstanceManager.java b/core-lib/src/main/java/de/kentoj/scrowlib/instancemanager/InstanceManager.java index ad67923..ee1eb1b 100644 --- a/core-lib/src/main/java/de/kentoj/scrowlib/instancemanager/InstanceManager.java +++ b/core-lib/src/main/java/de/kentoj/scrowlib/instancemanager/InstanceManager.java @@ -1,6 +1,6 @@ package de.kentoj.scrowlib.instancemanager; -import org.jspecify.annotations.Nullable; +import org.jetbrains.annotations.Nullable; import java.util.List; @@ -14,12 +14,14 @@ public interface InstanceManager { /** * Runs blocking. + * * @return if the instance was found */ boolean destroyInstance(String handle); /** * Runs blocking. + * * @return list of running instances */ List getInstances(); diff --git a/core-lib/src/main/java/de/kentoj/scrowlib/instancemanager/InstanceManagerImpl.java b/core-lib/src/main/java/de/kentoj/scrowlib/instancemanager/InstanceManagerImpl.java index a390d7e..f205e48 100644 --- a/core-lib/src/main/java/de/kentoj/scrowlib/instancemanager/InstanceManagerImpl.java +++ b/core-lib/src/main/java/de/kentoj/scrowlib/instancemanager/InstanceManagerImpl.java @@ -4,7 +4,7 @@ import de.kentoj.scrowlib.messaging.MessageBroker; import de.kentoj.scrowlib.messaging.RemoteException; import lombok.RequiredArgsConstructor; import org.bson.Document; -import org.jspecify.annotations.Nullable; +import org.jetbrains.annotations.Nullable; import java.util.List; diff --git a/core-lib/src/main/java/de/kentoj/scrowlib/messaging/SyncRequestHandler.java b/core-lib/src/main/java/de/kentoj/scrowlib/messaging/SyncRequestHandler.java index ef604f7..6b486c2 100644 --- a/core-lib/src/main/java/de/kentoj/scrowlib/messaging/SyncRequestHandler.java +++ b/core-lib/src/main/java/de/kentoj/scrowlib/messaging/SyncRequestHandler.java @@ -5,7 +5,6 @@ import org.bson.Document; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Future; -@FunctionalInterface public interface SyncRequestHandler extends RequestHandler { Document handleSync(Document doc); diff --git a/core-velocity-api/BUILD b/core-velocity-api/BUILD new file mode 100644 index 0000000..27a81a1 --- /dev/null +++ b/core-velocity-api/BUILD @@ -0,0 +1,20 @@ +load("@rules_jvm_external//:defs.bzl", "artifact") +load("@rules_java//java:java_library.bzl", "java_library") + +java_library( + name = "core-velocity-api", + srcs = glob(["src/main/**/*.java"]), + visibility = ["//visibility:public"], + deps = [ + "//core-lib:core", + artifact("com.velocitypowered:velocity-api"), + artifact("org.projectlombok:lombok"), + artifact("de.kentoj.scrow:kencommandapi-velocity"), + ], + exports = [ + "//core-lib:core", + artifact("de.kentoj.scrow:kencommandapi-velocity"), + artifact("org.mongodb:bson"), + ], + plugins = [ "//third_party:lombok_plugin" ], +) \ No newline at end of file diff --git a/core-velocity-api/src/main/java/de/kentoj/scrow/velocity/ScrowAPI.java b/core-velocity-api/src/main/java/de/kentoj/scrow/velocity/ScrowAPI.java index 571b3a5..580b222 100644 --- a/core-velocity-api/src/main/java/de/kentoj/scrow/velocity/ScrowAPI.java +++ b/core-velocity-api/src/main/java/de/kentoj/scrow/velocity/ScrowAPI.java @@ -1,5 +1,6 @@ package de.kentoj.scrow.velocity; +import com.velocitypowered.api.command.CommandSource; import com.velocitypowered.api.proxy.Player; import de.kentoj.kencommandapi.CommandAPI; import de.kentoj.scrowlib.instancemanager.InstanceManager; @@ -20,7 +21,9 @@ public class ScrowAPI { @Getter private static Jdbi jdbi; @Getter - private static CommandAPI commandApi; + private static CommandAPI commands; + @Getter + private static CommandAPI playerCommands; @Getter private static MessageBroker messageBroker; @Getter @@ -35,12 +38,6 @@ public class ScrowAPI { return playerFactory.create(uuid); } - - @ApiStatus.Internal - public static void setCommandApi(CommandAPI commandApi) { - ScrowAPI.commandApi = commandApi; - } - @ApiStatus.Internal public static void setMessageBroker(MessageBroker messageBroker) { ScrowAPI.messageBroker = messageBroker; @@ -60,5 +57,15 @@ public class ScrowAPI { public static void setPlayerFactory(NetworkPlayerFactory playerFactory) { ScrowAPI.playerFactory = playerFactory; } + + @ApiStatus.Internal + public static void setPlayerCommands(CommandAPI playerCommands) { + ScrowAPI.playerCommands = playerCommands; + } + + @ApiStatus.Internal + public static void setCommands(CommandAPI commands) { + ScrowAPI.commands = commands; + } } diff --git a/core-velocity-impl/BUILD b/core-velocity-impl/BUILD new file mode 100644 index 0000000..46d4e8d --- /dev/null +++ b/core-velocity-impl/BUILD @@ -0,0 +1,15 @@ +load("@rules_java//java:java_binary.bzl", "java_binary") +load("@rules_jvm_external//:defs.bzl", "artifact") + +java_binary( + name = "core-velocity-impl", + srcs = glob(["src/main/**/*.java"]), + main_class = "none", + resources = glob(["src/main/resources/**"], allow_empty = True), + deps = [ + "//core-velocity-api", + artifact("com.velocitypowered:velocity-api"), + artifact("io.nats:jnats"), + ], + plugins = [ "//third_party:lombok_plugin" ], +) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml deleted file mode 100644 index 8a73caf..0000000 --- a/gradle/libs.versions.toml +++ /dev/null @@ -1,41 +0,0 @@ -[versions] -shadow = "9.2.0" -scrow-commandapi = "0.33-SNAPSHOT" -postgress = "42.7.12" -nats = "2.25.2" -papermc = "1.21.11-rc3-R0.1-SNAPSHOT" -velocity = "3.5.0-SNAPSHOT" -bson = "5.8.0" -adventure = "5.2.0" -luckperms = "5.5" - -[plugins] -shadow = { id = "com.gradleup.shadow", version.ref = "shadow" } -scrow-basedependencies = { id = "scrow.base-dependencies" } -scrow-javalibrary = { id = "scrow.java-library" } -scrow-database = { id = "scrow.database" } -scrow-publish = { id = "scrow.scrow-publish" } -scrow-runserver = { id = "scrow.run-server" } - -[libraries] -# https://mvnrepository.com/artifact/org.postgresql/postgresql -postgres = { module = "org.postgresql:postgresql", version.ref = "postgress" } -# https://mvnrepository.com/artifact/org.mongodb/bson -bson = { module = "org.mongodb:bson", version.ref = "bson" } -# https://mvnrepository.com/artifact/io.nats/jnats -nats = { module = "io.nats:jnats", version.ref = "nats" } -# https://docs.papermc.io/paper/dev/project-setup/ -papermc-api = { module = "io.papermc.paper:paper-api", version.ref = "papermc" } -# https://docs.papermc.io/velocity/dev/creating-your-first-plugin/ -velocity-api = { module = "com.velocitypowered:velocity-api", version.ref = "velocity" } -adventure-api = { module = "net.kyori:adventure-api", version.ref = "adventure" } -adventure-minimessage = { module = "net.kyori:adventure-text-minimessage", version.ref = "adventure" } -# https://luckperms.net/wiki/Developer-API -luckperms = { module = "net.luckperms:api", version.ref = "luckperms" } - -# http://forge.kentoj.de/scrow/-/packages/maven/de.kentoj.scrow:kencommandapi-core -scrow-commandapi-core = { module = "de.kentoj.scrow:kencommandapi-core", version.ref = "scrow-commandapi" } -# http://forge.kentoj.de/scrow/-/packages/maven/de.kentoj.scrow:kencommandapi-bukkit -scrow-commandapi-bukkit = { module = "de.kentoj.scrow:kencommandapi-bukkit", version.ref = "scrow-commandapi" } -# http://forge.kentoj.de/scrow/-/packages/maven/de.kentoj.scrow:kencommandapi-velocity -scrow-commandapi-velocity = { module = "de.kentoj.scrow:kencommandapi-velocity", version.ref = "scrow-commandapi" } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index a4b76b9..0000000 Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 94113f2..0000000 --- a/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,7 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip -networkTimeout=10000 -validateDistributionUrl=true -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew deleted file mode 100755 index f5feea6..0000000 --- a/gradlew +++ /dev/null @@ -1,252 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# SPDX-License-Identifier: Apache-2.0 -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -# This is normally unused -# shellcheck disable=SC2034 -APP_BASE_NAME=${0##*/} -# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s -' "$PWD" ) || exit - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - if ! command -v java >/dev/null 2>&1 - then - die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, -# and any embedded shellness will be escaped. -# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be -# treated as '${Hostname}' itself on the command line. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat deleted file mode 100644 index 9d21a21..0000000 --- a/gradlew.bat +++ /dev/null @@ -1,94 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem -@rem SPDX-License-Identifier: Apache-2.0 -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/settings.gradle.kts b/settings.gradle.kts deleted file mode 100644 index 45a5bc9..0000000 --- a/settings.gradle.kts +++ /dev/null @@ -1,15 +0,0 @@ -pluginManagement { - includeBuild("../build-logic") -} - -plugins { - id("scrow.scrow-repository") -} - -rootProject.name = "core" - -include("core-bukkit-api") -include("core-bukkit-impl") -include("core-lib") -include("core-velocity-api") -include("core-velocity-impl") \ No newline at end of file diff --git a/third_party/BUILD b/third_party/BUILD new file mode 100644 index 0000000..0e6cbc7 --- /dev/null +++ b/third_party/BUILD @@ -0,0 +1,22 @@ +load("@rules_java//java:java_plugin.bzl", "java_plugin") +java_plugin( + name = "lombok_plugin", + visibility = ["//visibility:public"], + deps = ["@maven//:org_projectlombok_lombok"], + processor_class = "lombok.launch.AnnotationProcessorHider$AnnotationProcessor", +) + +load("@rules_java//java:java_library.bzl", "java_library") +load("@rules_jvm_external//:defs.bzl", "artifact") +java_library( + name = "common_deps", + exports = [ + "@maven//:org_projectlombok_lombok", + "@maven//:com_leakyabstractions_result_api", + "@maven//:com_leakyabstractions_result", + "@maven//:org_jetbrains_annotations", + "@maven//:com_google_guava_guava", + "@maven//:org_slf4j_slf4j_api", + ], + visibility = ["//visibility:public"], +)