Skip to content

Commit 05484d4

Browse files
fancyholograms-v3: Add HologramController#updateHologramData
1 parent 9454f49 commit 05484d4

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

plugins/fancyholograms/fh-api/src/main/java/de/oliver/fancyholograms/api/HologramController.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ public interface HologramController {
3030
@ApiStatus.Internal
3131
boolean shouldSeeHologram(@NotNull final Hologram hologram, @NotNull final Player player);
3232

33+
/**
34+
* Updates hologram data such as text, background, etc. for the given players.
35+
* Be aware that some data changes require the hologram to be fully respawned.
36+
*/
37+
@ApiStatus.Internal
38+
void updateHologramData(@NotNull final Hologram hologram, @NotNull final Player ...players);;
39+
3340
/**
3441
* Spawns the hologram to the given players, if they should see it, and it is not already shown to them.
3542
* Hide the hologram from the players that should not see it.

plugins/fancyholograms/src/main/java/de/oliver/fancyholograms/controller/HologramControllerImpl.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import de.oliver.fancynpcs.api.FancyNpcsPlugin;
1111
import org.bukkit.Bukkit;
1212
import org.bukkit.entity.Player;
13+
import org.jetbrains.annotations.ApiStatus;
1314
import org.jetbrains.annotations.NotNull;
1415
import org.joml.Vector3f;
1516

@@ -46,6 +47,21 @@ public void hideHologramFrom(@NotNull final Hologram hologram, @NotNull final Pl
4647
}
4748
}
4849

50+
@Override
51+
@ApiStatus.Internal
52+
public void updateHologramData(@NotNull final Hologram hologram, @NotNull final Player ...players) {
53+
for (Player player : players) {
54+
boolean isVisible = hologram.isViewer(player);
55+
boolean shouldSee = shouldSeeHologram(hologram, player);
56+
57+
if (!isVisible || !shouldSee) {
58+
continue;
59+
}
60+
61+
hologram.updateFor(player);
62+
}
63+
}
64+
4965
@Override
5066
public boolean shouldSeeHologram(@NotNull final Hologram hologram, @NotNull final Player player) {
5167
if (!meetsVisibilityConditions(hologram, player)) {

0 commit comments

Comments
 (0)