null property fix if the property doesn't exist when loading.
This commit is contained in:
parent
ee30c7dd18
commit
63b049bb8c
1 changed files with 6 additions and 0 deletions
|
@ -14,12 +14,14 @@ import lol.pyr.znpcsplus.storage.NpcStorage;
|
||||||
import lol.pyr.znpcsplus.util.NpcLocation;
|
import lol.pyr.znpcsplus.util.NpcLocation;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class YamlStorage implements NpcStorage {
|
public class YamlStorage implements NpcStorage {
|
||||||
|
@ -59,6 +61,10 @@ public class YamlStorage implements NpcStorage {
|
||||||
if (properties != null) {
|
if (properties != null) {
|
||||||
for (String key : properties.getKeys(false)) {
|
for (String key : properties.getKeys(false)) {
|
||||||
EntityPropertyImpl<?> property = propertyRegistry.getByName(key);
|
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)));
|
npc.UNSAFE_setProperty(property, property.deserialize(properties.getString(key)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue