Check if config values aren't null before attempting to set them.

This commit is contained in:
extendedclip 2019-05-10 20:36:43 -04:00
parent 9377129554
commit f367abbdfa

View File

@ -20,11 +20,6 @@
*/ */
package me.clip.placeholderapi.expansion; 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.PlaceholderAPI;
import me.clip.placeholderapi.PlaceholderAPIPlugin; import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.PlaceholderHook; import me.clip.placeholderapi.PlaceholderHook;
@ -34,6 +29,12 @@ import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.Listener; 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 { public final class ExpansionManager {
private PlaceholderAPIPlugin plugin; private PlaceholderAPIPlugin plugin;
@ -65,6 +66,7 @@ public final class ExpansionManager {
String pre = "expansions." + expansion.getIdentifier() + "."; String pre = "expansions." + expansion.getIdentifier() + ".";
FileConfiguration cfg = plugin.getConfig(); FileConfiguration cfg = plugin.getConfig();
boolean save = false; boolean save = false;
if (defaults != null) {
for (Entry<String, Object> entries : defaults.entrySet()) { for (Entry<String, Object> entries : defaults.entrySet()) {
if (entries.getKey() == null || entries.getKey().isEmpty()) { if (entries.getKey() == null || entries.getKey().isEmpty()) {
continue; continue;
@ -81,6 +83,7 @@ public final class ExpansionManager {
} }
} }
} }
}
if (save) { if (save) {
plugin.saveConfig(); plugin.saveConfig();
plugin.reloadConfig(); plugin.reloadConfig();