Class RedisBungeeAPI
java.lang.Object
com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI
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 Summary
Modifier and TypeMethodDescriptionGet all the linked proxies in this network.final Collection<String>
Get a combined list of players on this network, as a collection of usernames.redis.clients.jedis.JedisPool
This gets Redis Bungee Jedis poolfinal long
getLastOnline
(@NonNull UUID player) Get the last time a player was on.final String
getNameFromUuid
(@NonNull UUID uuid) Fetch a name from the specified UUID.final String
getNameFromUuid
(@NonNull UUID uuid, boolean expensiveLookups) Fetch a name from the specified UUID.final int
Get a combined count of all players on this network.final InetAddress
getPlayerIp
(@NonNull UUID player) Get theInetAddress
associated with this player.Get a combined list of players on this network.getPlayersOnProxy
(@NonNull String server) Get a list of players on the specified proxy.getPlayersOnServer
(@NonNull String server) Get a list of players on the server with the given name.final String
Get the RedisBungee proxy ID this player is connected to.static RedisBungeeAPI
This alternative toRedisBungee.getApi()
which now deprecated.final net.md_5.bungee.api.config.ServerInfo
getServerFor
(@NonNull UUID player) Get the server where the specified player is playing.final String
Get the current BungeeCord server ID for this server.Get a full list of players on all servers.final UUID
getUuidFromName
(@NonNull String name) Fetch a UUID from the specified name.final UUID
getUuidFromName
(@NonNull String name, boolean expensiveLookups) Fetch a UUID from the specified name.final boolean
isPlayerOnline
(@NonNull UUID player) Convenience method: Checks if the specified player is online.final void
registerPubSubChannels
(String... channels) Register (a) PubSub channel(s), so that you may handlePubSubMessageEvent
for it.final void
sendChannelMessage
(@NonNull String channel, @NonNull String message) Sends a message to a PubSub channel.final void
sendProxyCommand
(@NonNull String command) Sends a proxy command to all proxies.final void
sendProxyCommand
(@NonNull String proxyId, @NonNull String command) Sends a proxy command to the proxy with the given ID.final void
unregisterPubSubChannels
(String... channels) Unregister (a) PubSub channel(s).
-
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
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
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
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
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
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
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
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
Convenience method: Checks if the specified player is online.- Parameters:
player
- a player name- Returns:
- if the player is online
-
getPlayerIp
Get theInetAddress
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
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
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 IDcommand
- 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 forPubSubMessageEvent
to fire.- Parameters:
channel
- The PubSub channelmessage
- the message body to send- Since:
- 0.3.3
-
getServerId
Get the current BungeeCord server ID for this server.- Returns:
- the current server ID
- Since:
- 0.2.5
- See Also:
-
getAllServers
Get all the linked proxies in this network.- Returns:
- the list of all proxies
- Since:
- 0.2.5
- See Also:
-
registerPubSubChannels
Register (a) PubSub channel(s), so that you may handlePubSubMessageEvent
for it.- Parameters:
channels
- the channels to register- Since:
- 0.3
-
unregisterPubSubChannels
Unregister (a) PubSub channel(s).- Parameters:
channels
- the channels to unregister- Since:
- 0.3
-
getNameFromUuid
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
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 ifexpensiveLookups
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 forexpensiveLookups
- whether or not to perform potentially expensive lookups- Returns:
- the name for the UUID
- Since:
- 0.3.2
-
getUuidFromName
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
Fetch a UUID from the specified name. Names are cached locally and in Redis. This function falls back to Mojang as a last resort ifexpensiveLookups
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 forexpensiveLookups
- 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
This alternative toRedisBungee.getApi()
which now deprecated. but to maintain old plugins compatibility it won't be removed.- Returns:
- the API instance.
- Since:
- 0.6.5
-