Class Hologram

java.lang.Object
tk.airshipcraft.commonlib.gui.Hologram
All Implemented Interfaces:
org.bukkit.event.Listener

public abstract class Hologram extends Object implements org.bukkit.event.Listener
Represents a hologram created using an ArmorStand in Minecraft. Holograms are used to display text to players in the game world. This class allows for the creation, manipulation, and interaction of holograms.

Subclasses should implement the addClickAction method to define behavior when a hologram is interacted with.

Since:
2023-04-11
Version:
1.0.0
Author:
Locutusque, notzune
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final List<Hologram>
    A list of all Hologram instances created.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Hologram(org.bukkit.Location location, String... lines)
    Creates a new Hologram at the given location with the given lines.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract void
    An abstract method that subclasses must implement to define the behavior when the hologram is clicked.
    static void
    Calls the addClickAction method for all hologram subclasses.
    static Hologram
    fromArmorStand(org.bukkit.entity.ArmorStand armorStand)
    Retrieves the Hologram instance corresponding to the given ArmorStand.
    List<org.bukkit.entity.ArmorStand>
     
    void
    hides a visible Hologram
    static boolean
    isHologram(org.bukkit.entity.ArmorStand armorStand)
    Checks if a given armor stand is associated with a Hologram
    void
    onHologramClick(org.bukkit.event.player.PlayerInteractAtEntityEvent event1, org.bukkit.event.entity.EntityDamageByEntityEvent event2)
    Handles click events on the hologram and triggers the appropriate actions.
    void
    removes the Hologram.
    void
    setSlot(org.bukkit.inventory.ItemStack item, org.bukkit.inventory.EquipmentSlot slot)
    Sets an item in a specified slot for the armor stand associated with this hologram.
    void
    shows an invisible Hologram
    void
    teleport(org.bukkit.Location location)
    Teleports the Holograms or the armor stands that are an instance of Hologram

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • hologramInstances

      public static final List<Hologram> hologramInstances
      A list of all Hologram instances created.
  • Constructor Details

    • Hologram

      public Hologram(org.bukkit.Location location, String... lines)
      Creates a new Hologram at the given location with the given lines.
      Parameters:
      location - The location of the Hologram.
      lines - the lines to add to the Hologram.
  • Method Details

    • isHologram

      public static boolean isHologram(org.bukkit.entity.ArmorStand armorStand)
      Checks if a given armor stand is associated with a Hologram
      Parameters:
      armorStand - the desired armor stand to check
      Returns:
      a boolean; if true, it means the given armor stand is associated with a Hologram, otherwise it is not.
    • fromArmorStand

      public static Hologram fromArmorStand(org.bukkit.entity.ArmorStand armorStand)
      Retrieves the Hologram instance corresponding to the given ArmorStand.
      Parameters:
      armorStand - The ArmorStand associated with a Hologram.
      Returns:
      The Hologram instance, or null if none found.
    • callClickAction

      public static void callClickAction(Hologram hologram)
      Calls the addClickAction method for all hologram subclasses.
      Parameters:
      hologram - The hologram that was clicked.
    • teleport

      public void teleport(org.bukkit.Location location)
      Teleports the Holograms or the armor stands that are an instance of Hologram
      Parameters:
      location - The desired location to teleport the Hologram to.
    • getArmorStands

      public List<org.bukkit.entity.ArmorStand> getArmorStands()
      Returns:
      all the armor stands that are an instance of Hologram
    • setSlot

      public void setSlot(org.bukkit.inventory.ItemStack item, org.bukkit.inventory.EquipmentSlot slot)
      Sets an item in a specified slot for the armor stand associated with this hologram.
      Parameters:
      item - The item to set.
      slot - The equipment slot to place the item in.
    • show

      public void show()
      shows an invisible Hologram
    • hide

      public void hide()
      hides a visible Hologram
    • remove

      public void remove()
      removes the Hologram.
    • addClickAction

      protected abstract void addClickAction(Hologram hologram)
      An abstract method that subclasses must implement to define the behavior when the hologram is clicked.
      Parameters:
      hologram - The hologram that was clicked.
    • onHologramClick

      public void onHologramClick(org.bukkit.event.player.PlayerInteractAtEntityEvent event1, org.bukkit.event.entity.EntityDamageByEntityEvent event2)
      Handles click events on the hologram and triggers the appropriate actions.
      Parameters:
      event1 - The PlayerInteractAtEntityEvent.
      event2 - The EntityDamageByEntityEvent.