Interface User

  • All Known Implementing Classes:
    SFSUser

    public interface User
    • Method Detail

      • getId

        int getId()
        Get the unique user ID
        Returns:
        the user id
      • getSession

        ISession getSession()
        Get the session object linked to this User
        Returns:
        the user sessions object
      • getIpAddress

        java.lang.String getIpAddress()
        Return the User IP address
        Returns:
        the IP address
      • getName

        java.lang.String getName()
        Get the User name
        Returns:
        the user name
      • getBuddyProperties

        BuddyProperties getBuddyProperties()
        Get the BuddyProperty object
        Returns:
        the buddy properties
      • setName

        void setName​(java.lang.String name)
        DO NOT use this method User names cannot be changed at runtime: they are unique and decided at login time exclusively. If you wish to alter the username of a specific client it can be done a login time as described in this article
      • isLocal

        boolean isLocal()
        Returns true if the User is connected to the local cluster node
        Returns:
        true if the user is local to the cluster node
      • isNpc

        boolean isNpc()
        Returns the NPC flag
        Returns:
        true if the user is an NPC
      • getLoginTime

        long getLoginTime()
        Get the user login time (Unix timestamp)
        Returns:
        login time
      • setLastLoginTime

        void setLastLoginTime​(long lastLoginTime)
      • getLastJoinedRoom

        Room getLastJoinedRoom()
        A reference to the last Room that was joined by this User
        Returns:
        the last joined Room
      • getJoinedRooms

        java.util.List<Room> getJoinedRooms()
        A list of Rooms currently joined by the User
        Returns:
        the list of Rooms
      • addJoinedRoom

        void addJoinedRoom​(Room room)
      • removeJoinedRoom

        void removeJoinedRoom​(Room room)
      • isJoinedInRoom

        boolean isJoinedInRoom​(Room room)
        Check if a User is joined in a Room
        Parameters:
        room - the Room
        Returns:
        true if the User is joined in the passed Room
      • addCreatedRoom

        void addCreatedRoom​(Room room)
      • removeCreatedRoom

        void removeCreatedRoom​(Room room)
      • getCreatedRooms

        java.util.List<Room> getCreatedRooms()
        Get a list of Rooms created by this User
        Returns:
        the list of Rooms (if any)
      • subscribeGroup

        void subscribeGroup​(java.lang.String groupId)
      • unsubscribeGroup

        void unsubscribeGroup​(java.lang.String groupId)
      • getSubscribedGroups

        java.util.List<java.lang.String> getSubscribedGroups()
        Get a list of Room Groups subscribed by the User
        Returns:
        the list of groups
      • isSubscribedToGroup

        boolean isSubscribedToGroup​(java.lang.String groupId)
        Check if the User is subscribed to a certain Room Group
        Parameters:
        groupId - the id of the group
        Returns:
        true if the User is currently subscribed to the group
      • getZone

        Zone getZone()
        Get the Zone where the User is currently logged in
        Returns:
        the Zone
      • setZone

        void setZone​(Zone zone)
      • getPlayerId

        int getPlayerId()
        Get the playerId of the User (if applicable).
        The User should be currently joined in a Game Room for this method to return a meaningful value.
        playerId == 0, if the Room is not a Game Room
        playerID > 0, if the Room is a Game Room
        Returns:
        the player id
      • getPlayerId

        int getPlayerId​(Room room)
        Get the playerId for the User in a specific Room
        Parameters:
        room -
        Returns:
        the playerId
        See Also:
        getPlayerId()
      • setPlayerId

        void setPlayerId​(int id,
                         Room room)
      • getPlayerIds

        java.util.Map<Room,​java.lang.Integer> getPlayerIds()
        Get a map of playerId(s) per Room
        This method can be used when a player is currently engaged in multiple games at the same time
        Returns:
        the map of playerIds per room
        See Also:
        getPlayerId()
      • isPlayer

        boolean isPlayer()
        Check if the User is a Player in the current Room (only for Game Rooms)
        Returns:
        true if the User is a player in the current Room
      • isSpectator

        boolean isSpectator()
        Check if the User is a Spectator in the current Room (only for Game Rooms)
        Returns:
        true if the User is a spectator in the current Room
      • isPlayer

        boolean isPlayer​(Room room)
        Check if the User is Player in a specific Room
        Parameters:
        room - the room
        Returns:
        true if the User is a player in the specified Room
      • isSpectator

        boolean isSpectator​(Room room)
        Check if the User is Spectator in a specific Room
        Parameters:
        room - the rooom
        Returns:
        true if the User is a spectator in the specified Room
      • isJoining

        boolean isJoining()
      • setJoining

        void setJoining​(boolean flag)
      • isConnected

        boolean isConnected()
        Check if the User is connected
        Returns:
        true if the user has an active connection
      • setConnected

        void setConnected​(boolean flag)
      • isSuperUser

        boolean isSuperUser()
        Check if the User has SuperUser capabilities (kicking/banning etc...)
        Returns:
        true if the User has SuperUser capabilities
      • getMaxAllowedVariables

        int getMaxAllowedVariables()
        Get the maximum allowed User Variables for this User
        Returns:
        the number of variables
      • setMaxAllowedVariables

        void setMaxAllowedVariables​(int max)
      • getProperty

        java.lang.Object getProperty​(java.lang.Object key)
        Get any custom property attached to this User.
        Parameters:
        key -
        Returns:
        the value
      • getProperties

        java.util.concurrent.ConcurrentMap<java.lang.Object,​java.lang.Object> getProperties()
        Get the map with all User properties
        Returns:
        the map with all User properties
      • setProperty

        void setProperty​(java.lang.Object key,
                         java.lang.Object val)
        Attach a custom (server-side only) property to the User object
        Parameters:
        key - the property name
        val - the property value
      • containsProperty

        boolean containsProperty​(java.lang.Object key)
        Checks whether a custom property exists or not
        Parameters:
        key - the name of the property
        Returns:
        true if the property exists
      • removeProperty

        void removeProperty​(java.lang.Object key)
        Removes a custom property
        Parameters:
        key - the name of the property
      • getOwnedRoomsCount

        int getOwnedRoomsCount()
        Get the number of Rooms created by the User
        Returns:
        the number of Rooms created by the User
      • isBeingKicked

        boolean isBeingKicked()
      • setBeingKicked

        void setBeingKicked​(boolean flag)
      • getPrivilegeId

        short getPrivilegeId()
        Return the Privilege ID of the User. Default privilege IDs are:
        • 0: guest
        • 1: regular user
        • 2: moderator
        • 3: administrator
        Returns:
        the privilege id
      • setPrivilegeId

        void setPrivilegeId​(short id)
      • getVariable

        UserVariable getVariable​(java.lang.String key)
        Return a UserVariable. It can return null if the UserVariable doesn't exist
        Parameters:
        key - the name of the variable
        Returns:
        the UserVariable
      • getVariables

        java.util.List<UserVariable> getVariables()
        Obtain the full list of UserVariables
        Returns:
        the list of UserVariables
      • removeVariable

        void removeVariable​(java.lang.String varName)
      • containsVariable

        boolean containsVariable​(java.lang.String varName)
        Checks whether or not the User has a specific UserVariable
        Parameters:
        varName - the name of the variable
        Returns:
        true if the UserVariable exists, false otherwise
      • getVariablesCount

        int getVariablesCount()
        Return the number of UserVariables for this User
        Returns:
        the number of UserVariables
      • getBadWordsWarnings

        int getBadWordsWarnings()
      • setBadWordsWarnings

        void setBadWordsWarnings​(int count)
      • getFloodWarnings

        int getFloodWarnings()
      • setFloodWarnings

        void setFloodWarnings​(int count)
      • getExtFloodWarnings

        int getExtFloodWarnings()
      • setExtFloodWarnings

        void setExtFloodWarnings​(int count)
      • getLastRequestTime

        long getLastRequestTime()
      • setLastRequestTime

        void setLastRequestTime​(long millis)
      • updateLastRequestTime

        void updateLastRequestTime()
      • getUserVariablesData

        ISFSArray getUserVariablesData()
      • getDump

        java.lang.String getDump()
        Return a full dump of the User properties, useful for debugging
        Returns:
        the User debug info
      • getReconnectionSeconds

        int getReconnectionSeconds()
      • setReconnectionSeconds

        void setReconnectionSeconds​(int seconds)
      • getLastProxyList

        java.util.List<User> getLastProxyList()
      • setLastProxyList

        void setLastProxyList​(java.util.List<User> proxyList)
      • getLastMMOItemsList

        java.util.List<BaseMMOItem> getLastMMOItemsList()
      • setLastMMOItemsList

        void setLastMMOItemsList​(java.util.List<BaseMMOItem> mmoItemsList)
      • getCurrentMMORoom

        MMORoom getCurrentMMORoom()
      • getCountry

        Country getCountry()
        If the geolocation service is enabled in the Zone it will return the location of the user
        Returns:
        the location of the user, null if the geolocation DB did not provide a match
        Since:
        2.12
      • addPersistentRoomVarReference

        void addPersistentRoomVarReference​(Room target)
      • getPersistentRoomVarReferences

        java.util.Set<java.lang.Integer> getPersistentRoomVarReferences()