diff --git a/.bazelrc b/.bazelrc index d3eb78f..7746d6d 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,7 +1,9 @@ -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://git.lab0x13.site/api/packages/scrow/maven build --remote_cache=https://cache.lab0x13.site -build --remote_upload_local_results=false \ No newline at end of file +build --remote_upload_local_results=false + +build --tool_java_runtime_version=25 +build --java_runtime_version=25 +build --tool_java_language_version=25 +build --java_language_version=25 +build --noexperimental_merged_skyframe_analysis_execution \ No newline at end of file diff --git a/MODULE.bazel b/MODULE.bazel index 00e84c1..69f7bd4 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -27,9 +27,9 @@ maven.install( "org.postgresql:postgresql:42.7.12", "org.mongodb:bson:5.8.0", "io.nats:jnats:2.25.2", - "de.kentoj.scrow:kencommandapi-core:0.39-SNAPSHOT", - "de.kentoj.scrow:kencommandapi-bukkit:0.39-SNAPSHOT", - "de.kentoj.scrow:kencommandapi-velocity:0.39-SNAPSHOT", + "de.kentoj.scrow:kencommandapi-core:0.41-SNAPSHOT", + "de.kentoj.scrow:kencommandapi-bukkit:0.41-SNAPSHOT", + "de.kentoj.scrow:kencommandapi-velocity:0.41-SNAPSHOT", "io.papermc.paper:paper-api:[26.2.build,)", "net.luckperms:api:5.5", "com.google.code.gson:gson:2.14.0", diff --git a/README.md b/README.md index ae64511..2333c18 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,12 @@ - make dev-server use $DOCKER and fallback to docker if podman is not available. - refactor BUILD files: MODULES.bazel +## core +- convert commands to new api +- CommandExecutor now has a style parameter which is always MessageStyle(not ScrowMessageStyle), + this kinda sucks. i could merge kencommandapi into core or make it more flexible(but then i need even more generics) + need to think about this. + ## bukkit - MAKE A MINIGAME FIRST - notification: Friend is now offline/online diff --git a/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/action/ConfigOptionAction.java b/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/action/ConfigOptionAction.java index 3f936fc..ccf44d1 100644 --- a/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/action/ConfigOptionAction.java +++ b/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/action/ConfigOptionAction.java @@ -2,7 +2,7 @@ package site.lab0x13.scrow.configurator.action; import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec; import de.kentoj.kencommandapi.api.invocation.CommandContext; -import de.kentoj.scrowlib.convention.ScrowMessageStyle; +import de.kentoj.kencommandapi.api.platform.MessageStyle; import org.bukkit.entity.Player; import java.util.List; @@ -19,7 +19,7 @@ public interface ConfigOptionAction { boolean requiresValue(); void execute( - ScrowMessageStyle style, + MessageStyle style, T node, CommandContext ctx ); diff --git a/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/action/GlobalShowAction.java b/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/action/GlobalShowAction.java index f3e587e..d355603 100644 --- a/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/action/GlobalShowAction.java +++ b/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/action/GlobalShowAction.java @@ -5,6 +5,7 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec; import de.kentoj.kencommandapi.api.invocation.CommandContext; +import de.kentoj.kencommandapi.api.platform.MessageStyle; import de.kentoj.scrowlib.convention.ScrowMessageStyle; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; @@ -33,7 +34,7 @@ public final class GlobalShowAction> implements ConfigOp } @Override - public void execute(ScrowMessageStyle style, S node, CommandContext ctx) { + public void execute(MessageStyle style, S node, CommandContext ctx) { var jsonElement = node.type().serialize(node.value()); var prettyJson = GSON.toJson(jsonElement, JsonElement.class); var component = Component.text(prettyJson + " [click to copy]") diff --git a/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/type/location/PickAction.java b/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/action/PickAction.java similarity index 82% rename from buildserver/configurator/main/java/site/lab0x13/scrow/configurator/type/location/PickAction.java rename to buildserver/configurator/main/java/site/lab0x13/scrow/configurator/action/PickAction.java index 787e8a8..8a8b086 100644 --- a/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/type/location/PickAction.java +++ b/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/action/PickAction.java @@ -1,11 +1,10 @@ -package site.lab0x13.scrow.configurator.type.location; +package site.lab0x13.scrow.configurator.action; import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec; import de.kentoj.kencommandapi.api.invocation.CommandContext; -import de.kentoj.scrowlib.convention.ScrowMessageStyle; +import de.kentoj.kencommandapi.api.platform.MessageStyle; import org.bukkit.Sound; import org.bukkit.entity.Player; -import site.lab0x13.scrow.configurator.action.ConfigOptionAction; import site.lab0x13.scrow.configurator.node.ConfigNode; import java.util.Collections; @@ -29,7 +28,7 @@ public abstract class PickAction> implements ConfigOp } @Override - public void execute(ScrowMessageStyle style, T node, CommandContext ctx) { + public void execute(MessageStyle style, T node, CommandContext ctx) { pick(ctx.sender()) .orTimeout(10, TimeUnit.MINUTES) .whenComplete((picked, ex) -> { diff --git a/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/command/KeyLiteral.java b/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/command/KeyLiteral.java index b3448df..f3b9978 100644 --- a/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/command/KeyLiteral.java +++ b/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/command/KeyLiteral.java @@ -1,13 +1,11 @@ package site.lab0x13.scrow.configurator.command; -import com.leakyabstractions.result.core.Results; import de.kentoj.kencommandapi.api.literal.Literal; import de.kentoj.kencommandapi.api.literal.LiteralBuilder; import de.kentoj.scrowlib.convention.ScrowMessageStyle; import org.bukkit.entity.Player; import site.lab0x13.scrow.configurator.action.ConfigOptionAction; import site.lab0x13.scrow.configurator.node.ConfigNode; -import site.lab0x13.scrow.configurator.node.ConfigValueNode; import site.lab0x13.scrow.configurator.noderegistry.ConfigNodeWalker; import java.util.ArrayList; @@ -40,13 +38,12 @@ class KeyLiteral { var actionLiteralBuilder = Literal.builder(action.name()); for (var argument : action.arguments()) actionLiteralBuilder.withArgument(argument); - actionLiteralBuilder.withSyncExecutor(ctx -> { + actionLiteralBuilder.withSyncExecutor((style, ctx) -> { if (action.requiresValue() && node.value() == null) { ctx.sender().sendMessage(style.err("No value set.")); - return Results.success(new Object()); + return; } action.execute(style, node, ctx); - return Results.success(new Object()); }); builder.withLiteral(actionLiteralBuilder.build()); } diff --git a/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/type/location/LocationPickCurrentAction.java b/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/type/location/LocationPickCurrentAction.java index 07cc32f..74de842 100644 --- a/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/type/location/LocationPickCurrentAction.java +++ b/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/type/location/LocationPickCurrentAction.java @@ -2,6 +2,7 @@ package site.lab0x13.scrow.configurator.type.location; import org.bukkit.Location; import org.bukkit.entity.Player; +import site.lab0x13.scrow.configurator.action.PickAction; import site.lab0x13.scrow.configurator.node.ConfigNode; import java.util.concurrent.CompletableFuture; diff --git a/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/type/location/LocationTeleportAction.java b/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/type/location/LocationTeleportAction.java index dcdbdb9..8ec5ae2 100644 --- a/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/type/location/LocationTeleportAction.java +++ b/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/type/location/LocationTeleportAction.java @@ -2,6 +2,7 @@ package site.lab0x13.scrow.configurator.type.location; import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec; import de.kentoj.kencommandapi.api.invocation.CommandContext; +import de.kentoj.kencommandapi.api.platform.MessageStyle; import de.kentoj.scrowlib.convention.ScrowMessageStyle; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -29,7 +30,7 @@ class LocationTeleportAction implements ConfigOptionAction node, CommandContext ctx) { + public void execute(MessageStyle style, ConfigValueNode node, CommandContext ctx) { ctx.sender().teleport(node.value()); ctx.sender().sendMessage(style.ok("You've been teleported.")); } diff --git a/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/type/world/WorldConfigType.java b/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/type/world/WorldConfigType.java index 433efcd..ea43d37 100644 --- a/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/type/world/WorldConfigType.java +++ b/buildserver/configurator/main/java/site/lab0x13/scrow/configurator/type/world/WorldConfigType.java @@ -6,6 +6,7 @@ import com.leakyabstractions.result.api.Result; import com.leakyabstractions.result.core.Results; import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec; import de.kentoj.kencommandapi.api.invocation.CommandContext; +import de.kentoj.kencommandapi.api.platform.MessageStyle; import de.kentoj.kencommandapi.type.WorldArgumentType; import de.kentoj.scrowlib.convention.ScrowMessageStyle; import org.bukkit.Bukkit; @@ -59,7 +60,7 @@ public class WorldConfigType implements ConfigType { } @Override - public void execute(ScrowMessageStyle style, ConfigValueNode node, CommandContext ctx) { + public void execute(MessageStyle style, ConfigValueNode node, CommandContext ctx) { World world = ctx.getArg("world"); node.value(world); ctx.sender().sendMessage(style.ok("Set world to " + world.getName() + "("+ world.getUID() + ")")); diff --git a/core/bukkit/plugin/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsCommand.java b/core/bukkit/plugin/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsCommand.java index c103a82..8a14e16 100644 --- a/core/bukkit/plugin/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsCommand.java +++ b/core/bukkit/plugin/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsCommand.java @@ -1,7 +1,5 @@ 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.literal.Literal; import de.kentoj.kencommandapi.api.literal.RootLiteral; @@ -16,26 +14,23 @@ import java.util.concurrent.CompletableFuture; public final class CoinsCommand { private final RootLiteral rootLiteral; - private final MessageStyle style; public CoinsCommand() { - style = ScrowMessageStyle.GENERIC; rootLiteral = Literal.builder("coins", "bal", "balance") .withPermission("command.coins.get.self") .withExecutor(this::execute) - .withLiteral(new CoinsSetLiteral(style).literal()) - .withLiteral(new CoinsGetLiteral(style).literal()) - .asRootLiteral(style); + .withLiteral(new CoinsSetLiteral().literal()) + .withLiteral(new CoinsGetLiteral().literal()) + .asRootLiteral(ScrowMessageStyle.GENERIC); } - public CompletableFuture> execute(CommandContext ctx) { + public CompletableFuture execute(MessageStyle style, CommandContext ctx) { var player = ctx.sender(); return Tasks.supplyAsync(() -> ScrowAPI.economyService().getCoins(player.getUniqueId())) - .>mapSync(amount -> { - player.sendMessage(style.ok("You have " + amount + "$")); - return Results.success(new Object()); - }).toFuture(); + .thenSync(amount -> + player.sendMessage(style.ok("You have " + amount + "$"))) + .toFuture(); } public RootLiteral rootLiteral() { diff --git a/core/bukkit/plugin/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsGetLiteral.java b/core/bukkit/plugin/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsGetLiteral.java index 3e4761f..fc5ad9a 100644 --- a/core/bukkit/plugin/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsGetLiteral.java +++ b/core/bukkit/plugin/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsGetLiteral.java @@ -1,7 +1,5 @@ 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.CommandArgumentSpec; import de.kentoj.kencommandapi.api.invocation.CommandContext; import de.kentoj.kencommandapi.api.literal.Literal; @@ -17,12 +15,9 @@ import java.util.concurrent.CompletableFuture; public final class CoinsGetLiteral { private final Literal literal; - private final MessageStyle style; private final CommandArgumentSpec playerArg; - public CoinsGetLiteral(MessageStyle style) { - this.style = style; - + public CoinsGetLiteral() { playerArg = CommandArgumentSpec.builder("player", new OfflinePlayerArgumentType()) .withDefaultValue(CommandContext::sender) .build(); @@ -33,14 +28,13 @@ public final class CoinsGetLiteral { .build(); } - private CompletableFuture> execute(CommandContext ctx) { + private CompletableFuture execute(MessageStyle style, CommandContext ctx) { var player = ctx.getArg(playerArg); return Tasks.supplyAsync(() -> ScrowAPI.economyService().getCoins(player.getUniqueId())) - .>mapSync(amount -> { - ctx.sender().sendMessage(style.ok(player.getName() + " has " + amount + "$")); - return Results.success(new Object()); - }).toFuture(); + .thenSync(amount -> + ctx.sender().sendMessage(style.ok(player.getName() + " has " + amount + "$"))) + .toFuture(); } public Literal literal() { diff --git a/core/bukkit/plugin/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsSetLiteral.java b/core/bukkit/plugin/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsSetLiteral.java index 895cc57..be2df81 100644 --- a/core/bukkit/plugin/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsSetLiteral.java +++ b/core/bukkit/plugin/main/java/de/kentoj/scrow/bukkit/command/economy/CoinsSetLiteral.java @@ -1,7 +1,5 @@ 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.CommandArgumentSpec; import de.kentoj.kencommandapi.api.argument.types.IntegerArgumentType; import de.kentoj.kencommandapi.api.invocation.CommandContext; @@ -18,12 +16,10 @@ import java.util.concurrent.CompletableFuture; public final class CoinsSetLiteral { private final Literal literal; - private final MessageStyle style; private final CommandArgumentSpec playerArg; private final CommandArgumentSpec amountArg; - CoinsSetLiteral(MessageStyle style) { - this.style = style; + CoinsSetLiteral() { playerArg = CommandArgumentSpec.builder("player", new OfflinePlayerArgumentType()) .withDefaultValue(CommandContext::sender) .build(); @@ -37,15 +33,14 @@ public final class CoinsSetLiteral { .build(); } - private CompletableFuture> execute(CommandContext ctx) { + private CompletableFuture execute(MessageStyle style, CommandContext ctx) { var player = ctx.getArg(playerArg); var amount = ctx.getArg(amountArg); return Tasks.runAsync(() -> ScrowAPI.economyService().setCoins(player.getUniqueId(), amount)) - .>supplySync(() -> { - ctx.sender().sendMessage(style.ok(player.getName() + " now has " + amount + "$")); - return Results.success(new Object()); - }).toFuture(); + .runSync(() -> + ctx.sender().sendMessage(style.ok(player.getName() + " now has " + amount + "$"))) + .toFuture(); } public Literal literal() { diff --git a/core/bukkit/plugin/main/java/de/kentoj/scrow/bukkit/command/friends/FriendCommand.java b/core/bukkit/plugin/main/java/de/kentoj/scrow/bukkit/command/friends/FriendCommand.java index 48cce41..0aea7d3 100644 --- a/core/bukkit/plugin/main/java/de/kentoj/scrow/bukkit/command/friends/FriendCommand.java +++ b/core/bukkit/plugin/main/java/de/kentoj/scrow/bukkit/command/friends/FriendCommand.java @@ -14,14 +14,13 @@ public final class FriendCommand { private final RootLiteral rootLiteral; public FriendCommand() { - var style = new ScrowMessageStyle("Friends", NamedTextColor.AQUA); rootLiteral = Literal.builder("f", "friend") - .withLiteral(new FriendListLiteral(style).literal()) - .withLiteral(new FriendAddLiteral(style).literal()) - .withLiteral(new FriendRemoveLiteral(style).literal()) - .withLiteral(new FriendRequestDeclineLiteral(style).literal()) - .withLiteral(new FriendRequestsLiteral(style).literal()) - .asRootLiteral(style); + .withLiteral(new FriendListLiteral().literal()) + .withLiteral(new FriendAddLiteral().literal()) + .withLiteral(new FriendRemoveLiteral().literal()) + .withLiteral(new FriendRequestDeclineLiteral().literal()) + .withLiteral(new FriendRequestsLiteral().literal()) + .asRootLiteral(new ScrowMessageStyle("Friends", NamedTextColor.AQUA)); } public static Component friendRequestOptions(String requestSenderName, boolean runInstantly) { diff --git a/core/bukkit/plugin/main/java/de/kentoj/scrow/bukkit/command/friends/FriendListLiteral.java b/core/bukkit/plugin/main/java/de/kentoj/scrow/bukkit/command/friends/FriendListLiteral.java index d1f3d99..9bb18b6 100644 --- a/core/bukkit/plugin/main/java/de/kentoj/scrow/bukkit/command/friends/FriendListLiteral.java +++ b/core/bukkit/plugin/main/java/de/kentoj/scrow/bukkit/command/friends/FriendListLiteral.java @@ -4,9 +4,9 @@ import com.leakyabstractions.result.api.Result; import com.leakyabstractions.result.core.Results; import de.kentoj.kencommandapi.api.invocation.CommandContext; import de.kentoj.kencommandapi.api.literal.Literal; +import de.kentoj.kencommandapi.api.platform.MessageStyle; import de.kentoj.scrow.bukkit.ScrowAPI; import de.kentoj.scrow.bukkit.scheduler.Tasks; -import de.kentoj.scrowlib.convention.ScrowMessageStyle; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.minimessage.MiniMessage; @@ -22,28 +22,28 @@ import static net.kyori.adventure.text.Component.text; public final class FriendListLiteral { private final Literal literal; - private final ScrowMessageStyle style; - FriendListLiteral(ScrowMessageStyle style) { - this.style = style; + FriendListLiteral() { literal = Literal.builder("list") - .withExecutor(this::displayFriendList) - .build(); + .withExecutor(this::displayFriendList) + .build(); } - private CompletableFuture> displayFriendList(CommandContext ctx) { + private CompletableFuture displayFriendList(MessageStyle style, CommandContext ctx) { var sender = ctx.sender(); return Tasks.supplyAsync(() -> ScrowAPI.friendshipService().getFriendships(sender.getUniqueId())) - .>mapSync(friendships -> { + .thenSync(friendships -> { var friends = friendships.stream() .map(friendship -> Bukkit.getOfflinePlayer(friendship.uuids().getOther(sender.getUniqueId()))) .sorted(this::compareByOnlineStatus) .toList(); - if (friends.isEmpty()) return Results.failure("You have no friends. Use /friend add "); + if (friends.isEmpty()) { + ctx.sender().sendMessage(style.err("You have no friends. Use /friend add ")); + return; + } - sender.sendMessage(formatList(friends)); - return Results.success(new Object()); + sender.sendMessage(formatList(style, friends)); }).toFuture(); } @@ -53,7 +53,7 @@ public final class FriendListLiteral { return 0; } - private Component formatList(List friends) { + private Component formatList(MessageStyle style, List friends) { var message = style.ok(MiniMessage.miniMessage().deserialize("Your friends:")); for (var friend : friends) { var status = MiniMessage.miniMessage().deserialize(friend.isOnline()