Class WorldTimes
- java.lang.Object
-
- com.djrapitops.plan.gathering.domain.WorldTimes
-
public class WorldTimes extends java.lang.Object
Class that tracks the time spent in each World based on GMTimes.
-
-
Constructor Summary
Constructors Constructor Description WorldTimes()
WorldTimes(java.lang.String startingWorld, java.lang.String startingGM, long time)
Creates a new Empty WorldTimes object.WorldTimes(java.util.Map<java.lang.String,GMTimes> times)
Re-Creates an existing WorldTimes object for viewing.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(WorldTimes toAdd)
boolean
contains(java.lang.String worldName)
boolean
equals(java.lang.Object o)
java.util.Optional<java.lang.String>
getCurrentWorld()
GMTimes
getGMTimes(java.lang.String world)
Used for Quick access to time of each GameMode.long
getTotal()
long
getWorldPlaytime(java.lang.String world)
Used to get a total playtime of a world.java.util.Map<java.lang.String,GMTimes>
getWorldTimes()
int
hashCode()
void
setGMTimesForWorld(java.lang.String world, GMTimes gmTimes)
java.lang.String
toString()
void
updateState(long changeTime)
Updates the state at the end of the session.void
updateState(java.lang.String worldName, java.lang.String gameMode, long changeTime)
Updates the time status to match the new state.
-
-
-
Constructor Detail
-
WorldTimes
public WorldTimes(java.lang.String startingWorld, java.lang.String startingGM, long time)
Creates a new Empty WorldTimes object.- Parameters:
startingWorld
- World to start the calculations at.startingGM
- GameMode to start the calculations at.time
- Epoch ms the time calculation should start
-
WorldTimes
public WorldTimes(java.util.Map<java.lang.String,GMTimes> times)
Re-Creates an existing WorldTimes object for viewing.- Parameters:
times
- Map of each World's GMTimes object.
-
WorldTimes
public WorldTimes()
-
-
Method Detail
-
updateState
public void updateState(long changeTime)
Updates the state at the end of the session. Does not change world or GameMode.- Parameters:
changeTime
- epoch ms session ended.
-
updateState
public void updateState(java.lang.String worldName, java.lang.String gameMode, long changeTime)
Updates the time status to match the new state.- Parameters:
worldName
- World name of the world swapped to.gameMode
- GameMode name of the gm swapped to.changeTime
- Epoch ms the change occurred.
-
getWorldPlaytime
public long getWorldPlaytime(java.lang.String world)
Used to get a total playtime of a world.- Parameters:
world
- World name being checked.- Returns:
- total milliseconds spent in a world.
-
getTotal
public long getTotal()
-
getGMTimes
public GMTimes getGMTimes(java.lang.String world)
Used for Quick access to time of each GameMode.Should not be used for changing state, because if player has not played in the world, an empty GMTimes is given, with 0 as playtime
- Parameters:
world
- World name being checked.- Returns:
- GMTimes object with play times of each GameMode.
-
getWorldTimes
public java.util.Map<java.lang.String,GMTimes> getWorldTimes()
-
setGMTimesForWorld
public void setGMTimesForWorld(java.lang.String world, GMTimes gmTimes)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getCurrentWorld
public java.util.Optional<java.lang.String> getCurrentWorld()
-
add
public void add(WorldTimes toAdd)
-
contains
public boolean contains(java.lang.String worldName)
-
-