From f367abbdfac173bff8d633ee73dea3d10428fd7f Mon Sep 17 00:00:00 2001 From: extendedclip Date: Fri, 10 May 2019 20:36:43 -0400 Subject: [PATCH] Check if config values aren't null before attempting to set them. --- .../expansion/ExpansionManager.java | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/expansion/ExpansionManager.java b/src/main/java/me/clip/placeholderapi/expansion/ExpansionManager.java index eab911f..9049ebd 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/ExpansionManager.java +++ b/src/main/java/me/clip/placeholderapi/expansion/ExpansionManager.java @@ -20,11 +20,6 @@ */ package me.clip.placeholderapi.expansion; -import java.io.File; -import java.lang.reflect.Constructor; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; import me.clip.placeholderapi.PlaceholderAPI; import me.clip.placeholderapi.PlaceholderAPIPlugin; import me.clip.placeholderapi.PlaceholderHook; @@ -34,6 +29,12 @@ import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.event.Listener; +import java.io.File; +import java.lang.reflect.Constructor; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + public final class ExpansionManager { private PlaceholderAPIPlugin plugin; @@ -65,19 +66,21 @@ public final class ExpansionManager { String pre = "expansions." + expansion.getIdentifier() + "."; FileConfiguration cfg = plugin.getConfig(); boolean save = false; - for (Entry entries : defaults.entrySet()) { - if (entries.getKey() == null || entries.getKey().isEmpty()) { - continue; - } - if (entries.getValue() == null) { - if (cfg.contains(pre + entries.getKey())) { - save = true; - cfg.set(pre + entries.getKey(), null); + if (defaults != null) { + for (Entry entries : defaults.entrySet()) { + if (entries.getKey() == null || entries.getKey().isEmpty()) { + continue; } - } else { - if (!cfg.contains(pre + entries.getKey())) { - save = true; - cfg.set(pre + entries.getKey(), entries.getValue()); + if (entries.getValue() == null) { + if (cfg.contains(pre + entries.getKey())) { + save = true; + cfg.set(pre + entries.getKey(), null); + } + } else { + if (!cfg.contains(pre + entries.getKey())) { + save = true; + cfg.set(pre + entries.getKey(), entries.getValue()); + } } } }