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)
|
.plugin(this)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
var command = WhitelistCommand.createBrigadierCommand(proxy, profileService, whitelist, config, messages);
|
var command = WhitelistCommand.createCommand(proxy, profileService, whitelist, config, messages);
|
||||||
commandManager.register(commandMeta, command);
|
commandManager.register(commandMeta, command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,12 @@ public final class WhitelistCommand {
|
||||||
private static final String PERMISSION_BASE = "globalwhitelist";
|
private static final String PERMISSION_BASE = "globalwhitelist";
|
||||||
private static final String PERMISSION_ADMIN = "globalwhitelist.admin";
|
private static final String PERMISSION_ADMIN = "globalwhitelist.admin";
|
||||||
|
|
||||||
public static BrigadierCommand createBrigadierCommand(
|
public static BrigadierCommand createCommand(
|
||||||
final ProxyServer proxy,
|
ProxyServer proxy,
|
||||||
final MinecraftProfileService profileService,
|
MinecraftProfileService profileService,
|
||||||
final Whitelist whitelist,
|
Whitelist whitelist,
|
||||||
final WhitelistConfig config,
|
WhitelistConfig config,
|
||||||
final MessagesConfig messages
|
MessagesConfig messages
|
||||||
) {
|
) {
|
||||||
var commandHandler = new WhitelistCommandHandler(proxy, profileService, whitelist, config, 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;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class WhitelistCommandHandler {
|
public record WhitelistCommandHandler(
|
||||||
private final ProxyServer proxy;
|
ProxyServer proxy,
|
||||||
private final MinecraftProfileService profileService;
|
MinecraftProfileService profileService,
|
||||||
|
Whitelist whitelist,
|
||||||
private final Whitelist whitelist;
|
WhitelistConfig config,
|
||||||
private final WhitelistConfig config;
|
MessagesConfig messages
|
||||||
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 CompletableFuture<Suggestions> suggestOnlinePlayers(CommandContext<CommandSource> ignored, SuggestionsBuilder builder) {
|
public CompletableFuture<Suggestions> suggestOnlinePlayers(CommandContext<CommandSource> ignored, SuggestionsBuilder builder) {
|
||||||
proxy.getAllPlayers().forEach(player -> builder.suggest(player.getUsername()));
|
proxy.getAllPlayers().forEach(player -> builder.suggest(player.getUsername()));
|
||||||
return builder.buildFuture();
|
return builder.buildFuture();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue