From 4d0222d2aea0a3114bfb3775cdca4aa8302d7730 Mon Sep 17 00:00:00 2001 From: mohammed jasem alaajel Date: Thu, 14 Apr 2022 14:12:47 +0400 Subject: [PATCH] added some javadocs info + added jedis summoner class for future release --- .../minecraft/redisbungee/RedisBungee.java | 32 +++++++++++++++++++ .../minecraft/redisbungee/RedisBungeeAPI.java | 5 +-- .../redisbungee/internal/JedisSummoner.java | 19 +++++++++++ .../internal/RedisBungeePlugin.java | 16 ++++++---- .../redisbungee/RedisBungeeBungeePlugin.java | 4 ++- 5 files changed, 67 insertions(+), 9 deletions(-) create mode 100644 RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java create mode 100644 RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/internal/JedisSummoner.java diff --git a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java new file mode 100644 index 0000000..c397942 --- /dev/null +++ b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungee.java @@ -0,0 +1,32 @@ +package com.imaginarycode.minecraft.redisbungee; + +/** + * This used to be old plugin instance of redis-bungee but now its used to get the api for old plugins + * + * @deprecated its deprecated but won't be removed, so please use {@link RedisBungeeAPI#getRedisBungeeApi()} + * + */ +@Deprecated +public class RedisBungee { + + private static RedisBungeeAPI api; + + public RedisBungee(RedisBungeeAPI api) { + RedisBungee.api = api; + } + + /** + * This returns instance of {@link RedisBungeeAPI} + * + * @deprecated Please use {@link RedisBungeeAPI#getRedisBungeeApi()} this class intended to for old plugins that no longer updated. + * + * @return the {@link RedisBungeeAPI} object instance. + */ + @Deprecated + public static RedisBungeeAPI getApi() { + return api; + } + + + +} diff --git a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeAPI.java b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeAPI.java index 6dc6316..8eaf3e2 100644 --- a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeAPI.java +++ b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeAPI.java @@ -14,8 +14,9 @@ import java.net.InetAddress; import java.util.*; /** - * This class exposes some internal RedisBungee functions. You obtain an instance of this object by invoking {@link RedisBungeePlugin#getApi()}. - * + * This 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#getApi()}. + * or * @author tuxed * @since 0.2.3 * diff --git a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/internal/JedisSummoner.java b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/internal/JedisSummoner.java new file mode 100644 index 0000000..731cfc6 --- /dev/null +++ b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/internal/JedisSummoner.java @@ -0,0 +1,19 @@ +package com.imaginarycode.minecraft.redisbungee.internal; + +import redis.clients.jedis.Jedis; + + +/** + * This class intended for future release to support redis sentinel or redis clusters + * + * @author Ham1255 + * @since 0.7.0 + * + */ +public interface JedisSummoner { + + Jedis requestJedis(); + + boolean isJedisAvailable(); + +} diff --git a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/internal/RedisBungeePlugin.java b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/internal/RedisBungeePlugin.java index 0461672..dfa369d 100644 --- a/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/internal/RedisBungeePlugin.java +++ b/RedisBungee-API/src/main/java/com/imaginarycode/minecraft/redisbungee/internal/RedisBungeePlugin.java @@ -7,7 +7,6 @@ import com.imaginarycode.minecraft.redisbungee.events.PlayerJoinedNetworkEvent; import com.imaginarycode.minecraft.redisbungee.events.PlayerLeftNetworkEvent; import com.imaginarycode.minecraft.redisbungee.events.PubSubMessageEvent; import com.imaginarycode.minecraft.redisbungee.internal.util.uuid.UUIDTranslator; -import redis.clients.jedis.Jedis; import java.net.InetAddress; import java.util.List; @@ -15,7 +14,16 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.TimeUnit; -public interface RedisBungeePlugin

{ + + +/** + * This Class has all internal methods needed by every redis bungee plugin, and it can be used to implement another platforms than bungeecord + * + * @author Ham1255 + * @since 0.7.0 + * + */ +public interface RedisBungeePlugin

extends JedisSummoner { default void enable() { @@ -37,10 +45,6 @@ public interface RedisBungeePlugin

{ Set getPlayers(); - Jedis requestJedis(); - - boolean isJedisAvailable(); - RedisBungeeAPI getApi(); UUIDTranslator getUuidTranslator(); diff --git a/RedisBungee-Bungee/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeBungeePlugin.java b/RedisBungee-Bungee/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeBungeePlugin.java index 1090fdd..c1c1383 100644 --- a/RedisBungee-Bungee/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeBungeePlugin.java +++ b/RedisBungee-Bungee/src/main/java/com/imaginarycode/minecraft/redisbungee/RedisBungeeBungeePlugin.java @@ -346,7 +346,9 @@ public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin } catch (JedisConnectionException e) { throw new RuntimeException("Unable to connect to your Redis server!", e); } - api = new RedisBungeeAPI(this); + this.api = new RedisBungeeAPI(this); + // call old plugin class to support old plugins + new RedisBungee(api); if (isJedisAvailable()) { try (Jedis tmpRsc = requestJedis()) { // This is more portable than INFO