[SPIGOT-2481] EnchantmentTarget not set for every Enchantment Created: 03/Jul/16 Updated: 11/Dec/17 Resolved: 08/Jul/16 |
|
Status: | Resolved |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | Priority: | Minor |
Reporter: | sirati97 | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 1 |
Labels: | 1.10, Craftbukkit, bug, spigot |
Description |
In NMS there is a new EnchantmentSlotType called BREAKABLE. In the method that maps these to Bukkit it is missing. This causes enchantments like Mending to not have a EnchantmentTarget. org.bukkit.craftbukkit.enchantments.CraftEnchantment.java: @Override public EnchantmentTarget getItemTarget() { switch (target.itemTarget) { case ALL: return EnchantmentTarget.ALL; case ARMOR: return EnchantmentTarget.ARMOR; case ARMOR_FEET: return EnchantmentTarget.ARMOR_FEET; case ARMOR_HEAD: return EnchantmentTarget.ARMOR_HEAD; case ARMOR_LEGS: return EnchantmentTarget.ARMOR_LEGS; case ARMOR_CHEST: return EnchantmentTarget.ARMOR_TORSO; case DIGGER: return EnchantmentTarget.TOOL; case WEAPON: return EnchantmentTarget.WEAPON; case BOW: return EnchantmentTarget.BOW; case FISHING_ROD: return EnchantmentTarget.FISHING_ROD; default: return null; } } is missing: case BREAKABLE: return EnchantmentTarget.BREAKABLE; //<- also needs to be added This causes even more errors as it seems that this part is not recompiled somehow. (could also be a decompilation error) As switch case with enums goes over the ordinals of the enum, some of the ordinals are out of sync. Decompiled code builded 10 minutes ago with --rev 1.10.2 : public EnchantmentTarget getItemTarget() { switch (this.target.itemTarget) { case ALL: return EnchantmentTarget.ALL; case ARMOR: return EnchantmentTarget.ARMOR; case ARMOR_CHEST: return EnchantmentTarget.ARMOR_FEET; case ARMOR_LEGS: return EnchantmentTarget.ARMOR_HEAD; case ARMOR_FEET: return EnchantmentTarget.ARMOR_LEGS; case ARMOR_HEAD: return EnchantmentTarget.ARMOR_TORSO; case BREAKABLE: return EnchantmentTarget.TOOL; case BOW: return EnchantmentTarget.WEAPON; case WEAPON: return EnchantmentTarget.BOW; case DIGGER: return EnchantmentTarget.FISHING_ROD; } return null; } |