diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitSenderFactory.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitSenderFactory.java index 9f1081597..2bf651878 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitSenderFactory.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitSenderFactory.java @@ -94,6 +94,11 @@ public class BukkitSenderFactory extends SenderFactory implements Sender { private final UUID uniqueId; private final String name; + private final boolean isConsole; AbstractSender(LuckPermsPlugin plugin, SenderFactory factory, T sender) { this.plugin = plugin; @@ -59,6 +60,7 @@ public final class AbstractSender implements Sender { this.sender = sender; this.uniqueId = factory.getUniqueId(this.sender); this.name = factory.getName(this.sender); + this.isConsole = this.factory.isConsole(this.sender); } @Override @@ -102,6 +104,11 @@ public final class AbstractSender implements Sender { this.factory.performCommand(this.sender, commandLine); } + @Override + public boolean isConsole() { + return this.isConsole; + } + @Override public boolean isValid() { return isConsole() || this.plugin.getBootstrap().isPlayerOnline(this.uniqueId); diff --git a/common/src/main/java/me/lucko/luckperms/common/sender/DummySender.java b/common/src/main/java/me/lucko/luckperms/common/sender/DummyConsoleSender.java similarity index 88% rename from common/src/main/java/me/lucko/luckperms/common/sender/DummySender.java rename to common/src/main/java/me/lucko/luckperms/common/sender/DummyConsoleSender.java index 8e21c7b99..8c7f31f06 100644 --- a/common/src/main/java/me/lucko/luckperms/common/sender/DummySender.java +++ b/common/src/main/java/me/lucko/luckperms/common/sender/DummyConsoleSender.java @@ -31,16 +31,16 @@ import net.luckperms.api.util.Tristate; import java.util.UUID; -public abstract class DummySender implements Sender { +public abstract class DummyConsoleSender implements Sender { private final LuckPermsPlugin platform; private final UUID uniqueId; private final String name; - public DummySender(LuckPermsPlugin plugin, UUID uniqueId, String name) { + public DummyConsoleSender(LuckPermsPlugin plugin) { this.platform = plugin; - this.uniqueId = uniqueId; - this.name = name; + this.uniqueId = Sender.CONSOLE_UUID; + this.name = Sender.CONSOLE_NAME; } @Override @@ -58,6 +58,11 @@ public abstract class DummySender implements Sender { } + @Override + public boolean isConsole() { + return true; + } + @Override public LuckPermsPlugin getPlugin() { return this.platform; diff --git a/common/src/main/java/me/lucko/luckperms/common/sender/Sender.java b/common/src/main/java/me/lucko/luckperms/common/sender/Sender.java index a9cd81d18..92d177e15 100644 --- a/common/src/main/java/me/lucko/luckperms/common/sender/Sender.java +++ b/common/src/main/java/me/lucko/luckperms/common/sender/Sender.java @@ -149,9 +149,7 @@ public interface Sender { * * @return if the sender is the console */ - default boolean isConsole() { - return CONSOLE_UUID.equals(getUniqueId()); - } + boolean isConsole(); /** * Gets whether this sender is still valid & receiving messages. diff --git a/common/src/main/java/me/lucko/luckperms/common/sender/SenderFactory.java b/common/src/main/java/me/lucko/luckperms/common/sender/SenderFactory.java index f0de00db7..797e2b6fe 100644 --- a/common/src/main/java/me/lucko/luckperms/common/sender/SenderFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/sender/SenderFactory.java @@ -62,6 +62,8 @@ public abstract class SenderFactory

implements Aut protected abstract void performCommand(T sender, String command); + protected abstract boolean isConsole(T sender); + public final Sender wrap(T sender) { Objects.requireNonNull(sender, "sender"); return new AbstractSender<>(this.plugin, this, sender); diff --git a/fabric/src/main/java/me/lucko/luckperms/fabric/FabricSenderFactory.java b/fabric/src/main/java/me/lucko/luckperms/fabric/FabricSenderFactory.java index 5bcc9aee5..5b5127d67 100644 --- a/fabric/src/main/java/me/lucko/luckperms/fabric/FabricSenderFactory.java +++ b/fabric/src/main/java/me/lucko/luckperms/fabric/FabricSenderFactory.java @@ -104,6 +104,11 @@ public class FabricSenderFactory extends SenderFactory this.senderFactory.wrap(s.getCommandSource())) - .orElseGet(() -> new DummySender(this, Sender.CONSOLE_UUID, Sender.CONSOLE_NAME) { + .orElseGet(() -> new DummyConsoleSender(this) { @Override public void sendMessage(Component message) { LPFabricPlugin.this.bootstrap.getPluginLogger().info(PlainComponentSerializer.plain().serialize(TranslationManager.render(message))); diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/NukkitSenderFactory.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/NukkitSenderFactory.java index 3ac1e2be2..dd2126b84 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/NukkitSenderFactory.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/NukkitSenderFactory.java @@ -35,6 +35,7 @@ import net.luckperms.api.util.Tristate; import cn.nukkit.Player; import cn.nukkit.command.CommandSender; +import cn.nukkit.command.ConsoleCommandSender; import java.util.Locale; import java.util.UUID; @@ -92,4 +93,8 @@ public class NukkitSenderFactory extends SenderFactory