refactor whitelist command
This commit is contained in:
parent
f7e40bef7c
commit
9828227f41
3 changed files with 14 additions and 29 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Suggestions> suggestOnlinePlayers(CommandContext<CommandSource> ignored, SuggestionsBuilder builder) {
|
||||
proxy.getAllPlayers().forEach(player -> builder.suggest(player.getUsername()));
|
||||
return builder.buildFuture();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue