From 0148ea838070c22b4d18cde0e07ef62ddc0171e4 Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Wed, 20 Nov 2024 23:33:08 +0800 Subject: [PATCH] fix: The option of Attribute Modify appears in configurations that don't contain such ability --- .../options/AttributeModifyOption.java | 27 ++++++++++++------- .../skill/SkillsConfigurationStoreNew.java | 2 +- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/main/java/xyz/nifeather/morph/abilities/options/AttributeModifyOption.java b/src/main/java/xyz/nifeather/morph/abilities/options/AttributeModifyOption.java index edb704ed..1efbfa41 100644 --- a/src/main/java/xyz/nifeather/morph/abilities/options/AttributeModifyOption.java +++ b/src/main/java/xyz/nifeather/morph/abilities/options/AttributeModifyOption.java @@ -69,20 +69,27 @@ public ISkillOption fromMap(@Nullable Map map) var modifiers = map == null ? null : tryGet(map, "modifiers", List.class); var defaultInfo = new AttributeInfo(); - if (modifiers != null) modifiers.forEach(o -> + if (modifiers != null) { - if (!(o instanceof Map optionMap)) return; + modifiers.forEach(o -> + { + if (!(o instanceof Map optionMap)) return; - var mmap = new Object2ObjectOpenHashMap(); + var mmap = new Object2ObjectOpenHashMap(); - optionMap.forEach((k, v) -> - { - if (!(k instanceof String kStr)) return; - mmap.put(kStr, v); - }); + optionMap.forEach((k, v) -> + { + if (!(k instanceof String kStr)) return; + mmap.put(kStr, v); + }); - instance.modifiers.add((AttributeInfo) defaultInfo.fromMap(mmap)); - }); + instance.modifiers.add((AttributeInfo) defaultInfo.fromMap(mmap)); + }); + } + else + { + return null; + } return instance; } diff --git a/src/main/java/xyz/nifeather/morph/storage/skill/SkillsConfigurationStoreNew.java b/src/main/java/xyz/nifeather/morph/storage/skill/SkillsConfigurationStoreNew.java index 06671484..62f51738 100644 --- a/src/main/java/xyz/nifeather/morph/storage/skill/SkillsConfigurationStoreNew.java +++ b/src/main/java/xyz/nifeather/morph/storage/skill/SkillsConfigurationStoreNew.java @@ -62,7 +62,7 @@ private void update(int currentVersion) private void migrate_attribute() { - logger.info("Migrating attribute names..."); + logger.info("Starting migration of attribute names..."); var files = directoryStorage.getFiles(".*\\.json$"); var abilityInstance = new AttributeModifyingAbility();