Class DegradingInventoryService

java.lang.Object
dev.deepcore.challenge.inventory.DegradingInventoryService

public final class DegradingInventoryService extends Object
Manages degrading-inventory slot locking and locked-barrier protections.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DegradingInventoryService(org.bukkit.NamespacedKey lockedInventoryBarrierKey, BooleanSupplier isDegradingInventoryEnabled, Predicate<org.bukkit.entity.Player> isChallengeActive)
    Creates a degrading inventory service.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    clearLockedBarrierSlots(org.bukkit.entity.Player player)
    Removes locked barrier markers from all hotbar and storage slots.
    void
    enforceInventorySlotCap(org.bukkit.entity.Player player)
    Enforces locked-slot barriers and clears stale barrier placement.
    int
    Returns the currently allowed hotbar and storage slot count.
    boolean
    isBarrier(org.bukkit.inventory.ItemStack stack)
    Returns whether the given item stack is any barrier item.
    boolean
    isBarrierProtectionActive(org.bukkit.entity.Player player)
    Returns whether barrier protection rules are active for the player.
    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.
    boolean
    Reduces allowed inventory slots down to, but not below, the provided floor.
    void
    Resets allowed slots to a fully unlocked inventory.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 barriers
      isDegradingInventoryEnabled - supplier reporting whether degrading inventory is enabled
      isChallengeActive - 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 evaluated
      player - 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 slot
      player - player whose inventory lock mapping should be used
      rawSlot - 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