Package dev.deepcore.challenge.inventory
Class DegradingInventoryService
java.lang.Object
dev.deepcore.challenge.inventory.DegradingInventoryService
Manages degrading-inventory slot locking and locked-barrier protections.
-
Constructor Summary
ConstructorsConstructorDescriptionDegradingInventoryService(org.bukkit.NamespacedKey lockedInventoryBarrierKey, BooleanSupplier isDegradingInventoryEnabled, Predicate<org.bukkit.entity.Player> isChallengeActive) Creates a degrading inventory service. -
Method Summary
Modifier and TypeMethodDescriptionvoidclearLockedBarrierSlots(org.bukkit.entity.Player player) Removes locked barrier markers from all hotbar and storage slots.voidenforceInventorySlotCap(org.bukkit.entity.Player player) Enforces locked-slot barriers and clears stale barrier placement.intReturns the currently allowed hotbar and storage slot count.booleanisBarrier(org.bukkit.inventory.ItemStack stack) Returns whether the given item stack is any barrier item.booleanisBarrierProtectionActive(org.bukkit.entity.Player player) Returns whether barrier protection rules are active for the player.booleanisLockedRawSlot(org.bukkit.inventory.InventoryView view, org.bukkit.entity.Player player, int rawSlot) Returns whether a raw inventory-view slot maps to a locked player slot.booleanreduceAllowedInventorySlots(int minSlots) Reduces allowed inventory slots down to, but not below, the provided floor.voidResets allowed slots to a fully unlocked inventory.booleanshouldCancelLockedSlotClick(org.bukkit.event.inventory.InventoryClickEvent event, org.bukkit.entity.Player player) Returns whether a click should be canceled due to locked-slot protections.
-
Constructor Details
-
DegradingInventoryService
public DegradingInventoryService(org.bukkit.NamespacedKey lockedInventoryBarrierKey, BooleanSupplier isDegradingInventoryEnabled, Predicate<org.bukkit.entity.Player> isChallengeActive) Creates a degrading inventory service.- Parameters:
lockedInventoryBarrierKey- metadata key used to mark managed lock barriersisDegradingInventoryEnabled- supplier reporting whether degrading inventory is enabledisChallengeActive- predicate reporting whether a player is in active challenge state
-
-
Method Details
-
resetAllowedInventorySlots
public void resetAllowedInventorySlots()Resets allowed slots to a fully unlocked inventory. -
getAllowedInventorySlots
public int getAllowedInventorySlots()Returns the currently allowed hotbar and storage slot count.- Returns:
- number of unlocked hotbar plus storage slots
-
reduceAllowedInventorySlots
public boolean reduceAllowedInventorySlots(int minSlots) Reduces allowed inventory slots down to, but not below, the provided floor.- Parameters:
minSlots- minimum allowed slot count to preserve- Returns:
- true when the allowed slot count was reduced
-
enforceInventorySlotCap
public void enforceInventorySlotCap(org.bukkit.entity.Player player) Enforces locked-slot barriers and clears stale barrier placement.- Parameters:
player- player whose inventory should be normalized to current slot cap
-
clearLockedBarrierSlots
public void clearLockedBarrierSlots(org.bukkit.entity.Player player) Removes locked barrier markers from all hotbar and storage slots.- Parameters:
player- player whose inventory lock markers should be cleared
-
shouldCancelLockedSlotClick
public boolean shouldCancelLockedSlotClick(org.bukkit.event.inventory.InventoryClickEvent event, org.bukkit.entity.Player player) Returns whether a click should be canceled due to locked-slot protections.- Parameters:
event- inventory click event being evaluatedplayer- player whose inventory interaction is being checked- Returns:
- true when the click should be canceled
-
isBarrierProtectionActive
public boolean isBarrierProtectionActive(org.bukkit.entity.Player player) Returns whether barrier protection rules are active for the player.- Parameters:
player- player to evaluate- Returns:
- true when barrier protections must be enforced for that player
-
isLockedRawSlot
public boolean isLockedRawSlot(org.bukkit.inventory.InventoryView view, org.bukkit.entity.Player player, int rawSlot) Returns whether a raw inventory-view slot maps to a locked player slot.- Parameters:
view- inventory view containing the raw slotplayer- player whose inventory lock mapping should be usedrawSlot- raw slot index in the view- Returns:
- true when the raw slot resolves to a currently locked player slot
-
isBarrier
public boolean isBarrier(org.bukkit.inventory.ItemStack stack) Returns whether the given item stack is any barrier item.- Parameters:
stack- item stack to inspect- Returns:
- true when the stack exists and is a barrier
-