This commit is contained in:
kento2 2026-08-10 02:44:17 +02:00
parent a9b7f47494
commit a088d27485
15 changed files with 65 additions and 74 deletions

View file

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

View file

@ -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",

View file

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

View file

@ -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<T> {
boolean requiresValue();
void execute(
ScrowMessageStyle style,
MessageStyle style,
T node,
CommandContext<Player> ctx
);

View file

@ -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<S extends ConfigNode<S>> implements ConfigOp
}
@Override
public void execute(ScrowMessageStyle style, S node, CommandContext<Player> ctx) {
public void execute(MessageStyle style, S node, CommandContext<Player> ctx) {
var jsonElement = node.type().serialize(node.value());
var prettyJson = GSON.toJson(jsonElement, JsonElement.class);
var component = Component.text(prettyJson + " [click to copy]")

View file

@ -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<S, T extends ConfigNode<S>> implements ConfigOp
}
@Override
public void execute(ScrowMessageStyle style, T node, CommandContext<Player> ctx) {
public void execute(MessageStyle style, T node, CommandContext<Player> ctx) {
pick(ctx.sender())
.orTimeout(10, TimeUnit.MINUTES)
.whenComplete((picked, ex) -> {

View file

@ -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.<Player>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());
}

View file

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

View file

@ -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<ConfigValueNode<Locat
}
@Override
public void execute(ScrowMessageStyle style, ConfigValueNode<Location> node, CommandContext<Player> ctx) {
public void execute(MessageStyle style, ConfigValueNode<Location> node, CommandContext<Player> ctx) {
ctx.sender().teleport(node.value());
ctx.sender().sendMessage(style.ok("You've been teleported."));
}

View file

@ -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<World> {
}
@Override
public void execute(ScrowMessageStyle style, ConfigValueNode<World> node, CommandContext<Player> ctx) {
public void execute(MessageStyle style, ConfigValueNode<World> node, CommandContext<Player> ctx) {
World world = ctx.getArg("world");
node.value(world);
ctx.sender().sendMessage(style.ok("Set world to " + world.getName() + "("+ world.getUID() + ")"));

View file

@ -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<Player> rootLiteral;
private final MessageStyle style;
public CoinsCommand() {
style = ScrowMessageStyle.GENERIC;
rootLiteral = Literal.<Player>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<Result<Object, String>> execute(CommandContext<Player> ctx) {
public CompletableFuture<?> execute(MessageStyle style, CommandContext<Player> ctx) {
var player = ctx.sender();
return Tasks.supplyAsync(() ->
ScrowAPI.economyService().getCoins(player.getUniqueId()))
.<Result<Object, String>>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<Player> rootLiteral() {

View file

@ -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<Player> literal;
private final MessageStyle style;
private final CommandArgumentSpec<Player, OfflinePlayer> playerArg;
public CoinsGetLiteral(MessageStyle style) {
this.style = style;
public CoinsGetLiteral() {
playerArg = CommandArgumentSpec.builder("player", new OfflinePlayerArgumentType<Player>())
.withDefaultValue(CommandContext::sender)
.build();
@ -33,14 +28,13 @@ public final class CoinsGetLiteral {
.build();
}
private CompletableFuture<Result<Object, String>> execute(CommandContext<Player> ctx) {
private CompletableFuture<?> execute(MessageStyle style, CommandContext<Player> ctx) {
var player = ctx.getArg(playerArg);
return Tasks.supplyAsync(() ->
ScrowAPI.economyService().getCoins(player.getUniqueId()))
.<Result<Object, String>>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<Player> literal() {

View file

@ -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<Player> literal;
private final MessageStyle style;
private final CommandArgumentSpec<Player, OfflinePlayer> playerArg;
private final CommandArgumentSpec<Player, Integer> amountArg;
CoinsSetLiteral(MessageStyle style) {
this.style = style;
CoinsSetLiteral() {
playerArg = CommandArgumentSpec.builder("player", new OfflinePlayerArgumentType<Player>())
.withDefaultValue(CommandContext::sender)
.build();
@ -37,15 +33,14 @@ public final class CoinsSetLiteral {
.build();
}
private CompletableFuture<Result<Object, String>> execute(CommandContext<Player> ctx) {
private CompletableFuture<?> execute(MessageStyle style, CommandContext<Player> ctx) {
var player = ctx.getArg(playerArg);
var amount = ctx.getArg(amountArg);
return Tasks.runAsync(() ->
ScrowAPI.economyService().setCoins(player.getUniqueId(), amount))
.<Result<Object, String>>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<Player> literal() {

View file

@ -14,14 +14,13 @@ public final class FriendCommand {
private final RootLiteral<Player> rootLiteral;
public FriendCommand() {
var style = new ScrowMessageStyle("Friends", NamedTextColor.AQUA);
rootLiteral = Literal.<Player>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) {

View file

@ -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<Player> literal;
private final ScrowMessageStyle style;
FriendListLiteral(ScrowMessageStyle style) {
this.style = style;
FriendListLiteral() {
literal = Literal.<Player>builder("list")
.withExecutor(this::displayFriendList)
.build();
.withExecutor(this::displayFriendList)
.build();
}
private CompletableFuture<Result<Object, String>> displayFriendList(CommandContext<Player> ctx) {
private CompletableFuture<?> displayFriendList(MessageStyle style, CommandContext<Player> ctx) {
var sender = ctx.sender();
return Tasks.supplyAsync(() ->
ScrowAPI.friendshipService().getFriendships(sender.getUniqueId()))
.<Result<Object, String>>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 <player>");
if (friends.isEmpty()) {
ctx.sender().sendMessage(style.err("You have no friends. Use /friend add <player>"));
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<OfflinePlayer> friends) {
private Component formatList(MessageStyle style, List<OfflinePlayer> friends) {
var message = style.ok(MiniMessage.miniMessage().deserialize("Your friends:"));
for (var friend : friends) {
var status = MiniMessage.miniMessage().deserialize(friend.isOnline()