Class InventoryManager

java.lang.Object
me.tayebyassine.homestead.gui.InventoryManager

public final class InventoryManager extends Object
Static registry mapping players to their open menus, with anti-autoclicker protection.

Tracks open menu instances per player, detects rapid click patterns, and temporarily bans players who exceed the click threshold to prevent menu exploits.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Object
    getMenu(org.bukkit.entity.Player player)
    Returns the currently open menu object for a player, or null if none is registered.
    static boolean
    hasMenu(org.bukkit.entity.Player player)
    Checks whether the player has an open menu registered.
    static boolean
    isBanned(org.bukkit.entity.Player player)
    Checks whether the player is currently banned by the anti-autoclicker system.
    static boolean
    isOnCooldown(org.bukkit.entity.Player player)
    Checks whether the player is still within the per-click cooldown period.
    static boolean
    recordAndCheckClick(org.bukkit.entity.Player player)
    Records a click event and checks whether the player has exceeded the click threshold.
    static void
    register(org.bukkit.entity.Player player, Menu menu)
    Registers a standard menu as the currently open menu for a player.
    static void
    register(org.bukkit.entity.Player player, PaginationMenu menu)
    Registers a pagination menu as the currently open menu for a player.
    static void
    unregister(org.bukkit.entity.Player player)
    Unregisters a player's open menu and clears their click cooldown.
    static void
    updateCooldown(org.bukkit.entity.Player player)
    Updates the player's click cooldown timestamp to the current time.

    Methods inherited from class Object

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

    • InventoryManager

      public InventoryManager()
  • Method Details

    • register

      public static void register(org.bukkit.entity.Player player, Menu menu)
      Registers a standard menu as the currently open menu for a player.
      Parameters:
      player - the player whose menu to track
      menu - the menu instance to register
    • register

      public static void register(org.bukkit.entity.Player player, PaginationMenu menu)
      Registers a pagination menu as the currently open menu for a player.
      Parameters:
      player - the player whose menu to track
      menu - the pagination menu instance to register
    • unregister

      public static void unregister(org.bukkit.entity.Player player)
      Unregisters a player's open menu and clears their click cooldown.
      Parameters:
      player - the player to unregister
    • getMenu

      public static Object getMenu(org.bukkit.entity.Player player)
      Returns the currently open menu object for a player, or null if none is registered.
      Parameters:
      player - the player to query
      Returns:
      the open menu (either Menu or PaginationMenu), or null
    • hasMenu

      public static boolean hasMenu(org.bukkit.entity.Player player)
      Checks whether the player has an open menu registered.
      Parameters:
      player - the player to check
      Returns:
      true if a menu is currently tracked for this player
    • isOnCooldown

      public static boolean isOnCooldown(org.bukkit.entity.Player player)
      Checks whether the player is still within the per-click cooldown period.
      Parameters:
      player - the player to check
      Returns:
      true if the player clicked too recently (within CLICK_COOLDOWN_MS)
    • updateCooldown

      public static void updateCooldown(org.bukkit.entity.Player player)
      Updates the player's click cooldown timestamp to the current time.
      Parameters:
      player - the player to update
    • recordAndCheckClick

      public static boolean recordAndCheckClick(org.bukkit.entity.Player player)
      Records a click event and checks whether the player has exceeded the click threshold. If the player exceeds CLICK_THRESHOLD clicks within DETECTION_WINDOW_MS, they are automatically kicked and temporarily banned.
      Parameters:
      player - the player who clicked
      Returns:
      true if the click is allowed, false if the player was banned
    • isBanned

      public static boolean isBanned(org.bukkit.entity.Player player)
      Checks whether the player is currently banned by the anti-autoclicker system. Automatically clears expired bans.
      Parameters:
      player - the player to check
      Returns:
      true if the player is banned and the ban has not yet expired