[SPIGOT-5650] setPage(int) causes a NullPointerException although getPage() works fine. Created: 31/Mar/20 Updated: 01/Apr/20 Resolved: 31/Mar/20 |
|
Status: | Resolved |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | Priority: | Minor |
Reporter: | Alexis Evelyn | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 0 |
Labels: | BlockState, Lectern, Spigot, getPage() | ||
Environment: |
➜ Minecraft-Test-Server env
|
Attachments: |
![]() ![]() ![]() ![]() |
Version: | git-Spigot-a03b1fd-95bd423 (MC: 1.15.2) (Implementing API version 1.15.2-R0.1-SNAPSHOT) |
Plugin: | Internet Redstone |
Guidelines Read: | Yes |
Description |
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();
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 |
Comments |
Comment by Alexis Evelyn [ 01/Apr/20 ] |
Thanks! The fix works wonderfully! |
Comment by md_5 [ 31/Mar/20 ] |
You can see the fix here https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/bbe3d58efc489ce7905d4334dba82426e36610b8 |
Comment by Alexis Evelyn [ 31/Mar/20 ] |
Digging into the NMS code (While following the stack trace), it appears the NullPointerException comes from TileEntity.java/getBlock(). I don't know how you would handle that, but I would love to know so I can learn how to fix NMS issues myself too! |