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 d2663045..d8898870 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitSenderFactory.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitSenderFactory.java @@ -28,7 +28,6 @@ package me.lucko.luckperms.bukkit; import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.bukkit.compat.MessageHandler; import me.lucko.luckperms.common.commands.sender.SenderFactory; -import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.constants.Constants; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; @@ -53,7 +52,7 @@ public class BukkitSenderFactory extends SenderFactory { if (sender instanceof Player) { return sender.getName(); } - return Constants.CONSOLE_NAME.apply(getPlugin().getConfiguration().get(ConfigKeys.SERVER)); + return getConsoleName(); } @Override diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeSenderFactory.java b/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeSenderFactory.java index 812bc67e..2b044660 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeSenderFactory.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeSenderFactory.java @@ -28,7 +28,6 @@ package me.lucko.luckperms.bungee; import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.bungee.event.TristateCheckEvent; import me.lucko.luckperms.common.commands.sender.SenderFactory; -import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.constants.Constants; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.TextUtils; @@ -51,7 +50,7 @@ public class BungeeSenderFactory extends SenderFactory { if (sender instanceof ProxiedPlayer) { return sender.getName(); } - return Constants.CONSOLE_NAME.apply(getPlugin().getConfiguration().get(ConfigKeys.SERVER)); + return getConsoleName(); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/sender/SenderFactory.java b/common/src/main/java/me/lucko/luckperms/common/commands/sender/SenderFactory.java index 4f17e968..1e05b2ff 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/sender/SenderFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/sender/SenderFactory.java @@ -31,6 +31,9 @@ import lombok.NonNull; import lombok.RequiredArgsConstructor; import me.lucko.luckperms.api.Tristate; +import me.lucko.luckperms.common.config.ConfigKeys; +import me.lucko.luckperms.common.config.LuckPermsConfiguration; +import me.lucko.luckperms.common.constants.Constants; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import net.kyori.text.Component; @@ -60,6 +63,16 @@ public abstract class SenderFactory { protected abstract boolean hasPermission(T t, String node); + protected String getConsoleName() { + LuckPermsConfiguration config = getPlugin().getConfiguration(); + return config == null ? Constants.CONSOLE_NAME.apply(null) : Constants.CONSOLE_NAME.apply(config.get(ConfigKeys.SERVER)); + } + + protected String getImportName() { + LuckPermsConfiguration config = getPlugin().getConfiguration(); + return config == null ? Constants.IMPORT_NAME.apply(null) : Constants.IMPORT_NAME.apply(config.get(ConfigKeys.SERVER)); + } + public final Sender wrap(@NonNull T sender) { return new AbstractSender<>(plugin, this, sender); } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java b/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java index 8380a0dc..d7f67263 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java @@ -454,7 +454,8 @@ public class LPSpongePlugin implements LuckPermsPlugin { @Override public String getName() { - return Constants.CONSOLE_NAME.apply(getConfiguration().get(ConfigKeys.SERVER)); + LuckPermsConfiguration config = getPlatform().getConfiguration(); + return config == null ? Constants.CONSOLE_NAME.apply(null) : Constants.CONSOLE_NAME.apply(config.get(ConfigKeys.SERVER)); } @Override diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeSenderFactory.java b/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeSenderFactory.java index e325c36c..e2728600 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeSenderFactory.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeSenderFactory.java @@ -27,7 +27,6 @@ package me.lucko.luckperms.sponge; import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.common.commands.sender.SenderFactory; -import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.constants.Constants; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.utils.TextUtils; @@ -52,7 +51,7 @@ public class SpongeSenderFactory extends SenderFactory { if (source instanceof Player) { return source.getName(); } - return Constants.CONSOLE_NAME.apply(getPlugin().getConfiguration().get(ConfigKeys.SERVER)); + return getConsoleName(); } @Override