Class PlaytimeData
java.lang.Object
com.storytimeproductions.stweaks.playtime.PlaytimeData
Represents the playtime data for a player. Stores the available seconds a player has and their
AFK (away-from-keyboard) status.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a PlaytimeData object with zero available seconds and not AFK.PlaytimeData(double availableSeconds) Constructs a PlaytimeData object with a predefined number of available seconds. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddAvailableSeconds(double seconds) Adds or subtracts seconds from the player's available time.Gets the time in milliseconds since the player was last marked as AFK.doubleRetrieves the number of full minutes available.doubleRetrieves the total available seconds for the player.intGets the number of banked 5-minute tickets for the player.Gets the last hour checked for daily playtime reset.booleanisAfk()Checks if the player is currently marked as AFK.booleanChecks if the player should be kicked on AFK timeout.voidreset()Resets the available seconds to zero.voidsetAfk(boolean afk) Sets the player's AFK status.voidsetAvailableSeconds(double seconds) Sets the total available seconds for the player.voidsetBankedTickets(int tickets) Sets the number of banked 5-minute tickets for the player.voidsetKickOnAfkTimeout(boolean kick) Sets whether the player should be kicked on AFK timeout.voidsetLastHourChecked(Integer hour) Sets the last hour checked for daily playtime reset.
-
Constructor Details
-
PlaytimeData
public PlaytimeData(double availableSeconds) Constructs a PlaytimeData object with a predefined number of available seconds.- Parameters:
availableSeconds- The initial amount of available seconds.
-
PlaytimeData
public PlaytimeData()Constructs a PlaytimeData object with zero available seconds and not AFK.
-
-
Method Details
-
reset
public void reset()Resets the available seconds to zero. -
addAvailableSeconds
public boolean addAvailableSeconds(double seconds) Adds or subtracts seconds from the player's available time.- Parameters:
seconds- The seconds to add (can be negative).
-
setAvailableSeconds
public void setAvailableSeconds(double seconds) Sets the total available seconds for the player.- Parameters:
seconds- The new total available seconds.
-
getAvailableSeconds
public double getAvailableSeconds()Retrieves the total available seconds for the player.- Returns:
- The total available seconds as a long.
-
getAvailableMinutes
public double getAvailableMinutes()Retrieves the number of full minutes available.- Returns:
- The total available minutes.
-
isAfk
public boolean isAfk()Checks if the player is currently marked as AFK.- Returns:
trueif the player is AFK,falseotherwise.
-
setAfk
public void setAfk(boolean afk) Sets the player's AFK status.- Parameters:
afk-trueto mark the player as AFK,falseotherwise.
-
getAfkSince
Gets the time in milliseconds since the player was last marked as AFK.- Returns:
- The time in milliseconds since the player was last marked AFK, or
nullif the player is not currently AFK.
-
getBankedTickets
public int getBankedTickets()Gets the number of banked 5-minute tickets for the player.- Returns:
- The number of banked tickets.
-
setBankedTickets
public void setBankedTickets(int tickets) Sets the number of banked 5-minute tickets for the player.- Parameters:
tickets- The number of tickets to set.
-
getLastHourChecked
Gets the last hour checked for daily playtime reset.- Returns:
- the last checked hour, or null if never set
-
setLastHourChecked
Sets the last hour checked for daily playtime reset.- Parameters:
hour- the hour to set
-
isKickOnAfkTimeout
public boolean isKickOnAfkTimeout()Checks if the player should be kicked on AFK timeout.- Returns:
trueif the player should be kicked on AFK timeout,falseotherwise.
-
setKickOnAfkTimeout
public void setKickOnAfkTimeout(boolean kick) Sets whether the player should be kicked on AFK timeout.- Parameters:
kick-trueto kick the player on AFK timeout,false
-