2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2026-05-03 11:40:29 +00:00

11 Commits
0.6.4 ... 0.6.5

Author SHA1 Message Date
mohammed jasem alaajel
5caabc8aa4 prepare for a release 2021-07-31 18:15:02 +04:00
mohammed jasem alaajel
9b4a49f66a don't display exception when can't replace the executor service 2021-07-31 17:07:42 +04:00
mohammed jasem alaajel
785b23ecfb fix java docs issue 2021-07-30 02:20:39 +04:00
mohammed jasem alaajel
d8e0ea71a2 oops 2021-07-30 02:13:39 +04:00
mohammed jasem alaajel
ac66899f98 new api functions 2021-07-30 02:12:01 +04:00
mohammed jasem alaajel
a8673c563b change version 2021-07-30 02:09:53 +04:00
mohammed jasem alaajel
8a4dd53e58 bump depends versions in pom.xml 2021-07-30 02:00:32 +04:00
mohammed jasem alaajel
85711c5688 changed ReadMe 2021-07-22 02:22:11 +04:00
mohammed jasem alaajel
86ebc9c0d2 Fix: Player being added into the Redis database if LoginEvent was cancelled..... (#16) 2021-07-22 02:06:36 +04:00
mohammed jasem alaajel
49ac1ba9ef bump jedis version 2021-07-21 20:50:42 +04:00
mohammed jasem alaajel
d29e51b4a6 Update README.md 2021-07-21 16:33:06 +04:00
5 changed files with 59 additions and 26 deletions

View File

@@ -7,15 +7,9 @@ The maintainer of RedisBungee has became inactive, so we have taken the developm
RedisBungee uses [Redis](https://redis.io) to Synchronize data between [BungeeCord](https://github.com/SpigotMC/BungeeCord) proxies RedisBungee uses [Redis](https://redis.io) to Synchronize data between [BungeeCord](https://github.com/SpigotMC/BungeeCord) proxies
# 0.7 API BREAKING CHANGE:
we do not advice using version (0.7) till we finish making it stable ,
but if you plan to use redis-bungee 0.7 the api has breaking change.
JedisPool was changed to Pool<Jedis> to support Redis Sentinel
If ANYONE found a good way to fix this api breaking change
pull requests are welcomed :)
## Notice: about older versions of redis than redis 6.0 ## Notice: about older versions of redis than redis 6.0
As of now Version 0.6.4-SNAPSHOT is only supporting redis 6.0 and above! As of now Version 0.6.4 is only supporting redis 6.0 and above!
## Compiling ## Compiling
@@ -36,7 +30,7 @@ And use it in your pom file.
<dependency> <dependency>
<groupId>com.imaginarycode.minecraft</groupId> <groupId>com.imaginarycode.minecraft</groupId>
<artifactId>RedisBungee</artifactId> <artifactId>RedisBungee</artifactId>
<version>0.6.4-SNAPSHOT</version> <version>0.6.5-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
@@ -54,14 +48,16 @@ And use it in your pom file.
<dependency> <dependency>
<groupId>com.github.limework</groupId> <groupId>com.github.limework</groupId>
<artifactId>redisbungee</artifactId> <artifactId>redisbungee</artifactId>
<version>0.6.3</version> <version>0.6.4</version>
</dependency> </dependency>
## Javadocs ## Javadocs
Hosted on limework website. Version 0.6.0 (note: any version 0.6.* will not have API changes.) Hosted on limework website. Version 0.6.0 ~~(note: any version 0.6.* will not have API changes.)~~
https://limework.net/JavaDocs/RedisBungee/ https://limework.net/JavaDocs/RedisBungee/
Note: we might add more api into RedisBungeeApi Class but we wont remove the old ones to
keep old plugins working....
## Configuration ## Configuration
**REDISBUNGEE REQUIRES A REDIS SERVER**, preferably with reasonably low latency. The default [config](https://github.com/limework/RedisBungee/blob/master/src/main/resources/example_config.yml) is saved when the plugin first starts. **REDISBUNGEE REQUIRES A REDIS SERVER**, preferably with reasonably low latency. The default [config](https://github.com/limework/RedisBungee/blob/master/src/main/resources/example_config.yml) is saved when the plugin first starts.

10
pom.xml
View File

@@ -6,7 +6,7 @@
<groupId>com.imaginarycode.minecraft</groupId> <groupId>com.imaginarycode.minecraft</groupId>
<artifactId>RedisBungee</artifactId> <artifactId>RedisBungee</artifactId>
<version>0.6.4</version> <version>0.6.5</version>
<repositories> <repositories>
@@ -80,7 +80,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version> <version>3.3.0</version>
<configuration> <configuration>
<source>8</source> <source>8</source>
</configuration> </configuration>
@@ -92,13 +92,13 @@
<dependency> <dependency>
<groupId>redis.clients</groupId> <groupId>redis.clients</groupId>
<artifactId>jedis</artifactId> <artifactId>jedis</artifactId>
<version>3.6.1</version> <version>3.6.3</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId> <artifactId>commons-pool2</artifactId>
<version>2.6.2</version> <version>2.10.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
@@ -123,7 +123,7 @@
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>4.13.1</version> <version>4.13.2</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@@ -37,7 +37,13 @@ import static com.google.common.base.Preconditions.checkArgument;
/** /**
* The RedisBungee plugin. * The RedisBungee plugin.
* <p> * <p>
* The only function of interest is {@link #getApi()}, which exposes some functions in this class. * The only function of interest is {@link #getApi()}, which deprecated now,
* Please check {@link RedisBungeeAPI#getRedisBungeeApi()},
*
* which exposes some functions in this class.
* but if you want old version support,
* then you can use old method {@link #getApi()}
*
*/ */
public final class RedisBungee extends Plugin { public final class RedisBungee extends Plugin {
@Getter @Getter
@@ -72,8 +78,11 @@ public final class RedisBungee extends Plugin {
/** /**
* Fetch the {@link RedisBungeeAPI} object created on plugin start. * Fetch the {@link RedisBungeeAPI} object created on plugin start.
* *
* @return the {@link RedisBungeeAPI} object * @deprecated Please use {@link RedisBungeeAPI#getRedisBungeeApi()}
*
* @return the {@link RedisBungeeAPI} object instance.
*/ */
@Deprecated
public static RedisBungeeAPI getApi() { public static RedisBungeeAPI getApi() {
return api; return api;
} }
@@ -230,8 +239,9 @@ public final class RedisBungee extends Plugin {
ExecutorService builtinService = (ExecutorService) field.get(this); ExecutorService builtinService = (ExecutorService) field.get(this);
field.set(this, service); field.set(this, service);
builtinService.shutdownNow(); builtinService.shutdownNow();
} catch (Exception e) { } catch (IllegalAccessException | NoSuchFieldException e) {
getLogger().log(Level.WARNING, "Can't replace BungeeCord thread pool with our own", e); getLogger().log(Level.WARNING, "Can't replace BungeeCord thread pool with our own");
getLogger().log(Level.INFO, "skipping replacement.....");
} }
try { try {
loadConfig(); loadConfig();

View File

@@ -6,6 +6,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import lombok.NonNull; import lombok.NonNull;
import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.config.ServerInfo;
import redis.clients.jedis.JedisPool;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.*; import java.util.*;
@@ -19,9 +20,11 @@ import java.util.*;
public class RedisBungeeAPI { public class RedisBungeeAPI {
private final RedisBungee plugin; private final RedisBungee plugin;
private final List<String> reservedChannels; private final List<String> reservedChannels;
private static RedisBungeeAPI redisBungeeApi;
RedisBungeeAPI(RedisBungee plugin) { RedisBungeeAPI(RedisBungee plugin) {
this.plugin = plugin; this.plugin = plugin;
redisBungeeApi = this;
this.reservedChannels = ImmutableList.of( this.reservedChannels = ImmutableList.of(
"redisbungee-allservers", "redisbungee-allservers",
"redisbungee-" + RedisBungee.getConfiguration().getServerId(), "redisbungee-" + RedisBungee.getConfiguration().getServerId(),
@@ -296,4 +299,26 @@ public class RedisBungeeAPI {
public final UUID getUuidFromName(@NonNull String name, boolean expensiveLookups) { public final UUID getUuidFromName(@NonNull String name, boolean expensiveLookups) {
return plugin.getUuidTranslator().getTranslatedUuid(name, expensiveLookups); return plugin.getUuidTranslator().getTranslatedUuid(name, expensiveLookups);
} }
/**
* This gets Redis Bungee Jedis pool
*
* @return {@link JedisPool}
* @since 0.6.5
*/
public JedisPool getJedisPool() {
return this.plugin.getPool();
}
/**
* This alternative to {@link RedisBungee#getApi()}
* which now deprecated. but to maintain old plugins compatibility it won't be removed.
*
* @return the API instance.
* @since 0.6.5
*/
public static RedisBungeeAPI getRedisBungeeApi() {
return redisBungeeApi;
}
} }

View File

@@ -74,13 +74,6 @@ public class RedisBungeeListener implements Listener {
return null; return null;
} }
} }
Pipeline pipeline = jedis.pipelined();
plugin.getUuidTranslator().persistInfo(event.getConnection().getName(), event.getConnection().getUniqueId(), pipeline);
RedisUtil.createPlayer(event.getConnection(), pipeline, false);
// We're not publishing, the API says we only publish at PostLoginEvent time.
pipeline.sync();
return null; return null;
} finally { } finally {
event.completeIntent(plugin); event.completeIntent(plugin);
@@ -94,6 +87,15 @@ public class RedisBungeeListener implements Listener {
plugin.getProxy().getScheduler().runAsync(plugin, new RedisCallable<Void>(plugin) { plugin.getProxy().getScheduler().runAsync(plugin, new RedisCallable<Void>(plugin) {
@Override @Override
protected Void call(Jedis jedis) { protected Void call(Jedis jedis) {
// this code was moved out from login event due being async..
// and it can be cancelled but it will show as false in redis-bungee
// which will register the player into the redis database.
Pipeline pipeline = jedis.pipelined();
plugin.getUuidTranslator().persistInfo(event.getPlayer().getName(), event.getPlayer().getUniqueId(), pipeline);
RedisUtil.createPlayer(event.getPlayer(), pipeline, false);
pipeline.sync();
// the end of moved code.
jedis.publish("redisbungee-data", RedisBungee.getGson().toJson(new DataManager.DataManagerMessage<>( jedis.publish("redisbungee-data", RedisBungee.getGson().toJson(new DataManager.DataManagerMessage<>(
event.getPlayer().getUniqueId(), DataManager.DataManagerMessage.Action.JOIN, event.getPlayer().getUniqueId(), DataManager.DataManagerMessage.Action.JOIN,
new DataManager.LoginPayload(event.getPlayer().getAddress().getAddress())))); new DataManager.LoginPayload(event.getPlayer().getAddress().getAddress()))));