Skip to content

Commit

Permalink
Add countdown fact documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
gabber235 committed Jul 12, 2024
1 parent 35c734d commit 58c82b9
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,31 @@ import java.time.LocalDateTime
import kotlin.math.max

@Entry(
"cooldown_fact",
"Cooldown fact for tracking time also when player is offline",
"countdown_fact",
"A fact that counts down from the set value",
Colors.BLUE,
"material-symbols:person-pin"
)
class CooldownFact(
/**
* The `Cooldown Fact` is a fact reflects the time since the last set value.
*
* When the value is set, it will count every second down from the set value.
*
* Suppose the value is set to 10.
* Then after 3 seconds, the value will be 7.
*
* The countdown will continue regardless if the player is online/offline or if the server is online/offline.
*
* ## How could this be used?
* This can be used to create a cooldown on a specific action.
* For example, daily rewards that the player can only get once a day.
*/
class CountdownFact(
override val id: String = "",
override val name: String = "",
override val comment: String = "",
override val group: Ref<GroupEntry> = emptyRef(),
) : PersistableFactEntry, ExpirableFactEntry {

override fun read(id: FactId): FactData {
val data = super<PersistableFactEntry>.read(id)
return FactData(calculateValue(data), data.lastUpdate)
Expand Down

0 comments on commit 58c82b9

Please sign in to comment.