Package com.ranull.graves.listener
Class PlayerMoveListener
java.lang.Object
com.ranull.graves.listener.PlayerMoveListener
- All Implemented Interfaces:
org.bukkit.event.Listener
Listener for handling PlayerMoveEvent to manage interactions with graves and related mechanics.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPlayerMoveListener(Graves plugin) Constructs a PlayerMoveListener with the specified Graves plugin. -
Method Summary
Modifier and TypeMethodDescriptionprivate BlockDatagetBlockDataFromLocation(ChunkData chunkData, org.bukkit.Location location) Retrieves the BlockData from the location within the ChunkData.private UUIDgetGraveUUIDFromItemStack(org.bukkit.inventory.ItemStack itemStack) Retrieves the Grave UUID from the item stack.private voidhandleGraveAutoLootOnWalk(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 booleanhasPlayerMoved(org.bukkit.event.player.PlayerMoveEvent event) Checks if the player has moved to a different block.private booleanisLocationContainingGrave(org.bukkit.Location location) Checks if the location contains a grave.private booleanisLocationSafe(org.bukkit.Location location) Checks if the location is safe for the player.private booleanisNotSpectatorMode(org.bukkit.entity.Player player) Checks if the player is not in Spectator mode.voidonPlayerMove(org.bukkit.event.player.PlayerMoveEvent event) Handles the PlayerMoveEvent to manage interactions with graves and update player locations.private voidremoveSpecificCompassNearGrave(org.bukkit.entity.Player player, org.bukkit.Location location)
-
Field Details
-
plugin
-
compassCheckCooldown
-
-
Constructor Details
-
PlayerMoveListener
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.
-
handleGraveAutoLootOnWalk
private void handleGraveAutoLootOnWalk(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
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
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.
-