diff --git a/src/main/java/cc/reconnected/server/commands/AfkCommand.java b/src/main/java/cc/reconnected/server/commands/AfkCommand.java index f610908..2945fc2 100644 --- a/src/main/java/cc/reconnected/server/commands/AfkCommand.java +++ b/src/main/java/cc/reconnected/server/commands/AfkCommand.java @@ -16,7 +16,7 @@ public class AfkCommand { .requires(Permissions.require("rcc.command.afk", true)) .executes(context -> { - if(!context.getSource().isExecutedByPlayer()) { + if (!context.getSource().isExecutedByPlayer()) { context.getSource().sendFeedback(() -> Text.of("This command can only be executed by players!"), false); return 1; } diff --git a/src/main/java/cc/reconnected/server/commands/BackCommand.java b/src/main/java/cc/reconnected/server/commands/BackCommand.java index f37cc81..344f1fe 100644 --- a/src/main/java/cc/reconnected/server/commands/BackCommand.java +++ b/src/main/java/cc/reconnected/server/commands/BackCommand.java @@ -1,7 +1,6 @@ package cc.reconnected.server.commands; import cc.reconnected.server.RccServer; -import cc.reconnected.server.struct.ServerPosition; import com.mojang.brigadier.CommandDispatcher; import me.lucko.fabric.api.permissions.v0.Permissions; import net.minecraft.command.CommandRegistryAccess; @@ -17,7 +16,7 @@ public class BackCommand { var rootCommand = literal("back") .requires(Permissions.require("rcc.command.back", true)) .executes(context -> { - if(!context.getSource().isExecutedByPlayer()) { + if (!context.getSource().isExecutedByPlayer()) { context.getSource().sendFeedback(() -> Text.of("This command can only be executed by players!"), false); return 1; } @@ -25,7 +24,7 @@ public class BackCommand { var player = context.getSource().getPlayer(); var lastPosition = RccServer.lastPlayerPositions.get(player.getUuid()); - if(lastPosition == null) { + if (lastPosition == null) { context.getSource().sendFeedback(() -> Text.literal("There is no position to return back to.").formatted(Formatting.RED), false); return 1; } diff --git a/src/main/java/cc/reconnected/server/commands/FlyCommand.java b/src/main/java/cc/reconnected/server/commands/FlyCommand.java index 2c7e1b9..6375454 100644 --- a/src/main/java/cc/reconnected/server/commands/FlyCommand.java +++ b/src/main/java/cc/reconnected/server/commands/FlyCommand.java @@ -40,7 +40,7 @@ public class FlyCommand { .executes(context -> { var playerName = StringArgumentType.getString(context, "player"); var player = context.getSource().getServer().getPlayerManager().getPlayer(playerName); - if(player == null) { + if (player == null) { context.getSource().sendFeedback(() -> Text.literal("Player not found").setStyle(Style.EMPTY.withColor(Formatting.RED)), false); return 1; } diff --git a/src/main/java/cc/reconnected/server/commands/GodCommand.java b/src/main/java/cc/reconnected/server/commands/GodCommand.java index c0d793c..30d687e 100644 --- a/src/main/java/cc/reconnected/server/commands/GodCommand.java +++ b/src/main/java/cc/reconnected/server/commands/GodCommand.java @@ -39,7 +39,7 @@ public class GodCommand { .executes(context -> { var playerName = StringArgumentType.getString(context, "player"); var player = context.getSource().getServer().getPlayerManager().getPlayer(playerName); - if(player == null) { + if (player == null) { context.getSource().sendFeedback(() -> Text.literal("Player not found").setStyle(Style.EMPTY.withColor(Formatting.RED)), false); return 1; } diff --git a/src/main/java/cc/reconnected/server/commands/ReplyCommand.java b/src/main/java/cc/reconnected/server/commands/ReplyCommand.java index 8d9b9f9..fb09b9d 100644 --- a/src/main/java/cc/reconnected/server/commands/ReplyCommand.java +++ b/src/main/java/cc/reconnected/server/commands/ReplyCommand.java @@ -29,7 +29,7 @@ public class ReplyCommand { var senderName = source.getName(); var message = StringArgumentType.getString(context, "message"); - if(!TellCommand.lastSender.containsKey(senderName)) { + if (!TellCommand.lastSender.containsKey(senderName)) { source.sendFeedback(() -> Text.literal("You have no one to reply to.").setStyle(Style.EMPTY.withColor(Formatting.RED)), false); return 1; } diff --git a/src/main/java/cc/reconnected/server/commands/TeleportAcceptCommand.java b/src/main/java/cc/reconnected/server/commands/TeleportAcceptCommand.java index 11b85a3..cb3e566 100644 --- a/src/main/java/cc/reconnected/server/commands/TeleportAcceptCommand.java +++ b/src/main/java/cc/reconnected/server/commands/TeleportAcceptCommand.java @@ -2,22 +2,15 @@ package cc.reconnected.server.commands; import cc.reconnected.server.RccServer; import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.context.CommandContext; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; import net.minecraft.command.CommandRegistryAccess; -import net.minecraft.command.CommandSource; import net.minecraft.command.argument.UuidArgumentType; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Style; import net.minecraft.text.Text; import net.minecraft.util.Formatting; -import java.util.ArrayList; -import java.util.HashMap; - import static net.minecraft.server.command.CommandManager.*; public class TeleportAcceptCommand { @@ -85,7 +78,7 @@ public class TeleportAcceptCommand { return; } - if(player.getUuid().equals(request.target)) { + if (player.getUuid().equals(request.target)) { // accepted a tpa from other to self context.getSource().sendFeedback(() -> Text.literal("Teleport request accepted.").formatted(Formatting.GREEN), false); sourcePlayer.sendMessage(Text.literal("Teleporting...").formatted(Formatting.GOLD), false); diff --git a/src/main/java/cc/reconnected/server/commands/TeleportAskCommand.java b/src/main/java/cc/reconnected/server/commands/TeleportAskCommand.java index 11db5c6..f15a2f1 100644 --- a/src/main/java/cc/reconnected/server/commands/TeleportAskCommand.java +++ b/src/main/java/cc/reconnected/server/commands/TeleportAskCommand.java @@ -5,8 +5,6 @@ import cc.reconnected.server.struct.ServerPosition; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.context.CommandContext; -import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; -import net.kyori.adventure.audience.Audience; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.ComponentLike; import net.kyori.adventure.text.event.ClickCallback; @@ -63,7 +61,7 @@ public class TeleportAskCommand { } var request = new TeleportRequest(player.getUuid(), target.getUuid()); - var targetRequests = RccServer.teleportRequests.get(target.getUuid()); + var targetRequests = RccServer.teleportRequests.get(target.getUuid()); targetRequests.addLast(request); var requestMessage = Component.empty() @@ -81,11 +79,6 @@ public class TeleportAskCommand { } public static Component makeButton(ComponentLike text, ComponentLike hoverText, String command) { - var options = ClickCallback.Options.builder() - .uses(1) - .lifetime(Duration.ofSeconds(RccServer.CONFIG.teleportRequestTimeout())) - .build(); - return Component.empty() .append(Component.text("[")) .append(text) diff --git a/src/main/java/cc/reconnected/server/commands/TeleportAskHereCommand.java b/src/main/java/cc/reconnected/server/commands/TeleportAskHereCommand.java index ac44dcb..24f8ae2 100644 --- a/src/main/java/cc/reconnected/server/commands/TeleportAskHereCommand.java +++ b/src/main/java/cc/reconnected/server/commands/TeleportAskHereCommand.java @@ -53,7 +53,7 @@ public class TeleportAskHereCommand { } var request = new TeleportAskCommand.TeleportRequest(target.getUuid(), player.getUuid()); - var targetRequests = RccServer.teleportRequests.get(target.getUuid()); + var targetRequests = RccServer.teleportRequests.get(target.getUuid()); targetRequests.addLast(request); var requestMessage = Component.empty() diff --git a/src/main/java/cc/reconnected/server/commands/TeleportDenyCommand.java b/src/main/java/cc/reconnected/server/commands/TeleportDenyCommand.java index 05d59e8..60845ec 100644 --- a/src/main/java/cc/reconnected/server/commands/TeleportDenyCommand.java +++ b/src/main/java/cc/reconnected/server/commands/TeleportDenyCommand.java @@ -12,8 +12,6 @@ import net.minecraft.text.Style; import net.minecraft.text.Text; import net.minecraft.util.Formatting; -import java.util.ArrayList; - import static net.minecraft.server.command.CommandManager.argument; import static net.minecraft.server.command.CommandManager.literal; @@ -81,7 +79,7 @@ public class TeleportDenyCommand { otherPlayer = playerManager.getPlayer(request.target); } - if(otherPlayer != null) { + if (otherPlayer != null) { otherPlayer.sendMessage(Text.empty().append(player.getDisplayName()).append(Text.literal(" denied your teleport request.").formatted(Formatting.RED))); } context.getSource().sendFeedback(() -> Text.literal("You denied the teleport request.").formatted(Formatting.GOLD), false); diff --git a/src/main/java/cc/reconnected/server/commands/TellCommand.java b/src/main/java/cc/reconnected/server/commands/TellCommand.java index 85bc2ce..e424588 100644 --- a/src/main/java/cc/reconnected/server/commands/TellCommand.java +++ b/src/main/java/cc/reconnected/server/commands/TellCommand.java @@ -78,9 +78,9 @@ public class TellCommand { if (!source.getName().equals(targetName)) { source.sendMessage(text); } - if(targetPlayer != null) { + if (targetPlayer != null) { targetPlayer.sendMessage(text); - if(source.isExecutedByPlayer()) { + if (source.isExecutedByPlayer()) { source.getServer().sendMessage(text); } } else { @@ -96,13 +96,14 @@ public class TellCommand { Placeholder.component("message", parsedMessage.toText())); source.getServer().getPlayerManager().getPlayerList().forEach(player -> { var playerName = player.getGameProfile().getName(); - if(playerName.equals(targetName) || playerName.equals(source.getName())) { + if (playerName.equals(targetName) || playerName.equals(source.getName())) { return; } var playerPerms = playerAdapter.getPermissionData(player); - if(playerPerms.checkPermission("rcc.tell.spy").asBoolean()) { + if (playerPerms.checkPermission("rcc.tell.spy").asBoolean()) { player.sendMessage(spyText); - }; + } + ; }); } } diff --git a/src/main/java/cc/reconnected/server/database/PlayerData.java b/src/main/java/cc/reconnected/server/database/PlayerData.java index 201e85f..4ea5282 100644 --- a/src/main/java/cc/reconnected/server/database/PlayerData.java +++ b/src/main/java/cc/reconnected/server/database/PlayerData.java @@ -103,6 +103,7 @@ public class PlayerData { public @Nullable MetaNode getNode(String key) { return rawNodes.stream().filter(rawNode -> rawNode.getMetaKey().equals(key)).findFirst().orElse(null); } + @SuppressWarnings("UnusedReturnValue") public CompletableFuture setBoolean(String key, boolean value) { return set(key, Boolean.toString(value)); @@ -119,6 +120,7 @@ public class PlayerData { return defaultValue; return Boolean.parseBoolean(nodes.get(nodePrefix + "." + key)); } + @SuppressWarnings("UnusedReturnValue") public CompletableFuture setDate(String key, Date date) { var dateString = DateTimeFormatter.ISO_INSTANT.format(date.toInstant()); @@ -132,6 +134,7 @@ public class PlayerData { var ta = DateTimeFormatter.ISO_INSTANT.parse(dateString); return Date.from(Instant.from(ta)); } + @SuppressWarnings("UnusedReturnValue") public CompletableFuture delete(String key) { return luckPerms().getUserManager().modifyUser(uuid, user -> { diff --git a/src/main/java/cc/reconnected/server/http/ServiceServer.java b/src/main/java/cc/reconnected/server/http/ServiceServer.java index 2587aa9..e3e4445 100644 --- a/src/main/java/cc/reconnected/server/http/ServiceServer.java +++ b/src/main/java/cc/reconnected/server/http/ServiceServer.java @@ -10,6 +10,7 @@ import java.net.InetSocketAddress; public class ServiceServer { private final HttpServer server; + public HttpServer httpServer() { return this.server; } diff --git a/src/main/java/cc/reconnected/server/parser/MarkdownParser.java b/src/main/java/cc/reconnected/server/parser/MarkdownParser.java index 8fdd70e..e5cfd47 100644 --- a/src/main/java/cc/reconnected/server/parser/MarkdownParser.java +++ b/src/main/java/cc/reconnected/server/parser/MarkdownParser.java @@ -7,7 +7,7 @@ import static eu.pb4.placeholders.api.parsers.MarkdownLiteParserV1.MarkdownForma public class MarkdownParser { - public static final MarkdownFormat[] ALL = new MarkdownFormat[] { + public static final MarkdownFormat[] ALL = new MarkdownFormat[]{ MarkdownFormat.QUOTE, MarkdownFormat.BOLD, MarkdownFormat.ITALIC,