Package dev.deepcore.challenge.inventory
Class SharedInventorySyncService
java.lang.Object
dev.deepcore.challenge.inventory.SharedInventorySyncService
Synchronizes participant inventories when shared-inventory challenge mode is
enabled.
-
Constructor Summary
ConstructorsConstructorDescriptionSharedInventorySyncService(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. -
Method Summary
Modifier and TypeMethodDescriptionvoidcapturePlayerWearableSnapshot(org.bukkit.entity.Player player) Captures the wearable snapshot for a single player.voidClears all cached wearable snapshots.voidconsumeItemFromOtherParticipants(org.bukkit.Material material, UUID sourcePlayerId) Removes one matching item from all participants except the source player.voidconsumeWearableFromOtherParticipants(org.bukkit.Material material, UUID sourcePlayerId) Removes one wearable item from others after a participant equips it.voidconsumeWearableFromParticipants(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.voiddetectNewlyEquippedWearables(org.bukkit.entity.Player player) Detects newly equipped wearables and mirrors consumption across participants.voidremovePlayerWearableSnapshot(UUID playerId) Removes the cached wearable snapshot associated with a player id.voidrequestSharedInventorySync(org.bukkit.entity.Player source) Requests a deferred shared-inventory sync using the provided source player.voidrequestWearableEquipSync(org.bukkit.entity.Player source) Schedules a wearable-equip synchronization pass for the source player.voidCaptures wearable snapshots for all current online participants.voidImmediately synchronizes shared inventory from the first available participant.voidsyncSharedInventoryFromSourceNow(org.bukkit.entity.Player source) Immediately synchronizes shared inventory from the provided source player.
-
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 tasksisChallengeActive- predicate indicating whether a player is in active challenge stateisSharedInventoryEnabled- supplier indicating whether shared inventory is enabledisRunningPhase- supplier indicating whether challenge is currently runningonlineParticipants- supplier for online challenge participantsisDegradingInventoryEnabled- supplier indicating whether degrading inventory is enabledenforceInventorySlotCap- action that enforces inventory slot caps for a playerequippedWearableCounts- mutable wearable snapshot cache keyed by player UUID
-
-
Method Details
-
consumeItemFromOtherParticipants
Removes one matching item from all participants except the source player.- Parameters:
material- material to consume from participant inventoriessourcePlayerId- player UUID that initiated the consume action
-
consumeWearableFromOtherParticipants
Removes one wearable item from others after a participant equips it.- Parameters:
material- wearable material that was equippedsourcePlayerId- 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 equippedsourcePlayerId- player UUID that equipped the wearableparticipants- 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
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.