Class Hologram

java.lang.Object
net.minestom.server.entity.hologram.Hologram
All Implemented Interfaces:
Viewable

public class Hologram extends Object implements Viewable
Represents an invisible armor stand showing a Component.
  • Constructor Details

    • Hologram

      public Hologram(Instance instance, Pos spawnPosition, Component text)
      Constructs a new Hologram with the given parameters.
      Parameters:
      instance - The instance where the hologram should be spawned.
      spawnPosition - The spawn position of this hologram.
      text - The text of this hologram.
    • Hologram

      public Hologram(Instance instance, Pos spawnPosition, Component text, boolean autoViewable)
      Constructs a new Hologram with the given parameters.
      Parameters:
      instance - The instance where the hologram should be spawned.
      spawnPosition - The spawn position of this hologram.
      text - The text of this hologram.
      autoViewable - trueif the hologram should be visible automatically, otherwise false.
    • Hologram

      public Hologram(Instance instance, Pos spawnPosition, Component text, boolean autoViewable, boolean marker)
      Constructs a new Hologram with the given parameters.
      Parameters:
      instance - The instance where the hologram should be spawned.
      spawnPosition - The spawn position of this hologram.
      text - The text of this hologram.
      autoViewable - trueif the hologram should be visible automatically, otherwise false.
  • Method Details

    • getPosition

      public Pos getPosition()
      Gets the position of the hologram.
      Returns:
      the hologram's position
    • setPosition

      public void setPosition(Pos position)
      Changes the position of the hologram.
      Parameters:
      position - the new hologram's position
    • getText

      public Component getText()
      Gets the hologram text.
      Returns:
      the hologram text
    • setText

      public void setText(Component text)
      Changes the hologram text.
      Parameters:
      text - the new hologram text
    • remove

      public void remove()
      Removes the hologram.
    • isRemoved

      public boolean isRemoved()
      Checks if the hologram is still present.
      Returns:
      true if the hologram is present, false otherwise
    • getEntity

      public Entity getEntity()
      Gets the hologram entity (armor stand).
      Returns:
      the hologram entity
    • addViewer

      public boolean addViewer(@NotNull @NotNull Player player)
      Adds a viewer.
      Specified by:
      addViewer in interface Viewable
      Parameters:
      player - the viewer to add
      Returns:
      true if the player has been added, false otherwise (could be because he is already a viewer)
    • removeViewer

      public boolean removeViewer(@NotNull @NotNull Player player)
      Removes a viewer.
      Specified by:
      removeViewer in interface Viewable
      Parameters:
      player - the viewer to remove
      Returns:
      true if the player has been removed, false otherwise (could be because he was not a viewer)
    • getViewers

      @NotNull public @NotNull Set<Player> getViewers()
      Gets all the viewers of this viewable element.
      Specified by:
      getViewers in interface Viewable
      Returns:
      A Set containing all the element's viewers