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 boolean
isArmorStand
(org.bukkit.entity.Entity entity) Checks if the entity being interacted with is an ArmorStand.private boolean
isMainHandInteraction
(org.bukkit.event.player.PlayerInteractAtEntityEvent event) Checks if the interaction is performed with the main hand.private boolean
isNotSpectatorMode
(org.bukkit.entity.Player player) Checks if the player is not in Spectator mode.void
onPlayerInteractAtEntity
(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 plugin version does not support a second hand). - The player is not in Spectator mode (if the server version is 1.7).- 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.- Parameters:
event
- The PlayerInteractAtEntityEvent.- Returns:
- True if the interaction is performed with the main hand, false otherwise.
-
isArmorStand
private boolean isArmorStand(org.bukkit.entity.Entity entity) Checks if the entity being interacted with is an ArmorStand.- Parameters:
entity
- The entity being interacted with.- Returns:
- True if the entity is an ArmorStand, false otherwise.
-
isNotSpectatorMode
private boolean isNotSpectatorMode(org.bukkit.entity.Player player) Checks if the player is not in Spectator mode.- Parameters:
player
- The player to check.- Returns:
- True if the player is not in Spectator mode, false otherwise.
-