Package com.ranull.graves.listener
Class PlayerInteractEntityListener
java.lang.Object
com.ranull.graves.listener.PlayerInteractEntityListener
- All Implemented Interfaces:
org.bukkit.event.Listener
Listener for handling PlayerInteractEntityEvent to interact with ItemFrame entities representing graves.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPlayerInteractEntityListener
(Graves plugin) Constructs a PlayerInteractEntityListener with the specified Graves plugin. -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
isItemFrame
(org.bukkit.entity.Entity entity) Checks if the entity being interacted with is an ItemFrame.private boolean
isMainHandInteraction
(org.bukkit.event.player.PlayerInteractEntityEvent 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
onPlayerInteractEntity
(org.bukkit.event.player.PlayerInteractEntityEvent event) Handles the PlayerInteractEntityEvent when a player interacts with an ItemFrame entity.
-
Field Details
-
plugin
-
-
Constructor Details
-
PlayerInteractEntityListener
Constructs a PlayerInteractEntityListener with the specified Graves plugin.- Parameters:
plugin
- The Graves plugin instance.
-
-
Method Details
-
onPlayerInteractEntity
public void onPlayerInteractEntity(org.bukkit.event.player.PlayerInteractEntityEvent event) Handles the PlayerInteractEntityEvent when a player interacts with an ItemFrame entity. If the interacted entity is an ItemFrame 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 PlayerInteractEntityEvent to handle.
-
isMainHandInteraction
private boolean isMainHandInteraction(org.bukkit.event.player.PlayerInteractEntityEvent event) Checks if the interaction is performed with the main hand.- Parameters:
event
- The PlayerInteractEntityEvent.- Returns:
- True if the interaction is performed with the main hand, false otherwise.
-
isItemFrame
private boolean isItemFrame(org.bukkit.entity.Entity entity) Checks if the entity being interacted with is an ItemFrame.- Parameters:
entity
- The entity being interacted with.- Returns:
- True if the entity is an ItemFrame, 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.
-