HologramsAPI#getRegisteredPlaceholders throws NPE
Workinq opened this issue ยท 1 comments
Confirmation
- I have read the FAQ.
- I have tested the latest development build of Holographic Displays and the bug is still present.
- I have updated Spigot (and ProtocolLib if installed) to the latest release for my particular Minecraft version.
- I made sure the bug hasn't already been reported on the issue tracker.
Description
I'm trying to register custom Hologram placeholders using HolographicDisplays' API which you can see from the following code extract:
public void register(String textPlaceholder, PlaceholderReplacer replacer)
{
Collection<String> textPlaceholders = HologramsAPI.getRegisteredPlaceholders(plugin);
if (textPlaceholders.contains(textPlaceholder)) return;
HologramsAPI.registerPlaceholder(plugin, textPlaceholder, 100, replacer);
}
However, when doing this I get spammed with NPEs in the console which come from the line:
Collection<String> textPlaceholders = HologramsAPI.getRegisteredPlaceholders(plugin);
You can find the stack trace below, I tried debugging by printing out the variables passed to this method and none of them were null so from what I can tell the issue shouldn't be on my side.
This method is ran in a task which executes every 10 minutes asynchronously. I've made the method synchronous to ensure it wasn't a threading issue and that didn't seem to solve the problem.
How to reproduce
- Register a task using the Bukkit scheduler.
- Call HologramsAPI.getRegisteredPlaceholders(Plugin)
- Get an NPE
Server version
This server is running CraftBukkit version git-Spigot-21fe707-e1ebe52 (MC: 1.8.8) (Implementing API version 1.8.8-R0.1-SNAPSHOT)
Holographic Displays version
HolographicDisplays version 2.4.9
ProtocolLib version (if installed)
ProtocolLib version 4.7.0
Installed plugins that allow players to join with multiple Minecraft versions
No response
Additional information
The NPE thrown when I try to call HologramsAPI#getRegisteredPlaceholders:
org.apache.commons.lang.UnhandledException: Plugin Leaderboards v1.0-SNAPSHOT generated an exception while executing task 71
at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:56)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.NullPointerException
at com.gmail.filoghost.holographicdisplays.placeholder.PlaceholdersRegister.getTextPlaceholdersByPlugin(PlaceholdersRegister.java:77)
at com.gmail.filoghost.holographicdisplays.object.DefaultBackendAPI.getRegisteredPlaceholders(DefaultBackendAPI.java:68)
at com.gmail.filoghost.holographicdisplays.api.HologramsAPI.getRegisteredPlaceholders(HologramsAPI.java:84)
at kr.kieran.leaderboards.manager.statistic.StatisticManager.register(StatisticManager.java:36)
at kr.kieran.leaderboards.manager.statistic.FactionStatisticManager.update(FactionStatisticManager.java:84)
at kr.kieran.leaderboards.manager.statistic.FactionStatisticManager.access$000(FactionStatisticManager.java:22)
at kr.kieran.leaderboards.manager.statistic.FactionStatisticManager$1.run(FactionStatisticManager.java:67)
at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:53)
at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:53)
... 3 more