net.minestom.server.command.ConsoleSender Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of minestom-snapshots Show documentation
Show all versions of minestom-snapshots Show documentation
1.20.4 Lightweight Minecraft server
package net.minestom.server.command;
import java.util.UUID;
import net.kyori.adventure.audience.MessageType;
import net.kyori.adventure.identity.Identified;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.pointer.Pointers;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.logger.slf4j.ComponentLogger;
import net.minestom.server.permission.Permission;
import net.minestom.server.tag.TagHandler;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
/**
* Represents the console when sending a command to the server.
*/
public class ConsoleSender implements CommandSender {
private static final ComponentLogger LOGGER = ComponentLogger.logger(ConsoleSender.class);
private final Set permissions = new CopyOnWriteArraySet<>();
private final TagHandler tagHandler = TagHandler.newHandler();
private final Identity identity = Identity.nil();
private final Pointers pointers = Pointers.builder()
.withStatic(Identity.UUID, this.identity.uuid())
.build();
@Override
public void sendMessage(@NotNull String message) {
LOGGER.info(message);
}
@Override
public void sendMessage(@NotNull Identity source, @NotNull Component message, @NotNull MessageType type) {
LOGGER.info(message);
}
@NotNull
@Override
public Set getAllPermissions() {
return permissions;
}
@Override
public boolean isConsole() {
return true;
}
@Override
public ConsoleSender asConsole() {
return this;
}
@Override
public @NotNull TagHandler tagHandler() {
return tagHandler;
}
@Override
public @NotNull Identity identity() {
return this.identity;
}
@Override
public @NotNull Pointers pointers() {
return this.pointers;
}
}