Class WorldTimes

java.lang.Object
com.djrapitops.plan.gathering.domain.WorldTimes

public class WorldTimes extends Object
Class that tracks the time spent in each World based on GMTimes.
  • Constructor Details

    • WorldTimes

      public WorldTimes(String startingWorld, 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(Map<String,GMTimes> times)
      Re-Creates an existing WorldTimes object for viewing.
      Parameters:
      times - Map of each World's GMTimes object.
    • WorldTimes

      public WorldTimes()
  • Method Details

    • 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(String worldName, 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(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(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 Map<String,GMTimes> getWorldTimes()
    • setGMTimesForWorld

      public void setGMTimesForWorld(String world, GMTimes gmTimes)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getCurrentWorld

      public Optional<String> getCurrentWorld()
    • add

      public void add(WorldTimes toAdd)
    • contains

      public boolean contains(String worldName)
    • isEmpty

      public boolean isEmpty()
    • setAll

      public void setAll(WorldTimes worldTimes)
    • toJson

      public String toJson()