inventivetalent submitted a new resource: [API] HologramAPI [1.7 + 1.8] - Simply API to create holograms Read more about this resource...
inventivetalent updated [API] HologramAPI [1.7 + 1.8] with a new update entry: Fixes Read the rest of this update entry...
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?
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?
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.
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.
inventivetalent updated [API] HologramAPI [1.7 + 1.8] with a new update entry: Per-player hologram content Read the rest of this update entry...
inventivetalent updated [API] HologramAPI [1.7 + 1.8] with a new update entry: Fixes Read the rest of this update entry...
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
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.
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. Spoiler: error 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.
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
I noticed that problem, but I fixed it in the latest update (1.2.1). How did you implement the ViewHandler?
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() { @Override 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); } }); h.spawn(); lines = new ArrayList<Hologram>(); lines.add(h); loaded.put(name, this); }