refactor whitelist command

This commit is contained in:
UrAvgCode 2025-09-10 12:44:52 +02:00
parent fe9ae3e071
commit 46da96472f
No known key found for this signature in database
GPG key ID: 8A76A22B2CDDD634
2 changed files with 7 additions and 8 deletions

View file

@ -24,7 +24,7 @@ public final class WhitelistCommand {
) {
var commandHandler = new WhitelistCommandHandler(proxy, profileService, whitelist, config, messages);
LiteralCommandNode<CommandSource> helloNode = BrigadierCommand.literalArgumentBuilder("globalwhitelist")
var rootNode = BrigadierCommand.literalArgumentBuilder("globalwhitelist")
.requires(source -> source.hasPermission(PERMISSION_BASE) || source.hasPermission(PERMISSION_ADMIN))
.executes(commandHandler::help)
.then(buildAddCommand(commandHandler))
@ -37,7 +37,7 @@ public final class WhitelistCommand {
.then(buildUnenforcedCommand(commandHandler))
.build();
return new BrigadierCommand(helloNode);
return new BrigadierCommand(rootNode);
}
private static LiteralArgumentBuilder<CommandSource> buildAddCommand(WhitelistCommandHandler handler) {

View file

@ -98,7 +98,7 @@ public class WhitelistCommandHandler {
}
public int on(CommandContext<CommandSource> context) {
CommandSource source = context.getSource();
var source = context.getSource();
if (config.whitelistEnabled()) {
source.sendMessage(messages.getMessage(MessagesConfig.WHITELIST_ON_ALREADY));
@ -118,7 +118,7 @@ public class WhitelistCommandHandler {
}
public int off(CommandContext<CommandSource> context) {
CommandSource source = context.getSource();
var source = context.getSource();
if (config.whitelistEnabled()) {
config.setWhitelistEnabled(false);
@ -131,7 +131,7 @@ public class WhitelistCommandHandler {
}
public int enforced(CommandContext<CommandSource> context) {
CommandSource source = context.getSource();
var source = context.getSource();
if (config.enforceWhitelistEnabled()) {
source.sendMessage(messages.getMessage(MessagesConfig.WHITELIST_ENFORCED_ALREADY));
@ -151,7 +151,7 @@ public class WhitelistCommandHandler {
}
public int unenforced(CommandContext<CommandSource> context) {
CommandSource source = context.getSource();
var source = context.getSource();
if (config.enforceWhitelistEnabled()) {
config.setEnforceWhitelistEnabled(false);
@ -167,8 +167,7 @@ public class WhitelistCommandHandler {
whitelist.reload();
config.reload();
messages.reload();
CommandSource source = context.getSource();
source.sendMessage(messages.getMessage(MessagesConfig.WHITELIST_RELOAD));
context.getSource().sendMessage(messages.getMessage(MessagesConfig.WHITELIST_RELOAD));
return Command.SINGLE_SUCCESS;
}
}