Global holograms
Global holograms are used when you want to display global information that is the same for all players on the server.
You cannot display translated text or data with global holograms.
If you want to create holograms that can either show translated data or stats for each player, check out player holograms.
Create a global hologram
Creating a hologram requires Vital to execute some more logic, so to create your hologram, you must use the VitalHologramService.
Use VitalHologramService.createGlobalHologram(List<VitalHologram.Line>, Location) to create a global hologram.
vitalHologramService.createGlobalHologram(
myPlayer.getLocation(),
() -> new VitalHologram.Line("Line 1"),
() -> new VitalHologram.Line("Line 2"),
() -> new VitalHologram.Line("Line 3")
);
Note that all lines are lambda functions that return a VitalHologram.Line.
Everytime you update your hologram, these functions will be called to produce your actual hologram lines.
This method will essentially spawn an invisible marker armor stand that will display all of your lines at the given location.
This hologram will be visible for all players on the server and will display the same text for all players.
To retrieve your hologram at a later time, e.g., in a scheduled task or in an event, you can use this method:
final var myVitalGlobalHologram = vitalHologramRepository.find(VitalGlobalHologram.class, hologram -> hologram.getPlayerUniqueId().equals(myPlayer.getUniqueId()));
To update your hologram, use the VitalHologramService.update(VitalHologram) method.
vitalHologramService.updateHologram(myVitalGlobalHologram);
Note that when you create your global hologram, Vital will automatically store it in VitalHologramRepository.
Deleting a global hologram
To delete a global hologram, simply use the VitalHologramService.deleteHologram(VitalHologram) method.
This will destroy the marker armor stand and all of its components, this cannot be undone!
After your hologram has been destroyed, it is removed from VitalHologramRepository.