Package com.ranull.graves.listener
Class PlayerInteractAtEntityListener
java.lang.Object
com.ranull.graves.listener.PlayerInteractAtEntityListener
- All Implemented Interfaces:
org.bukkit.event.Listener
Listener for handling PlayerInteractAtEntityEvent to interact with graves represented by ArmorStands.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPlayerInteractAtEntityListener(Graves plugin) Constructs a PlayerInteractAtEntityListener with the specified Graves plugin. -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanisArmorStand(org.bukkit.entity.Entity entity) Checks if the entity being interacted with is an ArmorStand.private booleanisMainHandInteraction(org.bukkit.event.player.PlayerInteractAtEntityEvent event) Checks if the interaction is performed with the main hand.private booleanisNotSpectatorMode(org.bukkit.entity.Player player) Checks if the player is not in Spectator mode.voidonPlayerInteractAtEntity(org.bukkit.event.player.PlayerInteractAtEntityEvent event) Handles the PlayerInteractAtEntityEvent when a player interacts with an ArmorStand entity.
-
Field Details
-
plugin
-
-
Constructor Details
-
PlayerInteractAtEntityListener
Constructs a PlayerInteractAtEntityListener with the specified Graves plugin.- Parameters:
plugin- The Graves plugin instance.
-
-
Method Details
-
onPlayerInteractAtEntity
public void onPlayerInteractAtEntity(org.bukkit.event.player.PlayerInteractAtEntityEvent event) Handles the PlayerInteractAtEntityEvent when a player interacts with an ArmorStand entity. If the interacted entity is an ArmorStand and represents a grave, the interaction will either open the grave or cancel the event based on the grave's state and the player's actions. The event is only processed if: - The hand used for the interaction is the main hand (or the server version does not support offhand). - The player is not in Spectator mode (except on very old versions that lack Spectator).- Parameters:
event- The PlayerInteractAtEntityEvent to handle.
-
isMainHandInteraction
private boolean isMainHandInteraction(org.bukkit.event.player.PlayerInteractAtEntityEvent event) Checks if the interaction is performed with the main hand. -
isArmorStand
private boolean isArmorStand(org.bukkit.entity.Entity entity) Checks if the entity being interacted with is an ArmorStand. -
isNotSpectatorMode
private boolean isNotSpectatorMode(org.bukkit.entity.Player player) Checks if the player is not in Spectator mode.
-