Spigot [API] HologramAPI 1.6.2

Simple API to create holograms | compatible with ProtocolSupport

  1. inventivetalent submitted a new resource:

    [API] HologramAPI [1.7 + 1.8] - Simply API to create holograms

    Read more about this resource...
    • Like Like x 1
  2. lol , what the deffrent between yours and the Holographic Display Holograme API?
    • The author
    • this one is more compact
    • uses reflection instead of the actual nms classes.
  3. Holographic Display API Has No Depends
    HologramAPI And Has Depend :p
    • Optimistic Optimistic x 1
  4. clip


    Looking at the source, PacketListenerAPI is only a softdepend I think.

    Correct me if I am wrong @inventivetalent but if PacketListenerAPI isn't installed, the TouchHandlers would be the only thing disabled right?
  5. Yes. Forgot to mention that.
  6. clip


    Is there any way possible to have different text per player?
    I would really like to use this API and allow my placeholders to be shown but as most placeholders are player specific, I am not sure if it is possible :/

    Also considering the possibility for multiple text lines?
    #8 clip, May 6, 2015
    Last edited: May 6, 2015
  7. oh , great
  8. There will be variables (also player specific) in the next version, feel free to suggest some.

    You would have to create multiple holograms with a different offset, but I think I could include that directly.
  9. clip


    Ah okay. Yeah for the variables, I mean I have a plugin that hooks into tons of plugins to obtain values for hundreds of placeholders. I would like to use that in my plugin which will hook into this to create the holograms and set player specific text depending on the hologram viewer. Maybe adding a ViewHandler similar to how your TouchHandler works? Which would allow me to set the text per viewer but would still hold the actual raw text? This way I would be able to handle / parse the placeholders myself depending on the actual placeholder identifier set in the hologram text.
  10. Seems to be a good idea, I'll handle it that way. Thanks for the suggestion!
  11. clip



    Placeholders working successfully for the most part!
    I am only having one small issue but I am hoping you might be able to help me with a solution.

    It seems that the ViewHandler doesn't update values after I leave the server or chunk. I was wondering if you could add some type or refresh time which would update it depending on what holograms are visible to a player on a specific interval. The values only seem to be set one time :/

    Thanks so much for the awesome API @inventivetalent
    #15 clip, May 7, 2015
    Last edited: May 7, 2015
  12. Interesting. The onView method is called every time the hologram is sent to a player, so there shouldn't be a way that the hologram is sent without calling the method.
    I'll check if I can find the problem.
  13. clip


    Another question is what do you think would be the best way to spawn holograms when the plugin is loaded?

    I have it set to load the holograms from the config which uses the same method I made to spawn the holograms by command but everything I have tried has been unsuccessful.

    I have created a delayed task which spawned the holograms onEnable after a certain amount of ticks, which I made sure to load the chunk before spawning and that didn't work. I have waited until the first player joined and attempted to spawn the holograms and that didn't either. This always resulted in this error when I attempt to delete them after they were created automatically.

    I am positive that the method I use to create the hologram does in fact call Hologram.spawn() but it seems that when there is no player where the hologram is spawned, the Hologram.spawn() method does nothing.

    Code (Text):
    [20:43:16] [Server thread/INFO]: extended_clip issued server command: /holo delete test1
    [20:43:16] [Server thread/ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'holo' in plugin InfoHolos v1.0
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot.jar:git-Spigot-2ec6f06-7722428]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot.jar:git-Spigot-2ec6f06-7722428]
        at org.bukkit.craftbukkit.v1_8_R2.CraftServer.dispatchCommand(CraftServer.java:646) ~[spigot.jar:git-Spigot-2ec6f06-7722428]
        at net.minecraft.server.v1_8_R2.PlayerConnection.handleCommand(PlayerConnection.java:1139) [spigot.jar:git-Spigot-2ec6f06-7722428]
        at net.minecraft.server.v1_8_R2.PlayerConnection.a(PlayerConnection.java:974) [spigot.jar:git-Spigot-2ec6f06-7722428]
        at net.minecraft.server.v1_8_R2.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot.jar:git-Spigot-2ec6f06-7722428]
        at net.minecraft.server.v1_8_R2.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot.jar:git-Spigot-2ec6f06-7722428]
        at net.minecraft.server.v1_8_R2.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-2ec6f06-7722428]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [?:1.7.0_72]
        at java.util.concurrent.FutureTask.run(FutureTask.java:262) [?:1.7.0_72]
        at net.minecraft.server.v1_8_R2.SystemUtils.a(SourceFile:60) [spigot.jar:git-Spigot-2ec6f06-7722428]
        at net.minecraft.server.v1_8_R2.MinecraftServer.A(MinecraftServer.java:712) [spigot.jar:git-Spigot-2ec6f06-7722428]
        at net.minecraft.server.v1_8_R2.DedicatedServer.A(DedicatedServer.java:368) [spigot.jar:git-Spigot-2ec6f06-7722428]
        at net.minecraft.server.v1_8_R2.MinecraftServer.z(MinecraftServer.java:651) [spigot.jar:git-Spigot-2ec6f06-7722428]
        at net.minecraft.server.v1_8_R2.MinecraftServer.run(MinecraftServer.java:554) [spigot.jar:git-Spigot-2ec6f06-7722428]
        at java.lang.Thread.run(Thread.java:745) [?:1.7.0_72]
    Caused by: java.lang.IllegalStateException: Not spawned
        at de.inventivegames.hologram.DefaultHologram.validateSpawned(DefaultHologram.java:222) ~[?:?]
        at de.inventivegames.hologram.DefaultHologram.despawn(DefaultHologram.java:105) ~[?:?]
        at me.clip.infoholos.HoloCommands.onCommand(HoloCommands.java:115) ~[?:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot.jar:git-Spigot-2ec6f06-7722428]
        ... 15 more

    Keep in mind that when I spawn them in by command which uses the players location, everything works perfect.
  14. clip


    So I found out (after finally testing with 2 players) When the hologram is created, the text set in the ViewHandler is set for all players :(

    Seems that it replaces the actual hologram text for the first person to see the hologram and since it has been replaced, all other players don't get a chance to obtain the placeholder value because the placeholder identifier has been replaced by the first persons value. If you would like to test with me @inventivetalent I have a test server running my plugin -> testplugins.com. Hop on if you can and I can walk you through what I have going on.

    Also, no need for you to add support to add multiple lines (at least for me) as I have already implemented multiple line support :)
    #18 clip, May 7, 2015
    Last edited: May 7, 2015
  15. I noticed that problem, but I fixed it in the latest update (1.2.1).
    How did you implement the ViewHandler?
  16. clip


    Yeah, I am on 1.2.1

    Here is my constructor for creating my hologram object:

    Code (Text):
        public InfoHologram(String name, Location l, String firstLine) {
            this.name = name;
            this.topLineLocation = l;
            Hologram h = HologramAPI.createHologram(l, firstLine);
            h.addViewHandler(new ViewHandler() {

                public String onView(Hologram holo, Player p, String text) {
                    //returns original text with all placeholders parsed to the correct values
                    return PlaceholderAPI.setPlaceholders(p, text);
            lines = new ArrayList<Hologram>();
            loaded.put(name, this);