Class NPCInteractListener

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

public class NPCInteractListener extends Object implements 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
    Modifier and Type
    Field
    Description
    private final PlayerNPC
     
    private final Graves
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    NPCInteractListener(Graves plugin, PlayerNPC playerNPC)
    Constructs a new NPCInteractListener with the specified Graves and PlayerNPC instances.
  • Method Summary

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

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

      private final PlayerNPC playerNPC
  • Constructor Details

    • NPCInteractListener

      public NPCInteractListener(Graves plugin, PlayerNPC playerNPC)
      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.