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

ClassCastException when getting InventoryHolder of lectern when it's destroyed

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • git-Spigot-df0eb25-411609d (MC: 1.14.2) (Implementing API version 1.14.2-R0.1-SNAPSHOT)
    • Yes

       

      [Server thread/ERROR]: Could not pass event InventoryCloseEvent to LecturnClassCast v1.0-SNAPSHOT
      org.bukkit.event.EventException: null
              at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:320) ~[spigot-1.14.2.jar:git-Spigot-df0eb25-411609d]
              at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[spigot-1.14.2.jar:git-Spigot-df0eb25-411609d]
              at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:520) ~[spigot-1.14.2.jar:git-Spigot-df0eb25-411609d]
              at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:505) ~[spigot-1.14.2.jar:git-Spigot-df0eb25-411609d]
              at org.bukkit.craftbukkit.v1_14_R1.event.CraftEventFactory.handleInventoryCloseEvent(CraftEventFactory.java:1213) ~[spigot-1.14.2.jar:git-Spigot-df0eb25-411609d]
              at net.minecraft.server.v1_14_R1.EntityPlayer.closeInventory(EntityPlayer.java:1148) ~[spigot-1.14.2.jar:git-Spigot-df0eb25-411609d]
              at net.minecraft.server.v1_14_R1.EntityPlayer.tick(EntityPlayer.java:354) ~[spigot-1.14.2.jar:git-Spigot-df0eb25-411609d]
              at net.minecraft.server.v1_14_R1.WorldServer.entityJoinedWorld(WorldServer.java:570) ~[spigot-1.14.2.jar:git-Spigot-df0eb25-411609d]
              at net.minecraft.server.v1_14_R1.WorldServer$$Lambda$2412.00000000151D36F0.accept(Unknown Source) ~[?:?]
              at net.minecraft.server.v1_14_R1.World.a(World.java:745) [spigot-1.14.2.jar:git-Spigot-df0eb25-411609d]
              at net.minecraft.server.v1_14_R1.WorldServer.doTick(WorldServer.java:346) [spigot-1.14.2.jar:git-Spigot-df0eb25-411609d]
              at net.minecraft.server.v1_14_R1.MinecraftServer.b(MinecraftServer.java:1057) [spigot-1.14.2.jar:git-Spigot-df0eb25-411609d]
              at net.minecraft.server.v1_14_R1.DedicatedServer.b(DedicatedServer.java:396) [spigot-1.14.2.jar:git-Spigot-df0eb25-411609d]
              at net.minecraft.server.v1_14_R1.MinecraftServer.a(MinecraftServer.java:956) [spigot-1.14.2.jar:git-Spigot-df0eb25-411609d]
              at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:801) [spigot-1.14.2.jar:git-Spigot-df0eb25-411609d]
              at java.lang.Thread.run(Thread.java:813) [?:1.8.0_202]
      Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_14_R1.block.CraftBlockState incompatible with org.bukkit.block.Lectern
              at net.minecraft.server.v1_14_R1.TileEntityLectern$LecternInventory.getOwner(TileEntityLectern.java:57) ~[spigot-1.14.2.jar:git-Spigot-df0eb25-411609d]
              at org.bukkit.craftbukkit.v1_14_R1.inventory.CraftInventoryLectern.getHolder(CraftInventoryLectern.java:15) ~[spigot-1.14.2.jar:git-Spigot-df0eb25-411609d]
              at org.bukkit.craftbukkit.v1_14_R1.inventory.CraftInventoryLectern.getHolder(CraftInventoryLectern.java:1) ~[spigot-1.14.2.jar:git-Spigot-df0eb25-411609d]
              at io.github.rypofalem.lecturn_class_cast.LecturnClassCastPlugin.onInventoryClose(LecturnClassCastPlugin.java:20) ~[?:?]
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_202]
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_202]
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_202]
              at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_202]
              at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:316) ~[spigot-1.14.2.jar:git-Spigot-df0eb25-411609d]
              ... 15 more

       

      Monitor(other priorities don't produce the issue) InventoryCloseEvent and check the inventory holder

      public class LecturnClassCastPlugin extends JavaPlugin implements Listener {
          public void onEnable(){
              Bukkit.getPluginManager().registerEvents(this,this);
          }
      
          @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled=true)
          public void onInventoryClose(InventoryCloseEvent event){
              event.getInventory().getHolder();
          }
      }
      
      1. Place down a lectern.
      2. Place a book in the lectern (tested with empty book and quill)
      3. Right click the lectern to view the book
      4. Exit and destroy the lectern in creative mode (survival doesn't produce the issue)

            Unassigned Unassigned
            rypofalem rypofalem
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: