Package com.smartfoxserver.v2.entities
Interface User
-
- All Known Implementing Classes:
SFSUser
public interface User
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddCreatedRoom(Room room)voidaddJoinedRoom(Room room)voidaddPersistentRoomVarReference(Room target)booleancontainsProperty(java.lang.Object key)Checks whether a custom property exists or notbooleancontainsVariable(java.lang.String varName)Checks whether or not the User has a specific UserVariablevoiddisconnect(IDisconnectionReason reason)intgetBadWordsWarnings()BuddyPropertiesgetBuddyProperties()Get the BuddyProperty objectCountrygetCountry()If the geolocation service is enabled in the Zone it will return the location of the userjava.util.List<Room>getCreatedRooms()Get a list of Rooms created by this UserMMORoomgetCurrentMMORoom()java.lang.StringgetDump()Return a full dump of the User properties, useful for debuggingintgetExtFloodWarnings()intgetFloodWarnings()intgetId()Get the unique user IDjava.lang.StringgetIpAddress()Return the User IP addressjava.util.List<Room>getJoinedRooms()A list of Rooms currently joined by the UserRoomgetLastJoinedRoom()A reference to the last Room that was joined by this Userjava.util.List<BaseMMOItem>getLastMMOItemsList()java.util.List<User>getLastProxyList()longgetLastRequestTime()longgetLoginTime()Get the user login time (Unix timestamp)intgetMaxAllowedVariables()Get the maximum allowed User Variables for this Userjava.lang.StringgetName()Get the User nameintgetOwnedRoomsCount()Get the number of Rooms created by the Userjava.util.Set<java.lang.Integer>getPersistentRoomVarReferences()intgetPlayerId()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 RoomintgetPlayerId(Room room)Get the playerId for the User in a specific Roomjava.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 timeshortgetPrivilegeId()Return the Privilege ID of the User.java.util.concurrent.ConcurrentMap<java.lang.Object,java.lang.Object>getProperties()Get the map with all User propertiesjava.lang.ObjectgetProperty(java.lang.Object key)Get any custom property attached to this User.intgetReconnectionSeconds()ISessiongetSession()Get the session object linked to this Userjava.util.List<java.lang.String>getSubscribedGroups()Get a list of Room Groups subscribed by the UserISFSArraygetUserVariablesData()UserVariablegetVariable(java.lang.String key)Return a UserVariable.java.util.List<UserVariable>getVariables()Obtain the full list of UserVariablesintgetVariablesCount()Return the number of UserVariables for this UserZonegetZone()Get the Zone where the User is currently logged inbooleanisBeingKicked()booleanisConnected()Check if the User is connectedbooleanisJoinedInRoom(Room room)Check if a User is joined in a RoombooleanisJoining()booleanisLocal()Returns true if the User is connected to the local cluster nodebooleanisNpc()Returns the NPC flagbooleanisPlayer()Check if the User is a Player in the current Room (only for Game Rooms)booleanisPlayer(Room room)Check if the User is Player in a specific RoombooleanisSpectator()Check if the User is a Spectator in the current Room (only for Game Rooms)booleanisSpectator(Room room)Check if the User is Spectator in a specific RoombooleanisSubscribedToGroup(java.lang.String groupId)Check if the User is subscribed to a certain Room GroupbooleanisSuperUser()Check if the User has SuperUser capabilities (kicking/banning etc...)voidremoveCreatedRoom(Room room)voidremoveJoinedRoom(Room room)voidremoveProperty(java.lang.Object key)Removes a custom propertyvoidremoveVariable(java.lang.String varName)voidsetBadWordsWarnings(int count)voidsetBeingKicked(boolean flag)voidsetConnected(boolean flag)voidsetExtFloodWarnings(int count)voidsetFloodWarnings(int count)voidsetJoining(boolean flag)voidsetLastLoginTime(long lastLoginTime)voidsetLastMMOItemsList(java.util.List<BaseMMOItem> mmoItemsList)voidsetLastProxyList(java.util.List<User> proxyList)voidsetLastRequestTime(long millis)voidsetMaxAllowedVariables(int max)voidsetName(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.voidsetPlayerId(int id, Room room)voidsetPrivilegeId(short id)voidsetProperty(java.lang.Object key, java.lang.Object val)Attach a custom (server-side only) property to the User objectvoidsetReconnectionSeconds(int seconds)voidsetVariable(UserVariable userVariable)voidsetVariables(java.util.List<UserVariable> userVariables)voidsetZone(Zone zone)voidsubscribeGroup(java.lang.String groupId)ISFSArraytoSFSArray()ISFSArraytoSFSArray(Room room)voidunsubscribeGroup(java.lang.String groupId)voidupdateLastRequestTime()
-
-
-
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 nameval- 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
-
setVariable
void setVariable(UserVariable userVariable) throws SFSVariableException
- Throws:
SFSVariableException
-
setVariables
void setVariables(java.util.List<UserVariable> userVariables) throws SFSVariableException
- Throws:
SFSVariableException
-
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()
-
toSFSArray
ISFSArray toSFSArray()
-
disconnect
void disconnect(IDisconnectionReason reason)
-
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()
-
-