Fix NPE on startup (#520)
This commit is contained in:
parent
54695b8046
commit
e8896fbdf7
@ -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<CommandSender> {
|
||||
if (sender instanceof Player) {
|
||||
return sender.getName();
|
||||
}
|
||||
return Constants.CONSOLE_NAME.apply(getPlugin().getConfiguration().get(ConfigKeys.SERVER));
|
||||
return getConsoleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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<CommandSender> {
|
||||
if (sender instanceof ProxiedPlayer) {
|
||||
return sender.getName();
|
||||
}
|
||||
return Constants.CONSOLE_NAME.apply(getPlugin().getConfiguration().get(ConfigKeys.SERVER));
|
||||
return getConsoleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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<T> {
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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<CommandSource> {
|
||||
if (source instanceof Player) {
|
||||
return source.getName();
|
||||
}
|
||||
return Constants.CONSOLE_NAME.apply(getPlugin().getConfiguration().get(ConfigKeys.SERVER));
|
||||
return getConsoleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user