From 31699e36603cce04f82604c0948c5aa229fc170b Mon Sep 17 00:00:00 2001 From: mohammed jasem alaajel Date: Tue, 14 May 2024 21:12:15 +0400 Subject: [PATCH] move backward api into Bungeecord only, and remove deprecated apis added after fork --- .../redisbungee/AbstractRedisBungeeAPI.java | 157 ------------------ .../minecraft/redisbungee/RedisBungeeAPI.java | 87 ++++++++++ .../minecraft/redisbungee/RedisBungee.java | 2 +- 3 files changed, 88 insertions(+), 158 deletions(-) diff --git a/api/src/main/java/com/imaginarycode/minecraft/redisbungee/AbstractRedisBungeeAPI.java b/api/src/main/java/com/imaginarycode/minecraft/redisbungee/AbstractRedisBungeeAPI.java index 50f475e..d1e6f13 100644 --- a/api/src/main/java/com/imaginarycode/minecraft/redisbungee/AbstractRedisBungeeAPI.java +++ b/api/src/main/java/com/imaginarycode/minecraft/redisbungee/AbstractRedisBungeeAPI.java @@ -14,16 +14,11 @@ import com.google.common.collect.ImmutableSet; 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.summoners.JedisClusterSummoner; -import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisPooledSummoner; import com.imaginarycode.minecraft.redisbungee.api.summoners.Summoner; import net.kyori.adventure.text.Component; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import redis.clients.jedis.Jedis; -import redis.clients.jedis.JedisCluster; import redis.clients.jedis.JedisPool; -import redis.clients.jedis.JedisPooled; import java.net.InetAddress; import java.util.*; @@ -216,19 +211,6 @@ public abstract class AbstractRedisBungeeAPI { return plugin.proxyDataManager().proxyId(); } - /** - * Get the current BungeeCord / Velocity proxy ID for this server. - * - * @return the current server ID - * @see #getAllServers() - * @since 0.2.5 - * @deprecated to avoid confusion between A server and A proxy see #getProxyId() - */ - @Deprecated(forRemoval = true) - public final String getServerId() { - return getProxyId(); - } - /** * Get all the linked proxies in this network. * @@ -240,41 +222,6 @@ public abstract class AbstractRedisBungeeAPI { return plugin.proxyDataManager().proxiesIds(); } - /** - * Get all the linked proxies in this network. - * - * @return the list of all proxies - * @see #getServerId() - * @since 0.2.5 - * @deprecated to avoid confusion between A server and A proxy see see {@link #getAllProxies()} - */ - @Deprecated(forRemoval = true) - public final List getAllServers() { - return getAllProxies(); - } - - /** - * Register (a) PubSub channel(s), so that you may handle PubSubMessageEvent for it. - * - * @param channels the channels to register - * @since 0.3 - * @deprecated No longer required - */ - @Deprecated(forRemoval = true) - public final void registerPubSubChannels(String... channels) { - } - - /** - * Unregister (a) PubSub channel(s). - * - * @param channels the channels to unregister - * @since 0.3 - * @deprecated No longer required - */ - @Deprecated(forRemoval = true) - public final void unregisterPubSubChannels(String... channels) { - } - /** * 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. @@ -342,34 +289,6 @@ public abstract class AbstractRedisBungeeAPI { return plugin.getUuidTranslator().getTranslatedUuid(name, expensiveLookups); } - - /** - * Kicks a player from the network - * calls {@link #getUuidFromName(String)} to get uuid - * - * @param playerName player name - * @param message kick message that player will see on kick - * @since 0.8.0 - * @deprecated - */ - @Deprecated(forRemoval = true) - public void kickPlayer(String playerName, String message) { - kickPlayer(getUuidFromName(playerName), message); - } - - /** - * Kicks a player from the network - * - * @param playerUUID player name - * @param message kick message that player will see on kick - * @since 0.8.0 - * @deprecated - */ - @Deprecated(forRemoval = true) - public void kickPlayer(UUID playerUUID, String message) { - kickPlayer(playerUUID, Component.text(message)); - } - /** * Kicks a player from the network * calls {@link #getUuidFromName(String)} to get uuid @@ -394,81 +313,6 @@ public abstract class AbstractRedisBungeeAPI { this.plugin.playerDataManager().kickPlayer(playerUUID, message); } - - /** - * This gives you instance of Jedis - * - * @return {@link Jedis} - * @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#SINGLE} - * @see #getJedisPool() - * @since 0.7.0 - * @deprecated use {@link #getSummoner() } - */ - @Deprecated(forRemoval = true) - public Jedis requestJedis() { - if (getMode() == RedisBungeeMode.SINGLE) { - return getJedisPool().getResource(); - } else { - throw new IllegalStateException("Mode is not " + RedisBungeeMode.SINGLE); - } - } - - /** - * This gets Redis Bungee {@link JedisPool} - * - * @return {@link JedisPool} - * @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#SINGLE} - * @throws IllegalStateException if JedisPool compatibility mode is disabled in the config - * @since 0.6.5 - */ - public JedisPool getJedisPool() { - if (getMode() == RedisBungeeMode.SINGLE) { - JedisPool jedisPool = ((JedisPooledSummoner) this.plugin.getSummoner()).getCompatibilityJedisPool(); - if (jedisPool == null) { - throw new IllegalStateException("JedisPool compatibility mode is disabled, Please enable it in the RedisBungee config.yml"); - } - return jedisPool; - } else { - throw new IllegalStateException("Mode is not " + RedisBungeeMode.SINGLE); - } - } - - /** - * This gives you an instance of JedisCluster that can't be closed - * see {@link com.imaginarycode.minecraft.redisbungee.api.summoners.NotClosableJedisCluster} - * - * @return {@link redis.clients.jedis.JedisCluster} - * @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#CLUSTER} - * @since 0.8.0 - * @deprecated use {@link #getSummoner()} - */ - @Deprecated(forRemoval = true) - public JedisCluster requestClusterJedis() { - if (getMode() == RedisBungeeMode.CLUSTER) { - return ((JedisClusterSummoner) this.plugin.getSummoner()).obtainResource(); - } else { - throw new IllegalStateException("Mode is not " + RedisBungeeMode.CLUSTER); - } - } - - /** - * This gives you an instance of JedisPooled that can't be closed - * see {@link com.imaginarycode.minecraft.redisbungee.api.summoners.NotClosableJedisPooled} - * - * @return {@link redis.clients.jedis.JedisPooled} - * @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#SINGLE} - * @since 0.8.0 - * @deprecated use {@link #getSummoner()} - */ - @Deprecated(forRemoval = true) - public JedisPooled requestJedisPooled() { - if (getMode() == RedisBungeeMode.SINGLE) { - return ((JedisPooledSummoner) this.plugin.getSummoner()).obtainResource(); - } else { - throw new IllegalStateException("Mode is not " + RedisBungeeMode.SINGLE); - } - } - /** * returns Summoner class responsible for Single Jedis {@link redis.clients.jedis.JedisPooled} with {@link JedisPool}, Cluster Jedis {@link redis.clients.jedis.JedisCluster} handling * @@ -479,7 +323,6 @@ public abstract class AbstractRedisBungeeAPI { return this.plugin.getSummoner(); } - /** * shows what mode is RedisBungee is on * Basically what every redis mode is used like cluster or single instance. diff --git a/proxies/bungeecord/bungeecord-api/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeAPI.java b/proxies/bungeecord/bungeecord-api/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeAPI.java index 5140fdb..7681063 100644 --- a/proxies/bungeecord/bungeecord-api/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeAPI.java +++ b/proxies/bungeecord/bungeecord-api/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeAPI.java @@ -10,12 +10,17 @@ package com.imaginarycode.minecraft.redisbungee; +import com.imaginarycode.minecraft.redisbungee.api.RedisBungeeMode; import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin; +import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisPooledSummoner; +import net.kyori.adventure.text.Component; import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.plugin.Plugin; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; +import redis.clients.jedis.JedisPool; +import java.util.List; import java.util.UUID; /** @@ -51,6 +56,88 @@ public class RedisBungeeAPI extends AbstractRedisBungeeAPI { return ((Plugin) this.plugin).getProxy().getServerInfo(serverName); } + // LEGACY API FOR BACKWARD COMPATIBILITY + + /** + * Warning: this is Legacy API to maintain backward compatibility with RedisBungee Pre fork 0.5 + *

+ * Get all the linked proxies in this network. + * + * @return the list of all proxies + * @see #getServerId() + * @since 0.2.5 + * @deprecated to avoid confusion between A server and A proxy see see {@link #getAllProxies()} + */ + @Deprecated + public final List getAllServers() { + return getAllProxies(); + } + + /** + * Warning: this is Legacy API to maintain backward compatibility with RedisBungee Pre fork 0.5 + *

+ * Get the current BungeeCord / Velocity proxy ID for this server. + * + * @return the current server ID + * @see #getAllServers() + * @since 0.2.5 + * @deprecated to avoid confusion between A server and A proxy see #getProxyId() + */ + @Deprecated + public final String getServerId() { + return getProxyId(); + } + + /** + * Warning: this is Legacy API to maintain backward compatibility with RedisBungee Pre fork 0.5 + *

+ * Register (a) PubSub channel(s), so that you may handle PubSubMessageEvent for it. + * + * @param channels the channels to register + * @since 0.3 + * @deprecated No longer required + */ + @Deprecated + public final void registerPubSubChannels(String... channels) { + } + + /** + * Warning: this is Legacy API to maintain backward compatibility with RedisBungee Pre fork 0.5 + *

+ * Unregister (a) PubSub channel(s). + * + * @param channels the channels to unregister + * @since 0.3 + * @deprecated No longer required + */ + @Deprecated + public final void unregisterPubSubChannels(String... channels) { + } + + + /** + * Warning: this is Legacy API to maintain backward compatibility with RedisBungee Pre fork 0.5 + *

+ * This gets Redis Bungee {@link JedisPool} + * + * @return {@link JedisPool} + * @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#SINGLE} + * @throws IllegalStateException if JedisPool compatibility mode is disabled in the config + * @since 0.6.5 + */ + public JedisPool getJedisPool() { + if (getMode() == RedisBungeeMode.SINGLE) { + JedisPool jedisPool = ((JedisPooledSummoner) this.plugin.getSummoner()).getCompatibilityJedisPool(); + if (jedisPool == null) { + throw new IllegalStateException("JedisPool compatibility mode is disabled, Please enable it in the RedisBungee config.yml"); + } + return jedisPool; + } else { + throw new IllegalStateException("Mode is not " + RedisBungeeMode.SINGLE); + } + } + // + /** * Api instance * diff --git a/proxies/bungeecord/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java b/proxies/bungeecord/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java index d5ae22b..987a52c 100644 --- a/proxies/bungeecord/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java +++ b/proxies/bungeecord/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java @@ -62,7 +62,7 @@ import java.util.logging.Level; public class RedisBungee extends Plugin implements RedisBungeePlugin, ConfigLoader, LangConfigLoader { private static RedisBungeeAPI apiStatic; - private AbstractRedisBungeeAPI api; + private RedisBungeeAPI api; private RedisBungeeMode redisBungeeMode; private ProxyDataManager proxyDataManager; private BungeePlayerDataManager playerDataManager;