Class PlayerMoveListener

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

public class PlayerMoveListener extends Object implements org.bukkit.event.Listener
Listener for handling PlayerMoveEvent to manage interactions with graves and related mechanics.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Map<UUID,Long>
     
    private final Graves
     
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    private BlockData
    getBlockDataFromLocation(ChunkData chunkData, org.bukkit.Location location)
    Retrieves the BlockData from the location within the ChunkData.
    private UUID
    getGraveUUIDFromItemStack(org.bukkit.inventory.ItemStack itemStack)
    Retrieves the Grave UUID from the item stack.
    private void
    handleGraveAutoLoot(org.bukkit.event.player.PlayerMoveEvent event, org.bukkit.entity.Player player, org.bukkit.Location location)
    Handles the auto-loot of a grave when a player moves over it.
    private boolean
    hasPlayerMoved(org.bukkit.event.player.PlayerMoveEvent event)
    Checks if the player has moved to a different block.
    private boolean
    isLocationContainingGrave(org.bukkit.Location location)
    Checks if the location contains a grave.
    private boolean
    isLocationSafe(org.bukkit.Location location)
    Checks if the location is safe for the player.
    private boolean
    isNotSpectatorMode(org.bukkit.entity.Player player)
    Checks if the player is not in Spectator mode.
    void
    onPlayerMove(org.bukkit.event.player.PlayerMoveEvent event)
    Handles the PlayerMoveEvent to manage interactions with graves and update player locations.
    private void
    removeSpecificCompassNearGrave(org.bukkit.entity.Player player, org.bukkit.Location location)
     

    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
    • compassCheckCooldown

      private final Map<UUID,Long> compassCheckCooldown
  • Constructor Details

    • PlayerMoveListener

      public PlayerMoveListener(Graves plugin)
      Constructs a PlayerMoveListener with the specified Graves plugin.
      Parameters:
      plugin - The Graves plugin instance.
  • Method Details

    • onPlayerMove

      public void onPlayerMove(org.bukkit.event.player.PlayerMoveEvent event)
      Handles the PlayerMoveEvent to manage interactions with graves and update player locations. This method checks if the player has moved and whether the new location is inside a border and safe. It then updates the player's last known solid location if applicable. Additionally, if the player is moving over a location that is known to contain a grave, and if the grave's configuration allows walking over it, the grave is automatically looted if the player is allowed to open it.
      Parameters:
      event - The PlayerMoveEvent to handle.
    • 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.
    • hasPlayerMoved

      private boolean hasPlayerMoved(org.bukkit.event.player.PlayerMoveEvent event)
      Checks if the player has moved to a different block.
      Parameters:
      event - The PlayerMoveEvent.
      Returns:
      True if the player has moved to a different block, false otherwise.
    • isLocationSafe

      private boolean isLocationSafe(org.bukkit.Location location)
      Checks if the location is safe for the player.
      Parameters:
      location - The location to check.
      Returns:
      True if the location is safe, false otherwise.
    • isLocationContainingGrave

      private boolean isLocationContainingGrave(org.bukkit.Location location)
      Checks if the location contains a grave.
      Parameters:
      location - The location to check.
      Returns:
      True if the location contains a grave, false otherwise.
    • handleGraveAutoLoot

      private void handleGraveAutoLoot(org.bukkit.event.player.PlayerMoveEvent event, org.bukkit.entity.Player player, org.bukkit.Location location)
      Handles the auto-loot of a grave when a player moves over it.
      Parameters:
      event - The PlayerMoveEvent.
      player - The player moving over the grave.
      location - The location of the grave.
    • removeSpecificCompassNearGrave

      private void removeSpecificCompassNearGrave(org.bukkit.entity.Player player, org.bukkit.Location location)
    • getGraveUUIDFromItemStack

      private UUID getGraveUUIDFromItemStack(org.bukkit.inventory.ItemStack itemStack)
      Retrieves the Grave UUID from the item stack.
      Parameters:
      itemStack - The item stack to check.
      Returns:
      The UUID of the grave associated with the item stack, or null if not found.
    • getBlockDataFromLocation

      private BlockData getBlockDataFromLocation(ChunkData chunkData, org.bukkit.Location location)
      Retrieves the BlockData from the location within the ChunkData.
      Parameters:
      chunkData - The ChunkData containing the block data map.
      location - The location to retrieve the block data from.
      Returns:
      The BlockData at the specified location, or null if not found.