1.8.8 Holographic Displays Issue

Discussion in 'Spigot Plugin Development' started by GamerDuck123, Jan 20, 2020.

  1. Hello! So I've recently wanted to add Holographic Displays but I've run into an issue. So I've been using this method to loop through a list to get each of the prizes from a crate:
    Code (Text):
    public static void registerCrazyCratesPlaceHolders(me.badbones69.crazycrates.api.objects.Crate c) {
                    HologramsAPI.registerPlaceholder(plugin, "%ccaddon_rewards_" + c.getName() + "%", 5, () -> {
                        me.badbones69.crazycrates.api.objects.Crate crate = cc.getCrateFromName(c.getName());
                            if (crate.getPrizes().size() <= i) {
                                i++;
                                return crate.getPrizes().get(i).getDisplayItem().getItemMeta().getDisplayName();
                            } else {
                                i = 0;
                                return crate.getPrizes().get(i).getDisplayItem().getItemMeta().getDisplayName();
                            }
                         
                            }
                            );  
             
        }
    And I get this error
    Code (Text):
    [17:14:22 WARN]: [HolographicDisplays] Task #4 for HolographicDisplays v2.4.0 generated an exception
    java.lang.NullPointerException
            at com.gmail.filoghost.holographicdisplays.placeholder.PlaceholdersManager.lambda$load$0(PlaceholdersManager.java:68) ~[?:?]
            at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:71) ~[sss1.8.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:350) [sss1.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:723) [sss1.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [sss1.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [sss1.8.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [sss1.8.jar:git-Spigot-db6de12-18fbb24]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_191]
    Anyone have any clue? If you need more information just respond! And I've checked everything while doing this nothing is null
     
  2. Here's your answer: NULL
    at com.gmail.filoghost.holographicdisplays.placeholder.PlaceholdersManager.lambda$load$0(PlaceholdersManager.java:68)
     
  3.  
  4. Could you please send in your line 68?
     
  5. It isn't MY line either its HD's but:
    Code (Text):
    ConsoleLogger.log(Level.WARNING, "The placeholder " + placeholder.getTextPlaceholder() + " registered by the plugin " + placeholder.getOwner().getName() + " generated an exception while updating. Please contact the author of " + placeholder.getOwner().getName(), t);
     
  6. Code (Text):
    public static boolean registerPlaceholder(Plugin plugin, String textPlaceholder, double refreshRate, PlaceholderReplacer replacer)
    Try using
    Code (Text):
    HologramsAPI.registerPlaceholder(plugin, "%ccaddon_rewards_" + c.getName() + "%", 5, new PlaceHolderReplacer(...));
     
  7. Nope nothing, but I've found the issue but I don't know how to get around it, it's the i variable/ArrayList.get() that is not working with the PlaceHolderReplacer
     
  8. Where do you initliaze your variable i ?