Package dev.deepcore.challenge.session
Class RunProgressService
java.lang.Object
dev.deepcore.challenge.session.RunProgressService
Tracks run milestone progress and computes split durations for record
storage.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classImmutable run-progress view model for action-bar/status rendering.static final classImmutable split-duration values used for persisted run records. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncalculateSectionDurations(long runStartMillis, long dragonDeathTime, long fallbackDurationMillis) Calculates each run split duration, falling back to overall duration when a milestone was not reached.intcountTeamBlazeRods(List<org.bukkit.entity.Player> participants) Counts total blaze rods across the given participant inventories.currentObjectiveText(int teamBlazeRodCount) Builds the current objective label for run HUD/status output.booleanReturns whether any participant has reached the End.booleanReturns whether any participant has reached the Nether.booleanReturns whether the dragon kill milestone has been reached.voidmarkDragonKilled(long timestampMillis) Marks the dragon kill milestone timestamp.booleanmarkEndReached(long timestampMillis) Marks the End milestone if it has not already been recorded.booleanmarkNetherReached(long timestampMillis) Marks the Nether milestone if it has not already been recorded.maybeMarkBlazeObjectiveReached(boolean runningPhase, int teamBlazeRodCount, long timestampMillis) Marks the blaze-rod milestone once the threshold is met during a run.voidreset()Resets all tracked run milestones.longresolveElapsedReferenceTime(long currentTimeMillis) Resolves the timestamp to use for elapsed-time rendering.snapshotForDisplay(int teamBlazeRodCount) Captures a lightweight immutable progress snapshot for UI rendering.voidupdateMilestonesFromParticipants(List<org.bukkit.entity.Player> participants, long timestampMillis) Updates Nether/End milestones by inspecting participant world locations.
-
Constructor Details
-
RunProgressService
public RunProgressService()
-
-
Method Details
-
reset
public void reset()Resets all tracked run milestones. -
hasReachedNether
public boolean hasReachedNether()Returns whether any participant has reached the Nether.- Returns:
- true when the Nether milestone has been recorded
-
hasReachedEnd
public boolean hasReachedEnd()Returns whether any participant has reached the End.- Returns:
- true when the End milestone has been recorded
-
isDragonKilled
public boolean isDragonKilled()Returns whether the dragon kill milestone has been reached.- Returns:
- true when the dragon kill milestone has been recorded
-
resolveElapsedReferenceTime
public long resolveElapsedReferenceTime(long currentTimeMillis) Resolves the timestamp to use for elapsed-time rendering.- Parameters:
currentTimeMillis- current wall-clock timestamp in milliseconds- Returns:
- timestamp to use for elapsed-time calculations
-
markNetherReached
public boolean markNetherReached(long timestampMillis) Marks the Nether milestone if it has not already been recorded.- Parameters:
timestampMillis- timestamp in milliseconds when the milestone was reached- Returns:
- true when the milestone was newly recorded
-
markEndReached
public boolean markEndReached(long timestampMillis) Marks the End milestone if it has not already been recorded.- Parameters:
timestampMillis- timestamp in milliseconds when the milestone was reached- Returns:
- true when the milestone was newly recorded
-
markDragonKilled
public void markDragonKilled(long timestampMillis) Marks the dragon kill milestone timestamp.- Parameters:
timestampMillis- timestamp in milliseconds when the dragon was killed
-
maybeMarkBlazeObjectiveReached
public OptionalLong maybeMarkBlazeObjectiveReached(boolean runningPhase, int teamBlazeRodCount, long timestampMillis) Marks the blaze-rod milestone once the threshold is met during a run.- Parameters:
runningPhase- whether the challenge is currently in the running phaseteamBlazeRodCount- total blaze rods currently held across participantstimestampMillis- timestamp in milliseconds for this progress sample- Returns:
- split duration from Nether entry to blaze objective completion when newly reached
-
currentObjectiveText
Builds the current objective label for run HUD/status output.- Parameters:
teamBlazeRodCount- total blaze rods currently held across participants- Returns:
- objective text representing the next run milestone
-
snapshotForDisplay
Captures a lightweight immutable progress snapshot for UI rendering.- Parameters:
teamBlazeRodCount- total blaze rods currently held across participants- Returns:
- immutable progress snapshot for action-bar and sidebar rendering
-
countTeamBlazeRods
Counts total blaze rods across the given participant inventories.- Parameters:
participants- participants whose inventories should be counted- Returns:
- total blaze rod count across all participant inventories
-
updateMilestonesFromParticipants
public void updateMilestonesFromParticipants(List<org.bukkit.entity.Player> participants, long timestampMillis) Updates Nether/End milestones by inspecting participant world locations.- Parameters:
participants- participants whose world locations should be inspectedtimestampMillis- timestamp in milliseconds for newly reached milestones
-
calculateSectionDurations
public RunProgressService.SectionDurations calculateSectionDurations(long runStartMillis, long dragonDeathTime, long fallbackDurationMillis) Calculates each run split duration, falling back to overall duration when a milestone was not reached.- Parameters:
runStartMillis- run start timestamp in millisecondsdragonDeathTime- dragon death timestamp in millisecondsfallbackDurationMillis- fallback duration used when a milestone is missing- Returns:
- calculated run section durations for persistence and display
-