2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2024-11-22 20:28:00 +00:00

make RedisBungeeAPI class platform dependant and make Abstract version of it

This commit is contained in:
mohammed jasem alaajel 2022-07-27 17:43:51 +04:00
parent 576bcc39d2
commit 17897bc112
18 changed files with 163 additions and 102 deletions

View File

@ -10,11 +10,11 @@ Velocity*: *version 3.1.2 or above is only supported, any version below that mig
This fork ensures compatibility with old plugins, so it should work as drop replacement, This fork ensures compatibility with old plugins, so it should work as drop replacement,
but since Api has been split from the platform there some changes that have to be done, so your plugin might not work if: but since Api has been split from the platform there some changes that have to be done, so your plugin might not work if:
* your plugin have used the Method `RedisBungeeAPI#getServerFor(UUID player)` as it was returning `net.md_5.bungee.api.config.ServerInfo` * there is none at the moment, please report any findings at the issue page.
now it returns `String`.
as of version 0.8.0, Cluster mode compatibility in version 0.8.0:
If you are using static method `RedisBungee#getPool()` it might fail in:
If you are using static legacy method `RedisBungee#getPool()` it might fail in:
* if Cluster mode is enabled, due fact its Uses different classes * if Cluster mode is enabled, due fact its Uses different classes
* JedisPool compatibility mode is disabled in the config due fact project internally switched to JedisPooled than Jedis * JedisPool compatibility mode is disabled in the config due fact project internally switched to JedisPooled than Jedis

View File

