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

35 Commits
0.6.3 ... 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
mohammed jasem alaajel
1620df961b bumped version 2021-07-21 16:20:48 +04:00
foss-mc
ede9a7cba9 Allow unsuccessful replacement of BungeeCord thread pool (#15)
* Allow unsuccessful replacement of BungeeCord thread pool

Port https://github.com/minecrafter/RedisBungee/pull/76

Some BungeeCord forks have different implementation of thread pool and RedisBungee won't load in such case

* Update RedisBungee.java
2021-07-21 16:13:25 +04:00
mohammed jasem alaajel
701c87db02 add another warning 2021-07-20 17:11:13 +04:00
mohammed jasem alaajel
0ac5a5eebb add warning 2021-07-20 17:08:17 +04:00
mohammed jasem alaajel
0758afeba1 update README.md 2021-07-20 14:55:54 +04:00
mohammed jasem alaajel
9227224248 fix the test checks 2021-07-20 14:52:03 +04:00
mohammed jasem alaajel
ba9ca03e1b oops its should be redis 6.0 not 6.2 2021-07-20 14:49:45 +04:00
williamd5
6c35f23e16 readme.md git clone in current dir, fix link formatting (#13)
* git clone in current dir, fix link formatting

No need to make the user clone into a new dir, then move into this new dir. They will most likely already have an empty dir already created or one with this name might already exist, e.g. a fork repository.

* Update README.md
2021-07-04 17:07:45 +04:00
mohammed jasem alaajel
16720487f0 Update issue templates 2021-06-24 03:58:50 +04:00
mohammed jasem alaajel
6391d8d92c Update issue templates 2021-06-24 03:57:52 +04:00
mohammed jasem alaajel
51115746c7 older versions or redis than (6.2) is no longer supported 2021-06-24 03:54:44 +04:00
mohammed jasem alaajel
f53829481a updated the notice 2021-06-24 03:54:06 +04:00
mohammed jasem alaajel
9441624c09 added java 16 support 2021-06-24 03:35:05 +04:00
mohammed jasem alaajel
4fa152b65f Update README.md 2021-06-22 04:07:02 +04:00
mohammed jasem alaajel
0e9388568a Update README.md 2021-06-22 04:04:53 +04:00
mohammed jasem alaajel
f5a2362b68 Update issue templates 2021-06-22 04:03:30 +04:00
mohammed jasem alaajel
513c1ae2ea Forgotten a word 2021-06-22 02:45:27 +04:00
mohammed jasem alaajel
2a8ab73c2b Update README.md 2021-06-22 01:33:33 +04:00
mohammed jasem alaajel
02a117228a Update README.md 2021-06-12 14:49:29 +04:00
mohammed jasem alaajel
3d1fd57c89 Update README.md 2021-05-31 05:33:00 +04:00
mohammed jasem alaajel
334c17d0d8 Update README.md 2021-05-24 00:45:13 +04:00
mohammed jasem alaajel
5ec5b7af9e Update README.md 2021-05-22 18:17:28 +04:00
mohammed jasem alaajel
ad18d168a8 Update README.md 2021-05-22 18:15:32 +04:00
mohammed jasem alaajel
96793e81c5 code clean up and lambda etc 2021-05-21 16:51:44 +04:00
9 changed files with 241 additions and 132 deletions

32
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,32 @@
---
name: Bug report
about: if you find a bug please report it here...
title: ''
labels: waiting.....
assignees: ham1255
---
**Describe the bug**
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Redis version? it should be at least 6 and above.**
**Bungeecord version or (the bungee fork name eg: waterfall) and your plugins**
**console logs?**
please provide any errors if there any.

10
.github/ISSUE_TEMPLATE/question.md vendored Normal file
View File

@@ -0,0 +1,10 @@
---
name: Question
about: ask your questions here
title: ''
labels: question
assignees: GovindasOM, ham1255
---
## What is your question?

View File

@@ -1,39 +1,63 @@
# Limework fork of RedisBungee
[![RedisBungee Build](https://github.com/Limework/RedisBungee/actions/workflows/maven.yml/badge.svg)](https://github.com/Limework/RedisBungee/actions/workflows/maven.yml)
[![RedisBungee Build](https://github.com/Limework/RedisBungee/actions/workflows/maven.yml/badge.svg)](https://github.com/Limework/RedisBungee/actions/workflows/maven.yml) [![](https://jitpack.io/v/limework/redisbungee.svg)](https://jitpack.io/#limework/redisbungee)
Spigot link: [click](https://www.spigotmc.org/resources/redisbungee.87700/)
The maintainer of RedisBungee has became inactive, so we have taken the development of the plugin.
RedisBungee bridges [Redis](https://redis.io) and [BungeeCord](https://github.com/SpigotMC/BungeeCord) together.
RedisBungee uses [Redis](https://redis.io) to Synchronize data between [BungeeCord](https://github.com/SpigotMC/BungeeCord) proxies
## Notice: about older versions of redis than redis 6.0
This is currently deployed on [Govindas Limework!](https://Limework.net)
As of now Version 0.6.4 is only supporting redis 6.0 and above!
## Compiling
Now you can use maven without installing it using Maven wrapper [github?](https://github.com/takari/maven-wrapper) :)
Now you can use Maven without installing it using [Maven wrappe](https://github.com/takari/maven-wrapper) :)
RedisBungee is distributed as a [maven](https://maven.apache.org) project. To compile it and install it in your local Maven repository:
RedisBungee is distributed as a [maven](https://maven.apache.org) project.
git clone https://github.com/Limework/RedisBungee.git
cd RedisBungee
To compile and installing to in your local Maven repository:
git clone https://github.com/Limework/RedisBungee.git .
mvnw clean install
mvnw package
If you have deb maven installed, you can use the `mvn` command instead.
And use it in your pom file.
<dependency>
<groupId>com.imaginarycode.minecraft</groupId>
<artifactId>RedisBungee</artifactId>
<version>0.6.3</version>
<version>0.6.5-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
Or if you want to use the jitpack maven server
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
And use it in your pom file.
<dependency>
<groupId>com.github.limework</groupId>
<artifactId>redisbungee</artifactId>
<version>0.6.4</version>
</dependency>
## 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/
Note: we might add more api into RedisBungeeApi Class but we wont remove the old ones to
keep old plugins working....
## 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.
@@ -45,3 +69,9 @@ This project is distributed under Eclipse Public License 1.0
You can find it [here](https://github.com/Limework/RedisBungee/blob/master/LICENSE)
You can find the original RedisBungee by minecrafter [here](https://github.com/minecrafter/RedisBungee) or spigot page [here](https://www.spigotmc.org/resources/redisbungee.13494/)
## YourKit
YourKit supports open source projects with innovative and intelligent tools for monitoring and profiling Java and .NET applications. YourKit is the creator of [YourKit Java Profiler](https://www.yourkit.com/java/profiler/), [YourKit .NET Profiler](https://www.yourkit.com/.net/profiler/) and [YourKit YouMonitor](https://www.yourkit.com/youmonitor/).
![YourKit](https://www.yourkit.com/images/yklogo.png)

14
pom.xml
View File

@@ -6,7 +6,7 @@
<groupId>com.imaginarycode.minecraft</groupId>
<artifactId>RedisBungee</artifactId>
<version>0.6.3</version>
<version>0.6.5</version>
<repositories>
@@ -80,7 +80,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<version>3.3.0</version>
<configuration>
<source>8</source>
</configuration>
@@ -92,26 +92,26 @@
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>3.4.1</version>
<version>3.6.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.6.2</version>
<version>2.10.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.16-R0.5-SNAPSHOT</version>
<version>1.17-R0.1-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.16</version>
<version>1.18.20</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -123,7 +123,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@@ -37,7 +37,13 @@ import static com.google.common.base.Preconditions.checkArgument;
/**
* The RedisBungee plugin.
* <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 {
@Getter
@@ -72,8 +78,11 @@ public final class RedisBungee extends Plugin {
/**
* 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() {
return api;
}
@@ -223,14 +232,16 @@ public final class RedisBungee extends Plugin {
@Override
public void onEnable() {
ThreadFactory factory = ((ThreadPoolExecutor) getExecutorService()).getThreadFactory();
getExecutorService().shutdownNow();
ScheduledExecutorService service;
ScheduledExecutorService service = Executors.newScheduledThreadPool(24, factory);
try {
Field field = Plugin.class.getDeclaredField("service");
field.setAccessible(true);
field.set(this, service = Executors.newScheduledThreadPool(24, factory));
} catch (Exception e) {
throw new RuntimeException("Can't replace BungeeCord thread pool with our own", e);
ExecutorService builtinService = (ExecutorService) field.get(this);
field.set(this, service);
builtinService.shutdownNow();
} catch (IllegalAccessException | NoSuchFieldException e) {
getLogger().log(Level.WARNING, "Can't replace BungeeCord thread pool with our own");
getLogger().log(Level.INFO, "skipping replacement.....");
}
try {
loadConfig();
@@ -246,8 +257,9 @@ public final class RedisBungee extends Plugin {
for (String s : info.split("\r\n")) {
if (s.startsWith("redis_version:")) {
String version = s.split(":")[1];
getLogger().info(version + " <- redis version");
if (!(usingLua = RedisUtil.canUseLua(version))) {
getLogger().warning("Your version of Redis (" + version + ") is not at least version 2.6. RedisBungee requires a newer version of Redis.");
getLogger().warning("Your version of Redis (" + version + ") is not at least version 6.0 RedisBungee requires a newer version of Redis.");
throw new RuntimeException("Unsupported Redis version detected");
} else {
LuaManager manager = new LuaManager(this);

View File

@@ -6,6 +6,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
import lombok.NonNull;
import net.md_5.bungee.api.config.ServerInfo;
import redis.clients.jedis.JedisPool;
import java.net.InetAddress;
import java.util.*;
@@ -19,9 +20,11 @@ import java.util.*;
public class RedisBungeeAPI {
private final RedisBungee plugin;
private final List<String> reservedChannels;
private static RedisBungeeAPI redisBungeeApi;
RedisBungeeAPI(RedisBungee plugin) {
this.plugin = plugin;
redisBungeeApi = this;
this.reservedChannels = ImmutableList.of(
"redisbungee-allservers",
"redisbungee-" + RedisBungee.getConfiguration().getServerId(),
@@ -296,4 +299,26 @@ public class RedisBungeeAPI {
public final UUID getUuidFromName(@NonNull String name, boolean 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

@@ -14,7 +14,6 @@ import net.md_5.bungee.api.AbstractReconnectHandler;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
@@ -62,7 +61,7 @@ public class RedisBungeeListener implements Listener {
if (player != null) {
event.setCancelled(true);
// TODO: Make it accept a BaseComponent[] like everything else.
event.setCancelReason(TextComponent.toLegacyText(ONLINE_MODE_RECONNECT));
event.setCancelReason(ONLINE_MODE_RECONNECT);
return null;
}
}
@@ -71,17 +70,10 @@ public class RedisBungeeListener implements Listener {
if (jedis.sismember("proxy:" + s + ":usersOnline", event.getConnection().getUniqueId().toString())) {
event.setCancelled(true);
// TODO: Make it accept a BaseComponent[] like everything else.
event.setCancelReason(TextComponent.toLegacyText(ALREADY_LOGGED_IN));
event.setCancelReason(ALREADY_LOGGED_IN);
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;
} finally {
event.completeIntent(plugin);
@@ -95,6 +87,15 @@ public class RedisBungeeListener implements Listener {
plugin.getProxy().getScheduler().runAsync(plugin, new RedisCallable<Void>(plugin) {
@Override
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<>(
event.getPlayer().getUniqueId(), DataManager.DataManagerMessage.Action.JOIN,
new DataManager.LoginPayload(event.getPlayer().getAddress().getAddress()))));
@@ -146,14 +147,13 @@ public class RedisBungeeListener implements Listener {
event.getResponse().getPlayers().setOnline(plugin.getCount());
}
@SuppressWarnings("UnstableApiUsage")
@EventHandler
public void onPluginMessage(final PluginMessageEvent event) {
if ((event.getTag().equals("legacy:redisbungee") || event.getTag().equals("RedisBungee")) && event.getSender() instanceof Server) {
final String currentChannel = event.getTag();
final byte[] data = Arrays.copyOf(event.getData(), event.getData().length);
plugin.getProxy().getScheduler().runAsync(plugin, new Runnable() {
@Override
public void run() {
plugin.getProxy().getScheduler().runAsync(plugin, () -> {
ByteArrayDataInput in = ByteStreams.newDataInput(data);
String subchannel = in.readUTF();
@@ -246,7 +246,6 @@ public class RedisBungeeListener implements Listener {
}
((Server) event.getSender()).sendData(currentChannel, out.toByteArray());
}
});
}
}
@@ -259,6 +258,7 @@ public class RedisBungeeListener implements Listener {
}
}
@SuppressWarnings("SameParameterValue")
private void serializeMultimap(Multimap<String, String> collection, boolean includeNames, ByteArrayDataOutput output) {
output.writeInt(collection.keySet().size());
for (Map.Entry<String, Collection<String>> entry : collection.asMap().entrySet()) {

View File

@@ -58,16 +58,13 @@ public class RedisUtil {
}
public static boolean canUseLua(String redisVersion) {
// Need to use >=2.6 to use Lua optimizations.
// Need to use >=6.2 to use Lua optimizations.
String[] args = redisVersion.split("\\.");
if (args.length < 2) {
return false;
}
int major = Integer.parseInt(args[0]);
int minor = Integer.parseInt(args[1]);
return major >= 3 || (major == 2 && minor >= 6);
return major >= 6 && minor >= 0;
}
}

View File

@@ -7,11 +7,14 @@ import org.junit.Test;
public class RedisUtilTest {
@Test
public void testRedisLuaCheck() {
Assert.assertTrue(RedisUtil.canUseLua("2.6.0"));
Assert.assertTrue(RedisUtil.canUseLua("6.2.0"));
Assert.assertTrue(RedisUtil.canUseLua("6.1.0"));
Assert.assertTrue(RedisUtil.canUseLua("6.0.0"));
Assert.assertFalse(RedisUtil.canUseLua("2.6.0"));
Assert.assertFalse(RedisUtil.canUseLua("2.2.12"));
Assert.assertFalse(RedisUtil.canUseLua("1.2.4"));
Assert.assertTrue(RedisUtil.canUseLua("2.8.4"));
Assert.assertTrue(RedisUtil.canUseLua("3.0.0"));
Assert.assertTrue(RedisUtil.canUseLua("3.2.1"));
Assert.assertFalse(RedisUtil.canUseLua("2.8.4"));
Assert.assertFalse(RedisUtil.canUseLua("3.0.0"));
Assert.assertFalse(RedisUtil.canUseLua("3.2.1"));
}
}