Fix sponge config loading - closes #407

This commit is contained in:
Luck 2017-07-31 22:26:59 +01:00
parent 234b9cafd7
commit 8618a67e2e
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B

View File

@ -33,6 +33,7 @@ import com.google.common.base.Splitter;
import me.lucko.luckperms.common.config.AbstractConfiguration;
import ninja.leaping.configurate.ConfigurationNode;
import ninja.leaping.configurate.SimpleConfigurationNode;
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
import ninja.leaping.configurate.hocon.HoconConfigurationLoader;
import ninja.leaping.configurate.loader.ConfigurationLoader;
@ -86,8 +87,16 @@ public class SpongeConfig extends AbstractConfiguration {
Iterable<String> paths = Splitter.on('.').split(path);
ConfigurationNode node = root;
if (node == null) {
throw new RuntimeException("Config is not loaded.");
}
for (String s : paths) {
node = node.getNode(s);
if (node == null) {
return SimpleConfigurationNode.root();
}
}
return node;