Interface PlayerManager


public interface PlayerManager
The player manager provides access to all information cloudnet has about online and offline players. Obtaining an instance of the player manager is possible through the ServiceRegistry.

If the player manager needs to be obtained from an injection context, the Service annotation can be added to the constructor or method.

private final PlayerManager playerManager;

@Inject
public YourClass(@Service PlayerManager playerManager) {
  this.playerManager = playerManager;
}

If the player manager needs to be obtained without an injection context, use ServiceRegistry.defaultInstance(Class).

 private final PlayerManager playerManager;

 public SomeClass() {
   var serviceRegistry = InjectionLayer.ext().instance(ServiceRegistry.class);
   this.playerManager = serviceRegistry.defaultInstance(PlayerManager.class);
 }
Since:
4.0
See Also:
  • Service
  • ServiceRegistry
  • Method Details

    • onlineCount

      @Range(from=0L,to=2147483647L) int onlineCount()
      Gets the amount of online players connected to the cloudnet network.
      Returns:
      the online player count.
    • registeredCount

      @Range(from=0L,to=9223372036854775807L) long registeredCount()
      Gets the amount of registered players in the database.
      Returns:
      the registered player count.
    • onlinePlayer

      Gets 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.

      Parameters:
      uniqueId - the unique id of the player.
      Returns:
      the online cloud player or null if the player is not online.
      Throws:
      NullPointerException - if the given unique id is null.
    • firstOnlinePlayer

      Gets 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.

      Parameters:
      name - the name of the cloud player.
      Returns:
      the first cloud player with the given name, null if no player was found.
      Throws:
      NullPointerException - if the given name is null.
    • onlinePlayers

      Gets all online cloud players that have the given case-insensitive name.

      All online players are cached on the node while they are online.

      Parameters:
      name - the name of the cloud players.
      Returns:
      a list of all online players with the given name.
      Throws:
      NullPointerException - if the given name is null.
    • environmentOnlinePlayers

      @NonNull @NonNull List<CloudPlayer> environmentOnlinePlayers(@NonNull @NonNull eu.cloudnetservice.driver.service.ServiceEnvironmentType environment)
      Gets 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.

      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.
      Throws:
      NullPointerException - if the given environment is null.
    • globalPlayerExecutor

      @NonNull @NonNull PlayerExecutor globalPlayerExecutor()
      Gets the jvm static player executor for all players that are connected to the network. All methods account for all connected players.
      Returns:
      the global player executor for all players.
    • playerExecutor

      Creates 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.
      Parameters:
      uniqueId - the unique id of the player for the new player executor.
      Returns:
      the player executor for the given player.
      Throws:
      NullPointerException - if the given unique id is null.
    • onlinePlayers

      Gets a player provider that provides access to all players that are connected to the cloudnet network.
      Returns:
      the player provider for all online players.
    • taskOnlinePlayers

      Gets a player provider that provides access to all players that are connected to a service of the task with the given name.
      Parameters:
      task - the task of the service the player has to be connected to.
      Returns:
      the player provider for the given task.
      Throws:
      NullPointerException - if the given task is null.
    • groupOnlinePlayers

      Gets a player provider that provides access to all players that are connected to a service with the group with the given name.
      Parameters:
      group - the group of the service the player has to be connected to.
      Returns:
      the player provider for the given group.
      Throws:
      NullPointerException - if the given group is null.
    • offlinePlayer

      Gets 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.

      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.
      Throws:
      NullPointerException - if the given unique id is null.
    • firstOfflinePlayer

      Gets 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.
      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.
      Throws:
      NullPointerException - if the given name is null.
    • offlinePlayers

      Gets all registered cloud players that have the given case-sensitive name. The player must have been previously connected.
      Parameters:
      name - the name of the registered cloud players.
      Returns:
      a list of all registered players with the given name.
      Throws:
      NullPointerException - if the given name is null.
    • registeredPlayers

      Gets 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.

      Returns:
      a list of all registered players.
    • updateOfflinePlayer

      void updateOfflinePlayer(@NonNull @NonNull CloudOfflinePlayer cloudOfflinePlayer)
      Updates the given cloud offline player in the database, in the local cache of the node and calls the update in the cluster.
      Parameters:
      cloudOfflinePlayer - the offline player to update.
      Throws:
      NullPointerException - if the given offline player is null.
    • updateOnlinePlayer

      void updateOnlinePlayer(@NonNull @NonNull CloudPlayer cloudPlayer)
      Updates the given cloud online player in the cache and calls the update in the cluster.
      Parameters:
      cloudPlayer - the cloud player to update.
      Throws:
      NullPointerException - if the given player is null.
    • deleteCloudOfflinePlayer

      void deleteCloudOfflinePlayer(@NonNull @NonNull CloudOfflinePlayer cloudOfflinePlayer)
      Deletes the given offline player from the database, the local cache of the node and calls the deletion in the cluster.
      Parameters:
      cloudOfflinePlayer - the offline player to delete.
      Throws:
      NullPointerException - if the given offline player is null.
    • onlineCountAsync

      Gets the amount of online players connected to the cloudnet network asynchronously.
      Returns:
      a task containing the online player count.
    • registeredCountAsync

      @NonNull @NonNull CompletableFuture<Long> registeredCountAsync()
      Gets the amount of registered players in the database asynchronously.
      Returns:
      a task containing the registered player count.
    • onlinePlayersAsync

      Gets an online cloud player by its unique id asynchronously.

      The online player is cached on the node until the player disconnects.

      Parameters:
      uniqueId - the unique id of the player.
      Returns:
      a task containing the online cloud player or an empty task if the player is not online.
      Throws:
      NullPointerException - if the given unique id is null.
    • firstOnlinePlayerAsync

      Gets the first cloud player that is online and has the given case-insensitive name asynchronously.

      All online players are cached on the node while they are online.

      Parameters:
      name - the name of the cloud player.
      Returns:
      a task containing the first cloud player with the given name.
      Throws:
      NullPointerException - if the given name is null.
    • onlinePlayersAsync

      Gets all online cloud players that have the given case-insensitive name asynchronously.

      All online players are cached on the node while they are online.

      Parameters:
      name - the name of the cloud players.
      Returns:
      a task containing a list of all online players with the given name.
      Throws:
      NullPointerException - if the given name is null.
    • environmentOnlinePlayersAsync

      @NonNull @NonNull CompletableFuture<List<CloudPlayer>> environmentOnlinePlayersAsync(@NonNull @NonNull eu.cloudnetservice.driver.service.ServiceEnvironmentType env)
      Gets all online cloud players that are connected to a service of given service environment asynchronously.

      All online players are cached on the node while they are online.

      Parameters:
      env - the environment to get all players for.
      Returns:
      a task containing a list of all cloud players connected to a service of the given service environment.
      Throws:
      NullPointerException - if the given environment is null.
    • offlinePlayerAsync

      Gets the offline player associated with the given unique id asynchronously. 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.

      Parameters:
      uniqueId - the unique id of the offline player.
      Returns:
      a task containing the offline player with the given unique id.
      Throws:
      NullPointerException - if the given unique id is null.
    • firstOfflinePlayerAsync

      Gets the first registered offline player that has the given name asynchronously. 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.
      Parameters:
      name - the name of the registered player.
      Returns:
      a task containing the first offline player with the given name.
      Throws:
      NullPointerException - if the given name is null.
    • offlinePlayersAsync

      Gets all registered cloud players that have the given case-sensitive name asynchronously. The player must have been previously connected.
      Parameters:
      name - the name of the registered cloud players.
      Returns:
      a task containing a list of all registered players with the given name.
      Throws:
      NullPointerException - if the given name is null.
    • updateOfflinePlayerAsync

      @NonNull @NonNull CompletableFuture<Void> updateOfflinePlayerAsync(@NonNull @NonNull CloudOfflinePlayer cloudOfflinePlayer)
      Updates the given cloud offline player in the database, in the local cache of the node and calls the update in the cluster asynchronously.
      Parameters:
      cloudOfflinePlayer - the offline player to update.
      Returns:
      a task completing after the player was updated.
      Throws:
      NullPointerException - if the given offline player is null.
    • updateOnlinePlayerAsync

      @NonNull @NonNull CompletableFuture<Void> updateOnlinePlayerAsync(@NonNull @NonNull CloudPlayer cloudPlayer)
      Updates the given cloud online player in the cache and calls the update in the cluster asynchronously.
      Parameters:
      cloudPlayer - the cloud player to update.
      Returns:
      a task completing after the player was updated.
      Throws:
      NullPointerException - if the given player is null.
    • deleteCloudOfflinePlayerAsync

      @NonNull @NonNull CompletableFuture<Void> deleteCloudOfflinePlayerAsync(@NonNull @NonNull CloudOfflinePlayer cloudOfflinePlayer)
      Deletes the given offline player from the database, the local cache of the node and calls the deletion in the cluster asynchronously.
      Parameters:
      cloudOfflinePlayer - the offline player to delete.
      Returns:
      a task completing after the player was deleted.
      Throws:
      NullPointerException - if the given offline player is null.