WhitelistRemoveCommand.java
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;
public WhitelistRemoveCommand(@Nonnull HytaleWhitelistProvider whitelistProvider) {
super("remove", "server.commands.whitelist.remove.desc");
this.playerArg = this.withRequiredArg("player", "server.commands.whitelist.remove.player.desc", ArgTypes.GAME_PROFILE_LOOKUP);
this.whitelistProvider = whitelistProvider;
}
@Nonnull
protected CompletableFuture<Void> executeAsync(@Nonnull CommandContext context) {
ProfileServiceClient.PublicGameProfile profile = (ProfileServiceClient.PublicGameProfile)this.playerArg.get(context);
if (profile == null) {
return CompletableFuture.completedFuture((Object)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((Object)null);
}
}
}