diff --git a/src/main/java/me/metallicgoat/tweaksaddon/config/ConfigManager.java b/src/main/java/me/metallicgoat/tweaksaddon/config/ConfigManager.java index 5a19bce..79b3487 100644 --- a/src/main/java/me/metallicgoat/tweaksaddon/config/ConfigManager.java +++ b/src/main/java/me/metallicgoat/tweaksaddon/config/ConfigManager.java @@ -5,28 +5,9 @@ import de.marcely.bedwars.tools.Helper; import de.marcely.bedwars.tools.VarParticle; import de.marcely.bedwars.tools.YamlConfigurationDescriptor; -import java.io.File; -import java.io.IOException; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; import lombok.Getter; -import me.metallicgoat.tweaksaddon.utils.Console; import me.metallicgoat.tweaksaddon.MBedwarsTweaksPlugin; +import me.metallicgoat.tweaksaddon.utils.Console; import net.md_5.bungee.api.ChatColor; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; @@ -39,6 +20,19 @@ import org.bukkit.potion.PotionEffectType; import org.jetbrains.annotations.Nullable; +import java.io.File; +import java.io.IOException; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.*; +import java.util.stream.Collectors; + public class ConfigManager { @SuppressWarnings("deprecation") @@ -266,8 +260,14 @@ else if (type == Set.class) return null; // Any type of Set or List - for (Object object : strings) - collection.add(deserializeObject(field, listType, (String) object, object)); + for (Object object : strings) { + final Object deserializeObject = deserializeObject(field, listType, (String) object, object); + + if (deserializeObject != null) + collection.add(deserializeObject); + else + Console.printConfigWarn("Failed to deserialize object in list/set in the config, with the name of " + object, "Main"); + } return collection; @@ -352,7 +352,8 @@ else if (type == Set.class) // Any type of List or Set for (Object object : objectList) - lines.add((String) serializeObject(null, listType, object)); + if (object != null) + lines.add((String) serializeObject(null, listType, object)); return lines;