diff --git a/build.gradle.kts b/build.gradle.kts index 3657f77..3c45817 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,6 +17,15 @@ subprojects { apply(plugin = "java") apply(plugin = "io.freefair.lombok") + java { + withSourcesJar() + withJavadocJar() + } + + tasks.withType().configureEach { + (options as StandardJavadocDocletOptions).addStringOption("Xdoclint:all,-missing", "-quiet") + } + repositories { mavenCentral() maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") { @@ -41,7 +50,7 @@ subprojects { implementation("org.jetbrains:annotations:26.0.2-1") // https://projectreactor.io/docs/core/release/reference/gettingStarted.html - implementation(platform("io.projectreactor:reactor-bom:2025.0.3")) + implementation(platform("io.projectreactor:reactor-bom:2025.0.3")) implementation("io.projectreactor:reactor-core") // https://mvnrepository.com/artifact/com.google.guava/guava diff --git a/core-bukkit-api/build.gradle.kts b/core-bukkit-api/build.gradle.kts index cb7bc0e..a99140d 100644 --- a/core-bukkit-api/build.gradle.kts +++ b/core-bukkit-api/build.gradle.kts @@ -36,9 +36,9 @@ dependencies { api("org.spigotmc:spigot-api:1.21.11-R0.1-SNAPSHOT") api("net.kyori:adventure-platform-bukkit:4.4.1") - api("de.kentoj:kencommandapi-core:2.0.2") - implementation("de.kentoj:kencommandapi-bukkit:2.0.2") - api("de.kentoj:kencommandapi-bukkit:2.0.2") + api("de.kentoj.scrow:kencommandapi-core:0.2") + implementation("de.kentoj.scrow:kencommandapi-bukkit:0.2") + api("de.kentoj.scrow:kencommandapi-bukkit:0.2") } publishing { diff --git a/core-bukkit-api/src/main/java/de/kentoj/scrow/bukkit/EconomyService.java b/core-bukkit-api/src/main/java/de/kentoj/scrow/bukkit/EconomyService.java index b74ac16..35a9d85 100644 --- a/core-bukkit-api/src/main/java/de/kentoj/scrow/bukkit/EconomyService.java +++ b/core-bukkit-api/src/main/java/de/kentoj/scrow/bukkit/EconomyService.java @@ -8,26 +8,26 @@ import java.util.UUID; public interface EconomyService { /** - * @throws IllegalArgumentException if amount < 0 + * @throws IllegalArgumentException if amount is less than 0 */ Mono<@NotNull Integer> getCoins(UUID playerId); /** * @param playerId uuid of player - * @throws IllegalArgumentException if amount < 0 + * @throws IllegalArgumentException if amount is less than 0 */ Mono<@NotNull Void> depositCoins(UUID playerId, int amount); /** * @param playerId uuid of player * @return true on success, false on insufficient funds - * @throws IllegalArgumentException if amount < 0 + * @throws IllegalArgumentException if amount is less than 0 */ Mono<@NotNull Boolean> tryWithdrawCoins(UUID playerId, int amount); /** * @param playerId uuid of player - * @throws IllegalArgumentException if amount < 0 + * @throws IllegalArgumentException if amount is less than 0 */ Mono<@NotNull Void> setCoins(UUID playerId, int amount); } diff --git a/core-bukkit-api/src/main/java/de/kentoj/scrow/bukkit/friends/FriendRequestUsageException.java b/core-bukkit-api/src/main/java/de/kentoj/scrow/bukkit/friends/FriendRequestUsageException.java deleted file mode 100644 index 7d08abc..0000000 --- a/core-bukkit-api/src/main/java/de/kentoj/scrow/bukkit/friends/FriendRequestUsageException.java +++ /dev/null @@ -1,12 +0,0 @@ -package de.kentoj.scrow.bukkit.friends; - -public class FriendRequestUsageException extends RuntimeException { - - public FriendRequestUsageException(String message) { - super(message); - } - - public FriendRequestUsageException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/core-bukkit-api/src/main/java/de/kentoj/scrow/bukkit/friends/FriendsService.java b/core-bukkit-api/src/main/java/de/kentoj/scrow/bukkit/friends/FriendsService.java index 202475b..d747f52 100644 --- a/core-bukkit-api/src/main/java/de/kentoj/scrow/bukkit/friends/FriendsService.java +++ b/core-bukkit-api/src/main/java/de/kentoj/scrow/bukkit/friends/FriendsService.java @@ -10,22 +10,9 @@ public interface FriendsService { Flux<@NotNull Friendship> getFriendships(UUID playerId); - /** - * @param initiator id of player who wished to end the friendship - * @param other id of the player the initiator wants to end the friendship with - * @throws FriendRequestUsageException - */ Mono<@NotNull Boolean> removeFriend(Friendship friendship); - /** - * @param playerId - */ Flux<@NotNull FriendRequest> getIncomingFriendRequests(UUID playerId); Flux<@NotNull FriendRequest> getOutgoingFriendRequests(UUID playerId); - - /** - * @param from id of player sending the friend request - * @param to id of the player the initiator wants to befriend - */ } diff --git a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/friends/handler/FriendAddHandler.java b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/friends/handler/FriendAddHandler.java index 7536f7f..668f564 100644 --- a/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/friends/handler/FriendAddHandler.java +++ b/core-bukkit-impl/src/main/java/de/kentoj/scrow/bukkit/friends/handler/FriendAddHandler.java @@ -1,5 +1,6 @@ package de.kentoj.scrow.bukkit.friends.handler; +import de.kentoj.kencommandapi.api.processing.CommandException; import de.kentoj.scrow.bukkit.ScrowAPI; import de.kentoj.scrow.bukkit.friends.friendship.FriendshipDAO; import de.kentoj.scrow.bukkit.friends.friendship.FriendshipImpl; @@ -25,15 +26,18 @@ public class FriendAddHandler { public void handle() { findAction() .flatMap(this::executeAction) + .doOnError(CommandException.class, e -> { + ScrowAPI.getCommandManager().sendErrorMessage(self, e); + }) .subscribeOn(Schedulers.boundedElastic()) .subscribe(); } private Mono executeAction(AddAction action) { return switch (action) { - case ERR_ALREADY_FRIENDS -> sendMessage(self, "[friends] You are already friends with " + other.getName()); - case ERR_ALREADY_REQUESTED -> - sendMessage(self, "[friends] You already requested " + other.getName() + " to be friends with you"); + case ERR_CAN_NOT_ADD_SELF -> throw new CommandException("You can not add yourself"); + case ERR_ALREADY_FRIENDS -> throw new CommandException("You are already friends with " + other.getName()); + case ERR_ALREADY_REQUESTED -> throw new CommandException("You already requested " + other.getName() + " to be friends with you"); case SEND_REQUEST -> sendRequest(); case ACCEPT_REQUEST -> acceptRequest(); }; @@ -41,11 +45,11 @@ public class FriendAddHandler { private Mono sendRequest() { return friendRequestDAO.saveFriendRequest(new FriendRequestImpl(self.getUniqueId(), other.getUniqueId(), Instant.now())) - .then(sendMessage(self.getPlayer(), "[friends] Successfully sent " + other.getName() + " a friend request.")) + .then(sendMessage(self.getPlayer(), "Successfully sent " + other.getName() + " a friend request.")) .then(Mono.fromRunnable(() -> { var otherPlayer = other.getPlayer(); if (otherPlayer != null) - sendMessage(otherPlayer, "[friends] " + self.getName() + " wants to be friends with you. Use '/f add " + self.getName() + "' to accept.").subscribe(); + sendMessage(otherPlayer, self.getName() + " wants to be friends with you. Use '/f add " + self.getName() + "' to accept.").subscribe(); })) .doOnError(this::handleError); } @@ -56,16 +60,17 @@ public class FriendAddHandler { friendRequestDAO.deleteFriendRequest(other.getUniqueId(), self.getUniqueId()), friendshipDAO.saveFriendship(new FriendshipImpl(self.getUniqueId(), other.getUniqueId(), Instant.now())) ) - .then(sendMessage(self, "[friends] You are now friends with " + other.getName())) + .then(sendMessage(self, "You are now friends with " + other.getName())) .then(Mono.fromRunnable(() -> { var otherPlayer = other.getPlayer(); if (otherPlayer != null) - sendMessage(otherPlayer, "[friends] You are now friends with " + self.getName()).subscribe(); + sendMessage(otherPlayer, "You are now friends with " + self.getName()).subscribe(); })) .doOnError(this::handleError); } private Mono<@NotNull AddAction> findAction() { + if (self.getUniqueId() == other.getUniqueId()) return Mono.just(AddAction.ERR_CAN_NOT_ADD_SELF); return friendshipDAO.getFriendship(self.getUniqueId(), other.getUniqueId()) .map(f -> AddAction.ERR_ALREADY_FRIENDS) .switchIfEmpty( @@ -91,6 +96,7 @@ public class FriendAddHandler { private enum AddAction { ERR_ALREADY_FRIENDS, ERR_ALREADY_REQUESTED, + ERR_CAN_NOT_ADD_SELF, SEND_REQUEST, ACCEPT_REQUEST }