Class 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.
    • 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 class java.lang.Object
      • hashCode

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

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

        public java.util.Optional<java.lang.String> getCurrentWorld()
      • contains

        public boolean contains​(java.lang.String worldName)
      • isEmpty

        public boolean isEmpty()
      • setAll

        public void setAll​(WorldTimes worldTimes)