Class NodePlayerManager
java.lang.Object
eu.cloudnetservice.modules.bridge.node.player.NodePlayerManager
- All Implemented Interfaces:
PlayerManager
@Singleton
@Provides(PlayerManager.class)
public class NodePlayerManager
extends Object
implements PlayerManager
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final PlayerProviderprotected final eu.cloudnetservice.node.command.CommandProviderprotected final Stringprotected final eu.cloudnetservice.driver.event.EventManagerprotected final eu.cloudnetservice.node.database.NodeDatabaseProviderprotected final com.github.benmanes.caffeine.cache.LoadingCache<UUID, Optional<CloudOfflinePlayer>> protected final Map<UUID, CloudPlayer> protected final com.google.common.util.concurrent.Striped<Lock> -
Constructor Summary
ConstructorsConstructorDescriptionNodePlayerManager(@NonNull eu.cloudnetservice.driver.event.EventManager eventManager, @NonNull eu.cloudnetservice.driver.network.rpc.factory.RPCFactory providerFactory, @NonNull eu.cloudnetservice.node.command.CommandProvider commandProvider, @NonNull eu.cloudnetservice.node.cluster.sync.DataSyncRegistry dataSyncRegistry, @NonNull eu.cloudnetservice.driver.network.rpc.handler.RPCHandlerRegistry handlerRegistry, @NonNull eu.cloudnetservice.node.database.NodeDatabaseProvider nodeDatabaseProvider) -
Method Summary
Modifier and TypeMethodDescriptionprotected @NonNull eu.cloudnetservice.node.database.LocalDatabasedatabase()voiddeleteCloudOfflinePlayer(@NonNull CloudOfflinePlayer cloudOfflinePlayer) Deletes the given offline player from the database, the local cache of the node and calls the deletion in the cluster.environmentOnlinePlayers(@NonNull eu.cloudnetservice.driver.service.ServiceEnvironmentType environment) Gets all online cloud players that are connected to a service of given service environment.firstOfflinePlayer(@NonNull String name) Gets the first registered offline player that has the given name.firstOnlinePlayer(@NonNull String name) Gets the first cloud player that is online and has the given case-insensitive name.Gets the jvm static player executor for all players that are connected to the network.groupOnlinePlayers(@NonNull String group) Gets a player provider that provides access to all players that are connected to a service with the group with the given name.voidloginPlayer(@NonNull NetworkPlayerProxyInfo networkPlayerProxyInfo, @Nullable NetworkServiceInfo joinedServiceInfo) protected voidloginPlayer0(@NonNull NetworkPlayerProxyInfo networkPlayerProxyInfo, @Nullable NetworkServiceInfo joinedServiceInfo) voidlogoutPlayer(@NonNull CloudPlayer cloudPlayer) voidlogoutPlayer(@Nullable UUID uniqueId, @Nullable String name, @Nullable Predicate<CloudPlayer> tester) private voidlogoutPlayer0(@NonNull CloudPlayer cloudPlayer) offlinePlayer(@NonNull UUID uniqueId) Gets the offline player associated with the given unique id.offlinePlayers(@NonNull String name) Gets all registered cloud players that have the given case-sensitive name.intGets the amount of online players connected to the cloudnet network.onlinePlayer(@NonNull UUID uniqueId) Gets an online cloud player by its unique id from the cache on the node.Gets a player provider that provides access to all players that are connected to the cloudnet network.onlinePlayers(@NonNull String name) Gets all online cloud players that have the given case-insensitive name.playerExecutor(@NonNull UUID uniqueId) Creates a new player executor for the player associated with the given unique id.players()protected voidprocessLogin(@NonNull CloudPlayer cloudPlayer) voidprocessLoginMessage(@NonNull CloudPlayer cloudPlayer) voidpushOfflinePlayerCache(@NonNull UUID uniqueId, @Nullable CloudOfflinePlayer cloudOfflinePlayer) voidpushOnlinePlayerCache(@NonNull CloudPlayer cloudPlayer) longGets the amount of registered players in the database.Gets a list with all registered players from the database.private voidprivate voidprotected @NonNull CloudPlayerselectPlayerForLogin(@NonNull NetworkPlayerProxyInfo connectionInfo, @Nullable NetworkServiceInfo joinedServiceInfo) taskOnlinePlayers(@NonNull String task) Gets a player provider that provides access to all players that are connected to a service of the task with the given name.voidUpdates the given cloud offline player in the database, in the local cache of the node and calls the update in the cluster.voidupdateOnlinePlayer(@NonNull CloudPlayer cloudPlayer) Updates the given cloud online player in the cache and calls the update in the cluster.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface eu.cloudnetservice.modules.bridge.player.PlayerManager
deleteCloudOfflinePlayerAsync, firstOfflinePlayerAsync, firstOnlinePlayerAsync, offlinePlayerAsync, offlinePlayerAsync, onlineCountAsync, onlinePlayerAsync, onlinePlayerAsync, onlinePlayerAsync, registeredCountAsync, updateOfflinePlayerAsync, updateOnlinePlayerAsync
-
Field Details
-
databaseName
-
eventManager
protected final eu.cloudnetservice.driver.event.EventManager eventManager -
commandProvider
protected final eu.cloudnetservice.node.command.CommandProvider commandProvider -
nodeDatabaseProvider
protected final eu.cloudnetservice.node.database.NodeDatabaseProvider nodeDatabaseProvider -
onlinePlayers
-
allPlayerProvider
-
playerReadWriteLocks
-
offlinePlayerCache
protected final com.github.benmanes.caffeine.cache.LoadingCache<UUID,Optional<CloudOfflinePlayer>> offlinePlayerCache
-
-
Constructor Details
-
NodePlayerManager
@Inject public NodePlayerManager(@NonNull @NonNull eu.cloudnetservice.driver.event.EventManager eventManager, @NonNull @NonNull eu.cloudnetservice.driver.network.rpc.factory.RPCFactory providerFactory, @NonNull @NonNull eu.cloudnetservice.node.command.CommandProvider commandProvider, @NonNull @NonNull eu.cloudnetservice.node.cluster.sync.DataSyncRegistry dataSyncRegistry, @NonNull @NonNull eu.cloudnetservice.driver.network.rpc.handler.RPCHandlerRegistry handlerRegistry, @NonNull @NonNull eu.cloudnetservice.node.database.NodeDatabaseProvider nodeDatabaseProvider)
-
-
Method Details
-
registerPlayerCommand
@PostConstruct private void registerPlayerCommand() -
registerListeners
@PostConstruct private void registerListeners() -
onlineCount
public int onlineCount()Description copied from interface:PlayerManagerGets the amount of online players connected to the cloudnet network.- Specified by:
onlineCountin interfacePlayerManager- Returns:
- the online player count.
-
registeredCount
public long registeredCount()Description copied from interface:PlayerManagerGets the amount of registered players in the database.- Specified by:
registeredCountin interfacePlayerManager- Returns:
- the registered player count.
-
onlinePlayer
Description copied from interface:PlayerManagerGets an online cloud player by its unique id from the cache on the node.The online player is cached on the node until the player disconnects.
- Specified by:
onlinePlayerin interfacePlayerManager- Parameters:
uniqueId- the unique id of the player.- Returns:
- the online cloud player or null if the player is not online.
-
firstOnlinePlayer
Description copied from interface:PlayerManagerGets the first cloud player that is online and has the given case-insensitive name.All online players are cached on the node while they are online.
- Specified by:
firstOnlinePlayerin interfacePlayerManager- Parameters:
name- the name of the cloud player.- Returns:
- the first cloud player with the given name, null if no player was found.
-
onlinePlayers
Description copied from interface:PlayerManagerGets all online cloud players that have the given case-insensitive name.All online players are cached on the node while they are online.
- Specified by:
onlinePlayersin interfacePlayerManager- Parameters:
name- the name of the cloud players.- Returns:
- a list of all online players with the given name.
-
environmentOnlinePlayers
@NonNull public @NonNull List<CloudPlayer> environmentOnlinePlayers(@NonNull @NonNull eu.cloudnetservice.driver.service.ServiceEnvironmentType environment) Description copied from interface:PlayerManagerGets all online cloud players that are connected to a service of given service environment.All online players are cached on the node while they are online.
- Specified by:
environmentOnlinePlayersin interfacePlayerManager- Parameters:
environment- the environment to get all players for.- Returns:
- a list of all cloud players connected to a service of the given service environment.
-
onlinePlayers
Description copied from interface:PlayerManagerGets a player provider that provides access to all players that are connected to the cloudnet network.- Specified by:
onlinePlayersin interfacePlayerManager- Returns:
- the player provider for all online players.
-
taskOnlinePlayers
Description copied from interface:PlayerManagerGets a player provider that provides access to all players that are connected to a service of the task with the given name.- Specified by:
taskOnlinePlayersin interfacePlayerManager- Parameters:
task- the task of the service the player has to be connected to.- Returns:
- the player provider for the given task.
-
groupOnlinePlayers
Description copied from interface:PlayerManagerGets a player provider that provides access to all players that are connected to a service with the group with the given name.- Specified by:
groupOnlinePlayersin interfacePlayerManager- Parameters:
group- the group of the service the player has to be connected to.- Returns:
- the player provider for the given group.
-
offlinePlayer
Description copied from interface:PlayerManagerGets the offline player associated with the given unique id. The player must have been previously connected.The cloud offline player is cached on the node and retrieved from the cache if present otherwise loaded from the database.
- Specified by:
offlinePlayerin interfacePlayerManager- Parameters:
uniqueId- the unique id of the offline player.- Returns:
- the offline player with the given unique id or null if there is no player.
-
firstOfflinePlayer
Description copied from interface:PlayerManagerGets the first registered offline player that has the given name. The player must have been previously connected. If the player is cached on the corresponding node which is handling the method call, then the given name check will be done case-insensitive against the underlying cache, if the player data must be queried from the database then this check is case-sensitive.- Specified by:
firstOfflinePlayerin interfacePlayerManager- Parameters:
name- the name of the registered player.- Returns:
- the first offline player with the given name or null if there is no player with the name.
-
offlinePlayers
Description copied from interface:PlayerManagerGets all registered cloud players that have the given case-sensitive name. The player must have been previously connected.- Specified by:
offlinePlayersin interfacePlayerManager- Parameters:
name- the name of the registered cloud players.- Returns:
- a list of all registered players with the given name.
-
registeredPlayers
Description copied from interface:PlayerManagerGets a list with all registered players from the database.This method should not be used if the database contains a lot of registered players. It can happen that the entire heap of the cloud is used up by this method and therefore errors occur.
- Specified by:
registeredPlayersin interfacePlayerManager- Returns:
- a list of all registered players.
-
updateOfflinePlayer
Description copied from interface:PlayerManagerUpdates the given cloud offline player in the database, in the local cache of the node and calls the update in the cluster.- Specified by:
updateOfflinePlayerin interfacePlayerManager- Parameters:
player- the offline player to update.
-
updateOnlinePlayer
Description copied from interface:PlayerManagerUpdates the given cloud online player in the cache and calls the update in the cluster.- Specified by:
updateOnlinePlayerin interfacePlayerManager- Parameters:
cloudPlayer- the cloud player to update.
-
deleteCloudOfflinePlayer
Description copied from interface:PlayerManagerDeletes the given offline player from the database, the local cache of the node and calls the deletion in the cluster.- Specified by:
deleteCloudOfflinePlayerin interfacePlayerManager- Parameters:
cloudOfflinePlayer- the offline player to delete.
-
globalPlayerExecutor
Description copied from interface:PlayerManagerGets the jvm static player executor for all players that are connected to the network. All methods account for all connected players.- Specified by:
globalPlayerExecutorin interfacePlayerManager- Returns:
- the global player executor for all players.
-
playerExecutor
Description copied from interface:PlayerManagerCreates a new player executor for the player associated with the given unique id. The player executor is created even if there is no online player with the given unique id.- Specified by:
playerExecutorin interfacePlayerManager- Parameters:
uniqueId- the unique id of the player for the new player executor.- Returns:
- the player executor for the given player.
-
pushOfflinePlayerCache
-
pushOnlinePlayerCache
-
database
-
players
-
loginPlayer
public void loginPlayer(@NonNull @NonNull NetworkPlayerProxyInfo networkPlayerProxyInfo, @Nullable @Nullable NetworkServiceInfo joinedServiceInfo) -
loginPlayer0
protected void loginPlayer0(@NonNull @NonNull NetworkPlayerProxyInfo networkPlayerProxyInfo, @Nullable @Nullable NetworkServiceInfo joinedServiceInfo) -
selectPlayerForLogin
@NonNull protected @NonNull CloudPlayer selectPlayerForLogin(@NonNull @NonNull NetworkPlayerProxyInfo connectionInfo, @Nullable @Nullable NetworkServiceInfo joinedServiceInfo) -
processLogin
-
processLoginMessage
-
getOrRegisterOfflinePlayer
@NonNull public @NonNull CloudOfflinePlayer getOrRegisterOfflinePlayer(@NonNull @NonNull NetworkPlayerProxyInfo proxyInfo) -
logoutPlayer
-
logoutPlayer0
-
logoutPlayer
-