Package com.ranull.graves.listener
Class PlayerInteractListener
java.lang.Object
com.ranull.graves.listener.PlayerInteractListener
- All Implemented Interfaces:
org.bukkit.event.Listener
Listener for handling PlayerInteractEvent to interact with graves and compasses.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPlayerInteractListener
(Graves plugin) Constructs a PlayerInteractListener with the specified Graves plugin. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
handleBlockInteraction
(org.bukkit.event.player.PlayerInteractEvent event, org.bukkit.entity.Player player) Handles interactions with blocks, including graves.private void
handleCompassInteraction
(org.bukkit.event.player.PlayerInteractEvent event, org.bukkit.entity.Player player) Handles interactions with compasses to update or remove them based on the graves they are tracking.private void
handleGraveInteraction
(org.bukkit.event.player.PlayerInteractEvent event, org.bukkit.entity.Player player, org.bukkit.block.Block block) Handles interactions with graves.private boolean
isMainHandInteraction
(org.bukkit.event.player.PlayerInteractEvent 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
onPlayerInteract
(org.bukkit.event.player.PlayerInteractEvent event) Handles the PlayerInteractEvent when a player interacts with blocks or items.
-
Field Details
-
plugin
-
-
Constructor Details
-
PlayerInteractListener
Constructs a PlayerInteractListener with the specified Graves plugin.- Parameters:
plugin
- The Graves plugin instance.
-
-
Method Details
-
onPlayerInteract
public void onPlayerInteract(org.bukkit.event.player.PlayerInteractEvent event) Handles the PlayerInteractEvent when a player interacts with blocks or items. This method processes interactions with: - Graves: Opens a grave if the player interacts with a block or adjacent block that represents a grave. - Compasses: Updates or removes the compass item based on the grave it is tracking. 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 PlayerInteractEvent to handle.
-
isMainHandInteraction
private boolean isMainHandInteraction(org.bukkit.event.player.PlayerInteractEvent event) Checks if the interaction is performed with the main hand.- Parameters:
event
- The PlayerInteractEvent.- Returns:
- True if the interaction is performed with the main hand, 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.
-
handleBlockInteraction
private void handleBlockInteraction(org.bukkit.event.player.PlayerInteractEvent event, org.bukkit.entity.Player player) Handles interactions with blocks, including graves.- Parameters:
event
- The PlayerInteractEvent.player
- The player interacting with the block.
-
handleGraveInteraction
private void handleGraveInteraction(org.bukkit.event.player.PlayerInteractEvent event, org.bukkit.entity.Player player, org.bukkit.block.Block block) Handles interactions with graves.- Parameters:
event
- The PlayerInteractEvent.player
- The player interacting with the block.block
- The block being interacted with.
-
handleCompassInteraction
private void handleCompassInteraction(org.bukkit.event.player.PlayerInteractEvent event, org.bukkit.entity.Player player) Handles interactions with compasses to update or remove them based on the graves they are tracking.- Parameters:
event
- The PlayerInteractEvent.player
- The player interacting with the item.
-