@ -4,11 +4,11 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeeMode;
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin; import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisClusterSummoner; import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisClusterSummoner;
import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisPooledSummoner; import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisPooledSummoner;
import com.imaginarycode.minecraft.redisbungee.api.summoners.Summoner; import com.imaginarycode.minecraft.redisbungee.api.summoners.Summoner;
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeeMode;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import redis.clients.jedis.Jedis; import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisCluster; import redis.clients.jedis.JedisCluster;
@ -18,21 +18,21 @@ import java.net.InetAddress;
import java.util.*; import java.util.*;
/** /**
* This class exposes some internal RedisBungee functions. You obtain an instance of this object by invoking {@link RedisBungeeAPI#getRedisBungeeApi()} * This abstract class is extended by platform plugin to provide some platform specific methods.
* or somehow you got the Plugin instance by you can call the api using {@link RedisBungeePlugin#getRedisBungeeApi()}. * overall its general contains all methods needed by external usage.
* *
* @author tuxed * @author Ham1255
* @since 0.2.3 | updated 0.7.0 * @since 0.8.0
*/ */
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class RedisBungeeAPI { public abstract class AbstractRedisBungeeAPI {
private final RedisBungeePlugin<?> plugin; protected final RedisBungeePlugin<?> plugin;
private final List<String> reservedChannels; private static AbstractRedisBungeeAPI abstractRedisBungeeAPI;
private static RedisBungeeAPI redisBungeeApi; protected final List<String> reservedChannels;
RedisBungeeAPI(RedisBungeePlugin<?> plugin) { AbstractRedisBungeeAPI(RedisBungeePlugin<?> plugin) {
abstractRedisBungeeAPI = this;
this.plugin = plugin; this.plugin = plugin;
redisBungeeApi = this;
this.reservedChannels = ImmutableList.of( this.reservedChannels = ImmutableList.of(
"redisbungee-allservers", "redisbungee-allservers",
"redisbungee-" + plugin.getConfiguration().getProxyId(), "redisbungee-" + plugin.getConfiguration().getProxyId(),
@ -59,15 +59,14 @@ public class RedisBungeeAPI {
public final long getLastOnline(@NonNull UUID player) { public final long getLastOnline(@NonNull UUID player) {
return plugin.getDataManager().getLastOnline(player); return plugin.getDataManager().getLastOnline(player);
} }
/** /**
* Get the server where the specified player is playing. This function also deals with the case of local players * 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. * as well, and will return local information on them.
* *
* @param player a player name * @param player a player uuid
* @return a String name for the server the player is on. * @return a String name for the server the player is on.
*/ */
public final String getServerFor(@NonNull UUID player) { public final String getServerNameFor(@NonNull UUID player) {
return plugin.getDataManager().getServer(player); return plugin.getDataManager().getServer(player);
} }
@ -447,15 +446,7 @@ public class RedisBungeeAPI {
return this.plugin.getRedisBungeeMode(); return this.plugin.getRedisBungeeMode();
} }
public static AbstractRedisBungeeAPI getAbstractRedisBungeeAPI() {
/** return abstractRedisBungeeAPI;
* Api instance
*
* @return the API instance.
* @since 0.6.5
*/
public static RedisBungeeAPI getRedisBungeeApi() {
return redisBungeeApi;
} }
} }

View File

@ -49,7 +49,7 @@ public abstract class AbstractDataManager<P, PL, PD, PS> {
return plugin.isPlayerOnAServer(player) ? plugin.getPlayerServerName(player) : null; return plugin.isPlayerOnAServer(player) ? plugin.getPlayerServerName(player) : null;
try { try {
return serverCache.get(uuid, new RedisTask<String>(plugin.getRedisBungeeApi()) { return serverCache.get(uuid, new RedisTask<String>(plugin.getAbstractRedisBungeeApi()) {
@Override @Override
public String unifiedJedisTask(UnifiedJedis unifiedJedis) { public String unifiedJedisTask(UnifiedJedis unifiedJedis) {
return Objects.requireNonNull(unifiedJedis.hget("player:" + uuid, "server"), "user not found"); return Objects.requireNonNull(unifiedJedis.hget("player:" + uuid, "server"), "user not found");
@ -72,7 +72,7 @@ public abstract class AbstractDataManager<P, PL, PD, PS> {
return plugin.getConfiguration().getProxyId(); return plugin.getConfiguration().getProxyId();
try { try {
return proxyCache.get(uuid, new RedisTask<String>(plugin.getRedisBungeeApi()) { return proxyCache.get(uuid, new RedisTask<String>(plugin.getAbstractRedisBungeeApi()) {
@Override @Override
public String unifiedJedisTask(UnifiedJedis unifiedJedis) { public String unifiedJedisTask(UnifiedJedis unifiedJedis) {
return Objects.requireNonNull(unifiedJedis.hget("player:" + uuid, "proxy"), "user not found"); return Objects.requireNonNull(unifiedJedis.hget("player:" + uuid, "proxy"), "user not found");
@ -93,7 +93,7 @@ public abstract class AbstractDataManager<P, PL, PD, PS> {
return plugin.getPlayerIp(player); return plugin.getPlayerIp(player);
try { try {
return ipCache.get(uuid, new RedisTask<InetAddress>(plugin.getRedisBungeeApi()) { return ipCache.get(uuid, new RedisTask<InetAddress>(plugin.getAbstractRedisBungeeApi()) {
@Override @Override
public InetAddress unifiedJedisTask(UnifiedJedis unifiedJedis) { public InetAddress unifiedJedisTask(UnifiedJedis unifiedJedis) {
String result = unifiedJedis.hget("player:" + uuid, "ip"); String result = unifiedJedis.hget("player:" + uuid, "ip");
@ -117,7 +117,7 @@ public abstract class AbstractDataManager<P, PL, PD, PS> {
return 0; return 0;
try { try {
return lastOnlineCache.get(uuid, new RedisTask<Long>(plugin.getRedisBungeeApi()) { return lastOnlineCache.get(uuid, new RedisTask<Long>(plugin.getAbstractRedisBungeeApi()) {
@Override @Override
public Long unifiedJedisTask(UnifiedJedis unifiedJedis) { public Long unifiedJedisTask(UnifiedJedis unifiedJedis) {

View File

@ -4,7 +4,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI; import com.imaginarycode.minecraft.redisbungee.AbstractRedisBungeeAPI;
import com.imaginarycode.minecraft.redisbungee.api.config.ConfigLoader; import com.imaginarycode.minecraft.redisbungee.api.config.ConfigLoader;
import com.imaginarycode.minecraft.redisbungee.api.config.RedisBungeeConfiguration; import com.imaginarycode.minecraft.redisbungee.api.config.RedisBungeeConfiguration;
import com.imaginarycode.minecraft.redisbungee.api.summoners.Summoner; import com.imaginarycode.minecraft.redisbungee.api.summoners.Summoner;
@ -101,7 +101,7 @@ public interface RedisBungeePlugin<P> extends EventsPlatform, ConfigLoader {
}.execute(); }.execute();
} }
RedisBungeeAPI getRedisBungeeApi(); AbstractRedisBungeeAPI getAbstractRedisBungeeApi();
UUIDTranslator getUuidTranslator(); UUIDTranslator getUuidTranslator();

View File

@ -1,6 +1,6 @@
package com.imaginarycode.minecraft.redisbungee.api.tasks; package com.imaginarycode.minecraft.redisbungee.api.tasks;
import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI; import com.imaginarycode.minecraft.redisbungee.AbstractRedisBungeeAPI;
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin; import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisClusterSummoner; import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisClusterSummoner;
import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisPooledSummoner; import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisPooledSummoner;
@ -13,7 +13,7 @@ import java.util.concurrent.Callable;
public abstract class RedisTask<V> implements Runnable, Callable<V> { public abstract class RedisTask<V> implements Runnable, Callable<V> {
protected final Summoner<?> summoner; protected final Summoner<?> summoner;
protected final RedisBungeeAPI api; protected final AbstractRedisBungeeAPI api;
protected RedisBungeePlugin<?> plugin; protected RedisBungeePlugin<?> plugin;
@Override @Override
@ -21,14 +21,14 @@ public abstract class RedisTask<V> implements Runnable, Callable<V> {
return execute(); return execute();
} }
public RedisTask(RedisBungeeAPI api) { public RedisTask(AbstractRedisBungeeAPI api) {
this.api = api; this.api = api;
this.summoner = api.getSummoner(); this.summoner = api.getSummoner();
} }
public RedisTask(RedisBungeePlugin<?> plugin) { public RedisTask(RedisBungeePlugin<?> plugin) {
this.plugin = plugin; this.plugin = plugin;
this.api = plugin.getRedisBungeeApi(); this.api = plugin.getAbstractRedisBungeeApi();
this.summoner = api.getSummoner(); this.summoner = api.getSummoner();
} }

View File

@ -1,11 +1,8 @@
package com.imaginarycode.minecraft.redisbungee.api.util.payload; package com.imaginarycode.minecraft.redisbungee.api.util.payload;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI; import com.imaginarycode.minecraft.redisbungee.AbstractRedisBungeeAPI;
import com.imaginarycode.minecraft.redisbungee.api.AbstractDataManager; import com.imaginarycode.minecraft.redisbungee.api.AbstractDataManager;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.Pipeline;
import redis.clients.jedis.UnifiedJedis; import redis.clients.jedis.UnifiedJedis;
import java.net.InetAddress; import java.net.InetAddress;
@ -16,14 +13,14 @@ public class PayloadUtils {
public static void playerJoinPayload(UUID uuid, UnifiedJedis unifiedJedis, InetAddress inetAddress) { public static void playerJoinPayload(UUID uuid, UnifiedJedis unifiedJedis, InetAddress inetAddress) {
unifiedJedis.publish("redisbungee-data", gson.toJson(new AbstractDataManager.DataManagerMessage<>( unifiedJedis.publish("redisbungee-data", gson.toJson(new AbstractDataManager.DataManagerMessage<>(
uuid, RedisBungeeAPI.getRedisBungeeApi().getProxyId(), AbstractDataManager.DataManagerMessage.Action.JOIN, uuid, AbstractRedisBungeeAPI.getAbstractRedisBungeeAPI().getProxyId(), AbstractDataManager.DataManagerMessage.Action.JOIN,
new AbstractDataManager.LoginPayload(inetAddress)))); new AbstractDataManager.LoginPayload(inetAddress))));
} }
public static void playerQuitPayload(String uuid, UnifiedJedis unifiedJedis, long timestamp) { public static void playerQuitPayload(String uuid, UnifiedJedis unifiedJedis, long timestamp) {
unifiedJedis.publish("redisbungee-data", gson.toJson(new AbstractDataManager.DataManagerMessage<>( unifiedJedis.publish("redisbungee-data", gson.toJson(new AbstractDataManager.DataManagerMessage<>(
UUID.fromString(uuid), RedisBungeeAPI.getRedisBungeeApi().getProxyId(), AbstractDataManager.DataManagerMessage.Action.LEAVE, UUID.fromString(uuid), AbstractRedisBungeeAPI.getAbstractRedisBungeeAPI().getProxyId(), AbstractDataManager.DataManagerMessage.Action.LEAVE,
new AbstractDataManager.LogoutPayload(timestamp)))); new AbstractDataManager.LogoutPayload(timestamp))));
} }
@ -31,14 +28,14 @@ public class PayloadUtils {
public static void playerServerChangePayload(UUID uuid, UnifiedJedis unifiedJedis, String newServer, String oldServer) { public static void playerServerChangePayload(UUID uuid, UnifiedJedis unifiedJedis, String newServer, String oldServer) {
unifiedJedis.publish("redisbungee-data", gson.toJson(new AbstractDataManager.DataManagerMessage<>( unifiedJedis.publish("redisbungee-data", gson.toJson(new AbstractDataManager.DataManagerMessage<>(
uuid, RedisBungeeAPI.getRedisBungeeApi().getProxyId(), AbstractDataManager.DataManagerMessage.Action.SERVER_CHANGE, uuid, AbstractRedisBungeeAPI.getAbstractRedisBungeeAPI().getProxyId(), AbstractDataManager.DataManagerMessage.Action.SERVER_CHANGE,
new AbstractDataManager.ServerChangePayload(newServer, oldServer)))); new AbstractDataManager.ServerChangePayload(newServer, oldServer))));
} }
public static void kickPlayerPayload(UUID uuid, String message, UnifiedJedis unifiedJedis) { public static void kickPlayerPayload(UUID uuid, String message, UnifiedJedis unifiedJedis) {
unifiedJedis.publish("redisbungee-data", gson.toJson(new AbstractDataManager.DataManagerMessage<>( unifiedJedis.publish("redisbungee-data", gson.toJson(new AbstractDataManager.DataManagerMessage<>(
uuid, RedisBungeeAPI.getRedisBungeeApi().getProxyId(), AbstractDataManager.DataManagerMessage.Action.KICK, uuid, AbstractRedisBungeeAPI.getAbstractRedisBungeeAPI().getProxyId(), AbstractDataManager.DataManagerMessage.Action.KICK,
new AbstractDataManager.KickPayload(message)))); new AbstractDataManager.KickPayload(message))));
} }
} }

View File

@ -1,15 +1,14 @@
package com.imaginarycode.minecraft.redisbungee.api.util.player; package com.imaginarycode.minecraft.redisbungee.api.util.player;
import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI; import com.imaginarycode.minecraft.redisbungee.AbstractRedisBungeeAPI;
import redis.clients.jedis.UnifiedJedis; import redis.clients.jedis.UnifiedJedis;
import static com.imaginarycode.minecraft.redisbungee.api.util.payload.PayloadUtils.playerQuitPayload; import static com.imaginarycode.minecraft.redisbungee.api.util.payload.PayloadUtils.playerQuitPayload;
public class PlayerUtils { public class PlayerUtils {
public static void cleanUpPlayer(String uuid, UnifiedJedis rsc, boolean firePayload) { public static void cleanUpPlayer(String uuid, UnifiedJedis rsc, boolean firePayload) {
rsc.srem("proxy:" + RedisBungeeAPI.getRedisBungeeApi().getProxyId() + ":usersOnline", uuid); rsc.srem("proxy:" + AbstractRedisBungeeAPI.getAbstractRedisBungeeAPI().getProxyId() + ":usersOnline", uuid);
rsc.hdel("player:" + uuid, "server", "ip", "proxy"); rsc.hdel("player:" + uuid, "server", "ip", "proxy");
long timestamp = System.currentTimeMillis(); long timestamp = System.currentTimeMillis();
rsc.hset("player:" + uuid, "online", String.valueOf(timestamp)); rsc.hset("player:" + uuid, "online", String.valueOf(timestamp));

View File

@ -70,7 +70,7 @@ public final class UUIDTranslator {
if (!plugin.isOnlineMode()) { if (!plugin.isOnlineMode()) {
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player).getBytes(Charsets.UTF_8)); return UUID.nameUUIDFromBytes(("OfflinePlayer:" + player).getBytes(Charsets.UTF_8));
} }
RedisTask<UUID> redisTask = new RedisTask<UUID>(plugin.getRedisBungeeApi()) { RedisTask<UUID> redisTask = new RedisTask<UUID>(plugin.getAbstractRedisBungeeApi()) {
@Override @Override
public UUID unifiedJedisTask(UnifiedJedis unifiedJedis) { public UUID unifiedJedisTask(UnifiedJedis unifiedJedis) {
String stored = unifiedJedis.hget("uuid-cache", player.toLowerCase()); String stored = unifiedJedis.hget("uuid-cache", player.toLowerCase());
@ -135,7 +135,7 @@ public final class UUIDTranslator {
uuidToNameMap.remove(player); uuidToNameMap.remove(player);
} }
RedisTask<String> redisTask = new RedisTask<String>(plugin.getRedisBungeeApi()) { RedisTask<String> redisTask = new RedisTask<String>(plugin.getAbstractRedisBungeeApi()) {
@Override @Override
public String unifiedJedisTask(UnifiedJedis unifiedJedis) { public String unifiedJedisTask(UnifiedJedis unifiedJedis) {
String stored = unifiedJedis.hget("uuid-cache", player.toString()); String stored = unifiedJedis.hget("uuid-cache", player.toString());

View File

@ -1,10 +1,7 @@
package com.imaginarycode.minecraft.redisbungee; package com.imaginarycode.minecraft.redisbungee;
import com.google.gson.Gson;
import net.md_5.bungee.api.connection.PendingConnection; import net.md_5.bungee.api.connection.PendingConnection;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.Pipeline;
import redis.clients.jedis.UnifiedJedis; import redis.clients.jedis.UnifiedJedis;
import java.util.HashMap; import java.util.HashMap;

View File

@ -38,7 +38,7 @@ public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlay
private static RedisBungeeAPI apiStatic; private static RedisBungeeAPI apiStatic;
private RedisBungeeAPI api; private AbstractRedisBungeeAPI api;
private RedisBungeeMode redisBungeeMode; private RedisBungeeMode redisBungeeMode;
private PubSubListener psl = null; private PubSubListener psl = null;
private Summoner<?> summoner; private Summoner<?> summoner;
@ -82,7 +82,7 @@ public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlay
@Override @Override
public RedisBungeeAPI getRedisBungeeApi() { public AbstractRedisBungeeAPI getAbstractRedisBungeeApi() {
return this.api; return this.api;
} }
@ -202,7 +202,7 @@ public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlay
} }
// init the api class // init the api class
this.api = new RedisBungeeAPI(this); this.api = new RedisBungeeAPI(this);
apiStatic = this.api; apiStatic = (RedisBungeeAPI) this.api;
// init the http lib // init the http lib
httpClient = new OkHttpClient(); httpClient = new OkHttpClient();
Dispatcher dispatcher = new Dispatcher(getExecutorService()); Dispatcher dispatcher = new Dispatcher(getExecutorService());
@ -333,7 +333,7 @@ public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlay
* *
* @deprecated Please use {@link RedisBungeeAPI#getRedisBungeeApi()} this class intended to for old plugins that no longer updated. * @deprecated Please use {@link RedisBungeeAPI#getRedisBungeeApi()} this class intended to for old plugins that no longer updated.
* *
* @return the {@link RedisBungeeAPI} object instance. * @return the {@link AbstractRedisBungeeAPI} object instance.
*/ */
@Deprecated @Deprecated
public static RedisBungeeAPI getApi() { public static RedisBungeeAPI getApi() {

View File

@ -0,0 +1,49 @@
package com.imaginarycode.minecraft.redisbungee;
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.plugin.Plugin;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.UUID;
/**
* This platform class exposes some internal RedisBungee functions. You obtain an instance of this object by invoking {@link RedisBungeeAPI#getRedisBungeeApi()}
* or somehow you got the Plugin instance by you can call the api using {@link RedisBungeePlugin#getAbstractRedisBungeeApi()}.
*
* @author tuxed
* @since 0.2.3 | updated 0.8.0
*/
public class RedisBungeeAPI extends AbstractRedisBungeeAPI {
private static RedisBungeeAPI redisBungeeApi;
RedisBungeeAPI(RedisBungeePlugin<?> plugin) {
super(plugin);
redisBungeeApi = this;
}
/**
* 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.
*
* @param player a player uuid
* @return {@link ServerInfo}
* @deprecated This does return null even if player is on a server if the server is not on the proxy
* @see #getServerNameFor(UUID)
*/
@Deprecated
public final ServerInfo getServerFor(@NonNull UUID player) {
return ((Plugin) this.plugin).getProxy().getServerInfo(this.getServerNameFor(player));
}
/**
* Api instance
*
* @return the API instance.
* @since 0.6.5
*/
public static RedisBungeeAPI getRedisBungeeApi() {
return redisBungeeApi;
}
}

View File

@ -152,7 +152,7 @@ public class RedisBungeeBungeeListener extends AbstractRedisBungeeListener<Login
original = plugin.getPlayers(); original = plugin.getPlayers();
} else { } else {
try { try {
original = plugin.getRedisBungeeApi().getPlayersOnServer(type); original = plugin.getAbstractRedisBungeeApi().getPlayersOnServer(type);
} catch (IllegalArgumentException ignored) { } catch (IllegalArgumentException ignored) {
} }
} }
@ -170,7 +170,7 @@ public class RedisBungeeBungeeListener extends AbstractRedisBungeeListener<Login
} else { } else {
out.writeUTF(type); out.writeUTF(type);
try { try {
out.writeInt(plugin.getRedisBungeeApi().getPlayersOnServer(type).size()); out.writeInt(plugin.getAbstractRedisBungeeApi().getPlayersOnServer(type).size());
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
out.writeInt(0); out.writeInt(0);
} }
@ -180,12 +180,12 @@ public class RedisBungeeBungeeListener extends AbstractRedisBungeeListener<Login
String user = in.readUTF(); String user = in.readUTF();
out.writeUTF("LastOnline"); out.writeUTF("LastOnline");
out.writeUTF(user); out.writeUTF(user);
out.writeLong(plugin.getRedisBungeeApi().getLastOnline(Objects.requireNonNull(plugin.getUuidTranslator().getTranslatedUuid(user, true)))); out.writeLong(plugin.getAbstractRedisBungeeApi().getLastOnline(Objects.requireNonNull(plugin.getUuidTranslator().getTranslatedUuid(user, true))));
break; break;
case "ServerPlayers": case "ServerPlayers":
String type1 = in.readUTF(); String type1 = in.readUTF();
out.writeUTF("ServerPlayers"); out.writeUTF("ServerPlayers");
Multimap<String, UUID> multimap = plugin.getRedisBungeeApi().getServerToPlayers(); Multimap<String, UUID> multimap = plugin.getAbstractRedisBungeeApi().getServerToPlayers();
boolean includesUsers; boolean includesUsers;
@ -221,7 +221,7 @@ public class RedisBungeeBungeeListener extends AbstractRedisBungeeListener<Login
String username = in.readUTF(); String username = in.readUTF();
out.writeUTF("PlayerProxy"); out.writeUTF("PlayerProxy");
out.writeUTF(username); out.writeUTF(username);
out.writeUTF(plugin.getRedisBungeeApi().getProxy(Objects.requireNonNull(plugin.getUuidTranslator().getTranslatedUuid(username, true)))); out.writeUTF(plugin.getAbstractRedisBungeeApi().getProxy(Objects.requireNonNull(plugin.getUuidTranslator().getTranslatedUuid(username, true))));
break; break;
default: default:
return; return;
@ -235,7 +235,7 @@ public class RedisBungeeBungeeListener extends AbstractRedisBungeeListener<Login
@Override @Override
@EventHandler @EventHandler
public void onPubSubMessage(PubSubMessageEvent event) { public void onPubSubMessage(PubSubMessageEvent event) {
if (event.getChannel().equals("redisbungee-allservers") || event.getChannel().equals("redisbungee-" + plugin.getRedisBungeeApi().getProxyId())) { if (event.getChannel().equals("redisbungee-allservers") || event.getChannel().equals("redisbungee-" + plugin.getAbstractRedisBungeeApi().getProxyId())) {
String message = event.getMessage(); String message = event.getMessage();
if (message.startsWith("/")) if (message.startsWith("/"))
message = message.substring(1); message = message.substring(1);

View File

@ -4,7 +4,7 @@ import com.google.common.base.Joiner;
import com.google.common.collect.HashMultimap; import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.imaginarycode.minecraft.redisbungee.RedisBungee; import com.imaginarycode.minecraft.redisbungee.RedisBungee;
import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI; import com.imaginarycode.minecraft.redisbungee.AbstractRedisBungeeAPI;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.BaseComponent;
@ -23,7 +23,7 @@ import java.util.UUID;
/** /**
* This class contains subclasses that are used for the commands RedisBungee overrides or includes: /glist, /find and /lastseen. * This class contains subclasses that are used for the commands RedisBungee overrides or includes: /glist, /find and /lastseen.
* <p> * <p>
* All classes use the {@link RedisBungeeAPI}. * All classes use the {@link AbstractRedisBungeeAPI}.
* *
* @author tuxed * @author tuxed
* @since 0.2.3 * @since 0.2.3
@ -53,11 +53,11 @@ public class RedisBungeeCommands {
plugin.getProxy().getScheduler().runAsync(plugin, new Runnable() { plugin.getProxy().getScheduler().runAsync(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
int count = plugin.getRedisBungeeApi().getPlayerCount(); int count = plugin.getAbstractRedisBungeeApi().getPlayerCount();
BaseComponent[] playersOnline = new ComponentBuilder("").color(ChatColor.YELLOW) BaseComponent[] playersOnline = new ComponentBuilder("").color(ChatColor.YELLOW)
.append(playerPlural(count) + " currently online.").create(); .append(playerPlural(count) + " currently online.").create();
if (args.length > 0 && args[0].equals("showall")) { if (args.length > 0 && args[0].equals("showall")) {
Multimap<String, UUID> serverToPlayers = plugin.getRedisBungeeApi().getServerToPlayers(); Multimap<String, UUID> serverToPlayers = plugin.getAbstractRedisBungeeApi().getServerToPlayers();
Multimap<String, String> human = HashMultimap.create(); Multimap<String, String> human = HashMultimap.create();
for (Map.Entry<String, UUID> entry : serverToPlayers.entries()) { for (Map.Entry<String, UUID> entry : serverToPlayers.entries()) {
// if for any reason UUID translation fails just return the uuid as name, to make command finish executing. // if for any reason UUID translation fails just return the uuid as name, to make command finish executing.
@ -105,7 +105,7 @@ public class RedisBungeeCommands {
sender.sendMessage(PLAYER_NOT_FOUND); sender.sendMessage(PLAYER_NOT_FOUND);
return; return;
} }
ServerInfo si = plugin.getProxy().getServerInfo(plugin.getRedisBungeeApi().getServerFor(uuid)); ServerInfo si = plugin.getProxy().getServerInfo(plugin.getAbstractRedisBungeeApi().getServerNameFor(uuid));
if (si != null) { if (si != null) {
TextComponent message = new TextComponent(); TextComponent message = new TextComponent();
message.setColor(ChatColor.BLUE); message.setColor(ChatColor.BLUE);
@ -141,7 +141,7 @@ public class RedisBungeeCommands {
sender.sendMessage(PLAYER_NOT_FOUND); sender.sendMessage(PLAYER_NOT_FOUND);
return; return;
} }
long secs = plugin.getRedisBungeeApi().getLastOnline(uuid); long secs = plugin.getAbstractRedisBungeeApi().getLastOnline(uuid);
TextComponent message = new TextComponent(); TextComponent message = new TextComponent();
if (secs == 0) { if (secs == 0) {
message.setColor(ChatColor.GREEN); message.setColor(ChatColor.GREEN);
@ -181,7 +181,7 @@ public class RedisBungeeCommands {
sender.sendMessage(PLAYER_NOT_FOUND); sender.sendMessage(PLAYER_NOT_FOUND);
return; return;
} }
InetAddress ia = plugin.getRedisBungeeApi().getPlayerIp(uuid); InetAddress ia = plugin.getAbstractRedisBungeeApi().getPlayerIp(uuid);
if (ia != null) { if (ia != null) {
TextComponent message = new TextComponent(); TextComponent message = new TextComponent();
message.setColor(ChatColor.GREEN); message.setColor(ChatColor.GREEN);
@ -217,7 +217,7 @@ public class RedisBungeeCommands {
sender.sendMessage(PLAYER_NOT_FOUND); sender.sendMessage(PLAYER_NOT_FOUND);
return; return;
} }
String proxy = plugin.getRedisBungeeApi().getProxy(uuid); String proxy = plugin.getAbstractRedisBungeeApi().getProxy(uuid);
if (proxy != null) { if (proxy != null) {
TextComponent message = new TextComponent(); TextComponent message = new TextComponent();
message.setColor(ChatColor.GREEN); message.setColor(ChatColor.GREEN);
@ -246,7 +246,7 @@ public class RedisBungeeCommands {
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
if (args.length > 0) { if (args.length > 0) {
String command = Joiner.on(" ").skipNulls().join(args); String command = Joiner.on(" ").skipNulls().join(args);
plugin.getRedisBungeeApi().sendProxyCommand(command); plugin.getAbstractRedisBungeeApi().sendProxyCommand(command);
TextComponent message = new TextComponent(); TextComponent message = new TextComponent();
message.setColor(ChatColor.GREEN); message.setColor(ChatColor.GREEN);
message.setText("Sent the command /" + command + " to all proxies."); message.setText("Sent the command /" + command + " to all proxies.");
@ -268,7 +268,7 @@ public class RedisBungeeCommands {
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
TextComponent textComponent = new TextComponent(); TextComponent textComponent = new TextComponent();
textComponent.setText("You are on " + plugin.getRedisBungeeApi().getProxyId() + "."); textComponent.setText("You are on " + plugin.getAbstractRedisBungeeApi().getProxyId() + ".");
textComponent.setColor(ChatColor.YELLOW); textComponent.setColor(ChatColor.YELLOW);
sender.sendMessage(textComponent); sender.sendMessage(textComponent);
} }
@ -284,7 +284,7 @@ public class RedisBungeeCommands {
@Override @Override
public void execute(CommandSender sender, String[] strings) { public void execute(CommandSender sender, String[] strings) {
TextComponent textComponent = new TextComponent(); TextComponent textComponent = new TextComponent();
textComponent.setText("All server IDs: " + Joiner.on(", ").join(plugin.getRedisBungeeApi().getAllProxies())); textComponent.setText("All server IDs: " + Joiner.on(", ").join(plugin.getAbstractRedisBungeeApi().getAllProxies()));
textComponent.setColor(ChatColor.YELLOW); textComponent.setColor(ChatColor.YELLOW);
sender.sendMessage(textComponent); sender.sendMessage(textComponent);
} }
@ -308,11 +308,11 @@ public class RedisBungeeCommands {
sender.sendMessage(new ComponentBuilder(proxy + " is not a valid proxy. See /serverids for valid proxies.").color(ChatColor.RED).create()); sender.sendMessage(new ComponentBuilder(proxy + " is not a valid proxy. See /serverids for valid proxies.").color(ChatColor.RED).create());
return; return;
} }
Set<UUID> players = plugin.getRedisBungeeApi().getPlayersOnProxy(proxy); Set<UUID> players = plugin.getAbstractRedisBungeeApi().getPlayersOnProxy(proxy);
BaseComponent[] playersOnline = new ComponentBuilder("").color(ChatColor.YELLOW) BaseComponent[] playersOnline = new ComponentBuilder("").color(ChatColor.YELLOW)
.append(playerPlural(players.size()) + " currently on proxy " + proxy + ".").create(); .append(playerPlural(players.size()) + " currently on proxy " + proxy + ".").create();
if (args.length >= 2 && args[1].equals("showall")) { if (args.length >= 2 && args[1].equals("showall")) {
Multimap<String, UUID> serverToPlayers = plugin.getRedisBungeeApi().getServerToPlayers(); Multimap<String, UUID> serverToPlayers = plugin.getAbstractRedisBungeeApi().getServerToPlayers();
Multimap<String, String> human = HashMultimap.create(); Multimap<String, String> human = HashMultimap.create();
for (Map.Entry<String, UUID> entry : serverToPlayers.entries()) { for (Map.Entry<String, UUID> entry : serverToPlayers.entries()) {
if (players.contains(entry.getValue())) { if (players.contains(entry.getValue())) {

View File

@ -0,0 +1,30 @@
package com.imaginarycode.minecraft.redisbungee;
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
/**
* This platform class exposes some internal RedisBungee functions. You obtain an instance of this object by invoking {@link RedisBungeeAPI#getRedisBungeeApi()}
* or somehow you got the Plugin instance by you can call the api using {@link RedisBungeePlugin#getAbstractRedisBungeeApi()}.
*
* @author tuxed
* @since 0.2.3 | updated 0.8.0
*/
public class RedisBungeeAPI extends AbstractRedisBungeeAPI {
private static RedisBungeeAPI redisBungeeApi;
RedisBungeeAPI(RedisBungeePlugin<?> plugin) {
super(plugin);
redisBungeeApi = this;
}
/**
* Api instance
*
* @return the API instance.
* @since 0.6.5
*/
public static RedisBungeeAPI getRedisBungeeApi() {
return redisBungeeApi;
}
}

View File

@ -156,7 +156,7 @@ public class RedisBungeeVelocityListener extends AbstractRedisBungeeListener<Log
original = plugin.getPlayers(); original = plugin.getPlayers();
} else { } else {
try { try {
original = plugin.getRedisBungeeApi().getPlayersOnServer(type); original = plugin.getAbstractRedisBungeeApi().getPlayersOnServer(type);
} catch (IllegalArgumentException ignored) { } catch (IllegalArgumentException ignored) {
} }
} }
@ -174,7 +174,7 @@ public class RedisBungeeVelocityListener extends AbstractRedisBungeeListener<Log
} else { } else {
out.writeUTF(type); out.writeUTF(type);
try { try {
out.writeInt(plugin.getRedisBungeeApi().getPlayersOnServer(type).size()); out.writeInt(plugin.getAbstractRedisBungeeApi().getPlayersOnServer(type).size());
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
out.writeInt(0); out.writeInt(0);
} }
@ -184,12 +184,12 @@ public class RedisBungeeVelocityListener extends AbstractRedisBungeeListener<Log
String user = in.readUTF(); String user = in.readUTF();
out.writeUTF("LastOnline"); out.writeUTF("LastOnline");
out.writeUTF(user); out.writeUTF(user);
out.writeLong(plugin.getRedisBungeeApi().getLastOnline(Objects.requireNonNull(plugin.getUuidTranslator().getTranslatedUuid(user, true)))); out.writeLong(plugin.getAbstractRedisBungeeApi().getLastOnline(Objects.requireNonNull(plugin.getUuidTranslator().getTranslatedUuid(user, true))));
break; break;
case "ServerPlayers": case "ServerPlayers":
String type1 = in.readUTF(); String type1 = in.readUTF();
out.writeUTF("ServerPlayers"); out.writeUTF("ServerPlayers");
Multimap<String, UUID> multimap = plugin.getRedisBungeeApi().getServerToPlayers(); Multimap<String, UUID> multimap = plugin.getAbstractRedisBungeeApi().getServerToPlayers();
boolean includesUsers; boolean includesUsers;
@ -225,7 +225,7 @@ public class RedisBungeeVelocityListener extends AbstractRedisBungeeListener<Log
String username = in.readUTF(); String username = in.readUTF();
out.writeUTF("PlayerProxy"); out.writeUTF("PlayerProxy");
out.writeUTF(username); out.writeUTF(username);
out.writeUTF(plugin.getRedisBungeeApi().getProxy(Objects.requireNonNull(plugin.getUuidTranslator().getTranslatedUuid(username, true)))); out.writeUTF(plugin.getAbstractRedisBungeeApi().getProxy(Objects.requireNonNull(plugin.getUuidTranslator().getTranslatedUuid(username, true))));
break; break;
default: default:
return; return;
@ -240,7 +240,7 @@ public class RedisBungeeVelocityListener extends AbstractRedisBungeeListener<Log
@Override @Override
@Subscribe @Subscribe
public void onPubSubMessage(PubSubMessageEvent event) { public void onPubSubMessage(PubSubMessageEvent event) {
if (event.getChannel().equals("redisbungee-allservers") || event.getChannel().equals("redisbungee-" + plugin.getRedisBungeeApi().getProxyId())) { if (event.getChannel().equals("redisbungee-allservers") || event.getChannel().equals("redisbungee-" + plugin.getAbstractRedisBungeeApi().getProxyId())) {
String message = event.getMessage(); String message = event.getMessage();
if (message.startsWith("/")) if (message.startsWith("/"))
message = message.substring(1); message = message.substring(1);

View File

@ -47,7 +47,7 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player> {
private final ProxyServer server; private final ProxyServer server;
private final Logger logger; private final Logger logger;
private final Path dataFolder; private final Path dataFolder;
private final RedisBungeeAPI api; private final AbstractRedisBungeeAPI api;
private final PubSubListener psl; private final PubSubListener psl;
private Summoner<?> jedisSummoner; private Summoner<?> jedisSummoner;
private RedisBungeeMode redisBungeeMode; private RedisBungeeMode redisBungeeMode;
@ -130,7 +130,7 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player> {
} }
@Override @Override
public RedisBungeeAPI getRedisBungeeApi() { public AbstractRedisBungeeAPI getAbstractRedisBungeeApi() {
return this.api; return this.api;
} }

View File

@ -2,8 +2,6 @@ package com.imaginarycode.minecraft.redisbungee;
import com.velocitypowered.api.proxy.Player; import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.ServerConnection; import com.velocitypowered.api.proxy.ServerConnection;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.Pipeline;
import redis.clients.jedis.UnifiedJedis; import redis.clients.jedis.UnifiedJedis;
import java.util.HashMap; import java.util.HashMap;
@ -20,9 +18,9 @@ public class VelocityPlayerUtils {
Map<String, String> playerData = new HashMap<>(4); Map<String, String> playerData = new HashMap<>(4);
playerData.put("online", "0"); playerData.put("online", "0");
playerData.put("ip", player.getRemoteAddress().getHostName()); playerData.put("ip", player.getRemoteAddress().getHostName());
playerData.put("proxy", RedisBungeeAPI.getRedisBungeeApi().getProxyId()); playerData.put("proxy", AbstractRedisBungeeAPI.getAbstractRedisBungeeAPI().getProxyId());
unifiedJedis.sadd("proxy:" + RedisBungeeAPI.getRedisBungeeApi().getProxyId() + ":usersOnline", player.getUniqueId().toString()); unifiedJedis.sadd("proxy:" + AbstractRedisBungeeAPI.getAbstractRedisBungeeAPI().getProxyId() + ":usersOnline", player.getUniqueId().toString());
unifiedJedis.hmset("player:" + player.getUniqueId().toString(), playerData); unifiedJedis.hmset("player:" + player.getUniqueId().toString(), playerData);
if (fireEvent) { if (fireEvent) {

View File

@ -9,7 +9,7 @@ import java.util.UUID;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.collect.HashMultimap; import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI; import com.imaginarycode.minecraft.redisbungee.AbstractRedisBungeeAPI;
import com.imaginarycode.minecraft.redisbungee.RedisBungeeVelocityPlugin; import com.imaginarycode.minecraft.redisbungee.RedisBungeeVelocityPlugin;
import com.velocitypowered.api.command.CommandSource; import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.command.SimpleCommand; import com.velocitypowered.api.command.SimpleCommand;
@ -24,7 +24,7 @@ import net.kyori.adventure.text.format.NamedTextColor;
/** /**
* This class contains subclasses that are used for the commands RedisBungee overrides or includes: /glist, /find and /lastseen. * This class contains subclasses that are used for the commands RedisBungee overrides or includes: /glist, /find and /lastseen.
* <p> * <p>
* All classes use the {@link RedisBungeeAPI}. * All classes use the {@link AbstractRedisBungeeAPI}.
* *
* @author tuxed * @author tuxed
* @since 0.2.3 * @since 0.2.3
@ -52,11 +52,11 @@ public class RedisBungeeCommands {
@Override @Override
public void execute(final Invocation invocation) { public void execute(final Invocation invocation) {
plugin.getProxy().getScheduler().buildTask(plugin, () -> { plugin.getProxy().getScheduler().buildTask(plugin, () -> {
int count = plugin.getRedisBungeeApi().getPlayerCount(); int count = plugin.getAbstractRedisBungeeApi().getPlayerCount();
Component playersOnline = Component.text(playerPlural(count) + " currently online.", NamedTextColor.YELLOW); Component playersOnline = Component.text(playerPlural(count) + " currently online.", NamedTextColor.YELLOW);
CommandSource sender = invocation.source(); CommandSource sender = invocation.source();
if (invocation.arguments().length > 0 && invocation.arguments()[0].equals("showall")) { if (invocation.arguments().length > 0 && invocation.arguments()[0].equals("showall")) {
Multimap<String, UUID> serverToPlayers = plugin.getRedisBungeeApi().getServerToPlayers(); Multimap<String, UUID> serverToPlayers = plugin.getAbstractRedisBungeeApi().getServerToPlayers();
Multimap<String, String> human = HashMultimap.create(); Multimap<String, String> human = HashMultimap.create();
serverToPlayers.forEach((key, value) -> { serverToPlayers.forEach((key, value) -> {
// if for any reason UUID translation fails just return the uuid as name, to make command finish executing. // if for any reason UUID translation fails just return the uuid as name, to make command finish executing.
@ -101,7 +101,7 @@ public class RedisBungeeCommands {
sender.sendMessage(PLAYER_NOT_FOUND); sender.sendMessage(PLAYER_NOT_FOUND);
return; return;
} }
ServerInfo si = plugin.getProxy().getServer(plugin.getRedisBungeeApi().getServerFor(uuid)).map(RegisteredServer::getServerInfo).orElse(null); ServerInfo si = plugin.getProxy().getServer(plugin.getAbstractRedisBungeeApi().getServerNameFor(uuid)).map(RegisteredServer::getServerInfo).orElse(null);
if (si != null) { if (si != null) {
Component message = Component.text(args[0] + " is on " + si.getName() + ".", NamedTextColor.BLUE); Component message = Component.text(args[0] + " is on " + si.getName() + ".", NamedTextColor.BLUE);
sender.sendMessage(message); sender.sendMessage(message);
@ -138,7 +138,7 @@ public class RedisBungeeCommands {
sender.sendMessage(PLAYER_NOT_FOUND); sender.sendMessage(PLAYER_NOT_FOUND);
return; return;
} }
long secs = plugin.getRedisBungeeApi().getLastOnline(uuid); long secs = plugin.getAbstractRedisBungeeApi().getLastOnline(uuid);
TextComponent.Builder message = Component.text(); TextComponent.Builder message = Component.text();
if (secs == 0) { if (secs == 0) {
message.color(NamedTextColor.GREEN); message.color(NamedTextColor.GREEN);
@ -181,7 +181,7 @@ public class RedisBungeeCommands {
sender.sendMessage(PLAYER_NOT_FOUND); sender.sendMessage(PLAYER_NOT_FOUND);
return; return;
} }
InetAddress ia = plugin.getRedisBungeeApi().getPlayerIp(uuid); InetAddress ia = plugin.getAbstractRedisBungeeApi().getPlayerIp(uuid);
if (ia != null) { if (ia != null) {
TextComponent message = Component.text(args[0] + " is connected from " + ia.toString() + ".", NamedTextColor.GREEN); TextComponent message = Component.text(args[0] + " is connected from " + ia.toString() + ".", NamedTextColor.GREEN);
sender.sendMessage(message); sender.sendMessage(message);
@ -218,7 +218,7 @@ public class RedisBungeeCommands {
sender.sendMessage(PLAYER_NOT_FOUND); sender.sendMessage(PLAYER_NOT_FOUND);
return; return;
} }
String proxy = plugin.getRedisBungeeApi().getProxy(uuid); String proxy = plugin.getAbstractRedisBungeeApi().getProxy(uuid);
if (proxy != null) { if (proxy != null) {
TextComponent message = Component.text(args[0] + " is connected to " + proxy + ".", NamedTextColor.GREEN); TextComponent message = Component.text(args[0] + " is connected to " + proxy + ".", NamedTextColor.GREEN);
sender.sendMessage(message); sender.sendMessage(message);
@ -251,7 +251,7 @@ public class RedisBungeeCommands {
CommandSource sender = invocation.source(); CommandSource sender = invocation.source();
if (args.length > 0) { if (args.length > 0) {
String command = Joiner.on(" ").skipNulls().join(args); String command = Joiner.on(" ").skipNulls().join(args);
plugin.getRedisBungeeApi().sendProxyCommand(command); plugin.getAbstractRedisBungeeApi().sendProxyCommand(command);
TextComponent message = Component.text("Sent the command /" + command + " to all proxies.", NamedTextColor.GREEN); TextComponent message = Component.text("Sent the command /" + command + " to all proxies.", NamedTextColor.GREEN);
sender.sendMessage(message); sender.sendMessage(message);
} else { } else {
@ -274,7 +274,7 @@ public class RedisBungeeCommands {
@Override @Override
public void execute(Invocation invocation) { public void execute(Invocation invocation) {
invocation.source().sendMessage(Component.text("You are on " + plugin.getRedisBungeeApi().getProxyId() + ".", NamedTextColor.YELLOW)); invocation.source().sendMessage(Component.text("You are on " + plugin.getAbstractRedisBungeeApi().getProxyId() + ".", NamedTextColor.YELLOW));
} }
@Override @Override
@ -293,7 +293,7 @@ public class RedisBungeeCommands {
@Override @Override
public void execute(Invocation invocation) { public void execute(Invocation invocation) {
invocation.source().sendMessage( invocation.source().sendMessage(
Component.text("All server IDs: " + Joiner.on(", ").join(plugin.getRedisBungeeApi().getAllProxies()), NamedTextColor.YELLOW)); Component.text("All server IDs: " + Joiner.on(", ").join(plugin.getAbstractRedisBungeeApi().getAllProxies()), NamedTextColor.YELLOW));
} }
@Override @Override
@ -319,10 +319,10 @@ public class RedisBungeeCommands {
sender.sendMessage(Component.text(proxy + " is not a valid proxy. See /serverids for valid proxies.", NamedTextColor.RED)); sender.sendMessage(Component.text(proxy + " is not a valid proxy. See /serverids for valid proxies.", NamedTextColor.RED));
return; return;
} }
Set<UUID> players = plugin.getRedisBungeeApi().getPlayersOnProxy(proxy); Set<UUID> players = plugin.getAbstractRedisBungeeApi().getPlayersOnProxy(proxy);
Component playersOnline = Component.text(playerPlural(players.size()) + " currently on proxy " + proxy + ".", NamedTextColor.YELLOW); Component playersOnline = Component.text(playerPlural(players.size()) + " currently on proxy " + proxy + ".", NamedTextColor.YELLOW);
if (args.length >= 2 && args[1].equals("showall")) { if (args.length >= 2 && args[1].equals("showall")) {
Multimap<String, UUID> serverToPlayers = plugin.getRedisBungeeApi().getServerToPlayers(); Multimap<String, UUID> serverToPlayers = plugin.getAbstractRedisBungeeApi().getServerToPlayers();
Multimap<String, String> human = HashMultimap.create(); Multimap<String, String> human = HashMultimap.create();
serverToPlayers.forEach((key, value) -> { serverToPlayers.forEach((key, value) -> {
if (players.contains(value)) { if (players.contains(value)) {