|
18 | 18 |
|
19 | 19 | import com.nisovin.magicspells.util.Util; |
20 | 20 | import com.nisovin.magicspells.MagicSpells; |
21 | | -import com.nisovin.magicspells.util.ItemUtil; |
22 | 21 | import com.nisovin.magicspells.util.itemreader.*; |
23 | 22 | import com.nisovin.magicspells.handlers.DebugHandler; |
24 | 23 | import com.nisovin.magicspells.handlers.EnchantmentHandler; |
@@ -134,23 +133,19 @@ private static MagicItemData getMagicItemDataFromItemStackInternal(ItemStack ite |
134 | 133 | // author, title, pages |
135 | 134 | WrittenBookHandler.processMagicItemData(meta, data); |
136 | 135 |
|
137 | | - // enchantments |
138 | | - Map<Enchantment, Integer> enchants = new HashMap<>(meta.getEnchants()); |
139 | | - if (ItemUtil.hasFakeEnchantment(meta)) { |
140 | | - enchants.remove(Enchantment.FROST_WALKER); |
141 | | - |
| 136 | + if (meta.hasEnchantmentGlintOverride() && meta.getEnchantmentGlintOverride()) |
142 | 137 | data.setAttribute(FAKE_GLINT, true); |
143 | | - } |
144 | | - if (!enchants.isEmpty()) data.setAttribute(ENCHANTS, enchants); |
| 138 | + |
| 139 | + // enchantments |
| 140 | + if (meta.hasEnchants()) |
| 141 | + data.setAttribute(ENCHANTS, meta.getEnchants()); |
145 | 142 |
|
146 | 143 | // attributes |
147 | 144 | AttributeHandler.processMagicItemData(meta, data); |
148 | 145 |
|
149 | 146 | // lore |
150 | | - if (meta.hasLore()) { |
151 | | - List<Component> lore = meta.lore(); |
152 | | - if (lore != null && !lore.isEmpty()) data.setAttribute(LORE, lore); |
153 | | - } |
| 147 | + if (meta.hasLore()) |
| 148 | + data.setAttribute(LORE, meta.lore()); |
154 | 149 |
|
155 | 150 | // patterns |
156 | 151 | BannerHandler.processMagicItemData(meta, data); |
@@ -218,13 +213,8 @@ public static MagicItem getMagicItemFromData(MagicItemData data) { |
218 | 213 | } |
219 | 214 | } |
220 | 215 |
|
221 | | - if (data.hasAttribute(FAKE_GLINT)) { |
222 | | - boolean fakeGlint = (boolean) data.getAttribute(FAKE_GLINT); |
223 | | - |
224 | | - if (fakeGlint && !meta.hasEnchants()) { |
225 | | - ItemUtil.addFakeEnchantment(meta); |
226 | | - } |
227 | | - } |
| 216 | + if (data.hasAttribute(FAKE_GLINT) && (boolean) data.getAttribute(FAKE_GLINT)) |
| 217 | + meta.setEnchantmentGlintOverride(true); |
228 | 218 |
|
229 | 219 | // Armor color |
230 | 220 | LeatherArmorHandler.processItemMeta(meta, data); |
@@ -412,13 +402,9 @@ public static MagicItem getMagicItemFromSection(ConfigurationSection section) { |
412 | 402 | } |
413 | 403 | } |
414 | 404 |
|
415 | | - if (section.isBoolean("fake-glint")) { |
416 | | - boolean fakeGlint = section.getBoolean("fake-glint"); |
417 | | - |
418 | | - if (fakeGlint && !meta.hasEnchants()) { |
419 | | - ItemUtil.addFakeEnchantment(meta); |
420 | | - itemData.setAttribute(FAKE_GLINT, true); |
421 | | - } |
| 405 | + if (section.getBoolean("fake-glint")) { |
| 406 | + meta.setEnchantmentGlintOverride(true); |
| 407 | + itemData.setAttribute(FAKE_GLINT, true); |
422 | 408 | } |
423 | 409 |
|
424 | 410 | // Armor color |
|
0 commit comments