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

added some javadocs info + added jedis summoner class for future release

This commit is contained in:
mohammed jasem alaajel 2022-04-14 14:12:47 +04:00
parent e53f8a02ba
commit 4d0222d2ae
5 changed files with 67 additions and 9 deletions

View File

@ -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;
}
}

View File

@ -14,8 +14,9 @@ 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 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 * @author tuxed
* @since 0.2.3 * @since 0.2.3
* *

View File

@ -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();
}

View File

@ -7,7 +7,6 @@ import com.imaginarycode.minecraft.redisbungee.events.PlayerJoinedNetworkEvent;
import com.imaginarycode.minecraft.redisbungee.events.PlayerLeftNetworkEvent; import com.imaginarycode.minecraft.redisbungee.events.PlayerLeftNetworkEvent;
import com.imaginarycode.minecraft.redisbungee.events.PubSubMessageEvent; import com.imaginarycode.minecraft.redisbungee.events.PubSubMessageEvent;
import com.imaginarycode.minecraft.redisbungee.internal.util.uuid.UUIDTranslator; import com.imaginarycode.minecraft.redisbungee.internal.util.uuid.UUIDTranslator;
import redis.clients.jedis.Jedis;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.List; import java.util.List;
@ -15,7 +14,16 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public interface RedisBungeePlugin<P> {
/**
* 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<P> extends JedisSummoner {
default void enable() { default void enable() {
@ -37,10 +45,6 @@ public interface RedisBungeePlugin<P> {
Set<UUID> getPlayers(); Set<UUID> getPlayers();
Jedis requestJedis();
boolean isJedisAvailable();
RedisBungeeAPI getApi(); RedisBungeeAPI getApi();
UUIDTranslator getUuidTranslator(); UUIDTranslator getUuidTranslator();

View File

@ -346,7 +346,9 @@ public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin
} catch (JedisConnectionException e) { } catch (JedisConnectionException e) {
throw new RuntimeException("Unable to connect to your Redis server!", 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()) { if (isJedisAvailable()) {
try (Jedis tmpRsc = requestJedis()) { try (Jedis tmpRsc = requestJedis()) {
// This is more portable than INFO <section> // This is more portable than INFO <section>