classpublicPriority 1
WhitelistRemoveCommand
com.hypixel.hytale.server.core.modules.accesscontrol.commands.WhitelistRemoveCommand
extends AbstractAsyncCommand
0
Methods
0
Public Methods
1
Fields
1
Constructors
Constructors
public
WhitelistRemoveCommand(HytaleWhitelistProvider whitelistProvider)Fields
Private/Package Fields (1)
private
HytaleWhitelistProvider whitelistProviderInheritance
Parent
Current
Interface
Child
Use mouse wheel to zoom, drag to pan. Click nodes to navigate.
Related Classes
Source Code
package com.hypixel.hytale.server.core.modules.accesscontrol.commands;
import com.hypixel.hytale.server.core.Message;
import com.hypixel.hytale.server.core.auth.ProfileServiceClient;
import com.hypixel.hytale.server.core.command.system.CommandContext;
import com.hypixel.hytale.server.core.command.system.arguments.system.RequiredArg;
import com.hypixel.hytale.server.core.command.system.arguments.types.ArgTypes;
import com.hypixel.hytale.server.core.command.system.basecommands.AbstractAsyncCommand;
import com.hypixel.hytale.server.core.modules.accesscontrol.provider.HytaleWhitelistProvider;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nonnull;
public class WhitelistRemoveCommand extends AbstractAsyncCommand {
@Nonnull
private final HytaleWhitelistProvider whitelistProvider;
@Nonnull
private final RequiredArg<ProfileServiceClient.PublicGameProfile> playerArg = this.withRequiredArg(
"player", "server.commands.whitelist.remove.player.desc", ArgTypes.GAME_PROFILE_LOOKUP
);
public WhitelistRemoveCommand(@Nonnull HytaleWhitelistProvider whitelistProvider) {
super("remove", "server.commands.whitelist.remove.desc");
this.whitelistProvider = whitelistProvider;
}
@Nonnull
@Override
protected CompletableFuture<Void> executeAsync(@Nonnull CommandContext context) {
ProfileServiceClient.PublicGameProfile profile = this.playerArg.get(context);
if (profile == null) {
return CompletableFuture.completedFuture(null);
} else {
UUID uuid = profile.getUuid();
Message displayMessage = Message.raw(profile.getUsername()).bold(true);
if (this.whitelistProvider.modify(list -> list.remove(uuid))) {
context.sendMessage(Message.translation("server.modules.whitelist.removalSuccess").param("uuid", displayMessage));
} else {
context.sendMessage(Message.translation("server.modules.whitelist.uuidNotWhitelisted").param("uuid", displayMessage));
}
return CompletableFuture.completedFuture(null);
}
}
}