refactor whitelist command
This commit is contained in:
parent
fe9ae3e071
commit
46da96472f
2 changed files with 7 additions and 8 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue