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

Error when checking if list contains custom skull item

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Minor Minor
    • None
    • None
    • Tested on both Windows and Linux using Java 8 and the latest spigot build (build today)

    • 1.15.2
    • Mobheads
    • Yes

       When I add a skull with custom texture and save that to a ArrayList and do a contains check on that list using the item object from EntityPickupItemEvent I get the following error. This only seems to happen with skulls that have a custom texture.

      [21:23:00] [Server thread/ERROR]: Could not pass event EntityPickupItemEvent to MobHeads v1.0.0
      org.bukkit.event.EventException: null
              at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:319) ~[spigot-1.15.2.jar:git-Spigot-2040c4c-1872231]
              at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[spigot-1.15.2.jar:git-Spigot-2040c4c-1872231]
              at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:589) [spigot-1.15.2.jar:git-Spigot-2040c4c-1872231]
              at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:576) [spigot-1.15.2.jar:git-Spigot-2040c4c-1872231]
              at net.minecraft.server.v1_15_R1.EntityItem.pickup(EntityItem.java:339) [spigot-1.15.2.jar:git-Spigot-2040c4c-1872231]
              at net.minecraft.server.v1_15_R1.EntityHuman.c(EntityHuman.java:482) [spigot-1.15.2.jar:git-Spigot-2040c4c-1872231]
              at net.minecraft.server.v1_15_R1.EntityHuman.movementTick(EntityHuman.java:455) [spigot-1.15.2.jar:git-Spigot-2040c4c-1872231]
              at net.minecraft.server.v1_15_R1.EntityLiving.tick(EntityLiving.java:2356) [spigot-1.15.2.jar:git-Spigot-2040c4c-1872231]
              at net.minecraft.server.v1_15_R1.EntityHuman.tick(EntityHuman.java:162) [spigot-1.15.2.jar:git-Spigot-2040c4c-1872231]
              at net.minecraft.server.v1_15_R1.EntityPlayer.playerTick(EntityPlayer.java:399) [spigot-1.15.2.jar:git-Spigot-2040c4c-1872231]
              at net.minecraft.server.v1_15_R1.PlayerConnection.tick(PlayerConnection.java:143) [spigot-1.15.2.jar:git-Spigot-2040c4c-1872231]
              at net.minecraft.server.v1_15_R1.NetworkManager.a(NetworkManager.java:224) [spigot-1.15.2.jar:git-Spigot-2040c4c-1872231]
              at net.minecraft.server.v1_15_R1.ServerConnection.c(ServerConnection.java:129) [spigot-1.15.2.jar:git-Spigot-2040c4c-1872231]
              at net.minecraft.server.v1_15_R1.MinecraftServer.b(MinecraftServer.java:1105) [spigot-1.15.2.jar:git-Spigot-2040c4c-1872231]
              at net.minecraft.server.v1_15_R1.DedicatedServer.b(DedicatedServer.java:406) [spigot-1.15.2.jar:git-Spigot-2040c4c-1872231]
              at net.minecraft.server.v1_15_R1.MinecraftServer.a(MinecraftServer.java:984) [spigot-1.15.2.jar:git-Spigot-2040c4c-1872231]
              at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:824) [spigot-1.15.2.jar:git-Spigot-2040c4c-1872231]
              at java.lang.Thread.run(Unknown Source) [?:1.8.0_201]
      Caused by: java.lang.NullPointerException
              at org.bukkit.craftbukkit.v1_15_R1.inventory.CraftMetaSkull.equalsCommon(CraftMetaSkull.java:198) ~[spigot-1.15.2.jar:git-Spigot-2040c4c-1872231]
              at org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemFactory.equals(CraftItemFactory.java:307) ~[spigot-1.15.2.jar:git-Spigot-2040c4c-1872231]
              at org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemFactory.equals(CraftItemFactory.java:294) ~[spigot-1.15.2.jar:git-Spigot-2040c4c-1872231]
              at org.bukkit.inventory.ItemStack.isSimilar(ItemStack.java:290) ~[spigot-1.15.2.jar:git-Spigot-2040c4c-1872231]
              at org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack.isSimilar(CraftItemStack.java:579) ~[spigot-1.15.2.jar:git-Spigot-2040c4c-1872231]
              at org.bukkit.inventory.ItemStack.equals(ItemStack.java:271) ~[spigot-1.15.2.jar:git-Spigot-2040c4c-1872231]
              at java.util.ArrayList.remove(Unknown Source) ~[?:1.8.0_201]
              at nl.chimpgamer.torchcraft.mobheads.listeners.ItemListener.onItemPickup(ItemListener.kt:25) ~[?:?]
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_201]
              at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_201]
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_201]
              at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_201]
              at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:315) ~[spigot-1.15.2.jar:git-Spigot-2040c4c-1872231]
              ... 17 more
      

       

       Also some piece of code that should be able to replicate the error

      public class TestPlugin extends JavaPlugin {
          private final List<ItemStack> skulls = new ArrayList<>();
      
          @Override
          public void onEnable() {
              ItemStack skull1 = new ItemStack(Material.PLAYER_HEAD);
      
              UUID uuid = UUID.randomUUID();
              GameProfile profile1 = new GameProfile(uuid, null);
              profile1.getProperties().put("textures", new Property("textures", "some random skin value"));
      
              setProfile(skull1, profile1);
      
              skulls.add(skull1);
              System.out.println(skull1);
              System.out.println("This should be true and not throw any errors: " + skulls.contains(skull1));
          }
      
          private void setProfile(ItemStack item, GameProfile profile) {
              ItemMeta meta = item.getItemMeta();
              try {
                  Field field = meta.getClass().getDeclaredField("profile");
                  field.setAccessible(true);
                  field.set(meta, profile);
              } catch (NoSuchFieldException | IllegalAccessException ex) {
                  ex.printStackTrace();
              }
              item.setItemMeta(meta);
          }
      }
      

            Unassigned Unassigned
            ChimpGamer Tim Cremers
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: