Class PlayerInteractListener

java.lang.Object
com.ranull.graves.listener.PlayerInteractListener
All Implemented Interfaces:
org.bukkit.event.Listener

public class PlayerInteractListener extends Object implements org.bukkit.event.Listener
Listener for handling PlayerInteractEvent to interact with graves and compasses.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Graves
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a PlayerInteractListener with the specified Graves plugin.
  • Method Summary

    Modifier and Type
    Method
    Description
    private 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • plugin

      private final Graves plugin
  • Constructor Details

    • PlayerInteractListener

      public PlayerInteractListener(Graves plugin)
      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.