fancyholograms-v3: Add HologramController#updateHologramData

This commit is contained in:
Oliver
2025-05-17 19:08:51 +02:00
parent 9454f4995c
commit 05484d42d5
2 changed files with 23 additions and 0 deletions

View File

@@ -30,6 +30,13 @@ public interface HologramController {
@ApiStatus.Internal
boolean shouldSeeHologram(@NotNull final Hologram hologram, @NotNull final Player player);
/**
* Updates hologram data such as text, background, etc. for the given players.
* Be aware that some data changes require the hologram to be fully respawned.
*/
@ApiStatus.Internal
void updateHologramData(@NotNull final Hologram hologram, @NotNull final Player ...players);;
/**
* Spawns the hologram to the given players, if they should see it, and it is not already shown to them.
* Hide the hologram from the players that should not see it.

View File

@@ -10,6 +10,7 @@ import de.oliver.fancyholograms.main.FancyHologramsPlugin;
import de.oliver.fancynpcs.api.FancyNpcsPlugin;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.joml.Vector3f;
@@ -46,6 +47,21 @@ public class HologramControllerImpl implements HologramController {
}
}
@Override
@ApiStatus.Internal
public void updateHologramData(@NotNull final Hologram hologram, @NotNull final Player ...players) {
for (Player player : players) {
boolean isVisible = hologram.isViewer(player);
boolean shouldSee = shouldSeeHologram(hologram, player);
if (!isVisible || !shouldSee) {
continue;
}
hologram.updateFor(player);
}
}
@Override
public boolean shouldSeeHologram(@NotNull final Hologram hologram, @NotNull final Player player) {
if (!meetsVisibilityConditions(hologram, player)) {