mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-06 16:37:38 +01:00
Implement some Adventure methods into ConsoleSender (#336)
* Implement some Adventure methods into ConsoleSender * Remove getUuid from CommandSender/ConsoleSender * rebase and review fixes Co-authored-by: mworzala <mattheworzala@gmail.com>
This commit is contained in:
parent
6870c37b94
commit
24cc458659
@ -1,6 +1,7 @@
|
||||
package net.minestom.server.command;
|
||||
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.identity.Identified;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.permission.PermissionHandler;
|
||||
@ -12,7 +13,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
* <p>
|
||||
* Main implementations are {@link Player} and {@link ConsoleSender}.
|
||||
*/
|
||||
public interface CommandSender extends PermissionHandler, Audience, Taggable {
|
||||
public interface CommandSender extends PermissionHandler, Audience, Taggable, Identified {
|
||||
|
||||
/**
|
||||
* Sends a raw string message.
|
||||
|
@ -1,7 +1,11 @@
|
||||
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;
|
||||
@ -20,6 +24,11 @@ public class ConsoleSender implements CommandSender {
|
||||
private final Set<Permission> 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);
|
||||
@ -50,4 +59,14 @@ public class ConsoleSender implements CommandSender {
|
||||
public @NotNull TagHandler tagHandler() {
|
||||
return tagHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Identity identity() {
|
||||
return this.identity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Pointers pointers() {
|
||||
return this.pointers;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.minestom.server.command;
|
||||
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.minestom.server.command.builder.CommandContext;
|
||||
import net.minestom.server.permission.Permission;
|
||||
import net.minestom.server.tag.TagHandler;
|
||||
@ -32,4 +33,9 @@ public class ServerSender implements CommandSender {
|
||||
public @NotNull TagHandler tagHandler() {
|
||||
return tagHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Identity identity() {
|
||||
return Identity.nil();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.minestom.server.command;
|
||||
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.minestom.server.command.builder.Command;
|
||||
import net.minestom.server.command.builder.CommandDispatcher;
|
||||
import net.minestom.server.permission.Permission;
|
||||
@ -134,5 +135,10 @@ public class CommandConditionTest {
|
||||
public @NotNull TagHandler tagHandler() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Identity identity() {
|
||||
return Identity.nil();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -76,5 +76,10 @@ public class CommandSenderTest {
|
||||
public @Nullable Component getMostRecentMessage() {
|
||||
return mostRecentMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Identity identity() {
|
||||
return Identity.nil();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user