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

15 Commits

Author SHA1 Message Date
265933f36e fix Velocity plugin startup / shutdown issues, java docs notes for some classes and logs for shutdown / startup (#73)
closes #71
2023-04-25 11:09:45 +04:00
mohammed Alteniji
9a583369e8 oops forgot to fix repo for gradle kotlin dsl 2023-04-16 23:02:36 +04:00
mohammed Alteniji
d9e5a21c14 Update README.md 2023-04-16 22:58:41 +04:00
mohammed Alteniji
4f43c98c87 reorder config.yml of redisbungee 2023-04-15 21:29:06 +04:00
26b58252eb oops remove password warn from the username 2023-04-13 03:06:16 +04:00
mohammed Alteniji
73879640e5 add ability to use redisbungee with acl username (#69) 2023-04-12 22:40:01 +04:00
mohammed Alteniji
c5040c9348 Update README.md 2023-04-12 20:26:06 +04:00
mohammed Alteniji
9ca72ff921 Update README.md 2023-04-10 01:56:35 +04:00
9050264b4d make velocity ping event execute as Last to prevent motd plugins changing online players 2023-04-10 01:48:20 +04:00
mohammed Alteniji
5b5f748cc9 fix wrong maven publishing error 2023-04-06 19:26:37 +04:00
mohammed Alteniji
47127c8520 Javadocs links update (#67) 2023-03-25 19:46:22 +04:00
mohammed Alteniji
b857bdb771 update to gradle (#66) 2023-03-23 15:42:59 +04:00
0f0f707ef7 bump version 2023-03-17 12:23:46 +04:00
441a12bb36 fix error being thrown getServerFor in Bungeecord/Velocity in the api closes #64
when plugins messing around with proxy internals (eg: limboapi) the field server in redis data of the player set to null which can become problematic for velocity due checking of null in velocity but i applied the same stuff to the bungeecord version aswell and document it in the javadocs
2023-03-17 12:15:10 +04:00
冰砚炽
0534970368 Fix PlayerList not returning server name when it is not ALL (#62) 2023-01-31 12:40:06 +04:00
33 changed files with 757 additions and 504 deletions

View File

@@ -21,22 +21,22 @@ jobs:
with: with:
java-version: '11' java-version: '11'
distribution: 'adopt' distribution: 'adopt'
- name: Build with Maven - name: Build with gradle
run: mvn -B package --file pom.xml run: ./gradlew shadowJar
- name: Upload Bungee - name: Upload Bungee
uses: actions/upload-artifact@v2.2.3 uses: actions/upload-artifact@v2.2.3
with: with:
# Artifact name # Artifact name
name: RedisBungee-Bungee name: RedisBungee-Bungee
# Destination path # Destination path
path: RedisBungee-Bungee/target/* path: RedisBungee-Bungee/build/libs/*
- name: Upload Velocity - name: Upload Velocity
uses: actions/upload-artifact@v2.2.3 uses: actions/upload-artifact@v2.2.3
with: with:
name: RedisBungee-Velocity name: RedisBungee-Velocity
path: RedisBungee-Velocity/target/* path: RedisBungee-Velocity/build/libs/*
- name: Upload API - name: Upload API
uses: actions/upload-artifact@v2.2.3 uses: actions/upload-artifact@v2.2.3
with: with:
name: RedisBungee-API name: RedisBungee-API
path: RedisBungee-API/target/* path: RedisBungee-API/build/libs/*

6
.gitignore vendored
View File

@@ -39,5 +39,11 @@ manifest.mf
*.versionBackup *.versionBackup
*.versionsBackup *.versionsBackup
# gradle
.gradle
# java docs # java docs
javadoc javadoc
# run-server folders
*/run

View File

@@ -1,39 +1,26 @@
# RedisBungee fork By Limework # RedisBungee fork By Limework
The original project of RedisBungee is no longer maintained, so we have forked the plugin.
*if you are here for transferring players to another proxy when the first proxy crashes or whatever this plugin won't do it, tell mojang to implement transfer packet*.
[Click here, for more information about transfer packet](https://hypixel.net/threads/why-do-we-need-transfer-packets.1390307/)
The original project of RedisBungee is no longer maintained, so we have forked the plugin.
RedisBungee uses [Redis](https://redis.io) with Java client [Jedis](https://github.com/redis/jedis/) RedisBungee uses [Redis](https://redis.io) with Java client [Jedis](https://github.com/redis/jedis/)
to Synchronize players data between [BungeeCord](https://github.com/SpigotMC/BungeeCord) or [Velocity*](https://github.com/PaperMC/Velocity) proxies to Synchronize players data between [BungeeCord](https://github.com/SpigotMC/BungeeCord) or [Velocity*](https://github.com/PaperMC/Velocity) proxies
Velocity*: *version 3.1.2 or above is only supported, any version below that might work but might be unstable* [#40](https://github.com/ProxioDev/RedisBungee/pull/40) Velocity*: *version 3.1.2 or above is only supported, any version below that might work but might be unstable* [#40](https://github.com/ProxioDev/RedisBungee/pull/40)
## compatibility with original RedisBungee in Bungeecord ecosystem ## Downloads
This fork ensures compatibility with old plugins, so it should work as drop replacement, [![](https://raw.githubusercontent.com/Prospector/badges/master/modrinth-badge-72h-padded.png)](https://modrinth.com/plugin/redisbungee)
but since Api has been split from the platform there some changes that have to be done, so your plugin might not work if:
* there is none at the moment, please report any findings at the issue page. or from github releases
Cluster mode compatibility in version 0.8.0: https://github.com/ProxioDev/RedisBungee/releases
If you are using static legacy method `RedisBungee#getPool()` it might fail in:
* if Cluster mode is enabled, due fact its Uses different classes
* if JedisPool compatibility mode is disabled in the config due fact project internally switched to JedisPooled than Jedis
*
## License
This project is distributed under Eclipse Public License 1.0
You can find it [here](https://github.com/proxiodev/RedisBungee/blob/master/LICENSE)
You can find the original RedisBungee is by [astei](https://github.com/astei) and project can be found [here](https://github.com/minecrafter/RedisBungee) or spigot page [here, but its no longer available](https://www.spigotmc.org/resources/redisbungee.13494/)
## notes ## notes
If you are looking to use Original RedisBungee without a change to internals, If you are looking to use Original RedisBungee without a change to internals,
with critical bugs fixed, please use version [0.6.5](https://github.com/ProxioDev/RedisBungee/releases/tag/0.6.5) and java docs For legacy Version [0.6.5](https://proxiodev.github.io/RedisBungee-JavaDocs/0.6.5-SNAPSHOT/) with critical bugs fixed, please use version [0.6.5](https://github.com/ProxioDev/RedisBungee/releases/tag/0.6.5) and java docs For legacy Version [0.6.5](https://proxiodev.github.io/RedisBungee-JavaDocs/0.6.5-SNAPSHOT/)
as its last version before internal changes. please note that you will not get support for any old builds unless critical bugs effecting both 0.6.5 and 0.7.0 or above. as its last version before internal changes. please note that you will not get support for any old builds unless critical bugs effecting both 0.6.5 and 0.7.0 or above.
*if you are here for transferring players to another proxy when the first proxy crashes or whatever this plugin won't do it, tell mojang to implement transfer packet*
[Click here, for more information about transfer packet](https://hypixel.net/threads/why-do-we-need-transfer-packets.1390307/)
SpigotMC resource page: [click](https://www.spigotmc.org/resources/redisbungee.87700/) SpigotMC resource page: [click](https://www.spigotmc.org/resources/redisbungee.87700/)
## Supported Redis versions ## Supported Redis versions
| Redis version | Supported | | Redis version | Supported |
@@ -49,11 +36,12 @@ SpigotMC resource page: [click](https://www.spigotmc.org/resources/redisbungee.8
## Implementing RedisBungee in your plugin: [![RedisBungee Build](https://github.com/proxiodev/RedisBungee/actions/workflows/maven.yml/badge.svg)](https://github.com/Limework/RedisBungee/actions/workflows/maven.yml) [![](https://jitpack.io/v/ProxioDev/redisbungee.svg)](https://jitpack.io/#ProxioDev/redisbungee) ## Implementing RedisBungee in your plugin: [![RedisBungee Build](https://github.com/proxiodev/RedisBungee/actions/workflows/maven.yml/badge.svg)](https://github.com/Limework/RedisBungee/actions/workflows/maven.yml) [![](https://jitpack.io/v/ProxioDev/redisbungee.svg)](https://jitpack.io/#ProxioDev/redisbungee)
RedisBungee is distributed as a [maven](https://maven.apache.org) project. RedisBungee is distributed as a [Gradle](https://gradle.org/) project.
By using jitpack [![](https://jitpack.io/v/ProxioDev/redisbungee.svg)](https://jitpack.io/#ProxioDev/redisbungee) By using jitpack [![](https://jitpack.io/v/ProxioDev/redisbungee.svg)](https://jitpack.io/#ProxioDev/redisbungee)
## Setup jitpack repository # Setup jitpack repository
## maven
```xml ```xml
<repositories> <repositories>
<repository> <repository>
@@ -62,16 +50,34 @@ By using jitpack [![](https://jitpack.io/v/ProxioDev/redisbungee.svg)](https://j
</repository> </repository>
</repositories> </repositories>
``` ```
## [BungeeCord](https://github.com/SpigotMC/BungeeCord) ## gradle (kotlin dsl)
```kotlin
repositories {
maven("https://jitpack.io/")
}
```
# [BungeeCord](https://github.com/SpigotMC/BungeeCord)
add this in your project dependencies add this in your project dependencies
## maven
```xml ```xml
<dependency> <dependency>
<groupId>com.github.proxiodev.redisbungee</groupId> <groupId>com.github.proxiodev.redisbungee</groupId>
<artifactId>RedisBungee-Bungee</artifactId> <artifactId>RedisBungee-Bungee</artifactId>
<version>VERSION</version> <version>VERSION</version>
<scope>provided</scope> <scope>provided</scope>
<!-- <classifier>all</classifier> USE THIS IF YOU WANT TO USE INCLUDED JEDIS LIB BECAUSE OF RELOCATION -->
</dependency> </dependency>
```
## gradle (kotlin dsl)
```
implementation("com.github.ProxioDev.redisbungee:RedisBungee-Bungee:0.11.0")
// USE THIS IF YOU WANT TO USE INCLUDED JEDIS LIB BECAUSE OF RELOACTION AND REMOVE THE ABOVE STATEMENT
implementation("com.github.ProxioDev.redisbungee:RedisBungee-Bungee:0.11.0:all") {
exclude("redis.clients", "jedis")
}
``` ```
then in your project plugin.yml add `RedisBungee` to `depends` like this then in your project plugin.yml add `RedisBungee` to `depends` like this
```yaml ```yaml
@@ -84,14 +90,26 @@ depends: [ RedisBungee ]
## [Velocity](https://github.com/PaperMC/Velocity) ## [Velocity](https://github.com/PaperMC/Velocity)
## maven
```xml ```xml
<dependency> <dependency>
<groupId>com.github.proxiodev.redisbungee</groupId> <groupId>com.github.proxiodev.redisbungee</groupId>
<artifactId>RedisBungee-Velocity</artifactId> <artifactId>RedisBungee-Velocity</artifactId>
<version>VERSION</version> <version>VERSION</version>
<scope>provided</scope> <scope>provided</scope>
<!-- <classifier>all</classifier> USE THIS IF YOU WANT TO USE INCLUDED JEDIS LIB BECAUSE OF RELOCATION -->
</dependency> </dependency>
``` ```
## gradle (kotlin dsl)
```
implementation("com.github.ProxioDev.redisbungee:RedisBungee-Velocity:0.11.0")
// USE THIS IF YOU WANT TO USE INCLUDED JEDIS LIB BECAUSE OF RELOACTION AND REMOVE THE ABOVE STATEMENT
implementation("com.github.ProxioDev.redisbungee:RedisBungee-Velocity:0.11.0:all") {
exclude("redis.clients", "jedis")
}
```
then to make your plugin depends on RedisBungee, make sure your plugin class Annotation have `@Dependency(id = "redisbungee")` like this then to make your plugin depends on RedisBungee, make sure your plugin class Annotation have `@Dependency(id = "redisbungee")` like this
```java ```java
@Plugin( @Plugin(
@@ -112,7 +130,7 @@ first, install it to your maven local repo
```bash ```bash
git clone https://github.com/ProxioDev/RedisBungee.git git clone https://github.com/ProxioDev/RedisBungee.git
cd RedisBungee cd RedisBungee
mvn clean install ./gradlew publishToMavenLocal
``` ```
then use any of these in your project. then use any of these in your project.
```xml ```xml
@@ -121,6 +139,7 @@ then use any of these in your project.
<artifactId>RedisBungee-Bungee</artifactId> <artifactId>RedisBungee-Bungee</artifactId>
<version>VERSION</version> <version>VERSION</version>
<scope>provided</scope> <scope>provided</scope>
<!-- <classifier>all</classifier> USE THIS IF YOU WANT TO USE INCLUDED JEDIS LIB BECAUSE OF RELOCATION -->
</dependency> </dependency>
``` ```
```xml ```xml
@@ -129,22 +148,47 @@ then use any of these in your project.
<artifactId>RedisBungee-Velocity</artifactId> <artifactId>RedisBungee-Velocity</artifactId>
<version>VERSION</version> <version>VERSION</version>
<scope>provided</scope> <scope>provided</scope>
<!-- <classifier>all</classifier> USE THIS IF YOU WANT TO USE INCLUDED JEDIS LIB BECAUSE OF RELOCATION -->
</dependency> </dependency>
``` ```
## Javadocs ## Javadocs
For current version [0.8.0](https://proxiodev.github.io/RedisBungee-JavaDocs/0.8.0-SNAPSHOT/) * API: https://ci.limework.net/RedisBungee/RedisBungee-API/build/docs/javadoc/
* Velocity: https://ci.limework.net/RedisBungee/RedisBungee-Velocity/build/docs/javadoc/
* Bungeecord: https://ci.limework.net/RedisBungee/RedisBungee-Bungee/build/docs/javadoc/
## Configuration ## Configuration
**REDISBUNGEE REQUIRES A REDIS SERVER**, preferably with reasonably low latency. The default [config](https://github.com/ProxioDev/RedisBungee/blob/develop/RedisBungee-API/src/main/resources/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/ProxioDev/RedisBungee/blob/develop/RedisBungee-API/src/main/resources/config.yml) is saved when the plugin first starts.
## compatibility with original RedisBungee in Bungeecord ecosystem
This fork ensures compatibility with old plugins, so it should work as drop replacement,
but since Api has been split from the platform there some changes that have to be done, so your plugin might not work if:
* there is none at the moment, please report any findings at the issue page.
Cluster mode compatibility in version 0.8.0:
If you are using static legacy method `RedisBungee#getPool()` it might fail in:
* if Cluster mode is enabled, due fact its Uses different classes
* if JedisPool compatibility mode is disabled in the config due fact project internally switched to JedisPooled than Jedis
## Support ## Support
You can join our matrix room [here](https://matrix.to/#/!zhedzmRNSZXfuOPZUB:govindas.net?via=govindas.net&via=matrix.org) You can join our matrix room [here](https://matrix.to/#/!zhedzmRNSZXfuOPZUB:govindas.net?via=govindas.net&via=matrix.org)
![icon](https://matrix.org/images/matrix-logo-white.svg) ![icon](https://matrix.org/images/matrix-logo-white.svg)
## License
This project is distributed under Eclipse Public License 1.0
You can find it [here](https://github.com/proxiodev/RedisBungee/blob/master/LICENSE)
You can find the original RedisBungee is by [astei](https://github.com/astei) and project can be found [here](https://github.com/minecrafter/RedisBungee) or spigot page [here, but its no longer available](https://www.spigotmc.org/resources/redisbungee.13494/)
## YourKit ## YourKit

View File

@@ -0,0 +1,88 @@
import java.io.ByteArrayOutputStream
plugins {
`java-library`
`maven-publish`
id("net.kyori.blossom") version "1.2.0"
}
repositories {
mavenCentral()
}
val jedisVersion = "4.3.2"
val configurateVersion = "3.7.3"
val guavaVersion = "31.1-jre"
dependencies {
api("com.google.guava:guava:$guavaVersion")
api("redis.clients:jedis:$jedisVersion")
api("com.squareup.okhttp:okhttp:2.7.5")
api("org.spongepowered:configurate-yaml:$configurateVersion")
// tests
testImplementation("junit:junit:4.13.2")
}
description = "RedisBungee interafaces"
blossom {
replaceToken("@version@", "$version")
// GIT
var commit: String = ""
val commitStdout = ByteArrayOutputStream()
rootProject.exec {
standardOutput = commitStdout
commandLine("git", "rev-parse", "HEAD")
}
commit = "$commitStdout".replace("\n", "") // for some reason it adds new line so remove it.
commitStdout.close()
replaceToken("@git_commit@", commit)
}
java {
withJavadocJar()
withSourcesJar()
}
tasks {
// thanks again for paper too
withType<Javadoc> {
val options = options as StandardJavadocDocletOptions
options.use()
options.isDocFilesSubDirs = true
options.links(
"https://configurate.aoeu.xyz/$configurateVersion/apidocs/", // configurate
"https://javadoc.io/doc/redis.clients/jedis/$jedisVersion/", // jedis
"https://guava.dev/releases/$guavaVersion/api/docs/" // guava
)
}
test {
useJUnitPlatform()
}
compileJava {
options.encoding = Charsets.UTF_8.name()
options.release.set(8)
}
javadoc {
options.encoding = Charsets.UTF_8.name()
}
processResources {
filteringCharset = Charsets.UTF_8.name()
}
}
publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])
}
}
}

View File

@@ -1,94 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>RedisBungee</artifactId>
<groupId>com.imaginarycode.minecraft</groupId>
<version>0.10.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>RedisBungee-API</artifactId>
<build>
<plugins>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<configuration>
</configuration>
<executions>
<execution>
<id>bundle-sources</id>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
<goal>test-jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.2</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<source>8</source>
<destDir>../javadoc/${project.name}</destDir>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.1-jre</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>4.3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>2.11.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>2.7.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.spongepowered</groupId>
<artifactId>configurate-yaml</artifactId>
<version>3.7.2</version>
</dependency>
</dependencies>
</project>

View File

@@ -20,6 +20,7 @@ import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisClusterSummone
import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisPooledSummoner; import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisPooledSummoner;
import com.imaginarycode.minecraft.redisbungee.api.summoners.Summoner; import com.imaginarycode.minecraft.redisbungee.api.summoners.Summoner;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import redis.clients.jedis.Jedis; import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisCluster; import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPool; import redis.clients.jedis.JedisPool;
@@ -81,8 +82,9 @@ public abstract class AbstractRedisBungeeAPI {
* as well, and will return local information on them. * as well, and will return local information on them.
* *
* @param player a player uuid * @param player a player uuid
* @return a String name for the server the player is on. * @return a String name for the server the player is on. Can be Null if plugins is doing weird stuff to the proxy internals
*/ */
@Nullable
public final String getServerNameFor(@NonNull UUID player) { public final String getServerNameFor(@NonNull UUID player) {
return plugin.getDataManager().getServer(player); return plugin.getDataManager().getServer(player);
} }

View File

@@ -8,8 +8,16 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
*/ */
package com.imaginarycode.minecraft.redisbungee; package com.imaginarycode.minecraft.redisbungee;
public class PomData { public class Constants {
public final static String VERSION = "${project.parent.version}";
public final static String VERSION = "@version@";
public final static String GIT_COMMIT = "@git_commit@";
public static String getGithubCommitLink() {
return "https://github.com/ProxioDev/RedisBungee/commit/" + GIT_COMMIT;
}
} }

View File

@@ -35,6 +35,8 @@ import static com.google.common.base.Preconditions.checkArgument;
/** /**
* This Class has all internal methods needed by every redis bungee plugin, and it can be used to implement another platforms than bungeecord or another forks of RedisBungee * This Class has all internal methods needed by every redis bungee plugin, and it can be used to implement another platforms than bungeecord or another forks of RedisBungee
* <p>
* Reason this is interface because some proxies implementations require the user to extend class for plugins for example bungeecord.
* *
* @author Ham1255 * @author Ham1255
* @since 0.7.0 * @since 0.7.0

View File

@@ -12,7 +12,6 @@ package com.imaginarycode.minecraft.redisbungee.api.config;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.reflect.TypeToken; import com.google.common.reflect.TypeToken;
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeeMode; import com.imaginarycode.minecraft.redisbungee.api.RedisBungeeMode;
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin; import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
@@ -54,6 +53,7 @@ public interface ConfigLoader {
final boolean registerLegacyCommands = node.getNode("register-legacy-commands").getBoolean(false); final boolean registerLegacyCommands = node.getNode("register-legacy-commands").getBoolean(false);
final boolean restoreOldKickBehavior = node.getNode("disable-kick-when-online").getBoolean(false); final boolean restoreOldKickBehavior = node.getNode("disable-kick-when-online").getBoolean(false);
String redisPassword = node.getNode("redis-password").getString(""); String redisPassword = node.getNode("redis-password").getString("");
String redisUsername = node.getNode("redis-username").getString("");
String proxyId = node.getNode("proxy-id").getString("test-1"); String proxyId = node.getNode("proxy-id").getString("test-1");
final int maxConnections = node.getNode("max-redis-connections").getInt(10); final int maxConnections = node.getNode("max-redis-connections").getInt(10);
List<String> exemptAddresses; List<String> exemptAddresses;
@@ -68,6 +68,10 @@ public interface ConfigLoader {
redisPassword = null; redisPassword = null;
plugin.logWarn("password is empty"); plugin.logWarn("password is empty");
} }
if ((redisUsername.isEmpty() || redisUsername.equals("none"))) {
redisUsername = null;
}
if (useSSL) { if (useSSL) {
plugin.logInfo("Using ssl"); plugin.logInfo("Using ssl");
} }
@@ -101,7 +105,7 @@ public interface ConfigLoader {
if (hostAndPortSet.isEmpty()) { if (hostAndPortSet.isEmpty()) {
throw new RuntimeException("No redis cluster servers specified"); throw new RuntimeException("No redis cluster servers specified");
} }
summoner = new JedisClusterSummoner(new ClusterConnectionProvider(hostAndPortSet, DefaultJedisClientConfig.builder().password(redisPassword).ssl(useSSL).socketTimeoutMillis(5000).timeoutMillis(10000).build(), poolConfig)); summoner = new JedisClusterSummoner(new ClusterConnectionProvider(hostAndPortSet, DefaultJedisClientConfig.builder().user(redisUsername).password(redisPassword).ssl(useSSL).socketTimeoutMillis(5000).timeoutMillis(10000).build(), poolConfig));
redisBungeeMode = RedisBungeeMode.CLUSTER; redisBungeeMode = RedisBungeeMode.CLUSTER;
} else { } else {
plugin.logInfo("RedisBungee MODE: SINGLE"); plugin.logInfo("RedisBungee MODE: SINGLE");
@@ -115,13 +119,13 @@ public interface ConfigLoader {
JedisPoolConfig config = new JedisPoolConfig(); JedisPoolConfig config = new JedisPoolConfig();
config.setMaxTotal(node.getNode("compatibility-max-connections").getInt(3)); config.setMaxTotal(node.getNode("compatibility-max-connections").getInt(3));
config.setBlockWhenExhausted(true); config.setBlockWhenExhausted(true);
jedisPool = new JedisPool(config, redisServer, redisPort, 5000, redisPassword, useSSL); jedisPool = new JedisPool(config, redisServer, redisPort, 5000, redisUsername, redisPassword, useSSL);
plugin.logInfo("Compatibility JedisPool was created"); plugin.logInfo("Compatibility JedisPool was created");
} }
GenericObjectPoolConfig<Connection> poolConfig = new GenericObjectPoolConfig<>(); GenericObjectPoolConfig<Connection> poolConfig = new GenericObjectPoolConfig<>();
poolConfig.setMaxTotal(maxConnections); poolConfig.setMaxTotal(maxConnections);
poolConfig.setBlockWhenExhausted(true); poolConfig.setBlockWhenExhausted(true);
summoner = new JedisPooledSummoner(new PooledConnectionProvider(new ConnectionFactory(new HostAndPort(redisServer, redisPort), DefaultJedisClientConfig.builder().timeoutMillis(5000).ssl(useSSL).password(redisPassword).build()), poolConfig), jedisPool); summoner = new JedisPooledSummoner(new PooledConnectionProvider(new ConnectionFactory(new HostAndPort(redisServer, redisPort), DefaultJedisClientConfig.builder().user(redisUsername).timeoutMillis(5000).ssl(useSSL).password(redisPassword).build()), poolConfig), jedisPool);
redisBungeeMode = RedisBungeeMode.SINGLE; redisBungeeMode = RedisBungeeMode.SINGLE;
} }
plugin.logInfo("Successfully connected to Redis."); plugin.logInfo("Successfully connected to Redis.");

View File

@@ -12,8 +12,6 @@ package com.imaginarycode.minecraft.redisbungee.api.tasks;
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin; import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
import com.imaginarycode.minecraft.redisbungee.api.util.RedisUtil; import com.imaginarycode.minecraft.redisbungee.api.util.RedisUtil;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.Protocol; import redis.clients.jedis.Protocol;
import redis.clients.jedis.UnifiedJedis; import redis.clients.jedis.UnifiedJedis;
@@ -28,12 +26,11 @@ public class InitialUtils {
@Override @Override
public Void unifiedJedisTask(UnifiedJedis unifiedJedis) { public Void unifiedJedisTask(UnifiedJedis unifiedJedis) {
// This is more portable than INFO <section> // This is more portable than INFO <section>
String info = new String((byte[]) unifiedJedis.sendCommand(Protocol.Command.INFO)); String info = new String((byte[]) unifiedJedis.sendCommand(Protocol.Command.INFO));
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];
plugin.logInfo(version + " <- redis version"); plugin.logInfo("Redis server version: " + version);
if (!RedisUtil.isRedisVersionRight(version)) { if (!RedisUtil.isRedisVersionRight(version)) {
plugin.logFatal("Your version of Redis (" + version + ") is not at least version 3.0 RedisBungee requires a newer version of Redis."); plugin.logFatal("Your version of Redis (" + version + ") is not at least version 3.0 RedisBungee requires a newer version of Redis.");
throw new RuntimeException("Unsupported Redis version detected"); throw new RuntimeException("Unsupported Redis version detected");
@@ -62,7 +59,7 @@ public class InitialUtils {
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
plugin.logInfo("crash file was deleted"); plugin.logInfo("crash file was deleted continuing RedisBungee startup ");
} else if (unifiedJedis.hexists("heartbeats", plugin.getConfiguration().getProxyId())) { } else if (unifiedJedis.hexists("heartbeats", plugin.getConfiguration().getProxyId())) {
try { try {
long value = Long.parseLong(unifiedJedis.hget("heartbeats", plugin.getConfiguration().getProxyId())); long value = Long.parseLong(unifiedJedis.hget("heartbeats", plugin.getConfiguration().getProxyId()));
@@ -81,7 +78,7 @@ public class InitialUtils {
} }
private static void logImposter(RedisBungeePlugin<?> plugin) { private static void logImposter(RedisBungeePlugin<?> plugin) {
plugin.logFatal("You have launched a possible impostor Velocity / Bungeecord instance. Another instance is already running."); plugin.logFatal("You have launched a possible impostor Velocity / Bungeecord instance. Another instance is already running.");
plugin.logFatal("For data consistency reasons, RedisBungee will now disable itself."); plugin.logFatal("For data consistency reasons, RedisBungee will now disable itself.");
plugin.logFatal("If this instance is coming up from a crash, create a file in your RedisBungee plugins directory with the name 'restarted_from_crash.txt' and RedisBungee will not perform this check."); plugin.logFatal("If this instance is coming up from a crash, create a file in your RedisBungee plugins directory with the name 'restarted_from_crash.txt' and RedisBungee will not perform this check.");
} }

View File

@@ -20,6 +20,10 @@ import redis.clients.jedis.UnifiedJedis;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
/**
* Since Jedis now have UnifiedJedis which basically extended by cluster / single connections classes
* can help us to have shared code.
*/
public abstract class RedisTask<V> implements Runnable, Callable<V> { public abstract class RedisTask<V> implements Runnable, Callable<V> {
protected final Summoner<?> summoner; protected final Summoner<?> summoner;

View File

@@ -1,4 +1,10 @@
# RedisBungee configuration file. # RedisBungee configuration file.
# Get Redis from http://redis.io/
# The Redis server you use.
# these settings are ignored when cluster mode is enabled.
redis-server: 127.0.0.1
redis-port: 6379
# Cluster Mode # Cluster Mode
# enabling this option will enable cluster mode. # enabling this option will enable cluster mode.
@@ -19,14 +25,13 @@ redis-cluster-servers:
- host: 127.0.0.1 - host: 127.0.0.1
port: 6379 port: 6379
# Get Redis from http://redis.io/ # THIS FEATURE IS REDIS V6+
# The Redis server you use. # OPTIONAL: if your redis uses acl usernames set the username here. leave empty for no username.
# these settings are ignored when cluster mode is enabled. redis-username: ""
redis-server: 127.0.0.1
redis-port: 6379
# OPTIONAL but recommended: If your Redis server uses AUTH, set the password required. # OPTIONAL but recommended: If your Redis server uses AUTH, set the password required.
redis-password: "" redis-password: ""
# Maximum connections that will be maintained to the Redis server. # Maximum connections that will be maintained to the Redis server.
# The default is 10. This setting should be left as-is unless you have some wildly # The default is 10. This setting should be left as-is unless you have some wildly
# inefficient plugins or a lot of players. # inefficient plugins or a lot of players.

View File

@@ -0,0 +1,82 @@
plugins {
`java-library`
`maven-publish`
id("com.github.johnrengelman.shadow") version "8.1.1"
id("xyz.jpenilla.run-waterfall") version "2.0.0"
}
repositories {
mavenCentral()
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") } // bungeecord
}
val bungeecordApiVersion = "1.19-R0.1-SNAPSHOT"
dependencies {
api(project(":RedisBungee-API")) {
exclude("com.google.guava", "guava")
exclude("com.google.code.gson", "gson")
}
compileOnly("net.md-5:bungeecord-api:$bungeecordApiVersion")
}
description = "RedisBungee Bungeecord implementation"
java {
withJavadocJar()
withSourcesJar()
}
tasks {
withType<Javadoc> {
dependsOn(project(":RedisBungee-API").getTasksByName("javadoc", false))
val options = options as StandardJavadocDocletOptions
options.use()
options.isDocFilesSubDirs = true
options.links(
"https://ci.md-5.net/job/BungeeCord/ws/api/target/apidocs/", // bungeecord api
)
val apiDocs = File(rootProject.projectDir, "RedisBungee-API/build/docs/javadoc")
options.linksOffline("https://ci.limework.net/RedisBungee/RedisBungee-API/build/docs/javadoc", apiDocs.path)
}
runWaterfall {
waterfallVersion("1.19")
}
compileJava {
options.encoding = Charsets.UTF_8.name()
options.release.set(8)
}
javadoc {
options.encoding = Charsets.UTF_8.name()
}
processResources {
filteringCharset = Charsets.UTF_8.name()
filesMatching("plugin.yml") {
filter {
it.replace("*{redisbungee.version}*", "$version", false)
}
}
}
shadowJar {
relocate("redis.clients.jedis", "com.imaginarycode.minecraft.redisbungee.internal.jedis")
relocate("redis.clients.util", "com.imaginarycode.minecraft.redisbungee.internal.jedisutil")
relocate("org.apache.commons.pool", "com.imaginarycode.minecraft.redisbungee.internal.commonspool")
relocate("com.squareup.okhttp", "com.imaginarycode.minecraft.redisbungee.internal.okhttp")
relocate("okio", "com.imaginarycode.minecraft.redisbungee.internal.okio")
relocate("org.json", "com.imaginarycode.minecraft.redisbungee.internal.json")
// configurate shade
relocate("ninja.leaping.configurate", "com.imaginarycode.minecraft.redisbungee.internal.configurate")
relocate("org.yaml", "com.imaginarycode.minecraft.redisbungee.internal.yml")
}
}
publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])
}
}
}

View File

@@ -1,147 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>RedisBungee</artifactId>
<groupId>com.imaginarycode.minecraft</groupId>
<version>0.10.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>RedisBungee-Bungee</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>bungeecord-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.2</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<source>8</source>
<includeDependencySources>true</includeDependencySources>
<dependencySourceExcludes>
<dependencySourceExclude>net.md-5:*</dependencySourceExclude>
</dependencySourceExcludes>
<destDir>../javadoc/${project.name}</destDir>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>redis.clients.jedis</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.jedis
</shadedPattern>
</relocation>
<relocation>
<pattern>redis.clients.util</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.jedisutil
</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache.commons.pool</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.commonspool
</shadedPattern>
</relocation>
<relocation>
<pattern>com.squareup.okhttp</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.okhttp
</shadedPattern>
</relocation>
<relocation>
<pattern>okio</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.okio</shadedPattern>
</relocation>
<relocation>
<pattern>com.google</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.google
</shadedPattern>
</relocation>
<relocation>
<pattern>org.json</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.json</shadedPattern>
</relocation>
<relocation>
<pattern>org.checkerframework</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.checkframework
</shadedPattern>
</relocation>
<relocation>
<pattern>ninja.leaping.configurate</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.configurate
</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.imaginarycode.minecraft</groupId>
<artifactId>RedisBungee-API</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>com.imaginarycode.minecraft</groupId>
<artifactId>RedisBungee-API</artifactId>
<version>${project.parent.version}</version>
<classifier>javadoc</classifier>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@@ -198,6 +198,7 @@ public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlay
@Override @Override
public void initialize() { public void initialize() {
logInfo("Initializing RedisBungee.....");
ThreadFactory factory = ((ThreadPoolExecutor) getExecutorService()).getThreadFactory(); ThreadFactory factory = ((ThreadPoolExecutor) getExecutorService()).getThreadFactory();
ScheduledExecutorService service = Executors.newScheduledThreadPool(24, factory); ScheduledExecutorService service = Executors.newScheduledThreadPool(24, factory);
try { try {
@@ -266,10 +267,12 @@ public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlay
getProxy().getPluginManager().registerCommand(this, new RedisBungeeCommands.PlayerProxyCommand(this)); getProxy().getPluginManager().registerCommand(this, new RedisBungeeCommands.PlayerProxyCommand(this));
getProxy().getPluginManager().registerCommand(this, new RedisBungeeCommands.PlistCommand(this)); getProxy().getPluginManager().registerCommand(this, new RedisBungeeCommands.PlistCommand(this));
} }
logInfo("RedisBungee initialized successfully ");
} }
@Override @Override
public void stop() { public void stop() {
logInfo("Turning off redis connections.....");
// Poison the PubSub listener // Poison the PubSub listener
if (psl != null) { if (psl != null) {
psl.poison(); psl.poison();
@@ -287,7 +290,7 @@ public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlay
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
logInfo("RedisBungee shutdown");
} }
@Override @Override

View File

@@ -14,6 +14,7 @@ import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.api.plugin.Plugin;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.UUID; import java.util.UUID;
@@ -43,8 +44,11 @@ public class RedisBungeeAPI extends AbstractRedisBungeeAPI {
* @return {@link ServerInfo} Can be null if proxy can't find it. * @return {@link ServerInfo} Can be null if proxy can't find it.
* @see #getServerNameFor(UUID) * @see #getServerNameFor(UUID)
*/ */
@Nullable
public final ServerInfo getServerFor(@NonNull UUID player) { public final ServerInfo getServerFor(@NonNull UUID player) {
return ((Plugin) this.plugin).getProxy().getServerInfo(this.getServerNameFor(player)); String serverName = this.getServerNameFor(player);
if (serverName == null) return null;
return ((Plugin) this.plugin).getProxy().getServerInfo(serverName);
} }
/** /**

View File

@@ -156,6 +156,7 @@ public class RedisBungeeBungeeListener extends AbstractRedisBungeeListener<Login
out.writeUTF("ALL"); out.writeUTF("ALL");
original = plugin.getPlayers(); original = plugin.getPlayers();
} else { } else {
out.writeUTF(type);
try { try {
original = plugin.getAbstractRedisBungeeApi().getPlayersOnServer(type); original = plugin.getAbstractRedisBungeeApi().getPlayersOnServer(type);
} catch (IllegalArgumentException ignored) { } catch (IllegalArgumentException ignored) {

View File

@@ -1,6 +1,6 @@
name: RedisBungee name: RedisBungee
main: com.imaginarycode.minecraft.redisbungee.RedisBungee main: com.imaginarycode.minecraft.redisbungee.RedisBungee
version: ${project.parent.version} version: *{redisbungee.version}*
author: "astei, ProxioDev" author: "astei, ProxioDev"
# This is used so that we can automatically override default BungeeCord behavior. # This is used so that we can automatically override default BungeeCord behavior.
softDepends: ["cmd_find", "cmd_list"] softDepends: ["cmd_find", "cmd_list"]

View File

@@ -0,0 +1,74 @@
plugins {
`java-library`
`maven-publish`
id("com.github.johnrengelman.shadow") version "8.1.1"
id("xyz.jpenilla.run-velocity") version "2.0.0"
}
repositories {
mavenCentral()
maven { url = uri("https://repo.papermc.io/repository/maven-public/") }
}
dependencies {
api(project(":RedisBungee-API")) {
// Since velocity already includes guava / configurate exlude them
exclude("com.google.guava", "guava")
exclude("com.google.code.gson", "gson")
exclude("org.spongepowered", "configurate-yaml")
}
compileOnly("com.velocitypowered:velocity-api:3.2.0-SNAPSHOT")
annotationProcessor("com.velocitypowered:velocity-api:3.2.0-SNAPSHOT")
}
description = "RedisBungee Velocity implementation"
java {
withJavadocJar()
withSourcesJar()
}
tasks {
withType<Javadoc> {
dependsOn(project(":RedisBungee-API").getTasksByName("javadoc", false))
val options = options as StandardJavadocDocletOptions
options.use()
options.isDocFilesSubDirs = true
options.links(
"https://jd.papermc.io/velocity/3.0.0/", // velocity api
)
val apiDocs = File(rootProject.projectDir, "RedisBungee-API/build/docs/javadoc")
options.linksOffline("https://ci.limework.net/RedisBungee/RedisBungee-API/build/docs/javadoc", apiDocs.path)
}
runVelocity {
velocityVersion("3.2.0-SNAPSHOT")
}
compileJava {
options.encoding = Charsets.UTF_8.name()
options.release.set(11)
}
javadoc {
options.encoding = Charsets.UTF_8.name()
}
processResources {
filteringCharset = Charsets.UTF_8.name()
}
shadowJar {
relocate("redis.clients.jedis", "com.imaginarycode.minecraft.redisbungee.internal.jedis")
relocate("redis.clients.util", "com.imaginarycode.minecraft.redisbungee.internal.jedisutil")
relocate("org.apache.commons.pool", "com.imaginarycode.minecraft.redisbungee.internal.commonspool")
relocate("com.squareup.okhttp", "com.imaginarycode.minecraft.redisbungee.internal.okhttp")
relocate("okio", "com.imaginarycode.minecraft.redisbungee.internal.okio")
relocate("org.json", "com.imaginarycode.minecraft.redisbungee.internal.json")
}
}
publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])
}
}
}

View File

@@ -1,170 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>RedisBungee</artifactId>
<groupId>com.imaginarycode.minecraft</groupId>
<version>0.10.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>RedisBungee-Velocity</artifactId>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>papermc-repo</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
</repositories>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>templating-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<id>add-plugin-info</id>
<goals>
<goal>filter-sources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.2</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<includeDependencySources>true</includeDependencySources>
<dependencySourceExcludes>
<dependencySourceExclude>com.velocitypowered:*</dependencySourceExclude>
</dependencySourceExcludes>
<source>11</source>
<destDir>../javadoc/${project.name}</destDir>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>redis.clients.jedis</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.jedis
</shadedPattern>
</relocation>
<relocation>
<pattern>redis.clients.util</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.jedisutil
</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache.commons.pool</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.commonspool
</shadedPattern>
</relocation>
<relocation>
<pattern>com.squareup.okhttp</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.okhttp
</shadedPattern>
</relocation>
<relocation>
<pattern>okio</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.okio</shadedPattern>
</relocation>
<relocation>
<pattern>org.json</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.json</shadedPattern>
</relocation>
<relocation>
<pattern>org.checkerframework</pattern>
<shadedPattern>com.imaginarycode.minecraft.redisbungee.internal.checkframework
</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.imaginarycode.minecraft</groupId>
<artifactId>RedisBungee-API</artifactId>
<version>${project.parent.version}</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
<exclusion>
<groupId>org.spongepowered</groupId>
<artifactId>configurate-yaml</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.imaginarycode.minecraft</groupId>
<artifactId>RedisBungee-API</artifactId>
<version>${project.parent.version}</version>
<classifier>javadoc</classifier>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
<exclusion>
<groupId>org.spongepowered</groupId>
<artifactId>configurate-yaml</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.velocitypowered</groupId>
<artifactId>velocity-api</artifactId>
<version>3.1.2-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@@ -14,6 +14,7 @@ import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
import com.velocitypowered.api.proxy.server.RegisteredServer; import com.velocitypowered.api.proxy.server.RegisteredServer;
import com.velocitypowered.api.proxy.server.ServerInfo; import com.velocitypowered.api.proxy.server.ServerInfo;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.UUID; import java.util.UUID;
@@ -44,8 +45,11 @@ public class RedisBungeeAPI extends AbstractRedisBungeeAPI {
* @return {@link ServerInfo} Can be null if proxy can't find it. * @return {@link ServerInfo} Can be null if proxy can't find it.
* @see #getServerNameFor(UUID) * @see #getServerNameFor(UUID)
*/ */
@Nullable
public final ServerInfo getServerFor(@NonNull UUID player) { public final ServerInfo getServerFor(@NonNull UUID player) {
return ((RedisBungeeVelocityPlugin) this.plugin).getProxy().getServer(this.getServerNameFor(player)).map((RegisteredServer::getServerInfo)).orElse(null); String serverName = this.getServerNameFor(player);
if (serverName == null) return null;
return ((RedisBungeeVelocityPlugin) this.plugin).getProxy().getServer(serverName).map((RegisteredServer::getServerInfo)).orElse(null);
} }
/** /**

View File

@@ -130,7 +130,7 @@ public class RedisBungeeVelocityListener extends AbstractRedisBungeeListener<Log
} }
@Override @Override
@Subscribe(order = PostOrder.EARLY) @Subscribe(order = PostOrder.LAST) // some plugins changes it online players so we need to be executed as last
public void onPing(ProxyPingEvent event) { public void onPing(ProxyPingEvent event) {
if (exemptAddresses.contains(event.getConnection().getRemoteAddress().getAddress())) { if (exemptAddresses.contains(event.getConnection().getRemoteAddress().getAddress())) {
return; return;
@@ -165,6 +165,7 @@ public class RedisBungeeVelocityListener extends AbstractRedisBungeeListener<Log
out.writeUTF("ALL"); out.writeUTF("ALL");
original = plugin.getPlayers(); original = plugin.getPlayers();
} else { } else {
out.writeUTF(type);
try { try {
original = plugin.getAbstractRedisBungeeApi().getPlayersOnServer(type); original = plugin.getAbstractRedisBungeeApi().getPlayersOnServer(type);
} catch (IllegalArgumentException ignored) { } catch (IllegalArgumentException ignored) {

View File

@@ -34,6 +34,7 @@ import com.imaginarycode.minecraft.redisbungee.events.PlayerLeftNetworkEvent;
import com.imaginarycode.minecraft.redisbungee.events.PubSubMessageEvent; import com.imaginarycode.minecraft.redisbungee.events.PubSubMessageEvent;
import com.squareup.okhttp.Dispatcher; import com.squareup.okhttp.Dispatcher;
import com.squareup.okhttp.OkHttpClient; import com.squareup.okhttp.OkHttpClient;
import com.velocitypowered.api.event.PostOrder;
import com.velocitypowered.api.event.Subscribe; import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent; import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.event.proxy.ProxyShutdownEvent; import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
@@ -57,7 +58,7 @@ import java.util.*;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@Plugin(id = "redisbungee", name = "RedisBungee", version = PomData.VERSION, url = "https://github.com/ProxioDev/RedisBungee", authors = {"astei", "ProxioDev"}) @Plugin(id = "redisbungee", name = "RedisBungee", version = Constants.VERSION, url = "https://github.com/ProxioDev/RedisBungee", authors = {"astei", "ProxioDev"})
public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, ConfigLoader { public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, ConfigLoader {
private final ProxyServer server; private final ProxyServer server;
private final Logger logger; private final Logger logger;
@@ -245,6 +246,7 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, Con
@Override @Override
public void initialize() { public void initialize() {
logInfo("Initializing RedisBungee.....");
updateProxiesIds(); updateProxiesIds();
// start heartbeat task // start heartbeat task
heartbeatTask = getProxy().getScheduler().buildTask(this, new HeartbeatTask(this, this.globalPlayerCount)).repeat(HeartbeatTask.INTERVAL, HeartbeatTask.REPEAT_INTERVAL_TIME_UNIT).schedule(); heartbeatTask = getProxy().getScheduler().buildTask(this, new HeartbeatTask(this, this.globalPlayerCount)).repeat(HeartbeatTask.INTERVAL, HeartbeatTask.REPEAT_INTERVAL_TIME_UNIT).schedule();
@@ -283,10 +285,12 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, Con
getProxy().getCommandManager().register("ip", new RedisBungeeCommands.IpCommand(this), "playerip", "rip", "rplayerip"); getProxy().getCommandManager().register("ip", new RedisBungeeCommands.IpCommand(this), "playerip", "rip", "rplayerip");
getProxy().getCommandManager().register("find", new RedisBungeeCommands.FindCommand(this), "rfind"); getProxy().getCommandManager().register("find", new RedisBungeeCommands.FindCommand(this), "rfind");
} }
logInfo("RedisBungee initialized successfully ");
} }
@Override @Override
public void stop() { public void stop() {
logInfo("Turning off redis connections.....");
// Poison the PubSub listener // Poison the PubSub listener
if (psl != null) { if (psl != null) {
psl.poison(); psl.poison();
@@ -306,10 +310,12 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, Con
this.httpClient.getDispatcher().getExecutorService().shutdown(); this.httpClient.getDispatcher().getExecutorService().shutdown();
try { try {
logInfo("waiting for httpclient thread-pool termination.....");
this.httpClient.getDispatcher().getExecutorService().awaitTermination(20, TimeUnit.SECONDS); this.httpClient.getDispatcher().getExecutorService().awaitTermination(20, TimeUnit.SECONDS);
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
logInfo("RedisBungee shutdown complete");
} }
@Override @Override
@@ -330,13 +336,13 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, Con
this.proxiesIds = this.getCurrentProxiesIds(false); this.proxiesIds = this.getCurrentProxiesIds(false);
} }
@Subscribe @Subscribe(order = PostOrder.FIRST)
public void proxyInit(ProxyInitializeEvent event) { public void onProxyInitializeEvent(ProxyInitializeEvent event) {
initialize(); initialize();
} }
@Subscribe @Subscribe(order = PostOrder.LAST)
public void proxyShutdownEvent(ProxyShutdownEvent event) { public void onProxyShutdownEvent(ProxyShutdownEvent event) {
stop(); stop();
} }

7
copyright_print.txt Normal file
View File

@@ -0,0 +1,7 @@
Copyright (c) 2013-present RedisBungee contributors
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html

0
gradle.build.kts Normal file
View File

2
gradle.properties Normal file
View File

@@ -0,0 +1,2 @@
group = com.imaginarycode.minecraft
version = 0.11.1-SNAPSHOT

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

244
gradlew vendored Executable file
View File

@@ -0,0 +1,244 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

92
gradlew.bat vendored Normal file
View File

@@ -0,0 +1,92 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@@ -1,3 +0,0 @@
rm -rf javadoc
mkdir javadoc
mvn clean install javadoc:javadoc -pl RedisBungee-API,RedisBungee-Bungee,RedisBungee-Velocity -am

30
pom.xml
View File

@@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.imaginarycode.minecraft</groupId>
<artifactId>RedisBungee</artifactId>
<packaging>pom</packaging>
<version>0.10.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
<modules>
<!-- Main modules -->
<module>RedisBungee-API</module>
<module>RedisBungee-Bungee</module>
<module>RedisBungee-Velocity</module>
</modules>
</project>

11
settings.gradle.kts Normal file
View File

@@ -0,0 +1,11 @@
pluginManagement {
repositories {
gradlePluginPortal()
}
}
rootProject.name = "RedisBungee-Parent"
include(":RedisBungee-Velocity")
include(":RedisBungee-Bungee")
include(":RedisBungee-API")