mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
fancyholograms-v3: Add HologramController#updateHologramData
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user