Package dev.deepcore.challenge.vitals
Class SharedVitalsService
java.lang.Object
dev.deepcore.challenge.vitals.SharedVitalsService
Synchronizes team health and hunger state for shared-vitals challenge mode.
-
Constructor Summary
ConstructorsConstructorDescriptionSharedVitalsService(org.bukkit.plugin.java.JavaPlugin plugin, Supplier<List<org.bukkit.entity.Player>> playersForSharedVitals) Creates a shared-vitals synchronizer. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether a health sync task is currently applying state.booleanReturns whether a hunger sync task is currently applying state.voidResets internal sync guard flags.voidsyncHealthAcrossParticipants(double targetHealth) Syncs team health to a target value without damage effects.voidsyncHealthAcrossParticipants(double targetHealth, UUID damageSourceId, boolean applyHurtEffect) Syncs team health to a target value with optional hurt feedback.voidsyncHungerAcrossParticipants(int targetFoodLevel, float targetSaturation) Syncs team hunger and saturation to the supplied target values.voidsyncHungerFromFoodLevelChange(org.bukkit.entity.Player source, int eventFoodLevel) Derives shared hunger targets from a food-level event and applies sync.voidCopies health from the first active participant to the entire team.voidSyncs team hunger from the most-filled active participant.
-
Constructor Details
-
SharedVitalsService
public SharedVitalsService(org.bukkit.plugin.java.JavaPlugin plugin, Supplier<List<org.bukkit.entity.Player>> playersForSharedVitals) Creates a shared-vitals synchronizer.- Parameters:
plugin- plugin instance used for scheduler tasksplayersForSharedVitals- supplier providing current shared-vitals participants
-
-
Method Details
-
isSyncingHealth
public boolean isSyncingHealth()Returns whether a health sync task is currently applying state.- Returns:
- true while health synchronization is in progress
-
isSyncingHunger
public boolean isSyncingHunger()Returns whether a hunger sync task is currently applying state.- Returns:
- true while hunger synchronization is in progress
-
resetSyncFlags
public void resetSyncFlags()Resets internal sync guard flags. -
syncHealthAcrossParticipants
public void syncHealthAcrossParticipants(double targetHealth) Syncs team health to a target value without damage effects.- Parameters:
targetHealth- target health value to apply to non-spectator participants
-
syncHealthAcrossParticipants
public void syncHealthAcrossParticipants(double targetHealth, UUID damageSourceId, boolean applyHurtEffect) Syncs team health to a target value with optional hurt feedback.- Parameters:
targetHealth- target health value to apply to non-spectator participantsdamageSourceId- source player UUID for optional hurt feedback filteringapplyHurtEffect- true to play hurt effects for affected non-source participants
-
syncHungerAcrossParticipants
public void syncHungerAcrossParticipants(int targetFoodLevel, float targetSaturation) Syncs team hunger and saturation to the supplied target values.- Parameters:
targetFoodLevel- target food level to applytargetSaturation- target saturation value to apply
-
syncHungerFromFoodLevelChange
public void syncHungerFromFoodLevelChange(org.bukkit.entity.Player source, int eventFoodLevel) Derives shared hunger targets from a food-level event and applies sync.- Parameters:
source- player whose food-level change triggered this synceventFoodLevel- proposed food level from the event
-