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

setPage(int) causes a NullPointerException although getPage() works fine.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • git-Spigot-a03b1fd-95bd423 (MC: 1.15.2) (Implementing API version 1.15.2-R0.1-SNAPSHOT)
    • Internet Redstone
    • Yes

      I originally was asking for help with this issue on: https://www.spigotmc.org/threads/attempting-lectern-setpage-int-results-in-a-nullpointerexception-getpage-works-fine.426628/

       

      However, Warren1001, pointed out that this could be a Spigot bug. I tested this on the latest version of Spigot I just built with Buildtools and the exception still occurs.

       

      Basically, the issue is, when using a BlockState that is an instance of org.bukkit.block.Lectern, I can use lectern.getPage() and get the current page as an integer, however, using lectern.setPage(int), I get a NullPointerException.

       

      The exception looks like this on the latest version of Spigot:

       

      The exception looks like this (and is colored) on the latest version of PaperSpigot:

      "Screen Shot 2020-03-31 at 12.06.07 PM.png"

       

      The stack trace printed with exception.printStackTrace();

       

      [12:07:58 WARN]: java.lang.NullPointerException
      [12:07:58 WARN]: at net.minecraft.server.v1_15_R1.TileEntity.getBlock(TileEntity.java:160)
      [12:07:58 WARN]: at net.minecraft.server.v1_15_R1.TileEntityLectern.setPage(TileEntityLectern.java:200)
      [12:07:58 WARN]: at org.bukkit.craftbukkit.v1_15_R1.block.CraftLectern.setPage(CraftLectern.java:27)
      [12:07:58 WARN]: at me.alexisevelyn.internetredstone.utilities.LecternTracker$1.run(LecternTracker.java:215)
      [12:07:58 WARN]: at org.bukkit.craftbukkit.v1_15_R1.scheduler.CraftTask.run(CraftTask.java:84)
      [12:07:58 WARN]: at org.bukkit.craftbukkit.v1_15_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:452)
      [12:07:58 WARN]: at net.minecraft.server.v1_15_R1.MinecraftServer.b(MinecraftServer.java:1185)
      [12:07:58 WARN]: at net.minecraft.server.v1_15_R1.DedicatedServer.b(DedicatedServer.java:430)
      [12:07:58 WARN]: at net.minecraft.server.v1_15_R1.MinecraftServer.a(MinecraftServer.java:1112)
      [12:07:58 WARN]: at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:934)
      [12:07:58 WARN]: at java.base/java.lang.Thread.run(Thread.java:834)

       

      Screenshot For printStackTrace();

      "Screen Shot 2020-03-31 at 12.08.17 PM.png"

       

      The Source Code to the Java file and method that's causing the issue can be found at: https://github.com/alexis-evelyn/InternetRedstone/blob/lectern/src/main/java/me/alexisevelyn/internetredstone/utilities/LecternTracker.java#L185-L229

       

      As for the minimal reproduction project, should I create one more simplified than this? If so, I'll see how to simplify it as much as possible.

       

      Edit: Here's the minimal reproduction project: https://github.com/alexis-evelyn/BugReport-5650

        1. image-2020-03-31-12-01-39-675.png
          625 kB
          Alexis Evelyn
        2. image-2020-03-31-12-11-29-339.png
          625 kB
          Alexis Evelyn
        3. Screen Shot 2020-03-31 at 12.06.07 PM.png
          705 kB
          Alexis Evelyn
        4. Screen Shot 2020-03-31 at 12.08.17 PM.png
          330 kB
          Alexis Evelyn

            Unassigned Unassigned
            Alexis_Evelyn Alexis Evelyn
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: