This repository has been archived by the owner on Jun 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 200
Individual holograms
filoghost edited this page May 1, 2023
·
29 revisions
This tutorial will teach you how to make individual holograms, and show/hide them to players dynamically.
The primary class to use for individual holograms is the VisibilitySettings of a hologram. You can retrieve it with this code:
// Suppose to have a player obtained before
HolographicDisplaysAPI api = HolographicDisplaysAPI.get(plugin);
Hologram hologram = api.createHologram(player.getLocation());
VisibilitySettings visibilitySettings = hologram.getVisibilitySettings();
With the VisibilitySettings you can choose if all the players should see or not a hologram by default, and also set rules for individual players. By default a hologram will be visible by default to everyone. Let's try to completely hide a hologram, for everyone:
// Hide the hologram to everyone
visibilitySettings.setGlobalVisibility(Visibility.HIDDEN);
Let's show it back:
// Show the hologram to everyone
visibilitySettings.setGlobalVisibility(Visibility.VISIBLE);
To hide a hologram to everyone except a player:
visibilitySettings.setGlobalVisibility(Visibility.HIDDEN);
visibilitySettings.setIndividualVisibility(player, Visibility.VISIBLE);
Now, let's bring everything back to the default values:
visibilitySettings.setGlobalVisibility(Visibility.VISIBLE);
visibilitySettings.clearIndividualVisibilities();
// The second line clears all the player specific settings