From 9828227f41740222fce6314b8d40c8c8f26a83d9 Mon Sep 17 00:00:00 2001 From: UrAvgCode Date: Thu, 2 Oct 2025 19:45:27 +0200 Subject: [PATCH] refactor whitelist command --- .../GlobalWhitelistPlugin.java | 2 +- .../command/WhitelistCommand.java | 12 ++++---- .../command/WhitelistCommandHandler.java | 29 +++++-------------- 3 files changed, 14 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/uravgcode/globalwhitelist/GlobalWhitelistPlugin.java b/src/main/java/com/uravgcode/globalwhitelist/GlobalWhitelistPlugin.java index b8db011..315d154 100644 --- a/src/main/java/com/uravgcode/globalwhitelist/GlobalWhitelistPlugin.java +++ b/src/main/java/com/uravgcode/globalwhitelist/GlobalWhitelistPlugin.java @@ -74,7 +74,7 @@ public class GlobalWhitelistPlugin { .plugin(this) .build(); - var command = WhitelistCommand.createBrigadierCommand(proxy, profileService, whitelist, config, messages); + var command = WhitelistCommand.createCommand(proxy, profileService, whitelist, config, messages); commandManager.register(commandMeta, command); } } diff --git a/src/main/java/com/uravgcode/globalwhitelist/command/WhitelistCommand.java b/src/main/java/com/uravgcode/globalwhitelist/command/WhitelistCommand.java index ca10e26..26f98c0 100644 --- a/src/main/java/com/uravgcode/globalwhitelist/command/WhitelistCommand.java +++ b/src/main/java/com/uravgcode/globalwhitelist/command/WhitelistCommand.java @@ -14,12 +14,12 @@ public final class WhitelistCommand { private static final String PERMISSION_BASE = "globalwhitelist"; private static final String PERMISSION_ADMIN = "globalwhitelist.admin"; - public static BrigadierCommand createBrigadierCommand( - final ProxyServer proxy, - final MinecraftProfileService profileService, - final Whitelist whitelist, - final WhitelistConfig config, - final MessagesConfig messages + public static BrigadierCommand createCommand( + ProxyServer proxy, + MinecraftProfileService profileService, + Whitelist whitelist, + WhitelistConfig config, + MessagesConfig messages ) { var commandHandler = new WhitelistCommandHandler(proxy, profileService, whitelist, config, messages); diff --git a/src/main/java/com/uravgcode/globalwhitelist/command/WhitelistCommandHandler.java b/src/main/java/com/uravgcode/globalwhitelist/command/WhitelistCommandHandler.java index 428fb87..f967949 100644 --- a/src/main/java/com/uravgcode/globalwhitelist/command/WhitelistCommandHandler.java +++ b/src/main/java/com/uravgcode/globalwhitelist/command/WhitelistCommandHandler.java @@ -14,28 +14,13 @@ import com.velocitypowered.api.proxy.ProxyServer; import java.util.concurrent.CompletableFuture; -public class WhitelistCommandHandler { - private final ProxyServer proxy; - private final MinecraftProfileService profileService; - - private final Whitelist whitelist; - private final WhitelistConfig config; - private final MessagesConfig messages; - - public WhitelistCommandHandler( - final ProxyServer proxy, - final MinecraftProfileService profileService, - final Whitelist whitelist, - final WhitelistConfig config, - final MessagesConfig messages - ) { - this.proxy = proxy; - this.profileService = profileService; - this.whitelist = whitelist; - this.config = config; - this.messages = messages; - } - +public record WhitelistCommandHandler( + ProxyServer proxy, + MinecraftProfileService profileService, + Whitelist whitelist, + WhitelistConfig config, + MessagesConfig messages +) { public CompletableFuture suggestOnlinePlayers(CommandContext ignored, SuggestionsBuilder builder) { proxy.getAllPlayers().forEach(player -> builder.suggest(player.getUsername())); return builder.buildFuture();