1.15.1 ItemStack#getEnchantmentLevel() will return a maximum level of 255

Discussion in 'Spigot Plugin Development' started by JustBru00, Jan 15, 2020.

Thread Status:
Not open for further replies.
  1. I have discovered while testing my plugin this evening, that ItemStack#getEnchantmentLevel() will return a maximum level of 255 on spigot 1.15.1.

    My 1.15.1 server is running git-Spigot-037559e-01334e7 (MC: 1.15.1) (Implementing API version 1.15.1-R0.1-SNAPSHOT) which is the latest as of this post.

    The expected behavior would be to return the actual level of the enchantment. The exact same method will return the accurate enchantment level, even if it is above level 255, on spigot 1.14.4. Specifically git-Spigot-cbd1a1b-009d8af (MC: 1.14.4) (Implementing API version 1.14.4-R0.1-SNAPSHOT).

    I could not find a documented reason for this change and the ItemStack#getEnchantmentLevel() method is not depreciated.

    As a workaround for this issue, the ItemStack#getEnchantments() method will return a Map<Enchantment, Integer> with the correct enchantment level on both 1.14.4 and 1.15.1.

    On 1.15.1:
    [​IMG]

    On 1.14.4:
    [​IMG]

    I created this post as a service to other developers who may encounter this issue.

    Justin B.
     
  2. md_5

    Administrator Developer

    This is not a bug tracker.

    That being said Mojang changed it so the maximum enchantment level is 255.
    Even though your item says it has a lure level of 4341, it behaves exactly the same as if the level was 'only' 255.
     
    • Informative Informative x 1
Thread Status:
Not open for further replies.