Class LockHandler

java.lang.Object
me.fami6xx.rpuniverse.core.locks.LockHandler
All Implemented Interfaces:
org.bukkit.event.Listener

public class LockHandler extends Object implements org.bukkit.event.Listener
The lock handler class Handles the creation, management, and interaction with locks. Implements the Listener interface to handle various events.
Version:
1.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor, which loads all locks when the plugin is initialized.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    checkBlockForAnyLocks​(org.bukkit.block.Block block)
    Checks if a block has any associated locks.
    createLock​(org.bukkit.Location location, org.bukkit.Material shownMaterial, List<String> owners, String jobName, int minWorkingLevel)
    Create a lock at the specified location with the specified owners, job name, minimum working level, and shown material.
    static void
    getAllLockBlocksFromBlock​(org.bukkit.block.Block block, org.bukkit.Material type, List<org.bukkit.block.Block> blocksToCheck)
    Retrieves all blocks associated with a lock from a given block.
    Returns a list of all locks managed by this handler.
    getLockByLocation​(org.bukkit.Location location)
    Returns the lock located at the specified location.
    Returns the lock with the specified UUID.
    getLocksByJob​(String jobName)
    Returns a list of locks associated with a specific job.
    Returns a list of locks owned by the specified owner.
    void
    onBlockBreak​(org.bukkit.event.block.BlockBreakEvent event)
    Handles the block break event.
    void
    onPlayerInteractEvent​(org.bukkit.event.player.PlayerInteractEvent event)
    Handles the player interact event.
    void
    onPlayerMove​(org.bukkit.event.player.PlayerMoveEvent event)
    Handles the player move event.
    void
    removeLock​(Lock lock)
    Removes the specified lock from the list of locks.
    void
    Save all locks to the data system when the plugin is shut down.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LockHandler

      public LockHandler()
      Constructor, which loads all locks when the plugin is initialized.
  • Method Details

    • shutdown

      public void shutdown()
      Save all locks to the data system when the plugin is shut down.
    • createLock

      public Lock createLock(org.bukkit.Location location, org.bukkit.Material shownMaterial, List<String> owners, String jobName, int minWorkingLevel)
      Create a lock at the specified location with the specified owners, job name, minimum working level, and shown material.
      Parameters:
      location - The location for the lock.
      shownMaterial - The material to show for the lock.
      owners - The owners of the lock.
      jobName - The name of the job required to open the lock.
      minWorkingLevel - The minimum working level required to open the lock.
      Returns:
      The created lock. Null if a lock already exists at the specified location.
    • getLockByLocation

      @Nullable public Lock getLockByLocation(org.bukkit.Location location)
      Returns the lock located at the specified location.
      Parameters:
      location - The location for which to find the lock.
      Returns:
      The lock at the given location or null if no lock exists.
    • getLocksByOwner

      public List<Lock> getLocksByOwner(String owner)
      Returns a list of locks owned by the specified owner.
      Parameters:
      owner - The name of the owner for whom to find locks.
      Returns:
      List of locks belonging to the specified owner.
    • getLocksByJob

      public List<Lock> getLocksByJob(String jobName)
      Returns a list of locks associated with a specific job.
      Parameters:
      jobName - The name of the job for which to find locks.
      Returns:
      List of locks associated with the specified job.
    • getLockByUUID

      public Lock getLockByUUID(UUID uuid)
      Returns the lock with the specified UUID.
      Parameters:
      uuid - The UUID of the lock to find.
      Returns:
      The lock with the specified UUID or null if no lock exists.
    • getAllLocks

      public List<Lock> getAllLocks()
      Returns a list of all locks managed by this handler. This list is a copy of the internal list and can be modified without affecting the internal list.
      Returns:
      List of all locks.
    • removeLock

      public void removeLock(Lock lock)
      Removes the specified lock from the list of locks.

      This method also triggers a LockDeletedEvent which can be cancelled to prevent the lock from being removed.

      Parameters:
      lock - The lock to remove.
    • onPlayerInteractEvent

      public void onPlayerInteractEvent(org.bukkit.event.player.PlayerInteractEvent event)
      Handles the player interact event.
      Parameters:
      event - The event to handle.
    • onPlayerMove

      public void onPlayerMove(org.bukkit.event.player.PlayerMoveEvent event)
      Handles the player move event.
      Parameters:
      event - The event to handle.
    • getAllLockBlocksFromBlock

      public static void getAllLockBlocksFromBlock(org.bukkit.block.Block block, org.bukkit.Material type, List<org.bukkit.block.Block> blocksToCheck)
      Retrieves all blocks associated with a lock from a given block.
      Parameters:
      block - The block to check.
      type - The material type of the block.
      blocksToCheck - The list to add the blocks to.
    • checkBlockForAnyLocks

      public static boolean checkBlockForAnyLocks(org.bukkit.block.Block block)
      Checks if a block has any associated locks.
      Parameters:
      block - The block to check.
      Returns:
      true if the block has any locks, false otherwise.
    • onBlockBreak

      public void onBlockBreak(org.bukkit.event.block.BlockBreakEvent event)
      Handles the block break event.
      Parameters:
      event - The event to handle.