Class InventoryManager
java.lang.Object
me.tayebyassine.homestead.gui.InventoryManager
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectgetMenu(org.bukkit.entity.Player player) Returns the currently open menu object for a player, ornullif none is registered.static booleanhasMenu(org.bukkit.entity.Player player) Checks whether the player has an open menu registered.static booleanisBanned(org.bukkit.entity.Player player) Checks whether the player is currently banned by the anti-autoclicker system.static booleanisOnCooldown(org.bukkit.entity.Player player) Checks whether the player is still within the per-click cooldown period.static booleanrecordAndCheckClick(org.bukkit.entity.Player player) Records a click event and checks whether the player has exceeded the click threshold.static voidRegisters a standard menu as the currently open menu for a player.static voidregister(org.bukkit.entity.Player player, PaginationMenu menu) Registers a pagination menu as the currently open menu for a player.static voidunregister(org.bukkit.entity.Player player) Unregisters a player's open menu and clears their click cooldown.static voidupdateCooldown(org.bukkit.entity.Player player) Updates the player's click cooldown timestamp to the current time.
-
Constructor Details
-
InventoryManager
public InventoryManager()
-
-
Method Details
-
register
Registers a standard menu as the currently open menu for a player.- Parameters:
player- the player whose menu to trackmenu- the menu instance to register
-
register
Registers a pagination menu as the currently open menu for a player.- Parameters:
player- the player whose menu to trackmenu- 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
Returns the currently open menu object for a player, ornullif none is registered.- Parameters:
player- the player to query- Returns:
- the open menu (either
MenuorPaginationMenu), ornull
-
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:
trueif 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:
trueif the player clicked too recently (withinCLICK_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 exceedsCLICK_THRESHOLDclicks withinDETECTION_WINDOW_MS, they are automatically kicked and temporarily banned.- Parameters:
player- the player who clicked- Returns:
trueif the click is allowed,falseif 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:
trueif the player is banned and the ban has not yet expired
-