|
1 | 1 | package studio.magemonkey.divinity.modules; |
2 | 2 |
|
3 | 3 | import org.apache.commons.lang3.ArrayUtils; |
4 | | -import org.bukkit.Bukkit; |
5 | 4 | import org.bukkit.Color; |
6 | 5 | import org.bukkit.Material; |
7 | 6 | import org.bukkit.NamespacedKey; |
8 | 7 | import org.bukkit.attribute.Attribute; |
9 | 8 | import org.bukkit.attribute.AttributeModifier; |
10 | 9 | import org.bukkit.configuration.InvalidConfigurationException; |
11 | 10 | import org.bukkit.enchantments.Enchantment; |
12 | | -import org.bukkit.inventory.EquipmentSlot; |
13 | 11 | import org.bukkit.inventory.ItemFlag; |
14 | 12 | import org.bukkit.inventory.ItemStack; |
15 | 13 | import org.bukkit.inventory.meta.*; |
@@ -137,25 +135,16 @@ public ModuleItem(@NotNull Divinity plugin, @NotNull JYML cfg, @NotNull QModuleD |
137 | 135 |
|
138 | 136 | this.attributes = new HashMap<>(); |
139 | 137 | for (String attr : cfg.getSection("attributes")) { |
140 | | - String[] attrData = cfg.getString("attributes." + attr, "").split(":"); |
141 | | - double value = Double.parseDouble(attrData[0]); |
142 | | - String operation = attrData.length > 1 ? attrData[1] : "ADD_NUMBER"; |
143 | | - String equipmentSlot = attrData.length > 2 ? attrData[2] : null; |
144 | | - NBTAttribute nbtAttr = NBTAttribute.valueOf(attr.toUpperCase()); |
145 | | - |
146 | | - // Check attribute through compat support |
147 | | - AttributeModifier attrModifier = VersionManager.getCompat().createAttributeModifier(nbtAttr, value, AttributeModifier.Operation.valueOf(operation)); |
| 138 | + String[] attrData = cfg.getString("attributes." + attr, "").split(":"); |
| 139 | + double value = Double.parseDouble(attrData[0]); |
| 140 | + String operation = attrData.length > 1 ? attrData[1] : "ADD_NUMBER"; |
| 141 | + NBTAttribute nbtAttr = NBTAttribute.valueOf(attr.toUpperCase()); |
| 142 | + AttributeModifier attrModifier = VersionManager.getCompat() |
| 143 | + .createAttributeModifier(nbtAttr, value, AttributeModifier.Operation.valueOf(operation)); |
148 | 144 | if (attrModifier == null) { |
149 | 145 | Codex.warn("Invalid attribute provided: " + attr + " (" + cfg.getFile().getName() + ")"); |
150 | 146 | continue; |
151 | 147 | } |
152 | | - // If everything was fine and equipmentslot != null, recreate the modifier including the equipment slot |
153 | | - if(equipmentSlot != null) { |
154 | | - EquipmentSlot slot = EquipmentSlot.valueOf(equipmentSlot.toUpperCase()); |
155 | | - attrModifier = new AttributeModifier(attrModifier.getUniqueId(), attrModifier.getName(), attrModifier.getAmount(), attrModifier.getOperation(), slot); |
156 | | - // Debug |
157 | | - Bukkit.getLogger().info("Registered attribute " + nbtAttr.name() + " with value " + value + ", operation " + operation + " and equipment slot " + equipmentSlot + " for item " + this.getId()); |
158 | | - } |
159 | 148 | this.attributes.put(nbtAttr.getAttribute(), attrModifier); |
160 | 149 | } |
161 | 150 |
|
@@ -288,7 +277,6 @@ protected ItemStack build(@NotNull ItemStack item) { |
288 | 277 |
|
289 | 278 | for (Map.Entry<Attribute, AttributeModifier> attribute : this.attributes.entrySet()) { |
290 | 279 | if (attribute != null) { |
291 | | - AttributeModifier mod = new AttributeModifier(attribute.getValue().getName(), attribute.getValue().getAmount(), attribute.getValue().getOperation()); |
292 | 280 | meta.addAttributeModifier(attribute.getKey(), attribute.getValue()); |
293 | 281 | } |
294 | 282 | } |
|
0 commit comments