sainttx / Holograms

A Bukkit plugin for creating and managing text Holograms
MIT License
32 stars 33 forks source link

TextLine.setText throws an NPE if the updated line is in an unloaded chunk #118

Open NickantX opened 3 years ago

NickantX commented 3 years ago

Error:

[06:59:38] [Server thread/WARN]: java.lang.NullPointerException
[06:59:38] [Server thread/WARN]:    at com.sainttx.holograms.api.line.TextLine.setText(TextLine.java:64)

This happens when calling .setText on a TextLine. The line itself updates perfectly fine, the NPE appears to be thrown by nameable.setName(text); which is called after setRaw(text).

NickantX commented 3 years ago

Update: the error only gets thrown if the updated hologram is in an unloaded chunk, so a simple if null check for nameable should fix the problem

NickantX commented 3 years ago

Update: the issue exists in all versions of Holograms starting with version 2.9, which introduced the new system that calls Hologram.despawn() when its containing chunk unloads. This internally calls the hide() method of every single line of the Hologram, which itself sets nameable to null. This doesn't happen if you use the /holo setline command since that command itself doesn't actually change the line, it just removes it and creates a new one.