mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2026-05-03 11:40:29 +00:00
Compare commits
63 Commits
0.6-SNAPSH
...
0.6.5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5caabc8aa4 | ||
|
|
9b4a49f66a | ||
|
|
785b23ecfb | ||
|
|
d8e0ea71a2 | ||
|
|
ac66899f98 | ||
|
|
a8673c563b | ||
|
|
8a4dd53e58 | ||
|
|
85711c5688 | ||
|
|
86ebc9c0d2 | ||
|
|
49ac1ba9ef | ||
|
|
d29e51b4a6 | ||
|
|
1620df961b | ||
|
|
ede9a7cba9 | ||
|
|
701c87db02 | ||
|
|
0ac5a5eebb | ||
|
|
0758afeba1 | ||
|
|
9227224248 | ||
|
|
ba9ca03e1b | ||
|
|
6c35f23e16 | ||
|
|
16720487f0 | ||
|
|
6391d8d92c | ||
|
|
51115746c7 | ||
|
|
f53829481a | ||
|
|
9441624c09 | ||
|
|
4fa152b65f | ||
|
|
0e9388568a | ||
|
|
f5a2362b68 | ||
|
|
513c1ae2ea | ||
|
|
2a8ab73c2b | ||
|
|
02a117228a | ||
|
|
3d1fd57c89 | ||
|
|
334c17d0d8 | ||
|
|
5ec5b7af9e | ||
|
|
ad18d168a8 | ||
|
|
96793e81c5 | ||
|
|
39b3c03604 | ||
|
|
373e1c16d4 | ||
|
|
56042af4eb | ||
|
|
8df8d96ced | ||
|
|
4c1ffa2b01 | ||
|
|
02caf2da5e | ||
|
|
a005b46467 | ||
|
|
65abb29558 | ||
|
|
5169d873a8 | ||
|
|
f0fbaab0b1 | ||
|
|
4091da2ed8 | ||
|
|
86bef752de | ||
|
|
17e203d7be | ||
|
|
ab8db5570c | ||
|
|
571a318969 | ||
|
|
f07eed220d | ||
|
|
76721cd5fd | ||
|
|
f8ed847857 | ||
|
|
bfdbe69b97 | ||
|
|
536686e92f | ||
|
|
78ee62a98a | ||
|
|
01f63f0f58 | ||
|
|
28640ab859 | ||
|
|
e72126a15b | ||
|
|
386b02ed30 | ||
|
|
40e8831ab8 | ||
|
|
aca5203962 | ||
|
|
3512895ad8 |
32
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
32
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal 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
10
.github/ISSUE_TEMPLATE/question.md
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
name: Question
|
||||||
|
about: ask your questions here
|
||||||
|
title: ''
|
||||||
|
labels: question
|
||||||
|
assignees: GovindasOM, ham1255
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## What is your question?
|
||||||
32
.github/workflows/maven.yml
vendored
Normal file
32
.github/workflows/maven.yml
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# This workflow will build a Java project with Maven
|
||||||
|
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
|
||||||
|
|
||||||
|
name: RedisBungee Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up JDK 11
|
||||||
|
uses: actions/setup-java@v2
|
||||||
|
with:
|
||||||
|
java-version: '8'
|
||||||
|
distribution: 'adopt'
|
||||||
|
- name: Build with Maven
|
||||||
|
run: mvn -B package --file pom.xml
|
||||||
|
- name: Download a Build Artifact
|
||||||
|
uses: actions/upload-artifact@v2.2.3
|
||||||
|
with:
|
||||||
|
# Artifact name
|
||||||
|
name: Redis_JAR
|
||||||
|
# Destination path
|
||||||
|
path: target/RedisBungee*
|
||||||
71
README.md
71
README.md
@@ -1,38 +1,77 @@
|
|||||||
# Limework fork of RedisBungee
|
# Limework fork of RedisBungee
|
||||||
|
[](https://github.com/Limework/RedisBungee/actions/workflows/maven.yml) [](https://jitpack.io/#limework/redisbungee)
|
||||||
|
|
||||||
this fork was made due maintainer of redisBungee became unactive so we took the place to develop it!
|
Spigot link: [click](https://www.spigotmc.org/resources/redisbungee.87700/)
|
||||||
|
|
||||||
RedisBungee bridges [Redis](http://redis.io) and BungeeCord together.
|
The maintainer of RedisBungee has became inactive, so we have taken the development of the plugin.
|
||||||
|
|
||||||
RedisBungee was used on thechunk server which we think was shutdown due website not loading...
|
RedisBungee uses [Redis](https://redis.io) to Synchronize data between [BungeeCord](https://github.com/SpigotMC/BungeeCord) proxies
|
||||||
|
|
||||||
this will be deployed soon on [Govindas limework!](https://Limework.net)
|
## Notice: about older versions of redis than redis 6.0
|
||||||
|
|
||||||
~~This is the solution deployed on [The Chunk](http://thechunk.net) to make sure our multi-Bungee setup flows smoothly together.~~
|
As of now Version 0.6.4 is only supporting redis 6.0 and above!
|
||||||
|
|
||||||
## Compiling
|
## Compiling
|
||||||
|
|
||||||
Now you can use maven without installing it using Maven wrapper 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](http://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
|
To compile and installing to in your local Maven repository:
|
||||||
cd RedisBungee
|
|
||||||
|
git clone https://github.com/Limework/RedisBungee.git .
|
||||||
mvnw clean install
|
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.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
|
## Javadocs
|
||||||
|
Hosted on limework website. Version 0.6.0 ~~(note: any version 0.6.* will not have API changes.)~~
|
||||||
|
https://limework.net/JavaDocs/RedisBungee/
|
||||||
|
|
||||||
will be availale soon!
|
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/minecrafter/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.
|
||||||
|
|
||||||
## License!
|
## License!
|
||||||
|
|
||||||
this project is distruped using Eclipse Public License 1.0
|
This project is distributed under Eclipse Public License 1.0
|
||||||
|
|
||||||
which you can find it [here](https://github.com/Limework/RedisBungee/blob/master/LICENSE)
|
You can find it [here](https://github.com/Limework/RedisBungee/blob/master/LICENSE)
|
||||||
|
|
||||||
you can find the orginal redisBungee by minecrafter [here](https://github.com/minecrafter/RedisBungee) or spigot page [here](https://www.spigotmc.org/resources/redisbungee.13494/)
|
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/).
|
||||||
|
|
||||||
|

|
||||||
|
|||||||
18
pom.xml
18
pom.xml
@@ -6,7 +6,8 @@
|
|||||||
|
|
||||||
<groupId>com.imaginarycode.minecraft</groupId>
|
<groupId>com.imaginarycode.minecraft</groupId>
|
||||||
<artifactId>RedisBungee</artifactId>
|
<artifactId>RedisBungee</artifactId>
|
||||||
<version>0.6-SNAPSHOT</version>
|
<version>0.6.5</version>
|
||||||
|
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
@@ -79,7 +80,10 @@
|
|||||||
<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>
|
||||||
|
<source>8</source>
|
||||||
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
@@ -88,26 +92,26 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>redis.clients</groupId>
|
<groupId>redis.clients</groupId>
|
||||||
<artifactId>jedis</artifactId>
|
<artifactId>jedis</artifactId>
|
||||||
<version>3.4.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>
|
||||||
<groupId>net.md-5</groupId>
|
<groupId>net.md-5</groupId>
|
||||||
<artifactId>bungeecord-api</artifactId>
|
<artifactId>bungeecord-api</artifactId>
|
||||||
<version>1.16-R0.4-SNAPSHOT</version>
|
<version>1.17-R0.1-SNAPSHOT</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>1.18.16</version>
|
<version>1.18.20</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -119,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>
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
@@ -104,7 +113,8 @@ public final class RedisBungee extends Plugin {
|
|||||||
if (lagged ? time >= stamp + 30 : time <= stamp + 30)
|
if (lagged ? time >= stamp + 30 : time <= stamp + 30)
|
||||||
servers.add(entry.getKey());
|
servers.add(entry.getKey());
|
||||||
else if (nag && nagTime <= 0) {
|
else if (nag && nagTime <= 0) {
|
||||||
getLogger().severe(entry.getKey() + " is " + (time - stamp) + " seconds behind! (Time not synchronized or server down?)");
|
getLogger().warning(entry.getKey() + " is " + (time - stamp) + " seconds behind! (Time not synchronized or server down?) and was removed from heartbeat.");
|
||||||
|
jedis.hdel("heartbeats", entry.getKey());
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {
|
||||||
}
|
}
|
||||||
@@ -222,14 +232,16 @@ public final class RedisBungee extends Plugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
ThreadFactory factory = ((ThreadPoolExecutor) getExecutorService()).getThreadFactory();
|
ThreadFactory factory = ((ThreadPoolExecutor) getExecutorService()).getThreadFactory();
|
||||||
getExecutorService().shutdownNow();
|
ScheduledExecutorService service = Executors.newScheduledThreadPool(24, factory);
|
||||||
ScheduledExecutorService service;
|
|
||||||
try {
|
try {
|
||||||
Field field = Plugin.class.getDeclaredField("service");
|
Field field = Plugin.class.getDeclaredField("service");
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
field.set(this, service = Executors.newScheduledThreadPool(24, factory));
|
ExecutorService builtinService = (ExecutorService) field.get(this);
|
||||||
} catch (Exception e) {
|
field.set(this, service);
|
||||||
throw new RuntimeException("Can't replace BungeeCord thread pool with our own", e);
|
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 {
|
try {
|
||||||
loadConfig();
|
loadConfig();
|
||||||
@@ -245,8 +257,9 @@ public final class RedisBungee extends Plugin {
|
|||||||
for (String s : info.split("\r\n")) {
|
for (String s : info.split("\r\n")) {
|
||||||
if (s.startsWith("redis_version:")) {
|
if (s.startsWith("redis_version:")) {
|
||||||
String version = s.split(":")[1];
|
String version = s.split(":")[1];
|
||||||
|
getLogger().info(version + " <- redis version");
|
||||||
if (!(usingLua = RedisUtil.canUseLua(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");
|
throw new RuntimeException("Unsupported Redis version detected");
|
||||||
} else {
|
} else {
|
||||||
LuaManager manager = new LuaManager(this);
|
LuaManager manager = new LuaManager(this);
|
||||||
@@ -415,6 +428,7 @@ public final class RedisBungee extends Plugin {
|
|||||||
final boolean useSSL = configuration.getBoolean("useSSL");
|
final boolean useSSL = configuration.getBoolean("useSSL");
|
||||||
String redisPassword = configuration.getString("redis-password");
|
String redisPassword = configuration.getString("redis-password");
|
||||||
String serverId = configuration.getString("server-id");
|
String serverId = configuration.getString("server-id");
|
||||||
|
final String randomUUID = UUID.randomUUID().toString();
|
||||||
|
|
||||||
if (redisPassword != null && (redisPassword.isEmpty() || redisPassword.equals("none"))) {
|
if (redisPassword != null && (redisPassword.isEmpty() || redisPassword.equals("none"))) {
|
||||||
redisPassword = null;
|
redisPassword = null;
|
||||||
@@ -422,7 +436,20 @@ public final class RedisBungee extends Plugin {
|
|||||||
|
|
||||||
// Configuration sanity checks.
|
// Configuration sanity checks.
|
||||||
if (serverId == null || serverId.isEmpty()) {
|
if (serverId == null || serverId.isEmpty()) {
|
||||||
throw new RuntimeException("server-id is not specified in the configuration or is empty");
|
/*
|
||||||
|
* this check causes the config comments to disappear somehow
|
||||||
|
* I think due snake yaml limitations so as todo: write our own yaml parser?
|
||||||
|
*/
|
||||||
|
String genId = UUID.randomUUID().toString();
|
||||||
|
getLogger().info("Generated server id " + genId + " and saving it to config.");
|
||||||
|
configuration.set("server-id", genId);
|
||||||
|
ConfigurationProvider.getProvider(YamlConfiguration.class).save(configuration, new File(getDataFolder(), "config.yml"));
|
||||||
|
} else {
|
||||||
|
getLogger().info("Loaded server id " + serverId + '.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configuration.getBoolean("use-random-id-string", false)) {
|
||||||
|
serverId = configuration.getString("server-id") + "-" + randomUUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (redisServer != null && !redisServer.isEmpty()) {
|
if (redisServer != null && !redisServer.isEmpty()) {
|
||||||
@@ -474,7 +501,7 @@ public final class RedisBungee extends Plugin {
|
|||||||
httpClient.setDispatcher(dispatcher);
|
httpClient.setDispatcher(dispatcher);
|
||||||
NameFetcher.setHttpClient(httpClient);
|
NameFetcher.setHttpClient(httpClient);
|
||||||
UUIDFetcher.setHttpClient(httpClient);
|
UUIDFetcher.setHttpClient(httpClient);
|
||||||
RedisBungee.configuration = new RedisBungeeConfiguration(RedisBungee.this.getPool(), configuration);
|
RedisBungee.configuration = new RedisBungeeConfiguration(RedisBungee.this.getPool(), configuration, randomUUID);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import redis.clients.jedis.JedisPool;
|
|||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class RedisBungeeConfiguration {
|
public class RedisBungeeConfiguration {
|
||||||
@Getter
|
@Getter
|
||||||
@@ -19,9 +20,15 @@ public class RedisBungeeConfiguration {
|
|||||||
@Getter
|
@Getter
|
||||||
private final List<InetAddress> exemptAddresses;
|
private final List<InetAddress> exemptAddresses;
|
||||||
|
|
||||||
public RedisBungeeConfiguration(JedisPool pool, Configuration configuration) {
|
|
||||||
|
public RedisBungeeConfiguration(JedisPool pool, Configuration configuration, String randomUUID) {
|
||||||
this.pool = pool;
|
this.pool = pool;
|
||||||
this.serverId = configuration.getString("server-id");
|
if (configuration.getBoolean("use-random-id-string", false)) {
|
||||||
|
this.serverId = configuration.getString("server-id") + "-" + randomUUID;
|
||||||
|
} else {
|
||||||
|
this.serverId = configuration.getString("server-id");
|
||||||
|
}
|
||||||
|
|
||||||
this.registerBungeeCommands = configuration.getBoolean("register-bungee-commands", true);
|
this.registerBungeeCommands = configuration.getBoolean("register-bungee-commands", true);
|
||||||
|
|
||||||
List<String> stringified = configuration.getStringList("exempt-ip-addresses");
|
List<String> stringified = configuration.getStringList("exempt-ip-addresses");
|
||||||
@@ -33,4 +40,5 @@ public class RedisBungeeConfiguration {
|
|||||||
|
|
||||||
this.exemptAddresses = addressBuilder.build();
|
this.exemptAddresses = addressBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import net.md_5.bungee.api.AbstractReconnectHandler;
|
|||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
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.config.ServerInfo;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.connection.Server;
|
import net.md_5.bungee.api.connection.Server;
|
||||||
@@ -62,7 +61,7 @@ public class RedisBungeeListener implements Listener {
|
|||||||
if (player != null) {
|
if (player != null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
// TODO: Make it accept a BaseComponent[] like everything else.
|
// TODO: Make it accept a BaseComponent[] like everything else.
|
||||||
event.setCancelReason(TextComponent.toLegacyText(ONLINE_MODE_RECONNECT));
|
event.setCancelReason(ONLINE_MODE_RECONNECT);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -71,17 +70,10 @@ public class RedisBungeeListener implements Listener {
|
|||||||
if (jedis.sismember("proxy:" + s + ":usersOnline", event.getConnection().getUniqueId().toString())) {
|
if (jedis.sismember("proxy:" + s + ":usersOnline", event.getConnection().getUniqueId().toString())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
// TODO: Make it accept a BaseComponent[] like everything else.
|
// TODO: Make it accept a BaseComponent[] like everything else.
|
||||||
event.setCancelReason(TextComponent.toLegacyText(ALREADY_LOGGED_IN));
|
event.setCancelReason(ALREADY_LOGGED_IN);
|
||||||
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);
|
||||||
@@ -95,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()))));
|
||||||
@@ -146,107 +147,105 @@ public class RedisBungeeListener implements Listener {
|
|||||||
event.getResponse().getPlayers().setOnline(plugin.getCount());
|
event.getResponse().getPlayers().setOnline(plugin.getCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("UnstableApiUsage")
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPluginMessage(final PluginMessageEvent event) {
|
public void onPluginMessage(final PluginMessageEvent event) {
|
||||||
if ((event.getTag().equals("legacy:RedisBungee") || event.getTag().equals("RedisBungee")) && event.getSender() instanceof Server) {
|
if ((event.getTag().equals("legacy:redisbungee") || event.getTag().equals("RedisBungee")) && event.getSender() instanceof Server) {
|
||||||
final String currentChannel = event.getTag();
|
final String currentChannel = event.getTag();
|
||||||
final byte[] data = Arrays.copyOf(event.getData(), event.getData().length);
|
final byte[] data = Arrays.copyOf(event.getData(), event.getData().length);
|
||||||
plugin.getProxy().getScheduler().runAsync(plugin, new Runnable() {
|
plugin.getProxy().getScheduler().runAsync(plugin, () -> {
|
||||||
@Override
|
ByteArrayDataInput in = ByteStreams.newDataInput(data);
|
||||||
public void run() {
|
|
||||||
ByteArrayDataInput in = ByteStreams.newDataInput(data);
|
|
||||||
|
|
||||||
String subchannel = in.readUTF();
|
String subchannel = in.readUTF();
|
||||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||||
String type;
|
String type;
|
||||||
|
|
||||||
switch (subchannel) {
|
switch (subchannel) {
|
||||||
case "PlayerList":
|
case "PlayerList":
|
||||||
out.writeUTF("PlayerList");
|
out.writeUTF("PlayerList");
|
||||||
Set<UUID> original = Collections.emptySet();
|
Set<UUID> original = Collections.emptySet();
|
||||||
type = in.readUTF();
|
type = in.readUTF();
|
||||||
if (type.equals("ALL")) {
|
if (type.equals("ALL")) {
|
||||||
out.writeUTF("ALL");
|
out.writeUTF("ALL");
|
||||||
original = plugin.getPlayers();
|
original = plugin.getPlayers();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
original = RedisBungee.getApi().getPlayersOnServer(type);
|
original = RedisBungee.getApi().getPlayersOnServer(type);
|
||||||
} catch (IllegalArgumentException ignored) {
|
} catch (IllegalArgumentException ignored) {
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Set<String> players = new HashSet<>();
|
}
|
||||||
for (UUID uuid : original)
|
Set<String> players = new HashSet<>();
|
||||||
players.add(plugin.getUuidTranslator().getNameFromUuid(uuid, false));
|
for (UUID uuid : original)
|
||||||
out.writeUTF(Joiner.on(',').join(players));
|
players.add(plugin.getUuidTranslator().getNameFromUuid(uuid, false));
|
||||||
break;
|
out.writeUTF(Joiner.on(',').join(players));
|
||||||
case "PlayerCount":
|
break;
|
||||||
out.writeUTF("PlayerCount");
|
case "PlayerCount":
|
||||||
type = in.readUTF();
|
out.writeUTF("PlayerCount");
|
||||||
if (type.equals("ALL")) {
|
type = in.readUTF();
|
||||||
out.writeUTF("ALL");
|
if (type.equals("ALL")) {
|
||||||
out.writeInt(plugin.getCount());
|
out.writeUTF("ALL");
|
||||||
} else {
|
out.writeInt(plugin.getCount());
|
||||||
out.writeUTF(type);
|
} else {
|
||||||
try {
|
out.writeUTF(type);
|
||||||
out.writeInt(RedisBungee.getApi().getPlayersOnServer(type).size());
|
try {
|
||||||
} catch (IllegalArgumentException e) {
|
out.writeInt(RedisBungee.getApi().getPlayersOnServer(type).size());
|
||||||
out.writeInt(0);
|
} catch (IllegalArgumentException e) {
|
||||||
}
|
out.writeInt(0);
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case "LastOnline":
|
break;
|
||||||
String user = in.readUTF();
|
case "LastOnline":
|
||||||
out.writeUTF("LastOnline");
|
String user = in.readUTF();
|
||||||
out.writeUTF(user);
|
out.writeUTF("LastOnline");
|
||||||
out.writeLong(RedisBungee.getApi().getLastOnline(plugin.getUuidTranslator().getTranslatedUuid(user, true)));
|
out.writeUTF(user);
|
||||||
break;
|
out.writeLong(RedisBungee.getApi().getLastOnline(plugin.getUuidTranslator().getTranslatedUuid(user, true)));
|
||||||
case "ServerPlayers":
|
break;
|
||||||
String type1 = in.readUTF();
|
case "ServerPlayers":
|
||||||
out.writeUTF("ServerPlayers");
|
String type1 = in.readUTF();
|
||||||
Multimap<String, UUID> multimap = RedisBungee.getApi().getServerToPlayers();
|
out.writeUTF("ServerPlayers");
|
||||||
|
Multimap<String, UUID> multimap = RedisBungee.getApi().getServerToPlayers();
|
||||||
|
|
||||||
boolean includesUsers;
|
boolean includesUsers;
|
||||||
|
|
||||||
switch (type1) {
|
switch (type1) {
|
||||||
case "COUNT":
|
case "COUNT":
|
||||||
includesUsers = false;
|
includesUsers = false;
|
||||||
break;
|
break;
|
||||||
case "PLAYERS":
|
case "PLAYERS":
|
||||||
includesUsers = true;
|
includesUsers = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// TODO: Should I raise an error?
|
// TODO: Should I raise an error?
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
out.writeUTF(type1);
|
||||||
|
|
||||||
|
if (includesUsers) {
|
||||||
|
Multimap<String, String> human = HashMultimap.create();
|
||||||
|
for (Map.Entry<String, UUID> entry : multimap.entries()) {
|
||||||
|
human.put(entry.getKey(), plugin.getUuidTranslator().getNameFromUuid(entry.getValue(), false));
|
||||||
}
|
}
|
||||||
|
serializeMultimap(human, true, out);
|
||||||
out.writeUTF(type1);
|
} else {
|
||||||
|
serializeMultiset(multimap.keys(), out);
|
||||||
if (includesUsers) {
|
}
|
||||||
Multimap<String, String> human = HashMultimap.create();
|
break;
|
||||||
for (Map.Entry<String, UUID> entry : multimap.entries()) {
|
case "Proxy":
|
||||||
human.put(entry.getKey(), plugin.getUuidTranslator().getNameFromUuid(entry.getValue(), false));
|
out.writeUTF("Proxy");
|
||||||
}
|
out.writeUTF(RedisBungee.getConfiguration().getServerId());
|
||||||
serializeMultimap(human, true, out);
|
break;
|
||||||
} else {
|
case "PlayerProxy":
|
||||||
serializeMultiset(multimap.keys(), out);
|
String username = in.readUTF();
|
||||||
}
|
out.writeUTF("PlayerProxy");
|
||||||
break;
|
out.writeUTF(username);
|
||||||
case "Proxy":
|
out.writeUTF(RedisBungee.getApi().getProxy(plugin.getUuidTranslator().getTranslatedUuid(username, true)));
|
||||||
out.writeUTF("Proxy");
|
break;
|
||||||
out.writeUTF(RedisBungee.getConfiguration().getServerId());
|
default:
|
||||||
break;
|
return;
|
||||||
case "PlayerProxy":
|
|
||||||
String username = in.readUTF();
|
|
||||||
out.writeUTF("PlayerProxy");
|
|
||||||
out.writeUTF(username);
|
|
||||||
out.writeUTF(RedisBungee.getApi().getProxy(plugin.getUuidTranslator().getTranslatedUuid(username, true)));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
((Server) event.getSender()).sendData(currentChannel, out.toByteArray());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
((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) {
|
private void serializeMultimap(Multimap<String, String> collection, boolean includeNames, ByteArrayDataOutput output) {
|
||||||
output.writeInt(collection.keySet().size());
|
output.writeInt(collection.keySet().size());
|
||||||
for (Map.Entry<String, Collection<String>> entry : collection.asMap().entrySet()) {
|
for (Map.Entry<String, Collection<String>> entry : collection.asMap().entrySet()) {
|
||||||
|
|||||||
@@ -58,16 +58,13 @@ public class RedisUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canUseLua(String redisVersion) {
|
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("\\.");
|
String[] args = redisVersion.split("\\.");
|
||||||
|
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int major = Integer.parseInt(args[0]);
|
int major = Integer.parseInt(args[0]);
|
||||||
int minor = Integer.parseInt(args[1]);
|
int minor = Integer.parseInt(args[1]);
|
||||||
|
return major >= 6 && minor >= 0;
|
||||||
return major >= 3 || (major == 2 && minor >= 6);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# RedisBungee configuration file.
|
# RedisBungee configuration file.
|
||||||
# PLEASE READ THE WIKI: https://github.com/minecrafter/RedisBungee/wiki
|
# PLEASE READ THE WIKI: https://github.com/Limework/RedisBungee/wiki
|
||||||
|
|
||||||
# The Redis server you use.
|
# The Redis server you use.
|
||||||
# Get Redis from http://redis.io/
|
# Get Redis from http://redis.io/
|
||||||
@@ -12,11 +12,17 @@ redis-password: ""
|
|||||||
# inefficient plugins or a lot of players.
|
# inefficient plugins or a lot of players.
|
||||||
max-redis-connections: 8
|
max-redis-connections: 8
|
||||||
|
|
||||||
# since redis can support ssl by version 6 you can use ssl in redis bungee too! (
|
# since redis can support ssl by version 6 you can use ssl in redis bungee too!
|
||||||
|
# you must disable this if redis version is under 6 you must disable this or connection wont work!!!
|
||||||
useSSL: false
|
useSSL: false
|
||||||
|
|
||||||
# An identifier for this BungeeCord instance.
|
# An identifier for this BungeeCord instance. Will randomly generate if leaving it blank.
|
||||||
server-id: test1
|
server-id: "test1"
|
||||||
|
# Should use random string? if this is enabled the proxy id will be like this if server-id is test1: "test1-66cd2aeb-91f3-43a7-a106-e0307b098652"
|
||||||
|
# or if id is limework-bungee it will be "limework-bungee-66cd2aeb-91f3-43a7-a106-e0307b098652"
|
||||||
|
# this great for servers who run replicas in Kubernetes or any auto deploying replica service
|
||||||
|
# and used for if proxy died in a kubernetes network and deleted then new proxy setup itself.
|
||||||
|
use-random-id-string: false
|
||||||
|
|
||||||
# Whether or not RedisBungee should install its version of regular BungeeCord commands.
|
# Whether or not RedisBungee should install its version of regular BungeeCord commands.
|
||||||
# Often, the RedisBungee commands are desired, but in some cases someone may wish to
|
# Often, the RedisBungee commands are desired, but in some cases someone may wish to
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
name: ${project.name}
|
name: ${project.name}
|
||||||
main: com.imaginarycode.minecraft.redisbungee.RedisBungee
|
main: com.imaginarycode.minecraft.redisbungee.RedisBungee
|
||||||
version: ${project.version}
|
version: ${project.version}
|
||||||
author: Chunker and Govindas limework
|
author: Chunkr and Govindas limework
|
||||||
authors:
|
authors:
|
||||||
- chunkr
|
- chunkr
|
||||||
- Govindas Limework
|
- Govindas Limework
|
||||||
|
|||||||
@@ -7,11 +7,14 @@ import org.junit.Test;
|
|||||||
public class RedisUtilTest {
|
public class RedisUtilTest {
|
||||||
@Test
|
@Test
|
||||||
public void testRedisLuaCheck() {
|
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("2.2.12"));
|
||||||
Assert.assertFalse(RedisUtil.canUseLua("1.2.4"));
|
Assert.assertFalse(RedisUtil.canUseLua("1.2.4"));
|
||||||
Assert.assertTrue(RedisUtil.canUseLua("2.8.4"));
|
Assert.assertFalse(RedisUtil.canUseLua("2.8.4"));
|
||||||
Assert.assertTrue(RedisUtil.canUseLua("3.0.0"));
|
Assert.assertFalse(RedisUtil.canUseLua("3.0.0"));
|
||||||
Assert.assertTrue(RedisUtil.canUseLua("3.2.1"));
|
Assert.assertFalse(RedisUtil.canUseLua("3.2.1"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user