Class SharedInventorySyncService

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

public final class SharedInventorySyncService extends Object
Synchronizes participant inventories when shared-inventory challenge mode is enabled.
  • Constructor Details

    • SharedInventorySyncService

      public SharedInventorySyncService(org.bukkit.plugin.java.JavaPlugin plugin, Predicate<org.bukkit.entity.Player> isChallengeActive, BooleanSupplier isSharedInventoryEnabled, Supplier<Boolean> isRunningPhase, Supplier<List<org.bukkit.entity.Player>> onlineParticipants, BooleanSupplier isDegradingInventoryEnabled, Consumer<org.bukkit.entity.Player> enforceInventorySlotCap, Map<UUID,Map<org.bukkit.Material,Integer>> equippedWearableCounts)
      Creates a shared inventory synchronization service.
      Parameters:
      plugin - plugin instance used for scheduling sync tasks
      isChallengeActive - predicate indicating whether a player is in active challenge state
      isSharedInventoryEnabled - supplier indicating whether shared inventory is enabled
      isRunningPhase - supplier indicating whether challenge is currently running
      onlineParticipants - supplier for online challenge participants
      isDegradingInventoryEnabled - supplier indicating whether degrading inventory is enabled
      enforceInventorySlotCap - action that enforces inventory slot caps for a player
      equippedWearableCounts - mutable wearable snapshot cache keyed by player UUID
  • Method Details

    • requestSharedInventorySync

      public void requestSharedInventorySync(org.bukkit.entity.Player source)
      Requests a deferred shared-inventory sync using the provided source player.
      Parameters:
      source - preferred source player for synchronization
    • syncSharedInventoryFromFirstParticipant

      public void syncSharedInventoryFromFirstParticipant()
      Immediately synchronizes shared inventory from the first available participant.
    • syncSharedInventoryFromSourceNow

      public void syncSharedInventoryFromSourceNow(org.bukkit.entity.Player source)
      Immediately synchronizes shared inventory from the provided source player.
      Parameters:
      source - preferred source player for synchronization
    • consumeItemFromOtherParticipants

      public void consumeItemFromOtherParticipants(org.bukkit.Material material, UUID sourcePlayerId)
      Removes one matching item from all participants except the source player.
      Parameters:
      material - material to consume from participant inventories
      sourcePlayerId - player UUID that initiated the consume action
    • consumeWearableFromOtherParticipants

      public void consumeWearableFromOtherParticipants(org.bukkit.Material material, UUID sourcePlayerId)
      Removes one wearable item from others after a participant equips it.
      Parameters:
      material - wearable material that was equipped
      sourcePlayerId - player UUID that equipped the wearable
    • consumeWearableFromParticipants

      public void consumeWearableFromParticipants(org.bukkit.Material material, UUID sourcePlayerId, List<org.bukkit.entity.Player> participants)
      Removes one wearable item from a provided participant snapshot except the source player.
      Parameters:
      material - wearable material that was equipped
      sourcePlayerId - player UUID that equipped the wearable
      participants - participant snapshot to apply removal against
    • requestWearableEquipSync

      public void requestWearableEquipSync(org.bukkit.entity.Player source)
      Schedules a wearable-equip synchronization pass for the source player.
      Parameters:
      source - player whose newly equipped wearables should be detected
    • detectNewlyEquippedWearables

      public void detectNewlyEquippedWearables(org.bukkit.entity.Player player)
      Detects newly equipped wearables and mirrors consumption across participants.
      Parameters:
      player - player whose equipped wearable set should be diffed
    • snapshotEquippedWearablesForParticipants

      public void snapshotEquippedWearablesForParticipants()
      Captures wearable snapshots for all current online participants.
    • capturePlayerWearableSnapshot

      public void capturePlayerWearableSnapshot(org.bukkit.entity.Player player)
      Captures the wearable snapshot for a single player.
      Parameters:
      player - player whose wearable snapshot should be stored
    • removePlayerWearableSnapshot

      public void removePlayerWearableSnapshot(UUID playerId)
      Removes the cached wearable snapshot associated with a player id.
      Parameters:
      playerId - player UUID whose snapshot should be removed
    • clearWearableSnapshots

      public void clearWearableSnapshots()
      Clears all cached wearable snapshots.