Class NPCInteractListener
java.lang.Object
com.ranull.graves.listener.integration.playernpc.NPCInteractListener
- All Implemented Interfaces:
org.bukkit.event.Listener
Listens for NPC interaction events and cancels the event if the player interacts with an NPC associated with a grave.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionNPCInteractListener
(Graves plugin, PlayerNPC playerNPC) Constructs a new NPCInteractListener with the specified Graves and PlayerNPC instances. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
handleNPCInteraction
(dev.sergiferry.playernpc.api.NPC.Events.Interact event) Handles the interaction with the NPC.private boolean
isRightClick
(dev.sergiferry.playernpc.api.NPC.Events.Interact event) Checks if the interaction is a right-click.void
onNPCInteract
(dev.sergiferry.playernpc.api.NPC.Events.Interact event) Handles NPC interaction events.private void
openGraveIfExists
(dev.sergiferry.playernpc.api.NPC.Events.Interact event, dev.sergiferry.playernpc.api.NPC.Global npcGlobal, UUID uuid) Opens the grave if it exists in the cache.
-
Field Details
-
plugin
-
playerNPC
-
-
Constructor Details
-
NPCInteractListener
Constructs a new NPCInteractListener with the specified Graves and PlayerNPC instances.- Parameters:
plugin
- The Graves instance to use.playerNPC
- The PlayerNPC instance to use.
-
-
Method Details
-
onNPCInteract
public void onNPCInteract(dev.sergiferry.playernpc.api.NPC.Events.Interact event) Handles NPC interaction events. If the player right-clicks an NPC associated with a grave, it cancels the event and opens the grave for the player.- Parameters:
event
- The NPC.Events.Interact event to handle.
-
isRightClick
private boolean isRightClick(dev.sergiferry.playernpc.api.NPC.Events.Interact event) Checks if the interaction is a right-click.- Parameters:
event
- The NPC.Events.Interact event.- Returns:
- True if the interaction is a right-click, false otherwise.
-
handleNPCInteraction
private void handleNPCInteraction(dev.sergiferry.playernpc.api.NPC.Events.Interact event) Handles the interaction with the NPC. If the NPC is associated with a grave, the event is cancelled and the grave is opened for the player.- Parameters:
event
- The NPC.Events.Interact event.
-
openGraveIfExists
private void openGraveIfExists(dev.sergiferry.playernpc.api.NPC.Events.Interact event, dev.sergiferry.playernpc.api.NPC.Global npcGlobal, UUID uuid) Opens the grave if it exists in the cache.- Parameters:
event
- The NPC.Events.Interact event.npcGlobal
- The global NPC instance.uuid
- The UUID of the grave.
-