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 TypeMethodDescriptionboolean
addAvailableSeconds
(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.double
Retrieves the number of full minutes available.double
Retrieves the total available seconds for the player.int
Gets the number of banked 5-minute tickets for the player.Gets the last hour checked for daily playtime reset.boolean
isAfk()
Checks if the player is currently marked as AFK.boolean
Checks if the player should be kicked on AFK timeout.void
reset()
Resets the available seconds to zero.void
setAfk
(boolean afk) Sets the player's AFK status.void
setAvailableSeconds
(double seconds) Sets the total available seconds for the player.void
setBankedTickets
(int tickets) Sets the number of banked 5-minute tickets for the player.void
setKickOnAfkTimeout
(boolean kick) Sets whether the player should be kicked on AFK timeout.void
setLastHourChecked
(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:
true
if the player is AFK,false
otherwise.
-
setAfk
public void setAfk(boolean afk) Sets the player's AFK status.- Parameters:
afk
-true
to mark the player as AFK,false
otherwise.
-
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
null
if 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:
true
if the player should be kicked on AFK timeout,false
otherwise.
-
setKickOnAfkTimeout
public void setKickOnAfkTimeout(boolean kick) Sets whether the player should be kicked on AFK timeout.- Parameters:
kick
-true
to kick the player on AFK timeout,false
-