Class IdleUsersService

Object
IdleUsersService

@Singleton public class IdleUsersService extends Object
Keeps a registration on when which user has last issued a command.
  • Constructor Details

    • IdleUsersService

      public IdleUsersService()
  • Method Details

    • resetUser

      public void resetUser(String name)
    • removeUser

      public LocalDateTime removeUser(String name)
    • getIdleTime

      public Long getIdleTime(String name)
      Retrieves the idle time in minutes, i,e. between the last entered command and the current time. Returns null if the last command date/time is not available.
      Returns:
      Long containing minutes, or null.
    • getIdleTimeInMinAndSeconds

      public String getIdleTimeInMinAndSeconds(String name)
      Returns the time that a user was inactive.
      Parameters:
      name - the name of the user to check
      Returns:
      String the number of minutes and seconds that the player has been idle in the following format: "(<min> min, <sec> sec idle)". Or empty string if user is not playing.
    • getIdleUsers

      public List<String> getIdleUsers()
      Returns a list of users that have been idle for more than one hour.
      Returns:
      list of names of users
    • isNobodyPlaying

      public boolean isNobodyPlaying()
      This method is mostly used to get the game to not do anything if nobody is playing, it's a good idea for efficiency reasons.
      Returns:
      If nobody is playing the game, will return true, otherwise false.