Class AbstractRedisBungeeAPI

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

public abstract class AbstractRedisBungeeAPI extends Object
This abstract class is extended by platform plugin to provide some platform specific methods. overall its general contains all methods needed by external usage.
Since:
0.8.0
  • Field Details

  • Constructor Details

    • AbstractRedisBungeeAPI

      public AbstractRedisBungeeAPI(RedisBungeePlugin<?> plugin)
  • 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 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
    • getServerNameFor

      public final @Nullable String getServerNameFor(@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 uuid
      Returns:
      a String name for the server the player is on. Can be Null if plugins is doing weird stuff to the proxy internals
    • 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 Multimap<String,UUID> getServerToPlayers()
      Get a full list of players on all servers.
      Returns:
      a immutable Multimap with all players found on this network
      Since:
      0.2.5
    • getPlayersOnServer

      public final Set<UUID> getPlayersOnServer(@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 String proxyID)
      Get a list of players on the specified proxy.
      Parameters:
      proxyID - proxy id
      Returns:
      a Set with all UUIDs found on this proxy
    • isPlayerOnline

      public final boolean isPlayerOnline(@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 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 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 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 String proxyId, @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 String channel, @NonNull String message)
      Sends a message to a PubSub channel which makes PubSubMessageEvent fire.

      Note: Since 0.12.0 registering a channel api is no longer required

      Parameters:
      channel - The PubSub channel
      message - the message body to send
      Since:
      0.3.3
    • getProxyId

      public final String getProxyId()
      Get the current BungeeCord / Velocity proxy ID for this server.
      Returns:
      the current server ID
      Since:
      0.8.0
      See Also:
    • getServerId

      @Deprecated public final String getServerId()
      Deprecated.
      to avoid confusion between A server and A proxy see #getProxyId()
      Get the current BungeeCord / Velocity proxy ID for this server.
      Returns:
      the current server ID
      Since:
      0.2.5
      See Also:
    • getAllProxies

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

      @Deprecated public final List<String> getAllServers()
      Deprecated.
      to avoid confusion between A server and A proxy see see getAllProxies()
      Get all the linked proxies in this network.
      Returns:
      the list of all proxies
      Since:
      0.2.5
      See Also:
    • registerPubSubChannels

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

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

      public final String getNameFromUuid(@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 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 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 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
    • kickPlayer

      @Deprecated public void kickPlayer(String playerName, String message)
      Deprecated.
      Kicks a player from the network calls getUuidFromName(String) to get uuid
      Parameters:
      playerName - player name
      message - kick message that player will see on kick
      Since:
      0.8.0
    • kickPlayer

      @Deprecated public void kickPlayer(UUID playerUUID, String message)
      Deprecated.
      Kicks a player from the network
      Parameters:
      playerUUID - player name
      message - kick message that player will see on kick
      Since:
      0.8.0
    • kickPlayer

      public void kickPlayer(String playerName, Component message)
      Kicks a player from the network calls getUuidFromName(String) to get uuid
      Parameters:
      playerName - player name
      message - kick message that player will see on kick
      Since:
      0.12.0
    • kickPlayer

      public void kickPlayer(UUID playerUUID, Component message)
      Kicks a player from the network
      Parameters:
      playerUUID - player name
      message - kick message that player will see on kick
      Since:
      0.12.0
    • requestJedis

      public Jedis requestJedis()
      This gives you instance of Jedis
      Returns:
      Jedis
      Throws:
      IllegalStateException - if the getMode() is not equal to RedisBungeeMode.SINGLE
      Since:
      0.7.0
      See Also:
    • getJedisPool

      public JedisPool getJedisPool()
      This gets Redis Bungee JedisPool
      Returns:
      JedisPool
      Throws:
      IllegalStateException - if the getMode() is not equal to RedisBungeeMode.SINGLE
      IllegalStateException - if JedisPool compatibility mode is disabled in the config
      Since:
      0.6.5
    • requestClusterJedis

      public JedisCluster requestClusterJedis()
      This gives you an instance of JedisCluster that can't be closed see NotClosableJedisCluster
      Returns:
      JedisCluster
      Throws:
      IllegalStateException - if the getMode() is not equal to RedisBungeeMode.CLUSTER
      Since:
      0.8.0
    • requestJedisPooled

      public JedisPooled requestJedisPooled()
      This gives you an instance of JedisPooled that can't be closed see NotClosableJedisPooled
      Returns:
      JedisPooled
      Throws:
      IllegalStateException - if the getMode() is not equal to RedisBungeeMode.SINGLE
      Since:
      0.8.0
    • getSummoner

      public Summoner<?> getSummoner()
      returns Summoner class responsible for Single Jedis JedisPooled with JedisPool, Cluster Jedis JedisCluster handling
      Returns:
      Summoner
      Since:
      0.8.0
    • getMode

      public RedisBungeeMode getMode()
      shows what mode is RedisBungee is on Basically what every redis mode is used like cluster or single instance.
      Returns:
      RedisBungeeMode
      Since:
      0.8.0
    • getAbstractRedisBungeeAPI

      public static AbstractRedisBungeeAPI getAbstractRedisBungeeAPI()