diff --git a/src/main/java/net/minestom/server/command/CommandSender.java b/src/main/java/net/minestom/server/command/CommandSender.java index 63f8f5b95..20a22bac0 100644 --- a/src/main/java/net/minestom/server/command/CommandSender.java +++ b/src/main/java/net/minestom/server/command/CommandSender.java @@ -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; *

* 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. diff --git a/src/main/java/net/minestom/server/command/ConsoleSender.java b/src/main/java/net/minestom/server/command/ConsoleSender.java index 3b31ea724..d97bc82ae 100644 --- a/src/main/java/net/minestom/server/command/ConsoleSender.java +++ b/src/main/java/net/minestom/server/command/ConsoleSender.java @@ -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 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; + } } diff --git a/src/main/java/net/minestom/server/command/ServerSender.java b/src/main/java/net/minestom/server/command/ServerSender.java index e69d01519..ee0496e01 100644 --- a/src/main/java/net/minestom/server/command/ServerSender.java +++ b/src/main/java/net/minestom/server/command/ServerSender.java @@ -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(); + } } diff --git a/src/test/java/net/minestom/server/command/CommandConditionTest.java b/src/test/java/net/minestom/server/command/CommandConditionTest.java index 0a913a8a2..f7450b020 100644 --- a/src/test/java/net/minestom/server/command/CommandConditionTest.java +++ b/src/test/java/net/minestom/server/command/CommandConditionTest.java @@ -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(); + } } } diff --git a/src/test/java/net/minestom/server/command/CommandSenderTest.java b/src/test/java/net/minestom/server/command/CommandSenderTest.java index 4e3518d69..fe2b5186f 100644 --- a/src/test/java/net/minestom/server/command/CommandSenderTest.java +++ b/src/test/java/net/minestom/server/command/CommandSenderTest.java @@ -76,5 +76,10 @@ public class CommandSenderTest { public @Nullable Component getMostRecentMessage() { return mostRecentMessage; } + + @Override + public @NotNull Identity identity() { + return Identity.nil(); + } } }