Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-5241

ItemMeta#setAttributeModifiers causes NullPointerException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • git-Spigot-e5b1b5d-803eaa3 (MC: 1.14.4) (Implementing API version 1.14.4-R0.1-SNAPSHOT)
    • Yes

      My plugin called ItemMeta#setAttributeModifiers to set attribute modifiers, then the method threw NullPointerException

       

      private Multimap<Attribute, AttributeModifier> attributeModifiers = HashMultimap.create();
      // ...................
      meta.setAttributeModifiers(attributeModifiers);
      

       

      The problem could be resolved temporarily by calling ItemMeta#addAttributeModifiers

      attributeModifiers.forEach(meta::addAttributeModifier);
      

       

      Stacktrace:

      java.lang.NullPointerException: nulljava.lang.NullPointerException: null at org.bukkit.craftbukkit.v1_14_R1.inventory.CraftMetaItem.setAttributeModifiers(CraftMetaItem.java:1014) ~[spigot.jar:git-Spigot-e5b1b5d-803eaa3] at dev.anhcraft.abif.PreparedItem.build(PreparedItem.java:150) ~[?:?] at dev.anhcraft.abifplugin.Abifplugin.lambda$reload$2(Abifplugin.java:64) ~[?:?] at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?] at dev.anhcraft.abifplugin.Abifplugin.reload(Abifplugin.java:64) ~[?:?] at dev.anhcraft.abifplugin.Abifplugin.onEnable(Abifplugin.java:23) ~[?:?] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[spigot.jar:git-Spigot-e5b1b5d-803eaa3] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:352) [spigot.jar:git-Spigot-e5b1b5d-803eaa3] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:417) [spigot.jar:git-Spigot-e5b1b5d-803eaa3] at org.bukkit.craftbukkit.v1_14_R1.CraftServer.enablePlugin(CraftServer.java:461) [spigot.jar:git-Spigot-e5b1b5d-803eaa3] at org.bukkit.craftbukkit.v1_14_R1.CraftServer.enablePlugins(CraftServer.java:375) [spigot.jar:git-Spigot-e5b1b5d-803eaa3] at net.minecraft.server.v1_14_R1.MinecraftServer.a(MinecraftServer.java:449) [spigot.jar:git-Spigot-e5b1b5d-803eaa3] at net.minecraft.server.v1_14_R1.DedicatedServer.init(DedicatedServer.java:266) [spigot.jar:git-Spigot-e5b1b5d-803eaa3] at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:775) [spigot.jar:git-Spigot-e5b1b5d-803eaa3]
      

       

      I suppose this caused as #setAttributeModifiers() does not have #checkAttributeList()
       

            Unassigned Unassigned
            anhcraft Duy Anh
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: