Class RedisBungeeAPI

java.lang.Object
com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI

public class RedisBungeeAPI extends Object
This class exposes some internal RedisBungee functions. You obtain an instance of this object by invoking RedisBungee.getApi().
Since:
0.2.3
Author:
tuxed
  • Method Details

    • getPlayerCount

      public final int getPlayerCount()
      Get a combined count of all players on this network.
      Returns:
      a count of all players found
    • getLastOnline

      public final long getLastOnline(@NonNull @NonNull UUID player)
      Get the last time a player was on. If the player is currently online, this will return 0. If the player has not been recorded, this will return -1. Otherwise it will return a value in milliseconds.
      Parameters:
      player - a player name
      Returns:
      the last time a player was on, if online returns a 0
    • getServerFor

      public final net.md_5.bungee.api.config.ServerInfo getServerFor(@NonNull @NonNull UUID player)
      Get the server where the specified player is playing. This function also deals with the case of local players as well, and will return local information on them.
      Parameters:
      player - a player name
      Returns:
      a ServerInfo for the server the player is on.
    • getPlayersOnline

      public final Set<UUID> getPlayersOnline()
      Get a combined list of players on this network.

      Note that this function returns an instance of ImmutableSet.

      Returns:
      a Set with all players found
    • getHumanPlayersOnline

      public final Collection<String> getHumanPlayersOnline()
      Get a combined list of players on this network, as a collection of usernames.
      Returns:
      a Set with all players found
      Since:
      0.3
      See Also:
    • getServerToPlayers

      public final com.google.common.collect.Multimap<String,UUID> getServerToPlayers()
      Get a full list of players on all servers.
      Returns:
      a immutable Multimap with all players found on this server
      Since:
      0.2.5
    • getPlayersOnServer

      public final Set<UUID> getPlayersOnServer(@NonNull @NonNull String server)
      Get a list of players on the server with the given name.
      Parameters:
      server - a server name
      Returns:
      a Set with all players found on this server
    • getPlayersOnProxy

      public final Set<UUID> getPlayersOnProxy(@NonNull @NonNull String server)
      Get a list of players on the specified proxy.
      Parameters:
      server - a server name
      Returns:
      a Set with all UUIDs found on this proxy
    • isPlayerOnline

      public final boolean isPlayerOnline(@NonNull @NonNull UUID player)
      Convenience method: Checks if the specified player is online.
      Parameters:
      player - a player name
      Returns:
      if the player is online
    • getPlayerIp

      public final InetAddress getPlayerIp(@NonNull @NonNull UUID player)
      Get the InetAddress associated with this player.
      Parameters:
      player - the player to fetch the IP for
      Returns:
      an InetAddress if the player is online, null otherwise
      Since:
      0.2.4
    • getProxy

      public final String getProxy(@NonNull @NonNull UUID player)
      Get the RedisBungee proxy ID this player is connected to.
      Parameters:
      player - the player to fetch the IP for
      Returns:
      the proxy the player is connected to, or null if they are offline
      Since:
      0.3.3
    • sendProxyCommand

      public final void sendProxyCommand(@NonNull @NonNull String command)
      Sends a proxy command to all proxies.
      Parameters:
      command - the command to send and execute
      Since:
      0.2.5
      See Also:
    • sendProxyCommand

      public final void sendProxyCommand(@NonNull @NonNull String proxyId, @NonNull @NonNull String command)
      Sends a proxy command to the proxy with the given ID. "allservers" means all proxies.
      Parameters:
      proxyId - a proxy ID
      command - the command to send and execute
      Since:
      0.2.5
      See Also:
    • sendChannelMessage

      public final void sendChannelMessage(@NonNull @NonNull String channel, @NonNull @NonNull String message)
      Sends a message to a PubSub channel. The channel has to be subscribed to on this, or another redisbungee instance for PubSubMessageEvent to fire.
      Parameters:
      channel - The PubSub channel
      message - the message body to send
      Since:
      0.3.3
    • getServerId

      public final String getServerId()
      Get the current BungeeCord server ID for this server.
      Returns:
      the current server ID
      Since:
      0.2.5
      See Also:
    • getAllServers

      public final List<String> getAllServers()
      Get all the linked proxies in this network.
      Returns:
      the list of all proxies
      Since:
      0.2.5
      See Also:
    • registerPubSubChannels

      public final void registerPubSubChannels(String... channels)
      Register (a) PubSub channel(s), so that you may handle PubSubMessageEvent for it.
      Parameters:
      channels - the channels to register
      Since:
      0.3
    • unregisterPubSubChannels

      public final void unregisterPubSubChannels(String... channels)
      Unregister (a) PubSub channel(s).
      Parameters:
      channels - the channels to unregister
      Since:
      0.3
    • getNameFromUuid

      public final String getNameFromUuid(@NonNull @NonNull UUID uuid)
      Fetch a name from the specified UUID. UUIDs are cached locally and in Redis. This function falls back to Mojang as a last resort, so calls may be blocking.

      For the common use case of translating a list of UUIDs into names, use getHumanPlayersOnline() instead.

      If performance is a concern, use getNameFromUuid(java.util.UUID, boolean) as this allows you to disable Mojang lookups.

      Parameters:
      uuid - the UUID to fetch the name for
      Returns:
      the name for the UUID
      Since:
      0.3
    • getNameFromUuid

      public final String getNameFromUuid(@NonNull @NonNull UUID uuid, boolean expensiveLookups)
      Fetch a name from the specified UUID. UUIDs are cached locally and in Redis. This function can fall back to Mojang as a last resort if expensiveLookups is true, so calls may be blocking.

      For the common use case of translating the list of online players into names, use getHumanPlayersOnline().

      If performance is a concern, set expensiveLookups to false as this will disable lookups via Mojang.

      Parameters:
      uuid - the UUID to fetch the name for
      expensiveLookups - whether or not to perform potentially expensive lookups
      Returns:
      the name for the UUID
      Since:
      0.3.2
    • getUuidFromName

      public final UUID getUuidFromName(@NonNull @NonNull String name)
      Fetch a UUID from the specified name. Names are cached locally and in Redis. This function falls back to Mojang as a last resort, so calls may be blocking.

      If performance is a concern, see getUuidFromName(String, boolean), which disables the following functions:

      • Searching local entries case-insensitively
      • Searching Mojang
      Parameters:
      name - the UUID to fetch the name for
      Returns:
      the UUID for the name
      Since:
      0.3
    • getUuidFromName

      public final UUID getUuidFromName(@NonNull @NonNull String name, boolean expensiveLookups)
      Fetch a UUID from the specified name. Names are cached locally and in Redis. This function falls back to Mojang as a last resort if expensiveLookups is true, so calls may be blocking.

      If performance is a concern, set expensiveLookups to false to disable searching Mojang and searching for usernames case-insensitively.

      Parameters:
      name - the UUID to fetch the name for
      expensiveLookups - whether or not to perform potentially expensive lookups
      Returns:
      the UUID for the name
      Since:
      0.3.2
    • getJedisPool

      public redis.clients.jedis.JedisPool getJedisPool()
      This gets Redis Bungee Jedis pool
      Returns:
      JedisPool
      Since:
      0.6.5
    • getRedisBungeeApi

      public static RedisBungeeAPI getRedisBungeeApi()
      This alternative to RedisBungee.getApi() which now deprecated. but to maintain old plugins compatibility it won't be removed.
      Returns:
      the API instance.
      Since:
      0.6.5