Class PlayerTeleportListener

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

public class PlayerTeleportListener extends Object implements org.bukkit.event.Listener
Listens for PlayerTeleportEvent to handle interactions with grave blocks and remove specific items from the player's inventory if they teleport into a grave location.
  • Field Summary

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

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

    Modifier and Type
    Method
    Description
    private UUID
    getGraveUUIDFromItemStack(org.bukkit.inventory.ItemStack itemStack)
    Retrieves the Grave UUID from the item stack.
    void
    onPlayerTeleport(org.bukkit.event.player.PlayerTeleportEvent event)
    Handles PlayerTeleportEvent to manage interactions with grave blocks when a player teleports.
    private void
    removeSpecificCompassNearGrave(org.bukkit.entity.Player player, org.bukkit.Location location)
    Removes a specific type of compass (e.g., RECOVERY_COMPASS) from the player's inventory if within a configured block radius of a grave.

    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

    • PlayerTeleportListener

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

    • onPlayerTeleport

      public void onPlayerTeleport(org.bukkit.event.player.PlayerTeleportEvent event)
      Handles PlayerTeleportEvent to manage interactions with grave blocks when a player teleports. Checks if the player's new location is within a 15-block radius of any grave and removes specific compass items from their inventory if so.
      Parameters:
      event - The PlayerTeleportEvent to handle.
    • removeSpecificCompassNearGrave

      private void removeSpecificCompassNearGrave(org.bukkit.entity.Player player, org.bukkit.Location location)
      Removes a specific type of compass (e.g., RECOVERY_COMPASS) from the player's inventory if within a configured block radius of a grave.
      Parameters:
      player - The player to check.
      location - The player's current 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.