Package tk.airshipcraft.commonlib.gui
Class Hologram
java.lang.Object
tk.airshipcraft.commonlib.gui.Hologram
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescriptionA list of all Hologram instances created. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
addClickAction
(Hologram hologram) An abstract method that subclasses must implement to define the behavior when the hologram is clicked.static void
callClickAction
(Hologram hologram) Calls theaddClickAction
method for all hologram subclasses.static Hologram
fromArmorStand
(org.bukkit.entity.ArmorStand armorStand) Retrieves theHologram
instance corresponding to the givenArmorStand
.List<org.bukkit.entity.ArmorStand>
void
hide()
hides a visible Hologramstatic boolean
isHologram
(org.bukkit.entity.ArmorStand armorStand) Checks if a given armor stand is associated with a Hologramvoid
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
remove()
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
show()
shows an invisible Hologramvoid
teleport
(org.bukkit.Location location) Teleports the Holograms or the armor stands that are an instance of Hologram
-
Field Details
-
hologramInstances
A list of all Hologram instances created.
-
-
Constructor Details
-
Hologram
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
Retrieves theHologram
instance corresponding to the givenArmorStand
.- Parameters:
armorStand
- The ArmorStand associated with a Hologram.- Returns:
- The Hologram instance, or null if none found.
-
callClickAction
Calls theaddClickAction
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
- 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
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.
-