From 63b049bb8c5c152c1a081ffc8ab4ce1aab2970be Mon Sep 17 00:00:00 2001 From: D3v1s0m <49519439+D3v1s0m@users.noreply.github.com> Date: Thu, 6 Jul 2023 19:34:14 +0530 Subject: [PATCH] null property fix if the property doesn't exist when loading. --- .../java/lol/pyr/znpcsplus/storage/yaml/YamlStorage.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugin/src/main/java/lol/pyr/znpcsplus/storage/yaml/YamlStorage.java b/plugin/src/main/java/lol/pyr/znpcsplus/storage/yaml/YamlStorage.java index 56621c1..27e8186 100644 --- a/plugin/src/main/java/lol/pyr/znpcsplus/storage/yaml/YamlStorage.java +++ b/plugin/src/main/java/lol/pyr/znpcsplus/storage/yaml/YamlStorage.java @@ -14,12 +14,14 @@ import lol.pyr.znpcsplus.storage.NpcStorage; import lol.pyr.znpcsplus.util.NpcLocation; import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; +import org.bukkit.Bukkit; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; import java.io.IOException; import java.util.*; +import java.util.logging.Level; import java.util.stream.Collectors; public class YamlStorage implements NpcStorage { @@ -59,6 +61,10 @@ public class YamlStorage implements NpcStorage { if (properties != null) { for (String key : properties.getKeys(false)) { EntityPropertyImpl property = propertyRegistry.getByName(key); + if (property == null) { + Bukkit.getLogger().log(Level.WARNING, "Unknown property '" + key + "' for npc '" + config.getString("id") + "'. skipping ..."); + continue; + } npc.UNSAFE_setProperty(property, property.deserialize(properties.getString(key))); } }