mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2026-05-03 11:40:29 +00:00
Compare commits
69 Commits
stable
...
d0ae5d5342
| Author | SHA1 | Date | |
|---|---|---|---|
| d0ae5d5342 | |||
| b88202ae38 | |||
| 3c4e45dfe2 | |||
| abd19c1c3a | |||
| b406c89406 | |||
| 91c3845b2e | |||
| 97e6b5c944 | |||
| 65ac465915 | |||
| 32826d843c | |||
| 78561fa467 | |||
| ab441503c7 | |||
| 51719f13e2 | |||
| 2015d1d0fd | |||
| 70aacc99c0 | |||
| 72025bc22c | |||
| de65b163e2 | |||
| 1e7f474a09 | |||
| 19064e0a60 | |||
| e76f0d0a00 | |||
| 40c542a50a | |||
| 86f64ab019 | |||
| 41b5bde55c | |||
| e5b1f9d76e | |||
|
|
0b8dc4bde6 | ||
| 782f0994c2 | |||
| ca8377ad4c | |||
| 69c3e30344 | |||
| b3eacbd1c4 | |||
| 72b2d46dcd | |||
| 44175e8a68 | |||
| 6c27228920 | |||
| 2eb7f3cf9d | |||
| 1c36aa5418 | |||
| c56a64bbc2 | |||
| 2429cc63d5 | |||
| 46d53fc018 | |||
| d70a5de829 | |||
| a6c6916103 | |||
| fa7ca2dacb | |||
| da255860bd | |||
| 983693b929 | |||
| 32b5e829ba | |||
| 383e647c87 | |||
| 9b54ca93db | |||
| eed91dd73d | |||
| b76709c291 | |||
| 4f6529b295 | |||
| 97cdf31cfc | |||
| 5ea8932ac4 | |||
| 20932d894b | |||
| 6bcba06f7a | |||
| 76c362cf66 | |||
| b7433bc9a3 | |||
| 7ba54ebfe2 | |||
| dd38532501 | |||
| 7183e809d0 | |||
| d1d848fa8c | |||
| e70a6e305c | |||
| e897a60976 | |||
| f6e1ca65bf | |||
| 11a0d84368 | |||
| a0fdd6d997 | |||
| 3c4f0d8c93 | |||
| 6d40c1902a | |||
| a2f1ec22c6 | |||
| 16576ab4c2 | |||
| f96c5759a2 | |||
| 8aaae6702e | |||
| 006066f66c |
20
.github/workflows/gradle.yml
vendored
20
.github/workflows/gradle.yml
vendored
@@ -5,9 +5,9 @@ name: RedisBungee Build
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ stable, develop ]
|
branches: [ develop ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ stable, develop ]
|
branches: [ develop ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -16,27 +16,27 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Set up JDK 21
|
- name: Set up JDK 17
|
||||||
uses: actions/setup-java@v2
|
uses: actions/setup-java@v2
|
||||||
with:
|
with:
|
||||||
java-version: '21'
|
java-version: '17'
|
||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
- name: Build with gradle
|
- name: Build with gradle
|
||||||
run: ./gradlew shadowJar
|
run: ./gradlew shadowJar
|
||||||
- name: Upload Bungee
|
- name: Upload Bungee
|
||||||
uses: actions/upload-artifact@v4.4.0
|
uses: actions/upload-artifact@v2.2.3
|
||||||
with:
|
with:
|
||||||
# Artifact name
|
# Artifact name
|
||||||
name: RedisBungee-Bungee
|
name: RedisBungee-Bungee
|
||||||
# Destination path
|
# Destination path
|
||||||
path: proxies/bungeecord/build/libs/*
|
path: RedisBungee-Bungee/build/libs/*
|
||||||
- name: Upload Velocity
|
- name: Upload Velocity
|
||||||
uses: actions/upload-artifact@v4.4.0
|
uses: actions/upload-artifact@v2.2.3
|
||||||
with:
|
with:
|
||||||
name: RedisBungee-Velocity
|
name: RedisBungee-Velocity
|
||||||
path: proxies/velocity/build/libs/*
|
path: RedisBungee-Velocity/build/libs/*
|
||||||
- name: Upload API
|
- name: Upload API
|
||||||
uses: actions/upload-artifact@v4.4.0
|
uses: actions/upload-artifact@v2.2.3
|
||||||
with:
|
with:
|
||||||
name: RedisBungee-API
|
name: RedisBungee-API
|
||||||
path: api/build/libs/*
|
path: RedisBungee-API/build/libs/*
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -46,4 +46,4 @@ manifest.mf
|
|||||||
javadoc
|
javadoc
|
||||||
|
|
||||||
# run-server folders
|
# run-server folders
|
||||||
proxies/*/run
|
*/run
|
||||||
|
|||||||
@@ -1,21 +1,14 @@
|
|||||||
# ValioBungee: The RedisBungee Limework's Fork
|
# RedisBungee Limework's Fork
|
||||||
|
|
||||||
The original project of RedisBungee is no longer maintained, so we have forked the plugin.
|
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)
|
to Synchronize players data between [BungeeCord](https://github.com/SpigotMC/BungeeCord)
|
||||||
or [Velocity*](https://github.com/PaperMC/Velocity) proxies
|
or [Velocity*](https://github.com/PaperMC/Velocity) proxies
|
||||||
## Why different name?
|
|
||||||
Because from our current understanding we cant use Redis name due trademark restrictions.
|
|
||||||
so we settled with valiobungee. But it doesnt not effect any internals naming schemes like plugin id and so on.
|
|
||||||
|
|
||||||
## Downloads
|
## Downloads
|
||||||
|
|
||||||
[](https://modrinth.com/plugin/redisbungee)
|
[](https://modrinth.com/plugin/redisbungee)
|
||||||
|
|
||||||
## Wiki
|
|
||||||
|
|
||||||
https://github.com/ProxioDev/ValioBungee/wiki
|
|
||||||
|
|
||||||
## Support
|
## Support
|
||||||
|
|
||||||
open an issue with question button
|
open an issue with question button
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
|
import java.time.Instant
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
`java-library`
|
`java-library`
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
alias(libs.plugins.blossom)
|
id("net.kyori.blossom") version "1.2.0"
|
||||||
alias(libs.plugins.indragit)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12,23 +12,33 @@ dependencies {
|
|||||||
api(libs.guava)
|
api(libs.guava)
|
||||||
api(libs.jedis)
|
api(libs.jedis)
|
||||||
api(libs.okhttp)
|
api(libs.okhttp)
|
||||||
api(libs.configurateV3)
|
api(libs.configurate)
|
||||||
api(libs.caffeine)
|
api(libs.caffeine)
|
||||||
|
api(libs.adventure.api)
|
||||||
|
api(libs.adventure.gson)
|
||||||
|
api(libs.adventure.legacy)
|
||||||
|
api(libs.adventure.plain)
|
||||||
|
api(libs.adventure.miniMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
description = "RedisBungee interfaces"
|
description = "RedisBungee interfaces"
|
||||||
|
|
||||||
sourceSets {
|
blossom {
|
||||||
main {
|
replaceToken("@version@", "$version")
|
||||||
blossom {
|
// GIT
|
||||||
javaSources {
|
val commit: String;
|
||||||
property("version", "$version")
|
val commitStdout = ByteArrayOutputStream()
|
||||||
property("git-commit", indraGit.commit().toString())
|
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)
|
||||||
|
replaceToken("@build_date@", "${Instant.now().epochSecond}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
java {
|
java {
|
||||||
withJavadocJar()
|
withJavadocJar()
|
||||||
withSourcesJar()
|
withSourcesJar()
|
||||||
@@ -41,9 +51,9 @@ tasks {
|
|||||||
options.use()
|
options.use()
|
||||||
options.isDocFilesSubDirs = true
|
options.isDocFilesSubDirs = true
|
||||||
val jedisVersion = libs.jedis.get().version
|
val jedisVersion = libs.jedis.get().version
|
||||||
val configurateVersion = libs.configurateV3.get().version
|
val configurateVersion = libs.configurate.get().version
|
||||||
val guavaVersion = libs.guava.get().version
|
val guavaVersion = libs.guava.get().version
|
||||||
val adventureVersion = libs.adventure.api.get().version
|
val adventureVersion = libs.guava.get().version
|
||||||
options.links(
|
options.links(
|
||||||
"https://configurate.aoeu.xyz/$configurateVersion/apidocs/", // configurate
|
"https://configurate.aoeu.xyz/$configurateVersion/apidocs/", // configurate
|
||||||
"https://javadoc.io/doc/redis.clients/jedis/$jedisVersion/", // jedis
|
"https://javadoc.io/doc/redis.clients/jedis/$jedisVersion/", // jedis
|
||||||
@@ -14,10 +14,16 @@ import com.google.common.collect.ImmutableSet;
|
|||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
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;
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisClusterSummoner;
|
||||||
|
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 net.kyori.adventure.text.Component;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
import redis.clients.jedis.Jedis;
|
||||||
|
import redis.clients.jedis.JedisCluster;
|
||||||
import redis.clients.jedis.JedisPool;
|
import redis.clients.jedis.JedisPool;
|
||||||
|
import redis.clients.jedis.JedisPooled;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -210,6 +216,19 @@ public abstract class AbstractRedisBungeeAPI {
|
|||||||
return plugin.proxyDataManager().proxyId();
|
return plugin.proxyDataManager().proxyId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current BungeeCord / Velocity proxy ID for this server.
|
||||||
|
*
|
||||||
|
* @return the current server ID
|
||||||
|
* @see #getAllServers()
|
||||||
|
* @since 0.2.5
|
||||||
|
* @deprecated to avoid confusion between A server and A proxy see #getProxyId()
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public final String getServerId() {
|
||||||
|
return getProxyId();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all the linked proxies in this network.
|
* Get all the linked proxies in this network.
|
||||||
*
|
*
|
||||||
@@ -221,6 +240,41 @@ public abstract class AbstractRedisBungeeAPI {
|
|||||||
return plugin.proxyDataManager().proxiesIds();
|
return plugin.proxyDataManager().proxiesIds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all the linked proxies in this network.
|
||||||
|
*
|
||||||
|
* @return the list of all proxies
|
||||||
|
* @see #getServerId()
|
||||||
|
* @since 0.2.5
|
||||||
|
* @deprecated to avoid confusion between A server and A proxy see see {@link #getAllProxies()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public final List<String> getAllServers() {
|
||||||
|
return getAllProxies();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register (a) PubSub channel(s), so that you may handle PubSubMessageEvent for it.
|
||||||
|
*
|
||||||
|
* @param channels the channels to register
|
||||||
|
* @since 0.3
|
||||||
|
* @deprecated No longer required
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public final void registerPubSubChannels(String... channels) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregister (a) PubSub channel(s).
|
||||||
|
*
|
||||||
|
* @param channels the channels to unregister
|
||||||
|
* @since 0.3
|
||||||
|
* @deprecated No longer required
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public final void unregisterPubSubChannels(String... channels) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch a name from the specified UUID. UUIDs are cached locally and in Redis. This function falls back to Mojang
|
* Fetch a name from the specified UUID. UUIDs are cached locally and in Redis. This function falls back to Mojang
|
||||||
* as a last resort, so calls <strong>may</strong> be blocking.
|
* as a last resort, so calls <strong>may</strong> be blocking.
|
||||||
@@ -289,6 +343,126 @@ public abstract class AbstractRedisBungeeAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kicks a player from the network
|
||||||
|
* calls {@link #getUuidFromName(String)} to get uuid
|
||||||
|
*
|
||||||
|
* @param playerName player name
|
||||||
|
* @param message kick message that player will see on kick
|
||||||
|
* @since 0.8.0
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public void kickPlayer(String playerName, String message) {
|
||||||
|
kickPlayer(getUuidFromName(playerName), message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kicks a player from the network
|
||||||
|
*
|
||||||
|
* @param playerUUID player name
|
||||||
|
* @param message kick message that player will see on kick
|
||||||
|
* @since 0.8.0
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public void kickPlayer(UUID playerUUID, String message) {
|
||||||
|
kickPlayer(playerUUID, Component.text(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kicks a player from the network
|
||||||
|
* calls {@link #getUuidFromName(String)} to get uuid
|
||||||
|
*
|
||||||
|
* @param playerName player name
|
||||||
|
* @param message kick message that player will see on kick
|
||||||
|
* @since 0.12.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public void kickPlayer(String playerName, Component message) {
|
||||||
|
kickPlayer(getUuidFromName(playerName), message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kicks a player from the network
|
||||||
|
*
|
||||||
|
* @param playerUUID player name
|
||||||
|
* @param message kick message that player will see on kick
|
||||||
|
* @since 0.12.0
|
||||||
|
*/
|
||||||
|
public void kickPlayer(UUID playerUUID, Component message) {
|
||||||
|
this.plugin.playerDataManager().kickPlayer(playerUUID, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This gives you instance of Jedis
|
||||||
|
*
|
||||||
|
* @return {@link Jedis}
|
||||||
|
* @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#SINGLE}
|
||||||
|
* @see #getJedisPool()
|
||||||
|
* @since 0.7.0
|
||||||
|
*/
|
||||||
|
public Jedis requestJedis() {
|
||||||
|
if (getMode() == RedisBungeeMode.SINGLE) {
|
||||||
|
return getJedisPool().getResource();
|
||||||
|
} else {
|
||||||
|
throw new IllegalStateException("Mode is not " + RedisBungeeMode.SINGLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This gets Redis Bungee {@link JedisPool}
|
||||||
|
*
|
||||||
|
* @return {@link JedisPool}
|
||||||
|
* @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#SINGLE}
|
||||||
|
* @throws IllegalStateException if JedisPool compatibility mode is disabled in the config
|
||||||
|
* @since 0.6.5
|
||||||
|
*/
|
||||||
|
public JedisPool getJedisPool() {
|
||||||
|
if (getMode() == RedisBungeeMode.SINGLE) {
|
||||||
|
JedisPool jedisPool = ((JedisPooledSummoner) this.plugin.getSummoner()).getCompatibilityJedisPool();
|
||||||
|
if (jedisPool == null) {
|
||||||
|
throw new IllegalStateException("JedisPool compatibility mode is disabled");
|
||||||
|
}
|
||||||
|
return jedisPool;
|
||||||
|
} else {
|
||||||
|
throw new IllegalStateException("Mode is not " + RedisBungeeMode.SINGLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This gives you an instance of JedisCluster that can't be closed
|
||||||
|
* see {@link com.imaginarycode.minecraft.redisbungee.api.summoners.NotClosableJedisCluster}
|
||||||
|
*
|
||||||
|
* @return {@link redis.clients.jedis.JedisCluster}
|
||||||
|
* @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#CLUSTER}
|
||||||
|
* @since 0.8.0
|
||||||
|
*/
|
||||||
|
public JedisCluster requestClusterJedis() {
|
||||||
|
if (getMode() == RedisBungeeMode.CLUSTER) {
|
||||||
|
return ((JedisClusterSummoner) this.plugin.getSummoner()).obtainResource();
|
||||||
|
} else {
|
||||||
|
throw new IllegalStateException("Mode is not " + RedisBungeeMode.CLUSTER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This gives you an instance of JedisPooled that can't be closed
|
||||||
|
* see {@link com.imaginarycode.minecraft.redisbungee.api.summoners.NotClosableJedisPooled}
|
||||||
|
*
|
||||||
|
* @return {@link redis.clients.jedis.JedisPooled}
|
||||||
|
* @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#SINGLE}
|
||||||
|
* @since 0.8.0
|
||||||
|
*/
|
||||||
|
public JedisPooled requestJedisPooled() {
|
||||||
|
if (getMode() == RedisBungeeMode.SINGLE) {
|
||||||
|
return ((JedisPooledSummoner) this.plugin.getSummoner()).obtainResource();
|
||||||
|
} else {
|
||||||
|
throw new IllegalStateException("Mode is not " + RedisBungeeMode.SINGLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns Summoner class responsible for Single Jedis {@link redis.clients.jedis.JedisPooled} with {@link JedisPool}, Cluster Jedis {@link redis.clients.jedis.JedisCluster} handling
|
* returns Summoner class responsible for Single Jedis {@link redis.clients.jedis.JedisPooled} with {@link JedisPool}, Cluster Jedis {@link redis.clients.jedis.JedisCluster} handling
|
||||||
*
|
*
|
||||||
@@ -299,28 +473,6 @@ public abstract class AbstractRedisBungeeAPI {
|
|||||||
return this.plugin.getSummoner();
|
return this.plugin.getSummoner();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Kicks a player from the network using miniMessage
|
|
||||||
* calls {@link #getUuidFromName(String)} to get uuid
|
|
||||||
* <a href="https://docs.advntr.dev/minimessage/format.html">...</a>
|
|
||||||
* @param playerName player name
|
|
||||||
* @param miniMessage kick message that player will see on kick using minimessage as format
|
|
||||||
* @since 0.13.0
|
|
||||||
*/
|
|
||||||
public void kickPlayer(String playerName, String miniMessage) {
|
|
||||||
kickPlayer(getUuidFromName(playerName), miniMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Kicks a player from the network
|
|
||||||
* <a href="https://docs.advntr.dev/minimessage/format.html">...</a>
|
|
||||||
* @param player player uuid
|
|
||||||
* @param miniMessage kick message that player will see on kick using minimessage as format
|
|
||||||
* @since 0.13.0
|
|
||||||
*/
|
|
||||||
public void kickPlayer(UUID player, String miniMessage) {
|
|
||||||
plugin.playerDataManager().serializedPlayerKick(player, miniMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* shows what mode is RedisBungee is on
|
* shows what mode is RedisBungee is on
|
||||||
@@ -13,11 +13,12 @@ package com.imaginarycode.minecraft.redisbungee;
|
|||||||
|
|
||||||
public class Constants {
|
public class Constants {
|
||||||
|
|
||||||
public final static String VERSION = "{{ version }}";
|
public final static String VERSION = "@version@";
|
||||||
public final static String GIT_COMMIT = "{{ git-commit }}";
|
public final static String GIT_COMMIT = "@git_commit@";
|
||||||
|
public final static long BUILD_DATE = Long.parseLong("@build_date@");
|
||||||
|
|
||||||
public static String getGithubCommitLink() {
|
public static String getGithubCommitLink() {
|
||||||
return "https://github.com/ProxioDev/ValioBungee/commit/" + GIT_COMMIT;
|
return "https://github.com/ProxioDev/RedisBungee/commit/" + GIT_COMMIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -16,10 +16,11 @@ import com.google.common.collect.ImmutableMultimap;
|
|||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import com.google.common.net.InetAddresses;
|
import com.google.common.net.InetAddresses;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerChangedServerNetworkEvent;
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerChangedServerNetworkEvent;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerJoinedNetworkEvent;
|
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerLeftNetworkEvent;
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerLeftNetworkEvent;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPubSubMessageEvent;
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPubSubMessageEvent;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.tasks.RedisPipelineTask;
|
import com.imaginarycode.minecraft.redisbungee.api.tasks.RedisPipelineTask;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.json.JSONComponentSerializer;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import redis.clients.jedis.ClusterPipeline;
|
import redis.clients.jedis.ClusterPipeline;
|
||||||
import redis.clients.jedis.Pipeline;
|
import redis.clients.jedis.Pipeline;
|
||||||
@@ -27,22 +28,25 @@ import redis.clients.jedis.Response;
|
|||||||
import redis.clients.jedis.UnifiedJedis;
|
import redis.clients.jedis.UnifiedJedis;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.*;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public abstract class PlayerDataManager<P> {
|
public abstract class PlayerDataManager<P, LE, DE, PS extends IPubSubMessageEvent, SC extends IPlayerChangedServerNetworkEvent, NJE extends IPlayerLeftNetworkEvent, CE> {
|
||||||
|
|
||||||
protected final RedisBungeePlugin<P> plugin;
|
protected final RedisBungeePlugin<P> plugin;
|
||||||
private final Object SERVERS_TO_PLAYERS_KEY = new Object();
|
|
||||||
private final UnifiedJedis unifiedJedis;
|
|
||||||
private final String proxyId;
|
|
||||||
private final String networkId;
|
|
||||||
private final LoadingCache<UUID, String> serverCache = Caffeine.newBuilder().expireAfterWrite(1, TimeUnit.HOURS).build(this::getServerFromRedis);
|
private final LoadingCache<UUID, String> serverCache = Caffeine.newBuilder().expireAfterWrite(1, TimeUnit.HOURS).build(this::getServerFromRedis);
|
||||||
private final LoadingCache<UUID, String> lastServerCache = Caffeine.newBuilder().expireAfterWrite(1, TimeUnit.HOURS).build(this::getLastServerFromRedis);
|
private final LoadingCache<UUID, String> lastServerCache = Caffeine.newBuilder().expireAfterWrite(1, TimeUnit.HOURS).build(this::getLastServerFromRedis);
|
||||||
private final LoadingCache<UUID, String> proxyCache = Caffeine.newBuilder().expireAfterWrite(1, TimeUnit.HOURS).build(this::getProxyFromRedis);
|
private final LoadingCache<UUID, String> proxyCache = Caffeine.newBuilder().expireAfterWrite(1, TimeUnit.HOURS).build(this::getProxyFromRedis);
|
||||||
private final LoadingCache<UUID, InetAddress> ipCache = Caffeine.newBuilder().expireAfterWrite(1, TimeUnit.HOURS).build(this::getIpAddressFromRedis);
|
private final LoadingCache<UUID, InetAddress> ipCache = Caffeine.newBuilder().expireAfterWrite(1, TimeUnit.HOURS).build(this::getIpAddressFromRedis);
|
||||||
private final LoadingCache<UUID, Long> lastOnlineCache = Caffeine.newBuilder().expireAfterWrite(1, TimeUnit.HOURS).build(this::getLastOnlineFromRedis);
|
private final LoadingCache<UUID, Long> lastOnlineCache = Caffeine.newBuilder().expireAfterWrite(1, TimeUnit.HOURS).build(this::getLastOnlineFromRedis);
|
||||||
|
private final Object SERVERS_TO_PLAYERS_KEY = new Object();
|
||||||
private final LoadingCache<Object, Multimap<String, UUID>> serverToPlayersCache = Caffeine.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES).build(this::serversToPlayersBuilder);
|
private final LoadingCache<Object, Multimap<String, UUID>> serverToPlayersCache = Caffeine.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES).build(this::serversToPlayersBuilder);
|
||||||
|
private final UnifiedJedis unifiedJedis;
|
||||||
|
private final String proxyId;
|
||||||
|
private final String networkId;
|
||||||
|
|
||||||
public PlayerDataManager(RedisBungeePlugin<P> plugin) {
|
public PlayerDataManager(RedisBungeePlugin<P> plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
@@ -53,27 +57,23 @@ public abstract class PlayerDataManager<P> {
|
|||||||
|
|
||||||
// handle network wide
|
// handle network wide
|
||||||
// server change
|
// server change
|
||||||
// public void onPlayerChangedServerNetworkEvent
|
public abstract void onPlayerChangedServerNetworkEvent(SC event);
|
||||||
|
|
||||||
// public void onNetworkPlayerQuit
|
public abstract void onNetworkPlayerQuit(NJE event);
|
||||||
|
|
||||||
// public void onNetworkPlayerJoin
|
|
||||||
|
|
||||||
// local events
|
// local events
|
||||||
// public void onPubSubMessageEvent
|
public abstract void onPubSubMessageEvent(PS event);
|
||||||
|
|
||||||
// public void onServerConnectedEvent
|
public abstract void onServerConnectedEvent(CE event);
|
||||||
|
|
||||||
// public void onLoginEvent
|
public abstract void onLoginEvent(LE event);
|
||||||
|
|
||||||
|
public abstract void onDisconnectEvent(DE event);
|
||||||
|
|
||||||
// public void onDisconnectEvent
|
|
||||||
|
|
||||||
protected void handleNetworkPlayerServerChange(IPlayerChangedServerNetworkEvent event) {
|
protected void handleNetworkPlayerServerChange(IPlayerChangedServerNetworkEvent event) {
|
||||||
this.serverCache.invalidate(event.getUuid());
|
this.serverCache.invalidate(event.getUuid());
|
||||||
this.lastServerCache.invalidate(event.getUuid());
|
this.lastServerCache.invalidate(event.getUuid());
|
||||||
|
|
||||||
//TODO: We could also rely on redisbungee-serverchange pubsub messages to update the cache in-place without querying redis. That would be a lot more efficient.
|
|
||||||
this.serverToPlayersCache.invalidate(SERVERS_TO_PLAYERS_KEY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleNetworkPlayerQuit(IPlayerLeftNetworkEvent event) {
|
protected void handleNetworkPlayerQuit(IPlayerLeftNetworkEvent event) {
|
||||||
@@ -81,48 +81,52 @@ public abstract class PlayerDataManager<P> {
|
|||||||
this.serverCache.invalidate(event.getUuid());
|
this.serverCache.invalidate(event.getUuid());
|
||||||
this.ipCache.invalidate(event.getUuid());
|
this.ipCache.invalidate(event.getUuid());
|
||||||
this.lastOnlineCache.invalidate(event.getUuid());
|
this.lastOnlineCache.invalidate(event.getUuid());
|
||||||
|
|
||||||
//TODO: We could also rely on redisbungee-serverchange pubsub messages to update the cache in-place without querying redis. That would be a lot more efficient.
|
|
||||||
this.serverToPlayersCache.invalidate(SERVERS_TO_PLAYERS_KEY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleNetworkPlayerJoin(IPlayerJoinedNetworkEvent event) {
|
|
||||||
this.proxyCache.invalidate(event.getUuid());
|
|
||||||
this.serverCache.invalidate(event.getUuid());
|
|
||||||
this.ipCache.invalidate(event.getUuid());
|
|
||||||
this.lastOnlineCache.invalidate(event.getUuid());
|
|
||||||
|
|
||||||
//TODO: We could also rely on redisbungee-serverchange pubsub messages to update the cache in-place without querying redis. That would be a lot more efficient.
|
|
||||||
this.serverToPlayersCache.invalidate(SERVERS_TO_PLAYERS_KEY);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected void handlePubSubMessageEvent(IPubSubMessageEvent event) {
|
protected void handlePubSubMessageEvent(IPubSubMessageEvent event) {
|
||||||
switch (event.getChannel()) {
|
// kick api
|
||||||
case "redisbungee-serverchange" -> {
|
if (event.getChannel().equals("redisbungee-kick")) {
|
||||||
JSONObject data = new JSONObject(event.getMessage());
|
JSONObject data = new JSONObject(event.getMessage());
|
||||||
UUID uuid = UUID.fromString(data.getString("uuid"));
|
String proxy = data.getString("proxy");
|
||||||
String from = null;
|
if (proxy.equals(this.proxyId)) {
|
||||||
if (data.has("from")) from = data.getString("from");
|
return;
|
||||||
String to = data.getString("to");
|
|
||||||
plugin.fireEvent(plugin.createPlayerChangedServerNetworkEvent(uuid, from, to));
|
|
||||||
}
|
}
|
||||||
case "redisbungee-player-join" -> {
|
UUID uuid = UUID.fromString(data.getString("uuid"));
|
||||||
JSONObject data = new JSONObject(event.getMessage());
|
String message = data.getString("message");
|
||||||
UUID uuid = UUID.fromString(data.getString("uuid"));
|
plugin.handlePlatformKick(uuid, COMPONENT_SERIALIZER.deserialize(message));
|
||||||
plugin.fireEvent(plugin.createPlayerJoinedNetworkEvent(uuid));
|
return;
|
||||||
|
}
|
||||||
|
if (event.getChannel().equals("redisbungee-serverchange")) {
|
||||||
|
JSONObject data = new JSONObject(event.getMessage());
|
||||||
|
String proxy = data.getString("proxy");
|
||||||
|
if (proxy.equals(this.proxyId)) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
case "redisbungee-player-leave" -> {
|
UUID uuid = UUID.fromString(data.getString("uuid"));
|
||||||
JSONObject data = new JSONObject(event.getMessage());
|
String from = null;
|
||||||
UUID uuid = UUID.fromString(data.getString("uuid"));
|
if (data.has("from")) from = data.getString("from");
|
||||||
plugin.fireEvent(plugin.createPlayerLeftNetworkEvent(uuid));
|
String to = data.getString("to");
|
||||||
|
plugin.fireEvent(plugin.createPlayerChangedServerNetworkEvent(uuid, from, to));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (event.getChannel().equals("redisbungee-player-join")) {
|
||||||
|
JSONObject data = new JSONObject(event.getMessage());
|
||||||
|
String proxy = data.getString("proxy");
|
||||||
|
if (proxy.equals(this.proxyId)) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
case "redisbungee-player-kick" -> {
|
UUID uuid = UUID.fromString(data.getString("uuid"));
|
||||||
JSONObject data = new JSONObject(event.getMessage());
|
plugin.fireEvent(plugin.createPlayerJoinedNetworkEvent(uuid));
|
||||||
UUID uuid = UUID.fromString(data.getString("uuid"));
|
return;
|
||||||
String message = data.getString("serialized-message");
|
}
|
||||||
handleSerializedKick(uuid, message);
|
if (event.getChannel().equals("redisbungee-player-leave")) {
|
||||||
|
JSONObject data = new JSONObject(event.getMessage());
|
||||||
|
String proxy = data.getString("proxy");
|
||||||
|
if (proxy.equals(this.proxyId)) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
UUID uuid = UUID.fromString(data.getString("uuid"));
|
||||||
|
plugin.fireEvent(plugin.createPlayerLeftNetworkEvent(uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -138,37 +142,32 @@ public abstract class PlayerDataManager<P> {
|
|||||||
handleServerChangeRedis(uuid, to);
|
handleServerChangeRedis(uuid, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
// must check if player is on the local proxy
|
private final JSONComponentSerializer COMPONENT_SERIALIZER =JSONComponentSerializer.json();
|
||||||
// https://docs.advntr.dev/minimessage/index.html
|
|
||||||
// implemented downstream in Velocity and Bungeecord
|
|
||||||
protected abstract boolean handleSerializedKick(UUID player, String serializedMiniMessage);
|
|
||||||
|
|
||||||
// https://docs.advntr.dev/minimessage/index.html
|
public void kickPlayer(UUID uuid, Component message) {
|
||||||
// implemented downstream in Velocity and Bungeecord
|
if (!plugin.handlePlatformKick(uuid, message)) { // handle locally before SENDING a message
|
||||||
// called by kickPlayer in each impl of this class `NOT OVERRIDE`
|
JSONObject data = new JSONObject();
|
||||||
public void serializedPlayerKick(UUID player, String serializedMiniMessage) {
|
data.put("proxy", this.proxyId);
|
||||||
JSONObject data = new JSONObject();
|
data.put("uuid", uuid);
|
||||||
data.put("proxy", this.proxyId);
|
data.put("message", COMPONENT_SERIALIZER.serialize(message));
|
||||||
data.put("uuid", player);
|
plugin.proxyDataManager().sendChannelMessage("redisbungee-kick", data.toString());
|
||||||
data.put("serialized-message", serializedMiniMessage);
|
}
|
||||||
if (!handleSerializedKick(player, serializedMiniMessage))
|
|
||||||
plugin.proxyDataManager().sendChannelMessage("redisbungee-player-kick", data.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleServerChangeRedis(UUID uuid, String server) {
|
private void handleServerChangeRedis(UUID uuid, String server) {
|
||||||
Map<String, String> data = new HashMap<>();
|
Map<String, String> data = new HashMap<>();
|
||||||
data.put("server", server);
|
data.put("server", server);
|
||||||
data.put("last-server", server);
|
data.put("last-server", server);
|
||||||
unifiedJedis.hset("redisbungee::" + this.networkId + "::player::" + uuid + "::data", data);
|
unifiedJedis.hset("redis-bungee::" + this.networkId + "::player::" + uuid + "::data", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addPlayer(final UUID uuid, final String name, final InetAddress inetAddress) {
|
protected void addPlayer(final UUID uuid, final InetAddress inetAddress) {
|
||||||
Map<String, String> redisData = new HashMap<>();
|
Map<String, String> redisData = new HashMap<>();
|
||||||
redisData.put("last-online", String.valueOf(0));
|
redisData.put("last-online", String.valueOf(0));
|
||||||
redisData.put("proxy", this.proxyId);
|
redisData.put("proxy", this.proxyId);
|
||||||
redisData.put("ip", inetAddress.getHostAddress());
|
redisData.put("ip", inetAddress.getHostAddress());
|
||||||
unifiedJedis.hset("redisbungee::" + this.networkId + "::player::" + uuid + "::data", redisData);
|
unifiedJedis.hset("redis-bungee::" + this.networkId + "::player::" + uuid + "::data", redisData);
|
||||||
plugin.getUuidTranslator().persistInfo(name, uuid, this.unifiedJedis);
|
|
||||||
JSONObject data = new JSONObject();
|
JSONObject data = new JSONObject();
|
||||||
data.put("proxy", this.proxyId);
|
data.put("proxy", this.proxyId);
|
||||||
data.put("uuid", uuid);
|
data.put("uuid", uuid);
|
||||||
@@ -178,8 +177,8 @@ public abstract class PlayerDataManager<P> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void removePlayer(UUID uuid) {
|
protected void removePlayer(UUID uuid) {
|
||||||
unifiedJedis.hset("redisbungee::" + this.networkId + "::player::" + uuid + "::data", "last-online", String.valueOf(System.currentTimeMillis()));
|
unifiedJedis.hset("redis-bungee::" + this.networkId + "::player::" + uuid + "::data", "last-online", String.valueOf(System.currentTimeMillis()));
|
||||||
unifiedJedis.hdel("redisbungee::" + this.networkId + "::player::" + uuid + "::data", "server", "proxy", "ip");
|
unifiedJedis.hdel("redis-bungee::" + this.networkId + "::player::" + uuid + "::data", "server", "proxy", "ip");
|
||||||
JSONObject data = new JSONObject();
|
JSONObject data = new JSONObject();
|
||||||
data.put("proxy", this.proxyId);
|
data.put("proxy", this.proxyId);
|
||||||
data.put("uuid", uuid);
|
data.put("uuid", uuid);
|
||||||
@@ -190,25 +189,25 @@ public abstract class PlayerDataManager<P> {
|
|||||||
|
|
||||||
|
|
||||||
protected String getProxyFromRedis(UUID uuid) {
|
protected String getProxyFromRedis(UUID uuid) {
|
||||||
return unifiedJedis.hget("redisbungee::" + this.networkId + "::player::" + uuid + "::data", "proxy");
|
return unifiedJedis.hget("redis-bungee::" + this.networkId + "::player::" + uuid + "::data", "proxy");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getServerFromRedis(UUID uuid) {
|
protected String getServerFromRedis(UUID uuid) {
|
||||||
return unifiedJedis.hget("redisbungee::" + this.networkId + "::player::" + uuid + "::data", "server");
|
return unifiedJedis.hget("redis-bungee::" + this.networkId + "::player::" + uuid + "::data", "server");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getLastServerFromRedis(UUID uuid) {
|
protected String getLastServerFromRedis(UUID uuid) {
|
||||||
return unifiedJedis.hget("redisbungee::" + this.networkId + "::player::" + uuid + "::data", "last-server");
|
return unifiedJedis.hget("redis-bungee::" + this.networkId + "::player::" + uuid + "::data", "last-server");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected InetAddress getIpAddressFromRedis(UUID uuid) {
|
protected InetAddress getIpAddressFromRedis(UUID uuid) {
|
||||||
String ip = unifiedJedis.hget("redisbungee::" + this.networkId + "::player::" + uuid + "::data", "ip");
|
String ip = unifiedJedis.hget("redis-bungee::" + this.networkId + "::player::" + uuid + "::data", "ip");
|
||||||
if (ip == null) return null;
|
if (ip == null) return null;
|
||||||
return InetAddresses.forString(ip);
|
return InetAddresses.forString(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected long getLastOnlineFromRedis(UUID uuid) {
|
protected long getLastOnlineFromRedis(UUID uuid) {
|
||||||
String unixString = unifiedJedis.hget("redisbungee::" + this.networkId + "::player::" + uuid + "::data", "last-online");
|
String unixString = unifiedJedis.hget("redis-bungee::" + this.networkId + "::player::" + uuid + "::data", "last-online");
|
||||||
if (unixString == null) return -1;
|
if (unixString == null) return -1;
|
||||||
return Long.parseLong(unixString);
|
return Long.parseLong(unixString);
|
||||||
}
|
}
|
||||||
@@ -216,7 +215,6 @@ public abstract class PlayerDataManager<P> {
|
|||||||
public String getLastServerFor(UUID uuid) {
|
public String getLastServerFor(UUID uuid) {
|
||||||
return this.lastServerCache.get(uuid);
|
return this.lastServerCache.get(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getServerFor(UUID uuid) {
|
public String getServerFor(UUID uuid) {
|
||||||
return this.serverCache.get(uuid);
|
return this.serverCache.get(uuid);
|
||||||
}
|
}
|
||||||
@@ -247,17 +245,10 @@ public abstract class PlayerDataManager<P> {
|
|||||||
public Multimap<String, UUID> doPooledPipeline(Pipeline pipeline) {
|
public Multimap<String, UUID> doPooledPipeline(Pipeline pipeline) {
|
||||||
HashMap<UUID, Response<String>> responses = new HashMap<>();
|
HashMap<UUID, Response<String>> responses = new HashMap<>();
|
||||||
for (UUID uuid : uuids) {
|
for (UUID uuid : uuids) {
|
||||||
Optional.ofNullable(pipeline.hget("redisbungee::" + networkId + "::player::" + uuid + "::data", "server")).ifPresent(stringResponse -> {
|
responses.put(uuid, pipeline.hget("redis-bungee::" + networkId + "::player::" + uuid + "::data", "server"));
|
||||||
responses.put(uuid, stringResponse);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
pipeline.sync();
|
pipeline.sync();
|
||||||
responses.forEach((uuid, response) -> {
|
responses.forEach((uuid, response) -> builder.put(response.get(), uuid));
|
||||||
String key = response.get();
|
|
||||||
if (key == null) return;
|
|
||||||
|
|
||||||
builder.put(key, uuid);
|
|
||||||
});
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,16 +256,10 @@ public abstract class PlayerDataManager<P> {
|
|||||||
public Multimap<String, UUID> clusterPipeline(ClusterPipeline pipeline) {
|
public Multimap<String, UUID> clusterPipeline(ClusterPipeline pipeline) {
|
||||||
HashMap<UUID, Response<String>> responses = new HashMap<>();
|
HashMap<UUID, Response<String>> responses = new HashMap<>();
|
||||||
for (UUID uuid : uuids) {
|
for (UUID uuid : uuids) {
|
||||||
Optional.ofNullable(pipeline.hget("redisbungee::" + networkId + "::player::" + uuid + "::data", "server")).ifPresent(stringResponse -> {
|
responses.put(uuid, pipeline.hget("redis-bungee::" + networkId + "::player::" + uuid + "::data", "server"));
|
||||||
responses.put(uuid, stringResponse);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
pipeline.sync();
|
pipeline.sync();
|
||||||
responses.forEach((uuid, response) -> {
|
responses.forEach((uuid, response) -> builder.put(response.get(), uuid));
|
||||||
String key = response.get();
|
|
||||||
if (key == null) return;
|
|
||||||
builder.put(key, uuid);
|
|
||||||
});
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
}.call();
|
}.call();
|
||||||
@@ -66,9 +66,9 @@ public abstract class ProxyDataManager implements Runnable {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.proxyId = this.plugin.configuration().getProxyId();
|
this.proxyId = this.plugin.configuration().getProxyId();
|
||||||
this.unifiedJedis = plugin.getSummoner().obtainResource();
|
this.unifiedJedis = plugin.getSummoner().obtainResource();
|
||||||
|
this.destroyProxyMembers();
|
||||||
this.networkId = plugin.configuration().networkId();
|
this.networkId = plugin.configuration().networkId();
|
||||||
this.STREAM_ID = "network-" + this.networkId + "-redisbungee-stream";
|
this.STREAM_ID = "network-" + this.networkId + "-redisbungee-stream";
|
||||||
this.destroyProxyMembers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Set<UUID> getLocalOnlineUUIDs();
|
public abstract Set<UUID> getLocalOnlineUUIDs();
|
||||||
@@ -82,27 +82,18 @@ public abstract class ProxyDataManager implements Runnable {
|
|||||||
return getProxyMembers(proxyId);
|
return getProxyMembers(proxyId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this skip checking if proxy is and its package private
|
|
||||||
// due proxy shutdown shenanigans
|
|
||||||
public boolean isPlayerTrulyOnProxy(String proxyId, UUID uuid) {
|
|
||||||
return unifiedJedis.sismember("redisbungee::" + this.networkId + "::proxies::" + proxyId + "::online-players", uuid.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public List<String> proxiesIds() {
|
public List<String> proxiesIds() {
|
||||||
return Collections.list(this.heartbeats.keys());
|
return Collections.list(this.heartbeats.keys());
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void sendCommandTo(String proxyToRun, String command) {
|
public synchronized void sendCommandTo(String proxyToRun, String command) {
|
||||||
if (isClosed()) return;
|
if (isClosed()) return;
|
||||||
if (proxyToRun.equals("allservers") || proxyToRun.equals(this.proxyId())) {
|
|
||||||
handlePlatformCommandExecution(command);
|
|
||||||
}
|
|
||||||
publishPayload(new RunCommandPayload(this.proxyId, proxyToRun, command));
|
publishPayload(new RunCommandPayload(this.proxyId, proxyToRun, command));
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void sendChannelMessage(String channel, String message) {
|
public synchronized void sendChannelMessage(String channel, String message) {
|
||||||
if (isClosed()) return;
|
if (isClosed()) return;
|
||||||
|
this.plugin.fireEvent(this.plugin.createPubSubEvent(channel, message));
|
||||||
publishPayload(new PubSubPayload(this.proxyId, channel, message));
|
publishPayload(new PubSubPayload(this.proxyId, channel, message));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,7 +190,7 @@ public abstract class ProxyDataManager implements Runnable {
|
|||||||
Set<UUID> storedRedisUuids = getProxyMembers(this.proxyId);
|
Set<UUID> storedRedisUuids = getProxyMembers(this.proxyId);
|
||||||
|
|
||||||
if (!localOnlineUUIDs.equals(storedRedisUuids)) {
|
if (!localOnlineUUIDs.equals(storedRedisUuids)) {
|
||||||
plugin.logWarn("De-synced players set detected correcting....");
|
plugin.logWarn("De-synced playerS set detected correcting....");
|
||||||
Set<UUID> add = new HashSet<>(localOnlineUUIDs);
|
Set<UUID> add = new HashSet<>(localOnlineUUIDs);
|
||||||
Set<UUID> remove = new HashSet<>(storedRedisUuids);
|
Set<UUID> remove = new HashSet<>(storedRedisUuids);
|
||||||
add.removeAll(storedRedisUuids);
|
add.removeAll(storedRedisUuids);
|
||||||
@@ -11,10 +11,12 @@
|
|||||||
package com.imaginarycode.minecraft.redisbungee.api;
|
package com.imaginarycode.minecraft.redisbungee.api;
|
||||||
|
|
||||||
import com.imaginarycode.minecraft.redisbungee.AbstractRedisBungeeAPI;
|
import com.imaginarycode.minecraft.redisbungee.AbstractRedisBungeeAPI;
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.config.LangConfiguration;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.config.RedisBungeeConfiguration;
|
import com.imaginarycode.minecraft.redisbungee.api.config.RedisBungeeConfiguration;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.events.EventsPlatform;
|
import com.imaginarycode.minecraft.redisbungee.api.events.EventsPlatform;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.Summoner;
|
import com.imaginarycode.minecraft.redisbungee.api.summoners.Summoner;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.util.uuid.UUIDTranslator;
|
import com.imaginarycode.minecraft.redisbungee.api.util.uuid.UUIDTranslator;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -53,6 +55,8 @@ public interface RedisBungeePlugin<P> extends EventsPlatform {
|
|||||||
|
|
||||||
RedisBungeeConfiguration configuration();
|
RedisBungeeConfiguration configuration();
|
||||||
|
|
||||||
|
LangConfiguration langConfiguration();
|
||||||
|
|
||||||
Summoner<?> getSummoner();
|
Summoner<?> getSummoner();
|
||||||
|
|
||||||
RedisBungeeMode getRedisBungeeMode();
|
RedisBungeeMode getRedisBungeeMode();
|
||||||
@@ -61,7 +65,7 @@ public interface RedisBungeePlugin<P> extends EventsPlatform {
|
|||||||
|
|
||||||
ProxyDataManager proxyDataManager();
|
ProxyDataManager proxyDataManager();
|
||||||
|
|
||||||
PlayerDataManager<P> playerDataManager();
|
PlayerDataManager<P, ?, ?, ?, ?, ?, ?> playerDataManager();
|
||||||
|
|
||||||
UUIDTranslator getUuidTranslator();
|
UUIDTranslator getUuidTranslator();
|
||||||
|
|
||||||
@@ -73,8 +77,11 @@ public interface RedisBungeePlugin<P> extends EventsPlatform {
|
|||||||
|
|
||||||
UUID getPlayerUUID(String player);
|
UUID getPlayerUUID(String player);
|
||||||
|
|
||||||
|
|
||||||
String getPlayerName(UUID player);
|
String getPlayerName(UUID player);
|
||||||
|
|
||||||
|
boolean handlePlatformKick(UUID uuid, Component message);
|
||||||
|
|
||||||
String getPlayerServerName(P player);
|
String getPlayerServerName(P player);
|
||||||
|
|
||||||
boolean isPlayerOnAServer(P player);
|
boolean isPlayerOnAServer(P player);
|
||||||
@@ -85,5 +92,5 @@ public interface RedisBungeePlugin<P> extends EventsPlatform {
|
|||||||
|
|
||||||
void executeAsyncAfter(Runnable runnable, TimeUnit timeUnit, int time);
|
void executeAsyncAfter(Runnable runnable, TimeUnit timeUnit, int time);
|
||||||
|
|
||||||
String platformId();
|
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.limework.valiobungee.config.lang;
|
package com.imaginarycode.minecraft.redisbungee.api.config;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
@@ -13,6 +13,7 @@ package com.imaginarycode.minecraft.redisbungee.api.config;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.net.InetAddresses;
|
import com.google.common.net.InetAddresses;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -24,13 +25,12 @@ public class RedisBungeeConfiguration {
|
|||||||
|
|
||||||
private final boolean handleReconnectToLastServer;
|
private final boolean handleReconnectToLastServer;
|
||||||
private final boolean handleMotd;
|
private final boolean handleMotd;
|
||||||
private final HandleMotdOrder handleMotdOrder;
|
|
||||||
|
|
||||||
private final CommandsConfiguration commandsConfiguration;
|
private final CommandsConfiguration commandsConfiguration;
|
||||||
private final String networkId;
|
private final String networkId;
|
||||||
|
|
||||||
|
|
||||||
public RedisBungeeConfiguration(String networkId, String proxyId, List<String> exemptAddresses, boolean kickWhenOnline, boolean handleReconnectToLastServer, boolean handleMotd, HandleMotdOrder handleMotdOrder, CommandsConfiguration commandsConfiguration) {
|
public RedisBungeeConfiguration(String networkId, String proxyId, List<String> exemptAddresses, boolean kickWhenOnline, boolean handleReconnectToLastServer, boolean handleMotd, CommandsConfiguration commandsConfiguration) {
|
||||||
this.proxyId = proxyId;
|
this.proxyId = proxyId;
|
||||||
ImmutableList.Builder<InetAddress> addressBuilder = ImmutableList.builder();
|
ImmutableList.Builder<InetAddress> addressBuilder = ImmutableList.builder();
|
||||||
for (String s : exemptAddresses) {
|
for (String s : exemptAddresses) {
|
||||||
@@ -40,7 +40,6 @@ public class RedisBungeeConfiguration {
|
|||||||
this.kickWhenOnline = kickWhenOnline;
|
this.kickWhenOnline = kickWhenOnline;
|
||||||
this.handleReconnectToLastServer = handleReconnectToLastServer;
|
this.handleReconnectToLastServer = handleReconnectToLastServer;
|
||||||
this.handleMotd = handleMotd;
|
this.handleMotd = handleMotd;
|
||||||
this.handleMotdOrder = handleMotdOrder;
|
|
||||||
this.commandsConfiguration = commandsConfiguration;
|
this.commandsConfiguration = commandsConfiguration;
|
||||||
this.networkId = networkId;
|
this.networkId = networkId;
|
||||||
}
|
}
|
||||||
@@ -61,16 +60,12 @@ public class RedisBungeeConfiguration {
|
|||||||
return this.handleMotd;
|
return this.handleMotd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandleMotdOrder handleMotdOrder() {
|
|
||||||
return handleMotdOrder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean handleReconnectToLastServer() {
|
public boolean handleReconnectToLastServer() {
|
||||||
return this.handleReconnectToLastServer;
|
return this.handleReconnectToLastServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public record CommandsConfiguration(boolean redisbungeeEnabled, boolean redisbungeeLegacyEnabled,
|
public record CommandsConfiguration(boolean redisbungeeEnabled, boolean redisbungeeLegacyEnabled,
|
||||||
LegacySubCommandsConfiguration legacySubCommandsConfiguration) {
|
@Nullable LegacySubCommandsConfiguration legacySubCommandsConfiguration) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,7 +14,6 @@ package com.imaginarycode.minecraft.redisbungee.api.config.loaders;
|
|||||||
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;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.config.HandleMotdOrder;
|
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.config.RedisBungeeConfiguration;
|
import com.imaginarycode.minecraft.redisbungee.api.config.RedisBungeeConfiguration;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisClusterSummoner;
|
import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisClusterSummoner;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisPooledSummoner;
|
import com.imaginarycode.minecraft.redisbungee.api.summoners.JedisPooledSummoner;
|
||||||
@@ -97,25 +96,14 @@ public interface ConfigLoader extends GenericConfigLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugin.logInfo("Loaded network id " + networkId);
|
plugin.logInfo("Loaded network id " + networkId);
|
||||||
// TO avoid proxies from different platforms from seeing each other.
|
|
||||||
networkId = plugin.platformId() + "-" + networkId;
|
|
||||||
plugin.logInfo("Platform is {} so network id is now is {}", plugin.platformId(), networkId);
|
|
||||||
|
|
||||||
boolean reconnectToLastServer = node.getNode("reconnect-to-last-server").getBoolean();
|
boolean reconnectToLastServer = node.getNode("reconnect-to-last-server").getBoolean();
|
||||||
boolean handleMotd = node.getNode("handle-motd").getBoolean(true);
|
boolean handleMotd = node.getNode("handle-motd").getBoolean(true);
|
||||||
plugin.logInfo("handle reconnect to last server: {}", reconnectToLastServer);
|
plugin.logInfo("handle reconnect to last server: {}", reconnectToLastServer);
|
||||||
plugin.logInfo("handle motd: {}", handleMotd);
|
plugin.logInfo("handle motd: {}", handleMotd);
|
||||||
|
|
||||||
HandleMotdOrder handleMotdOrder = HandleMotdOrder.NORMAL;
|
|
||||||
String handleMotdOrderName = node.getNode("handle-motd-priority").getString();
|
|
||||||
if (handleMotdOrderName != null) {
|
|
||||||
try {
|
|
||||||
handleMotdOrder = HandleMotdOrder.valueOf(handleMotdOrderName.toUpperCase(Locale.ROOT));
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
plugin.logWarn("handle motd order value '{}' is unsupported (allowed: {})", handleMotdOrderName, HandleMotdOrder.values());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
plugin.logInfo("handle motd order: {}", handleMotdOrder);
|
|
||||||
|
|
||||||
// commands
|
// commands
|
||||||
boolean redisBungeeEnabled = node.getNode("commands", "redisbungee", "enabled").getBoolean(true);
|
boolean redisBungeeEnabled = node.getNode("commands", "redisbungee", "enabled").getBoolean(true);
|
||||||
@@ -142,8 +130,7 @@ public interface ConfigLoader extends GenericConfigLoader {
|
|||||||
boolean installPlist = node.getNode("commands", "redisbungee-legacy", "subcommands", "plist", "install").getBoolean(false);
|
boolean installPlist = node.getNode("commands", "redisbungee-legacy", "subcommands", "plist", "install").getBoolean(false);
|
||||||
|
|
||||||
|
|
||||||
RedisBungeeConfiguration configuration = new RedisBungeeConfiguration(networkId, proxyId, exemptAddresses, kickWhenOnline, reconnectToLastServer, handleMotd, handleMotdOrder,
|
RedisBungeeConfiguration configuration = new RedisBungeeConfiguration(networkId, proxyId, exemptAddresses, kickWhenOnline, reconnectToLastServer, handleMotd, new RedisBungeeConfiguration.CommandsConfiguration(
|
||||||
new RedisBungeeConfiguration.CommandsConfiguration(
|
|
||||||
redisBungeeEnabled, redisBungeeLegacyEnabled,
|
redisBungeeEnabled, redisBungeeLegacyEnabled,
|
||||||
new RedisBungeeConfiguration.LegacySubCommandsConfiguration(
|
new RedisBungeeConfiguration.LegacySubCommandsConfiguration(
|
||||||
findEnabled, glistEnabled, ipEnabled,
|
findEnabled, glistEnabled, ipEnabled,
|
||||||
@@ -12,6 +12,7 @@ package com.imaginarycode.minecraft.redisbungee.api.config.loaders;
|
|||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@@ -8,10 +8,10 @@
|
|||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.limework.valiobungee.config.lang;
|
package com.imaginarycode.minecraft.redisbungee.api.config.loaders;
|
||||||
|
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.config.loaders.GenericConfigLoader;
|
import com.imaginarycode.minecraft.redisbungee.api.config.LangConfiguration;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import ninja.leaping.configurate.ConfigurationNode;
|
import ninja.leaping.configurate.ConfigurationNode;
|
||||||
@@ -34,7 +34,7 @@ public class InitialUtils {
|
|||||||
}
|
}
|
||||||
long uuidCacheSize = unifiedJedis.hlen("uuid-cache");
|
long uuidCacheSize = unifiedJedis.hlen("uuid-cache");
|
||||||
if (uuidCacheSize > 750000) {
|
if (uuidCacheSize > 750000) {
|
||||||
plugin.logInfo("Looks like you have a really big UUID cache! Run '/rb clean' to remove expired cache entries");
|
plugin.logInfo("Looks like you have a really big UUID cache! Run https://github.com/ProxioDev/Brains");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,28 @@ package com.imaginarycode.minecraft.redisbungee.api.util.uuid;
|
|||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public record CachedUUIDEntry(String name, UUID uuid, Calendar expiry) {
|
public class CachedUUIDEntry {
|
||||||
|
private final String name;
|
||||||
|
private final UUID uuid;
|
||||||
|
private final Calendar expiry;
|
||||||
|
|
||||||
|
public CachedUUIDEntry(String name, UUID uuid, Calendar expiry) {
|
||||||
|
this.name = name;
|
||||||
|
this.uuid = uuid;
|
||||||
|
this.expiry = expiry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getUuid() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Calendar getExpiry() {
|
||||||
|
return expiry;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean expired() {
|
public boolean expired() {
|
||||||
return Calendar.getInstance().after(expiry);
|
return Calendar.getInstance().after(expiry);
|
||||||
@@ -12,9 +12,9 @@ package com.imaginarycode.minecraft.redisbungee.api.util.uuid;
|
|||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import okhttp3.OkHttpClient;
|
import com.squareup.okhttp.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import com.squareup.okhttp.Request;
|
||||||
import okhttp3.ResponseBody;
|
import com.squareup.okhttp.ResponseBody;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -22,9 +22,13 @@ import java.util.List;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class NameFetcher {
|
public class NameFetcher {
|
||||||
private static final OkHttpClient httpClient = new OkHttpClient();
|
private static OkHttpClient httpClient;
|
||||||
private static final Gson gson = new Gson();
|
private static final Gson gson = new Gson();
|
||||||
|
|
||||||
|
public static void setHttpClient(OkHttpClient httpClient) {
|
||||||
|
NameFetcher.httpClient = httpClient;
|
||||||
|
}
|
||||||
|
|
||||||
public static List<String> nameHistoryFromUuid(UUID uuid) throws IOException {
|
public static List<String> nameHistoryFromUuid(UUID uuid) throws IOException {
|
||||||
String name = getName(uuid);
|
String name = getName(uuid);
|
||||||
if (name == null) return Collections.emptyList();
|
if (name == null) return Collections.emptyList();
|
||||||
@@ -12,7 +12,7 @@ package com.imaginarycode.minecraft.redisbungee.api.util.uuid;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import okhttp3.*;
|
import com.squareup.okhttp.*;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -28,7 +28,13 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
|
|||||||
private final List<String> names;
|
private final List<String> names;
|
||||||
private final boolean rateLimiting;
|
private final boolean rateLimiting;
|
||||||
private static final Gson gson = new Gson();
|
private static final Gson gson = new Gson();
|
||||||
private static final OkHttpClient httpClient = new OkHttpClient();
|
|
||||||
|
|
||||||
|
public static void setHttpClient(OkHttpClient httpClient) {
|
||||||
|
UUIDFetcher.httpClient = httpClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static OkHttpClient httpClient;
|
||||||
|
|
||||||
private UUIDFetcher(List<String> names, boolean rateLimiting) {
|
private UUIDFetcher(List<String> names, boolean rateLimiting) {
|
||||||
this.names = ImmutableList.copyOf(names);
|
this.names = ImmutableList.copyOf(names);
|
||||||
@@ -61,7 +61,7 @@ public final class UUIDTranslator {
|
|||||||
CachedUUIDEntry cachedUUIDEntry = nameToUuidMap.get(player.toLowerCase());
|
CachedUUIDEntry cachedUUIDEntry = nameToUuidMap.get(player.toLowerCase());
|
||||||
if (cachedUUIDEntry != null) {
|
if (cachedUUIDEntry != null) {
|
||||||
if (!cachedUUIDEntry.expired())
|
if (!cachedUUIDEntry.expired())
|
||||||
return cachedUUIDEntry.uuid();
|
return cachedUUIDEntry.getUuid();
|
||||||
else
|
else
|
||||||
nameToUuidMap.remove(player);
|
nameToUuidMap.remove(player);
|
||||||
}
|
}
|
||||||
@@ -93,11 +93,11 @@ public final class UUIDTranslator {
|
|||||||
if (entry.expired()) {
|
if (entry.expired()) {
|
||||||
unifiedJedis.hdel("uuid-cache", player.toLowerCase());
|
unifiedJedis.hdel("uuid-cache", player.toLowerCase());
|
||||||
// Doesn't hurt to also remove the UUID entry as well.
|
// Doesn't hurt to also remove the UUID entry as well.
|
||||||
unifiedJedis.hdel("uuid-cache", entry.uuid().toString());
|
unifiedJedis.hdel("uuid-cache", entry.getUuid().toString());
|
||||||
} else {
|
} else {
|
||||||
nameToUuidMap.put(player.toLowerCase(), entry);
|
nameToUuidMap.put(player.toLowerCase(), entry);
|
||||||
uuidToNameMap.put(entry.uuid(), entry);
|
uuidToNameMap.put(entry.getUuid(), entry);
|
||||||
return entry.uuid();
|
return entry.getUuid();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +141,7 @@ public final class UUIDTranslator {
|
|||||||
CachedUUIDEntry cachedUUIDEntry = uuidToNameMap.get(player);
|
CachedUUIDEntry cachedUUIDEntry = uuidToNameMap.get(player);
|
||||||
if (cachedUUIDEntry != null) {
|
if (cachedUUIDEntry != null) {
|
||||||
if (!cachedUUIDEntry.expired())
|
if (!cachedUUIDEntry.expired())
|
||||||
return cachedUUIDEntry.name();
|
return cachedUUIDEntry.getName();
|
||||||
else
|
else
|
||||||
uuidToNameMap.remove(player);
|
uuidToNameMap.remove(player);
|
||||||
}
|
}
|
||||||
@@ -159,11 +159,11 @@ public final class UUIDTranslator {
|
|||||||
unifiedJedis.hdel("uuid-cache", player.toString());
|
unifiedJedis.hdel("uuid-cache", player.toString());
|
||||||
// Doesn't hurt to also remove the named entry as well.
|
// Doesn't hurt to also remove the named entry as well.
|
||||||
// TODO: Since UUIDs are fixed, we could look up the name and see if the UUID matches.
|
// TODO: Since UUIDs are fixed, we could look up the name and see if the UUID matches.
|
||||||
unifiedJedis.hdel("uuid-cache", entry.name());
|
unifiedJedis.hdel("uuid-cache", entry.getName());
|
||||||
} else {
|
} else {
|
||||||
nameToUuidMap.put(entry.name().toLowerCase(), entry);
|
nameToUuidMap.put(entry.getName().toLowerCase(), entry);
|
||||||
uuidToNameMap.put(player, entry);
|
uuidToNameMap.put(player, entry);
|
||||||
return entry.name();
|
return entry.getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,15 +50,13 @@ useSSL: false
|
|||||||
|
|
||||||
# An identifier for this network, which helps to separate redisbungee instances on same redis instance.
|
# An identifier for this network, which helps to separate redisbungee instances on same redis instance.
|
||||||
# You can use environment variable 'REDISBUNGEE_NETWORK_ID' to override
|
# You can use environment variable 'REDISBUNGEE_NETWORK_ID' to override
|
||||||
# Depending on the platform bungeecord or velocity system will append platform id to the network id
|
|
||||||
# to prevent proxies from different platforms from seeing each other. since 0.13.0
|
|
||||||
network-id: "main"
|
network-id: "main"
|
||||||
|
|
||||||
# An identifier for this BungeeCord / Velocity instance. Will randomly generate if leaving it blank.
|
# An identifier for this BungeeCord / Velocity instance. Will randomly generate if leaving it blank.
|
||||||
# You can set Environment variable 'REDISBUNGEE_PROXY_ID' to override
|
# You can set Environment variable 'REDISBUNGEE_PROXY_ID' to override
|
||||||
proxy-id: "proxy-1"
|
proxy-id: "proxy-1"
|
||||||
|
|
||||||
# since RedisBungee Internally now uses UnifiedJedis instead of Jedis, JedisPool.
|
# since RedisBungee Internally now uses JedisPooled instead of Jedis, JedisPool.
|
||||||
# which will break compatibility with old plugins that uses RedisBungee JedisPool
|
# which will break compatibility with old plugins that uses RedisBungee JedisPool
|
||||||
# so to mitigate this issue, RedisBungee will create an JedisPool for compatibility reasons.
|
# so to mitigate this issue, RedisBungee will create an JedisPool for compatibility reasons.
|
||||||
# disabled by default
|
# disabled by default
|
||||||
@@ -79,13 +77,6 @@ kick-when-online: true
|
|||||||
# you can disable this when you want to handle motd yourself, use RedisBungee api to get total players when needed :)
|
# you can disable this when you want to handle motd yourself, use RedisBungee api to get total players when needed :)
|
||||||
handle-motd: true
|
handle-motd: true
|
||||||
|
|
||||||
# MOTD plugins compatibility setting
|
|
||||||
# Allowed values: FIRST, NORMAL, LAST
|
|
||||||
# This option enables RedisBungee to manage various interactions between other plugins and the online player count,
|
|
||||||
# which is dynamically updated to a global player count in ping responses if the handle-motd option is enabled.
|
|
||||||
# If you encounter issues with other plugins accessing or modifying the player count, try using a value of FIRST or LAST.
|
|
||||||
handle-motd-order: NORMAL
|
|
||||||
|
|
||||||
# A list of IP addresses for which RedisBungee will not modify the response for, useful for automatic
|
# A list of IP addresses for which RedisBungee will not modify the response for, useful for automatic
|
||||||
# restart scripts.
|
# restart scripts.
|
||||||
# Automatically disabled if handle-motd is disabled.
|
# Automatically disabled if handle-motd is disabled.
|
||||||
@@ -1,30 +1,55 @@
|
|||||||
plugins {
|
plugins {
|
||||||
java
|
`java-library`
|
||||||
alias(libs.plugins.shadow)
|
`maven-publish`
|
||||||
|
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||||
|
id("xyz.jpenilla.run-waterfall") version "2.0.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":RedisBungee-Bungee"))
|
api(project(":RedisBungee-API"))
|
||||||
compileOnly(libs.platform.bungeecord)
|
compileOnly(libs.platform.bungeecord) {
|
||||||
|
exclude("com.google.guava", "guava")
|
||||||
|
exclude("com.google.code.gson", "gson")
|
||||||
|
exclude("net.kyori","adventure-api")
|
||||||
|
}
|
||||||
implementation(libs.adventure.platforms.bungeecord)
|
implementation(libs.adventure.platforms.bungeecord)
|
||||||
implementation(libs.adventure.miniMessage)
|
implementation(libs.adventure.gson)
|
||||||
implementation(libs.acf.bungeecord)
|
implementation(libs.acf.bungeecord)
|
||||||
implementation(project(":RedisBungee-Commands"))
|
implementation(project(":RedisBungee-Commands"))
|
||||||
implementation(project(":RedisBungee-Lang"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
description = "RedisBungee Bungeecord implementation"
|
description = "RedisBungee Bungeecord implementation"
|
||||||
|
|
||||||
java {
|
java {
|
||||||
|
withJavadocJar()
|
||||||
withSourcesJar()
|
withSourcesJar()
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
|
||||||
|
|
||||||
|
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.20")
|
||||||
|
environment["REDISBUNGEE_PROXY_ID"] = "bungeecord-1"
|
||||||
|
environment["REDISBUNGEE_NETWORK_ID"] = "dev"
|
||||||
|
}
|
||||||
compileJava {
|
compileJava {
|
||||||
options.encoding = Charsets.UTF_8.name()
|
options.encoding = Charsets.UTF_8.name()
|
||||||
options.release.set(17)
|
options.release.set(17)
|
||||||
}
|
}
|
||||||
|
javadoc {
|
||||||
|
options.encoding = Charsets.UTF_8.name()
|
||||||
|
}
|
||||||
processResources {
|
processResources {
|
||||||
filteringCharset = Charsets.UTF_8.name()
|
filteringCharset = Charsets.UTF_8.name()
|
||||||
filesMatching("plugin.yml") {
|
filesMatching("plugin.yml") {
|
||||||
@@ -38,8 +63,7 @@ tasks {
|
|||||||
relocate("redis.clients.jedis", "com.imaginarycode.minecraft.redisbungee.internal.jedis")
|
relocate("redis.clients.jedis", "com.imaginarycode.minecraft.redisbungee.internal.jedis")
|
||||||
relocate("redis.clients.util", "com.imaginarycode.minecraft.redisbungee.internal.jedisutil")
|
relocate("redis.clients.util", "com.imaginarycode.minecraft.redisbungee.internal.jedisutil")
|
||||||
relocate("org.apache.commons.pool", "com.imaginarycode.minecraft.redisbungee.internal.commonspool")
|
relocate("org.apache.commons.pool", "com.imaginarycode.minecraft.redisbungee.internal.commonspool")
|
||||||
relocate("okhttp3", "com.imaginarycode.minecraft.redisbungee.internal.okhttp3")
|
relocate("com.squareup.okhttp", "com.imaginarycode.minecraft.redisbungee.internal.okhttp")
|
||||||
relocate("kotlin", "com.imaginarycode.minecraft.redisbungee.internal.kotlin")
|
|
||||||
relocate("okio", "com.imaginarycode.minecraft.redisbungee.internal.okio")
|
relocate("okio", "com.imaginarycode.minecraft.redisbungee.internal.okio")
|
||||||
relocate("org.json", "com.imaginarycode.minecraft.redisbungee.internal.json")
|
relocate("org.json", "com.imaginarycode.minecraft.redisbungee.internal.json")
|
||||||
// configurate shade
|
// configurate shade
|
||||||
@@ -53,9 +77,15 @@ tasks {
|
|||||||
relocate("com.github.benmanes.caffeine", "com.imaginarycode.minecraft.redisbungee.internal.caffeine")
|
relocate("com.github.benmanes.caffeine", "com.imaginarycode.minecraft.redisbungee.internal.caffeine")
|
||||||
// acf shade
|
// acf shade
|
||||||
relocate("co.aikar.commands", "com.imaginarycode.minecraft.redisbungee.internal.acf.commands")
|
relocate("co.aikar.commands", "com.imaginarycode.minecraft.redisbungee.internal.acf.commands")
|
||||||
// adventure :/
|
|
||||||
relocate("net.kyori", "com.imaginarycode.minecraft.redisbungee.internal.net.kyori")
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
create<MavenPublication>("maven") {
|
||||||
|
from(components["java"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,13 +13,10 @@ package com.imaginarycode.minecraft.redisbungee;
|
|||||||
import com.imaginarycode.minecraft.redisbungee.api.PlayerDataManager;
|
import com.imaginarycode.minecraft.redisbungee.api.PlayerDataManager;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
||||||
import com.imaginarycode.minecraft.redisbungee.events.PlayerChangedServerNetworkEvent;
|
import com.imaginarycode.minecraft.redisbungee.events.PlayerChangedServerNetworkEvent;
|
||||||
import com.imaginarycode.minecraft.redisbungee.events.PlayerJoinedNetworkEvent;
|
|
||||||
import com.imaginarycode.minecraft.redisbungee.events.PlayerLeftNetworkEvent;
|
import com.imaginarycode.minecraft.redisbungee.events.PlayerLeftNetworkEvent;
|
||||||
import com.imaginarycode.minecraft.redisbungee.events.PubSubMessageEvent;
|
import com.imaginarycode.minecraft.redisbungee.events.PubSubMessageEvent;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
|
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.LoginEvent;
|
import net.md_5.bungee.api.event.LoginEvent;
|
||||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||||
@@ -29,38 +26,34 @@ import net.md_5.bungee.api.plugin.Listener;
|
|||||||
import net.md_5.bungee.api.plugin.Plugin;
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
|
||||||
public class BungeePlayerDataManager extends PlayerDataManager<ProxiedPlayer> implements Listener {
|
public class BungeePlayerDataManager extends PlayerDataManager<ProxiedPlayer, PostLoginEvent, PlayerDisconnectEvent, PubSubMessageEvent, PlayerChangedServerNetworkEvent, PlayerLeftNetworkEvent, ServerConnectedEvent> implements Listener {
|
||||||
|
|
||||||
private final RedisBungee bPlugin;
|
public BungeePlayerDataManager(RedisBungeePlugin<ProxiedPlayer> plugin) {
|
||||||
public BungeePlayerDataManager(RedisBungee plugin) {
|
|
||||||
super(plugin);
|
super(plugin);
|
||||||
bPlugin = plugin;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerChangedServerNetworkEvent(PlayerChangedServerNetworkEvent event) {
|
public void onPlayerChangedServerNetworkEvent(PlayerChangedServerNetworkEvent event) {
|
||||||
super.handleNetworkPlayerServerChange(event);
|
super.handleNetworkPlayerServerChange(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onNetworkPlayerQuit(PlayerLeftNetworkEvent event) {
|
public void onNetworkPlayerQuit(PlayerLeftNetworkEvent event) {
|
||||||
super.handleNetworkPlayerQuit(event);
|
super.handleNetworkPlayerQuit(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@Override
|
||||||
public void onNetworkPlayerJoin(PlayerJoinedNetworkEvent event) {
|
|
||||||
super.handleNetworkPlayerJoin(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPubSubMessageEvent(PubSubMessageEvent event) {
|
public void onPubSubMessageEvent(PubSubMessageEvent event) {
|
||||||
super.handlePubSubMessageEvent(event);
|
super.handlePubSubMessageEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onServerConnectedEvent(ServerConnectedEvent event) {
|
public void onServerConnectedEvent(ServerConnectedEvent event) {
|
||||||
final String currentServer = event.getServer().getInfo().getName();
|
final String currentServer = event.getServer().getInfo().getName();
|
||||||
@@ -68,49 +61,19 @@ public class BungeePlayerDataManager extends PlayerDataManager<ProxiedPlayer> im
|
|||||||
super.playerChangedServer(event.getPlayer().getUniqueId(), oldServer, currentServer);
|
super.playerChangedServer(event.getPlayer().getUniqueId(), oldServer, currentServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final BungeeComponentSerializer BUNGEE_COMPONENT_SERIALIZER = BungeeComponentSerializer.get();
|
|
||||||
|
|
||||||
private final static MiniMessage MINI_MESSAGE_SERIALIZER = MiniMessage.miniMessage();
|
|
||||||
@Override
|
|
||||||
public boolean handleSerializedKick(UUID uuid, String serializedMiniMessage) {
|
|
||||||
ProxiedPlayer player = plugin.getPlayer(uuid);
|
|
||||||
if (player == null) return false;
|
|
||||||
// decode the adventure component
|
|
||||||
if (serializedMiniMessage == null) {
|
|
||||||
// kick the player too even if the message is invalid
|
|
||||||
player.disconnect(BUNGEE_COMPONENT_SERIALIZER.serialize(Component.empty()));
|
|
||||||
plugin.logWarn("unable to decode serialized adventure component because its empty or null");
|
|
||||||
} else {
|
|
||||||
Component message = MINI_MESSAGE_SERIALIZER.deserialize(serializedMiniMessage);
|
|
||||||
player.disconnect(BUNGEE_COMPONENT_SERIALIZER.serialize(message));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void kickPlayer(UUID player, Component message) {
|
|
||||||
serializedPlayerKick(player, MINI_MESSAGE_SERIALIZER.serialize(message));
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onLoginEvent(LoginEvent event) {
|
public void onLoginEvent(LoginEvent event) {
|
||||||
event.registerIntent((Plugin) plugin);
|
event.registerIntent((Plugin) plugin);
|
||||||
// check if online
|
// check if online
|
||||||
if (getLastOnline(event.getConnection().getUniqueId()) == 0) {
|
if (getLastOnline(event.getConnection().getUniqueId()) == 0) {
|
||||||
// because something can go wrong and proxy somehow does not update player data correctly on shutdown
|
if (plugin.configuration().kickWhenOnline()) {
|
||||||
// we have to check proxy if it has the player
|
kickPlayer(event.getConnection().getUniqueId(), plugin.langConfiguration().messages().loggedInFromOtherLocation());
|
||||||
String proxyId = getProxyFor(event.getConnection().getUniqueId());
|
// wait 3 seconds before releasing the event
|
||||||
if (proxyId == null || !plugin.proxyDataManager().isPlayerTrulyOnProxy(proxyId, event.getConnection().getUniqueId())) {
|
plugin.executeAsyncAfter(() -> event.completeIntent((Plugin) plugin), TimeUnit.SECONDS, 3);
|
||||||
event.completeIntent((Plugin) plugin);
|
|
||||||
} else {
|
} else {
|
||||||
if (plugin.configuration().kickWhenOnline()) {
|
event.setCancelled(true);
|
||||||
kickPlayer(event.getConnection().getUniqueId(), bPlugin.langConfiguration().messages().loggedInFromOtherLocation());
|
event.setCancelReason(BungeeComponentSerializer.get().serialize(plugin.langConfiguration().messages().alreadyLoggedIn()));
|
||||||
// wait 3 seconds before releasing the event
|
event.completeIntent((Plugin) plugin);
|
||||||
plugin.executeAsyncAfter(() -> event.completeIntent((Plugin) plugin), TimeUnit.SECONDS, 3);
|
|
||||||
} else {
|
|
||||||
event.setCancelled(true);
|
|
||||||
event.setCancelReason(BungeeComponentSerializer.get().serialize(bPlugin.langConfiguration().messages().alreadyLoggedIn()));
|
|
||||||
event.completeIntent((Plugin) plugin);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
event.completeIntent((Plugin) plugin);
|
event.completeIntent((Plugin) plugin);
|
||||||
@@ -118,13 +81,13 @@ public class BungeePlayerDataManager extends PlayerDataManager<ProxiedPlayer> im
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onLoginEvent(PostLoginEvent event) {
|
public void onLoginEvent(PostLoginEvent event) {
|
||||||
super.addPlayer(event.getPlayer().getUniqueId(), event.getPlayer().getName(), event.getPlayer().getAddress().getAddress());
|
super.addPlayer(event.getPlayer().getUniqueId(), event.getPlayer().getAddress().getAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDisconnectEvent(PlayerDisconnectEvent event) {
|
public void onDisconnectEvent(PlayerDisconnectEvent event) {
|
||||||
super.removePlayer(event.getPlayer().getUniqueId());
|
super.removePlayer(event.getPlayer().getUniqueId());
|
||||||
@@ -15,15 +15,18 @@ import com.imaginarycode.minecraft.redisbungee.api.PlayerDataManager;
|
|||||||
import com.imaginarycode.minecraft.redisbungee.api.ProxyDataManager;
|
import com.imaginarycode.minecraft.redisbungee.api.ProxyDataManager;
|
||||||
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;
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.config.LangConfiguration;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.config.loaders.ConfigLoader;
|
import com.imaginarycode.minecraft.redisbungee.api.config.loaders.ConfigLoader;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.config.RedisBungeeConfiguration;
|
import com.imaginarycode.minecraft.redisbungee.api.config.RedisBungeeConfiguration;
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.config.loaders.LangConfigLoader;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerChangedServerNetworkEvent;
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerChangedServerNetworkEvent;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerJoinedNetworkEvent;
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerJoinedNetworkEvent;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerLeftNetworkEvent;
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerLeftNetworkEvent;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPubSubMessageEvent;
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPubSubMessageEvent;
|
||||||
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 com.imaginarycode.minecraft.redisbungee.api.util.InitialUtils;
|
import com.imaginarycode.minecraft.redisbungee.api.util.InitialUtils;
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.util.uuid.NameFetcher;
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.util.uuid.UUIDFetcher;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.util.uuid.UUIDTranslator;
|
import com.imaginarycode.minecraft.redisbungee.api.util.uuid.UUIDTranslator;
|
||||||
import com.imaginarycode.minecraft.redisbungee.commands.CommandLoader;
|
import com.imaginarycode.minecraft.redisbungee.commands.CommandLoader;
|
||||||
import com.imaginarycode.minecraft.redisbungee.commands.utils.CommandPlatformHelper;
|
import com.imaginarycode.minecraft.redisbungee.commands.utils.CommandPlatformHelper;
|
||||||
@@ -31,9 +34,10 @@ import com.imaginarycode.minecraft.redisbungee.events.PlayerChangedServerNetwork
|
|||||||
import com.imaginarycode.minecraft.redisbungee.events.PlayerJoinedNetworkEvent;
|
import com.imaginarycode.minecraft.redisbungee.events.PlayerJoinedNetworkEvent;
|
||||||
import com.imaginarycode.minecraft.redisbungee.events.PlayerLeftNetworkEvent;
|
import com.imaginarycode.minecraft.redisbungee.events.PlayerLeftNetworkEvent;
|
||||||
import com.imaginarycode.minecraft.redisbungee.events.PubSubMessageEvent;
|
import com.imaginarycode.minecraft.redisbungee.events.PubSubMessageEvent;
|
||||||
|
import com.squareup.okhttp.Dispatcher;
|
||||||
|
import com.squareup.okhttp.OkHttpClient;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.limework.valiobungee.config.lang.LangConfigLoader;
|
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
|
||||||
import net.limework.valiobungee.config.lang.LangConfiguration;
|
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.plugin.Event;
|
import net.md_5.bungee.api.plugin.Event;
|
||||||
@@ -46,6 +50,8 @@ import redis.clients.jedis.JedisPool;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
import java.sql.Date;
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -53,7 +59,7 @@ import java.util.concurrent.*;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
|
||||||
public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlayer>, ConfigLoader, LangConfigLoader, ApiPlatformSupport {
|
public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlayer>, ConfigLoader, LangConfigLoader {
|
||||||
|
|
||||||
private static RedisBungeeAPI apiStatic;
|
private static RedisBungeeAPI apiStatic;
|
||||||
private AbstractRedisBungeeAPI api;
|
private AbstractRedisBungeeAPI api;
|
||||||
@@ -66,6 +72,7 @@ public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlay
|
|||||||
private UUIDTranslator uuidTranslator;
|
private UUIDTranslator uuidTranslator;
|
||||||
private RedisBungeeConfiguration configuration;
|
private RedisBungeeConfiguration configuration;
|
||||||
private LangConfiguration langConfiguration;
|
private LangConfiguration langConfiguration;
|
||||||
|
private OkHttpClient httpClient;
|
||||||
private BungeeCommandManager commandManager;
|
private BungeeCommandManager commandManager;
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger("RedisBungee");
|
private final Logger logger = LoggerFactory.getLogger("RedisBungee");
|
||||||
@@ -76,6 +83,7 @@ public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlay
|
|||||||
return this.configuration;
|
return this.configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public LangConfiguration langConfiguration() {
|
public LangConfiguration langConfiguration() {
|
||||||
return this.langConfiguration;
|
return this.langConfiguration;
|
||||||
}
|
}
|
||||||
@@ -91,7 +99,7 @@ public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlay
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlayerDataManager<ProxiedPlayer> playerDataManager() {
|
public PlayerDataManager<ProxiedPlayer, ?, ?, ?, ?, ?, ?> playerDataManager() {
|
||||||
return this.playerDataManager;
|
return this.playerDataManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,6 +168,15 @@ public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlay
|
|||||||
return this.getProxy().getPlayer(player).getName();
|
return this.getProxy().getPlayer(player).getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handlePlatformKick(UUID uuid, Component message) {
|
||||||
|
ProxiedPlayer player = getPlayer(uuid);
|
||||||
|
if (player == null) return false;
|
||||||
|
if (!player.isConnected()) return false;
|
||||||
|
player.disconnect(BungeeComponentSerializer.get().serialize(message));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlayerServerName(ProxiedPlayer player) {
|
public String getPlayerServerName(ProxiedPlayer player) {
|
||||||
return player.getServer().getInfo().getName();
|
return player.getServer().getInfo().getName();
|
||||||
@@ -180,6 +197,7 @@ public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlay
|
|||||||
public void initialize() {
|
public void initialize() {
|
||||||
logInfo("Initializing RedisBungee.....");
|
logInfo("Initializing RedisBungee.....");
|
||||||
logInfo("Version: {}", Constants.VERSION);
|
logInfo("Version: {}", Constants.VERSION);
|
||||||
|
logInfo("Build date: {}", Date.from(Instant.ofEpochSecond(Constants.BUILD_DATE)));
|
||||||
ThreadFactory factory = ((ThreadPoolExecutor) getExecutorService()).getThreadFactory();
|
ThreadFactory factory = ((ThreadPoolExecutor) getExecutorService()).getThreadFactory();
|
||||||
ScheduledExecutorService service = Executors.newScheduledThreadPool(24, factory);
|
ScheduledExecutorService service = Executors.newScheduledThreadPool(24, factory);
|
||||||
try {
|
try {
|
||||||
@@ -224,6 +242,11 @@ public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlay
|
|||||||
// cleanup
|
// cleanup
|
||||||
this.cleanupTask = getProxy().getScheduler().schedule(this, () -> this.proxyDataManager.correctionTask(), 0, 60, TimeUnit.SECONDS);
|
this.cleanupTask = getProxy().getScheduler().schedule(this, () -> this.proxyDataManager.correctionTask(), 0, 60, TimeUnit.SECONDS);
|
||||||
// init the http lib
|
// init the http lib
|
||||||
|
httpClient = new OkHttpClient();
|
||||||
|
Dispatcher dispatcher = new Dispatcher(getExecutorService());
|
||||||
|
httpClient.setDispatcher(dispatcher);
|
||||||
|
NameFetcher.setHttpClient(httpClient);
|
||||||
|
UUIDFetcher.setHttpClient(httpClient);
|
||||||
InitialUtils.checkRedisVersion(this);
|
InitialUtils.checkRedisVersion(this);
|
||||||
uuidTranslator = new UUIDTranslator(this);
|
uuidTranslator = new UUIDTranslator(this);
|
||||||
|
|
||||||
@@ -327,21 +350,6 @@ public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlay
|
|||||||
this.summoner = summoner;
|
this.summoner = summoner;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLangConfigLoad(LangConfiguration langConfiguration) {
|
|
||||||
this.langConfiguration = langConfiguration;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String platformId() {
|
|
||||||
return "bungeecord";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void kickPlayer(UUID player, Component message) {
|
|
||||||
this.playerDataManager.kickPlayer(player, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This returns an instance of {@link RedisBungeeAPI}
|
* This returns an instance of {@link RedisBungeeAPI}
|
||||||
*
|
*
|
||||||
@@ -355,15 +363,12 @@ public class RedisBungee extends Plugin implements RedisBungeePlugin<ProxiedPlay
|
|||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public JedisPool getPool() {
|
public JedisPool getPool() {
|
||||||
if (api.getMode() == RedisBungeeMode.SINGLE) {
|
return api.getJedisPool();
|
||||||
JedisPool jedisPool = ((JedisPooledSummoner) getSummoner()).getCompatibilityJedisPool();
|
|
||||||
if (jedisPool == null) {
|
|
||||||
throw new IllegalStateException("JedisPool compatibility mode is disabled, Please enable it in the RedisBungee config.yml");
|
|
||||||
}
|
|
||||||
return jedisPool;
|
|
||||||
} else {
|
|
||||||
throw new IllegalStateException("Mode is not " + RedisBungeeMode.SINGLE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLangConfigLoad(LangConfiguration langConfiguration) {
|
||||||
|
this.langConfiguration = langConfiguration;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.imaginarycode.minecraft.redisbungee;
|
||||||
|
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
||||||
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This platform class exposes some internal RedisBungee functions. You obtain an instance of this object by invoking {@link RedisBungeeAPI#getRedisBungeeApi()}
|
||||||
|
* or somehow you got the Plugin instance by you can call the api using {@link RedisBungeePlugin#getAbstractRedisBungeeApi()}.
|
||||||
|
*
|
||||||
|
* @author tuxed
|
||||||
|
* @since 0.2.3 | updated 0.8.0
|
||||||
|
*/
|
||||||
|
public class RedisBungeeAPI extends AbstractRedisBungeeAPI {
|
||||||
|
|
||||||
|
private static RedisBungeeAPI redisBungeeApi;
|
||||||
|
|
||||||
|
public RedisBungeeAPI(RedisBungeePlugin<?> plugin) {
|
||||||
|
super(plugin);
|
||||||
|
if (redisBungeeApi == null) {
|
||||||
|
redisBungeeApi = this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the server where the specified player is playing. This function also deals with the case of local players
|
||||||
|
* as well, and will return local information on them.
|
||||||
|
*
|
||||||
|
* @param player a player uuid
|
||||||
|
* @return {@link ServerInfo} Can be null if proxy can't find it.
|
||||||
|
* @see #getServerNameFor(UUID)
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public final ServerInfo getServerFor(@NonNull UUID player) {
|
||||||
|
String serverName = this.getServerNameFor(player);
|
||||||
|
if (serverName == null) return null;
|
||||||
|
return ((Plugin) this.plugin).getProxy().getServerInfo(serverName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Api instance
|
||||||
|
*
|
||||||
|
* @return the API instance.
|
||||||
|
* @since 0.6.5
|
||||||
|
*/
|
||||||
|
public static RedisBungeeAPI getRedisBungeeApi() {
|
||||||
|
return redisBungeeApi;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ import com.google.common.io.ByteArrayDataInput;
|
|||||||
import com.google.common.io.ByteArrayDataOutput;
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.config.HandleMotdOrder;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
|
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
|
||||||
import net.md_5.bungee.api.AbstractReconnectHandler;
|
import net.md_5.bungee.api.AbstractReconnectHandler;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
@@ -29,7 +29,6 @@ import net.md_5.bungee.api.event.ProxyPingEvent;
|
|||||||
import net.md_5.bungee.api.event.ServerConnectEvent;
|
import net.md_5.bungee.api.event.ServerConnectEvent;
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
import net.md_5.bungee.event.EventPriority;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -37,37 +36,14 @@ import static com.imaginarycode.minecraft.redisbungee.api.util.serialize.MultiMa
|
|||||||
|
|
||||||
public class RedisBungeeListener implements Listener {
|
public class RedisBungeeListener implements Listener {
|
||||||
|
|
||||||
private final RedisBungee plugin;
|
private final RedisBungeePlugin<ProxiedPlayer> plugin;
|
||||||
|
|
||||||
public RedisBungeeListener(RedisBungee plugin) {
|
public RedisBungeeListener(RedisBungeePlugin<ProxiedPlayer> plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler
|
||||||
public void onPingFirst(ProxyPingEvent event) {
|
public void onPing(ProxyPingEvent event) {
|
||||||
if (plugin.configuration().handleMotdOrder() != HandleMotdOrder.FIRST) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
onPing0(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
|
||||||
public void onPingNormal(ProxyPingEvent event) {
|
|
||||||
if (plugin.configuration().handleMotdOrder() != HandleMotdOrder.NORMAL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
onPing0(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
|
||||||
public void onPingLast(ProxyPingEvent event) {
|
|
||||||
if (plugin.configuration().handleMotdOrder() != HandleMotdOrder.LAST) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
onPing0(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onPing0(ProxyPingEvent event) {
|
|
||||||
if (!plugin.configuration().handleMotd()) return;
|
if (!plugin.configuration().handleMotd()) return;
|
||||||
if (plugin.configuration().getExemptAddresses().contains(event.getConnection().getAddress().getAddress())) return;
|
if (plugin.configuration().getExemptAddresses().contains(event.getConnection().getAddress().getAddress())) return;
|
||||||
ServerInfo forced = AbstractReconnectHandler.getForcedHost(event.getConnection());
|
ServerInfo forced = AbstractReconnectHandler.getForcedHost(event.getConnection());
|
||||||
@@ -3,10 +3,8 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":RedisBungee-API"))
|
implementation(project(":RedisBungee-API"))
|
||||||
implementation(libs.acf.core)
|
implementation(libs.acf.core)
|
||||||
compileOnly(libs.adventure.api)
|
|
||||||
compileOnly(libs.adventure.miniMessage)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
description = "RedisBungee common commands"
|
description = "RedisBungee common commands"
|
||||||
@@ -10,19 +10,14 @@
|
|||||||
|
|
||||||
package com.imaginarycode.minecraft.redisbungee.commands;
|
package com.imaginarycode.minecraft.redisbungee.commands;
|
||||||
|
|
||||||
import co.aikar.commands.CommandContexts;
|
|
||||||
import co.aikar.commands.CommandManager;
|
import co.aikar.commands.CommandManager;
|
||||||
import co.aikar.commands.InvalidCommandArgument;
|
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
||||||
|
|
||||||
import com.imaginarycode.minecraft.redisbungee.commands.legacy.LegacyRedisBungeeCommands;
|
import com.imaginarycode.minecraft.redisbungee.commands.legacy.LegacyRedisBungeeCommands;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class CommandLoader {
|
public class CommandLoader {
|
||||||
|
|
||||||
public static void initCommands(CommandManager<?, ?, ?, ?, ?, ?> commandManager, RedisBungeePlugin<?> plugin) {
|
public static void initCommands(CommandManager<?, ?, ?, ?, ?, ?> commandManager, RedisBungeePlugin<?> plugin) {
|
||||||
registerContexts(commandManager);
|
|
||||||
var commandsConfiguration = plugin.configuration().commandsConfiguration();
|
var commandsConfiguration = plugin.configuration().commandsConfiguration();
|
||||||
if (commandsConfiguration.redisbungeeEnabled()) {
|
if (commandsConfiguration.redisbungeeEnabled()) {
|
||||||
commandManager.registerCommand(new CommandRedisBungee(plugin));
|
commandManager.registerCommand(new CommandRedisBungee(plugin));
|
||||||
@@ -31,20 +26,6 @@ public class CommandLoader {
|
|||||||
commandManager.registerCommand(new LegacyRedisBungeeCommands(commandManager,plugin));
|
commandManager.registerCommand(new LegacyRedisBungeeCommands(commandManager,plugin));
|
||||||
}
|
}
|
||||||
|
|
||||||
commandManager.registerCommand(new CommandRedisBungeeDebug(plugin));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
private static void registerContexts(CommandManager<?, ?, ?, ?, ?, ?> commandManager) {
|
|
||||||
CommandContexts<?> commandContexts = commandManager.getCommandContexts();
|
|
||||||
commandContexts.registerContext(UUID.class, c -> {
|
|
||||||
String uuidString = c.popFirstArg();
|
|
||||||
try {
|
|
||||||
return UUID.fromString(uuidString);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
throw new InvalidCommandArgument("invaild uuid");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,6 @@
|
|||||||
package com.imaginarycode.minecraft.redisbungee.commands;
|
package com.imaginarycode.minecraft.redisbungee.commands;
|
||||||
|
|
||||||
import co.aikar.commands.CommandIssuer;
|
import co.aikar.commands.CommandIssuer;
|
||||||
import co.aikar.commands.RegisteredCommand;
|
|
||||||
import co.aikar.commands.annotation.*;
|
import co.aikar.commands.annotation.*;
|
||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
import com.imaginarycode.minecraft.redisbungee.Constants;
|
import com.imaginarycode.minecraft.redisbungee.Constants;
|
||||||
@@ -27,12 +26,12 @@ import net.kyori.adventure.text.minimessage.MiniMessage;
|
|||||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@CommandAlias("rb|redisbungee")
|
@CommandAlias("rb|redisbungee")
|
||||||
@CommandPermission("redisbungee.command.use")
|
@CommandPermission("redisbungee.command.use")
|
||||||
@Description("Main command")
|
|
||||||
public class CommandRedisBungee extends AdventureBaseCommand {
|
public class CommandRedisBungee extends AdventureBaseCommand {
|
||||||
|
|
||||||
private final RedisBungeePlugin<?> plugin;
|
private final RedisBungeePlugin<?> plugin;
|
||||||
@@ -43,12 +42,12 @@ public class CommandRedisBungee extends AdventureBaseCommand {
|
|||||||
|
|
||||||
@Default
|
@Default
|
||||||
@Subcommand("info|version|git")
|
@Subcommand("info|version|git")
|
||||||
@Description("information about current redisbungee build")
|
|
||||||
public void info(CommandIssuer issuer) {
|
public void info(CommandIssuer issuer) {
|
||||||
final String message = """
|
final String message = """
|
||||||
<color:aqua>This proxy is running RedisBungee Limework's fork
|
<color:aqua>This proxy is running RedisBungee Limework's fork
|
||||||
<color:gold>========================================
|
<color:gold>========================================
|
||||||
<color:aqua>RedisBungee version: <color:green><version>
|
<color:aqua>RedisBungee version: <color:green><version>
|
||||||
|
<color:aqua>Build date: <color:green><build-date>
|
||||||
<color:aqua>Commit: <color:green><commit>
|
<color:aqua>Commit: <color:green><commit>
|
||||||
<color:gold>========================================
|
<color:gold>========================================
|
||||||
<color:gold>run /rb help for more commands""";
|
<color:gold>run /rb help for more commands""";
|
||||||
@@ -58,6 +57,7 @@ public class CommandRedisBungee extends AdventureBaseCommand {
|
|||||||
.deserialize(
|
.deserialize(
|
||||||
message,
|
message,
|
||||||
Placeholder.component("version", Component.text(Constants.VERSION)),
|
Placeholder.component("version", Component.text(Constants.VERSION)),
|
||||||
|
Placeholder.component("build-date", Component.text( new Date(Constants.BUILD_DATE * 1000).toString() )),
|
||||||
Placeholder.component(
|
Placeholder.component(
|
||||||
"commit",
|
"commit",
|
||||||
Component.text(Constants.GIT_COMMIT.substring(0, 8))
|
Component.text(Constants.GIT_COMMIT.substring(0, 8))
|
||||||
@@ -67,29 +67,19 @@ public class CommandRedisBungee extends AdventureBaseCommand {
|
|||||||
}
|
}
|
||||||
// <color:aqua>......: <color:green>......
|
// <color:aqua>......: <color:green>......
|
||||||
@HelpCommand
|
@HelpCommand
|
||||||
@Description("shows the help page")
|
|
||||||
public void help(CommandIssuer issuer) {
|
public void help(CommandIssuer issuer) {
|
||||||
final String barFormat = "<color:gold>========================================";
|
final String message = """
|
||||||
final String commandFormat = "<color:aqua>/rb <sub-command>: <color:green><description>";
|
<color:gold>========================================
|
||||||
|
<color:aqua>/rb info: <color:green>shows info of this version.
|
||||||
TextComponent.Builder message = Component.text();
|
<color:aqua>/rb help: <color:green>shows this page.
|
||||||
message.append(MiniMessage.miniMessage().deserialize(barFormat));
|
<color:aqua>/rb clean: <color:green>cleans up the uuid cache
|
||||||
|
<color:red><bold>WARNING...</bold> <color:white>command above could cause performance issues
|
||||||
getSubCommands().forEach((subCommand, registeredCommand) -> {
|
<color:aqua>/rb show: <color:green>shows list of proxies with player count
|
||||||
String[] split = registeredCommand.getCommand().split(" ");
|
<color:gold>========================================
|
||||||
if (split.length > 1 && subCommand.equalsIgnoreCase(split[1])) {
|
<color:gold>run /rb help for more commands""";
|
||||||
message.appendNewline().append(MiniMessage.miniMessage().deserialize(commandFormat, Placeholder.component("sub-command", Component.text(subCommand)),
|
sendMessage(issuer, MiniMessage.miniMessage().deserialize(message));
|
||||||
Placeholder.component("description", MiniMessage.miniMessage().deserialize(registeredCommand.getHelpText()))
|
|
||||||
));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
message.appendNewline().append(MiniMessage.miniMessage().deserialize(barFormat));
|
|
||||||
|
|
||||||
sendMessage(issuer, message.build());
|
|
||||||
}
|
}
|
||||||
@Subcommand("clean")
|
@Subcommand("clean")
|
||||||
@Description("cleans up the uuid cache<color:red> <bold>WARNING...</bold> <color:white>command above could cause performance issues")
|
|
||||||
@Private
|
@Private
|
||||||
public void cleanUp(CommandIssuer issuer) {
|
public void cleanUp(CommandIssuer issuer) {
|
||||||
if (StopperUUIDCleanupTask.isRunning) {
|
if (StopperUUIDCleanupTask.isRunning) {
|
||||||
@@ -109,7 +99,6 @@ public class CommandRedisBungee extends AdventureBaseCommand {
|
|||||||
|
|
||||||
}
|
}
|
||||||
@Subcommand("show")
|
@Subcommand("show")
|
||||||
@Description("Shows proxies in this network")
|
|
||||||
public void showProxies(CommandIssuer issuer, String[] args) {
|
public void showProxies(CommandIssuer issuer, String[] args) {
|
||||||
final String closer = "<color:gold>========================================";
|
final String closer = "<color:gold>========================================";
|
||||||
final String pageTop = "<color:yellow>Page: <color:green><current>/<max> <color:yellow>Network ID: <color:green><network> <color:yellow>Proxies online: <color:green><proxies>";
|
final String pageTop = "<color:yellow>Page: <color:green><current>/<max> <color:yellow>Network ID: <color:green><network> <color:yellow>Proxies online: <color:green><proxies>";
|
||||||
@@ -134,6 +123,15 @@ public class CommandRedisBungee extends AdventureBaseCommand {
|
|||||||
} else currentPage = 1;
|
} else currentPage = 1;
|
||||||
|
|
||||||
var data = new ArrayList<>(plugin.proxyDataManager().eachProxyCount().entrySet());
|
var data = new ArrayList<>(plugin.proxyDataManager().eachProxyCount().entrySet());
|
||||||
|
data.addAll(data);
|
||||||
|
data.addAll(data);
|
||||||
|
data.addAll(data);
|
||||||
|
data.addAll(data);
|
||||||
|
data.addAll(data);
|
||||||
|
data.addAll(data);
|
||||||
|
data.addAll(data);
|
||||||
|
data.addAll(data);
|
||||||
|
|
||||||
// there is no way this runs because there is always an heartbeat.
|
// there is no way this runs because there is always an heartbeat.
|
||||||
// if not could be some shenanigans done by devs :P
|
// if not could be some shenanigans done by devs :P
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
@@ -141,7 +139,7 @@ public class CommandRedisBungee extends AdventureBaseCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// compute the total pages
|
// compute the total pages
|
||||||
int maxPages = (int) Math.ceil(data.size() / (double) pageSize);
|
int maxPages = data.size() < pageSize ? 1 : data.size() / pageSize ;
|
||||||
if (currentPage > maxPages) currentPage = maxPages;
|
if (currentPage > maxPages) currentPage = maxPages;
|
||||||
var subList = subListProxies(data, currentPage, pageSize);
|
var subList = subListProxies(data, currentPage, pageSize);
|
||||||
TextComponent.Builder builder = Component.text();
|
TextComponent.Builder builder = Component.text();
|
||||||
@@ -171,19 +169,17 @@ public class CommandRedisBungee extends AdventureBaseCommand {
|
|||||||
}
|
}
|
||||||
if (currentPage > 1) {
|
if (currentPage > 1) {
|
||||||
builder.append(MiniMessage.miniMessage().deserialize(previousPage)
|
builder.append(MiniMessage.miniMessage().deserialize(previousPage)
|
||||||
.color(NamedTextColor.WHITE).clickEvent(ClickEvent.runCommand("/rb show " + (currentPage - 1))));
|
.clickEvent(ClickEvent.runCommand("/rb show " + (currentPage - 1))));
|
||||||
} else {
|
|
||||||
builder.append(MiniMessage.miniMessage().deserialize(previousPage).color(NamedTextColor.GRAY));
|
|
||||||
}
|
}
|
||||||
if (subList.size() == pageSize && !subListProxies(data, currentPage + 1, pageSize).isEmpty()) {
|
if (subList.size() == pageSize && !subListProxies(data, currentPage + 1, pageSize).isEmpty()) {
|
||||||
builder.append(MiniMessage.miniMessage().deserialize(nextPage)
|
builder.append(MiniMessage.miniMessage().deserialize(nextPage)
|
||||||
.color(NamedTextColor.WHITE).clickEvent(ClickEvent.runCommand("/rb show " + (currentPage + 1))));
|
.clickEvent(ClickEvent.runCommand("/rb show " + (currentPage + 1))));
|
||||||
} else {
|
|
||||||
builder.append(MiniMessage.miniMessage().deserialize(nextPage).color(NamedTextColor.GRAY));
|
|
||||||
}
|
}
|
||||||
builder.appendNewline();
|
builder.appendNewline();
|
||||||
builder.append(MiniMessage.miniMessage().deserialize(closer));
|
builder.append(MiniMessage.miniMessage().deserialize(closer));
|
||||||
sendMessage(issuer, builder.build());
|
sendMessage(issuer, builder.build());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,7 @@ import net.kyori.adventure.text.Component;
|
|||||||
*/
|
*/
|
||||||
public abstract class AdventureBaseCommand extends BaseCommand {
|
public abstract class AdventureBaseCommand extends BaseCommand {
|
||||||
|
|
||||||
protected void sendMessage(CommandIssuer issuer, Component component) {
|
public static void sendMessage(CommandIssuer issuer, Component component) {
|
||||||
CommandPlatformHelper.getPlatformHelper().sendMessage(issuer, component);
|
CommandPlatformHelper.getPlatformHelper().sendMessage(issuer, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
84
RedisBungee-Velocity/build.gradle.kts
Normal file
84
RedisBungee-Velocity/build.gradle.kts
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
plugins {
|
||||||
|
`java-library`
|
||||||
|
`maven-publish`
|
||||||
|
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||||
|
id("xyz.jpenilla.run-velocity") version "2.0.0"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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")
|
||||||
|
// exclude also adventure api
|
||||||
|
exclude("net.kyori", "adventure-api")
|
||||||
|
exclude("net.kyori", "adventure-text-serializer-gson")
|
||||||
|
exclude("net.kyori", "adventure-text-serializer-legacy")
|
||||||
|
exclude("net.kyori", "adventure-text-serializer-plain")
|
||||||
|
exclude("net.kyori", "adventure-text-minimessage")
|
||||||
|
}
|
||||||
|
compileOnly(libs.platform.velocity)
|
||||||
|
annotationProcessor(libs.platform.velocity)
|
||||||
|
implementation(project(":RedisBungee-Commands"))
|
||||||
|
implementation(libs.acf.velocity)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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.3.0-SNAPSHOT")
|
||||||
|
environment["REDISBUNGEE_PROXY_ID"] = "velocity-1"
|
||||||
|
environment["REDISBUNGEE_NETWORK_ID"] = "dev"
|
||||||
|
}
|
||||||
|
compileJava {
|
||||||
|
options.encoding = Charsets.UTF_8.name()
|
||||||
|
options.release.set(17)
|
||||||
|
}
|
||||||
|
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")
|
||||||
|
relocate("com.github.benmanes.caffeine", "com.imaginarycode.minecraft.redisbungee.internal.caffeine")
|
||||||
|
// acf shade
|
||||||
|
relocate("co.aikar.commands", "com.imaginarycode.minecraft.redisbungee.internal.acf.commands")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
create<MavenPublication>("maven") {
|
||||||
|
from(components["java"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,7 +13,6 @@ package com.imaginarycode.minecraft.redisbungee;
|
|||||||
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
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 net.kyori.adventure.text.Component;
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
@@ -50,33 +49,9 @@ public class RedisBungeeAPI extends AbstractRedisBungeeAPI {
|
|||||||
public final ServerInfo getServerFor(@NonNull UUID player) {
|
public final ServerInfo getServerFor(@NonNull UUID player) {
|
||||||
String serverName = this.getServerNameFor(player);
|
String serverName = this.getServerNameFor(player);
|
||||||
if (serverName == null) return null;
|
if (serverName == null) return null;
|
||||||
return ((ApiPlatformSupport) this.plugin).getProxy().getServer(serverName).map((RegisteredServer::getServerInfo)).orElse(null);
|
return ((RedisBungeeVelocityPlugin) this.plugin).getProxy().getServer(serverName).map((RegisteredServer::getServerInfo)).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Kicks a player from the network
|
|
||||||
* calls {@link #getUuidFromName(String)} to get uuid
|
|
||||||
*
|
|
||||||
* @param playerName player name
|
|
||||||
* @param message kick message that player will see on kick
|
|
||||||
* @since 0.12.0
|
|
||||||
*/
|
|
||||||
public void kickPlayer(String playerName, Component message) {
|
|
||||||
kickPlayer(getUuidFromName(playerName), message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Kicks a player from the network
|
|
||||||
*
|
|
||||||
* @param playerUUID player name
|
|
||||||
* @param message kick message that player will see on kick
|
|
||||||
* @since 0.12.0
|
|
||||||
*/
|
|
||||||
public void kickPlayer(UUID playerUUID, Component message) {
|
|
||||||
((ApiPlatformSupport) this.plugin).kickPlayer(playerUUID, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Api instance
|
* Api instance
|
||||||
*
|
*
|
||||||
@@ -17,7 +17,6 @@ import com.google.common.io.ByteArrayDataInput;
|
|||||||
import com.google.common.io.ByteArrayDataOutput;
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.config.HandleMotdOrder;
|
|
||||||
import com.velocitypowered.api.event.PostOrder;
|
import com.velocitypowered.api.event.PostOrder;
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||||
@@ -27,6 +26,7 @@ import com.velocitypowered.api.proxy.Player;
|
|||||||
import com.velocitypowered.api.proxy.ServerConnection;
|
import com.velocitypowered.api.proxy.ServerConnection;
|
||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
import com.velocitypowered.api.proxy.server.ServerPing;
|
import com.velocitypowered.api.proxy.server.ServerPing;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -36,37 +36,14 @@ import static com.imaginarycode.minecraft.redisbungee.api.util.serialize.MultiMa
|
|||||||
|
|
||||||
public class RedisBungeeListener {
|
public class RedisBungeeListener {
|
||||||
|
|
||||||
private final RedisBungeeVelocityPlugin plugin;
|
private final RedisBungeePlugin<Player> plugin;
|
||||||
|
|
||||||
public RedisBungeeListener(RedisBungeeVelocityPlugin plugin) {
|
public RedisBungeeListener(RedisBungeePlugin<Player> plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe(order = PostOrder.FIRST)
|
@Subscribe(order = PostOrder.LAST) // some plugins changes it online players so we need to be executed as last
|
||||||
public void onPingFirst(ProxyPingEvent event) {
|
public void onPing(ProxyPingEvent event) {
|
||||||
if (plugin.configuration().handleMotdOrder() != HandleMotdOrder.FIRST) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
onPing0(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe(order = PostOrder.NORMAL)
|
|
||||||
public void onPingNormal(ProxyPingEvent event) {
|
|
||||||
if (plugin.configuration().handleMotdOrder() != HandleMotdOrder.NORMAL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
onPing0(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe(order = PostOrder.LAST)
|
|
||||||
public void onPingLast(ProxyPingEvent event) {
|
|
||||||
if (plugin.configuration().handleMotdOrder() != HandleMotdOrder.LAST) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
onPing0(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onPing0(ProxyPingEvent event) {
|
|
||||||
if (!plugin.configuration().handleMotd()) return;
|
if (!plugin.configuration().handleMotd()) return;
|
||||||
if (plugin.configuration().getExemptAddresses().contains(event.getConnection().getRemoteAddress().getAddress())) return;
|
if (plugin.configuration().getExemptAddresses().contains(event.getConnection().getRemoteAddress().getAddress())) return;
|
||||||
|
|
||||||
@@ -169,11 +146,8 @@ public class RedisBungeeListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
// ServerConnection throws IllegalStateException when connection dies somehow so just ignore :/
|
((ServerConnection) event.getSource()).sendPluginMessage(event.getIdentifier(), out.toByteArray());
|
||||||
((ServerConnection) event.getSource()).sendPluginMessage(event.getIdentifier(), out.toByteArray());
|
|
||||||
} catch (IllegalStateException ignored) {
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -18,19 +18,25 @@ import com.imaginarycode.minecraft.redisbungee.api.RedisBungeeMode;
|
|||||||
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
||||||
import com.imaginarycode.minecraft.redisbungee.commands.CommandLoader;
|
import com.imaginarycode.minecraft.redisbungee.commands.CommandLoader;
|
||||||
import com.imaginarycode.minecraft.redisbungee.commands.utils.CommandPlatformHelper;
|
import com.imaginarycode.minecraft.redisbungee.commands.utils.CommandPlatformHelper;
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.config.LangConfiguration;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.config.loaders.ConfigLoader;
|
import com.imaginarycode.minecraft.redisbungee.api.config.loaders.ConfigLoader;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.config.RedisBungeeConfiguration;
|
import com.imaginarycode.minecraft.redisbungee.api.config.RedisBungeeConfiguration;
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.config.loaders.LangConfigLoader;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerChangedServerNetworkEvent;
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerChangedServerNetworkEvent;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerJoinedNetworkEvent;
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerJoinedNetworkEvent;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerLeftNetworkEvent;
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPlayerLeftNetworkEvent;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.events.IPubSubMessageEvent;
|
import com.imaginarycode.minecraft.redisbungee.api.events.IPubSubMessageEvent;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.summoners.Summoner;
|
import com.imaginarycode.minecraft.redisbungee.api.summoners.Summoner;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.util.InitialUtils;
|
import com.imaginarycode.minecraft.redisbungee.api.util.InitialUtils;
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.util.uuid.NameFetcher;
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.util.uuid.UUIDFetcher;
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.util.uuid.UUIDTranslator;
|
import com.imaginarycode.minecraft.redisbungee.api.util.uuid.UUIDTranslator;
|
||||||
import com.imaginarycode.minecraft.redisbungee.events.PlayerChangedServerNetworkEvent;
|
import com.imaginarycode.minecraft.redisbungee.events.PlayerChangedServerNetworkEvent;
|
||||||
import com.imaginarycode.minecraft.redisbungee.events.PlayerJoinedNetworkEvent;
|
import com.imaginarycode.minecraft.redisbungee.events.PlayerJoinedNetworkEvent;
|
||||||
import com.imaginarycode.minecraft.redisbungee.events.PlayerLeftNetworkEvent;
|
import com.imaginarycode.minecraft.redisbungee.events.PlayerLeftNetworkEvent;
|
||||||
import com.imaginarycode.minecraft.redisbungee.events.PubSubMessageEvent;
|
import com.imaginarycode.minecraft.redisbungee.events.PubSubMessageEvent;
|
||||||
|
import com.squareup.okhttp.Dispatcher;
|
||||||
|
import com.squareup.okhttp.OkHttpClient;
|
||||||
import com.velocitypowered.api.event.PostOrder;
|
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;
|
||||||
@@ -44,8 +50,6 @@ import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
|
|||||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||||
import com.velocitypowered.api.scheduler.ScheduledTask;
|
import com.velocitypowered.api.scheduler.ScheduledTask;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.limework.valiobungee.config.lang.LangConfiguration;
|
|
||||||
import net.limework.valiobungee.config.lang.LangConfigLoader;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import redis.clients.jedis.exceptions.JedisConnectionException;
|
import redis.clients.jedis.exceptions.JedisConnectionException;
|
||||||
|
|
||||||
@@ -53,15 +57,18 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.sql.Date;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Plugin(id = "redisbungee", name = "RedisBungee", version = Constants.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, LangConfigLoader, ApiPlatformSupport {
|
public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, ConfigLoader, LangConfigLoader {
|
||||||
private final ProxyServer server;
|
private final ProxyServer server;
|
||||||
private final Logger logger;
|
private final Logger logger;
|
||||||
private final Path dataFolder;
|
private final Path dataFolder;
|
||||||
@@ -71,6 +78,7 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, Con
|
|||||||
private final UUIDTranslator uuidTranslator;
|
private final UUIDTranslator uuidTranslator;
|
||||||
private RedisBungeeConfiguration configuration;
|
private RedisBungeeConfiguration configuration;
|
||||||
private LangConfiguration langConfiguration;
|
private LangConfiguration langConfiguration;
|
||||||
|
private final OkHttpClient httpClient;
|
||||||
|
|
||||||
private final ProxyDataManager proxyDataManager;
|
private final ProxyDataManager proxyDataManager;
|
||||||
|
|
||||||
@@ -94,6 +102,7 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, Con
|
|||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.dataFolder = dataDirectory;
|
this.dataFolder = dataDirectory;
|
||||||
logInfo("Version: {}", Constants.VERSION);
|
logInfo("Version: {}", Constants.VERSION);
|
||||||
|
logInfo("Build date: {}", Date.from(Instant.ofEpochSecond(Constants.BUILD_DATE)));
|
||||||
try {
|
try {
|
||||||
loadConfig(this, dataDirectory);
|
loadConfig(this, dataDirectory);
|
||||||
loadLangConfig(this, dataDirectory);
|
loadLangConfig(this, dataDirectory);
|
||||||
@@ -119,6 +128,11 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, Con
|
|||||||
};
|
};
|
||||||
this.playerDataManager = new VelocityPlayerDataManager(this);
|
this.playerDataManager = new VelocityPlayerDataManager(this);
|
||||||
uuidTranslator = new UUIDTranslator(this);
|
uuidTranslator = new UUIDTranslator(this);
|
||||||
|
this.httpClient = new OkHttpClient();
|
||||||
|
Dispatcher dispatcher = new Dispatcher(Executors.newFixedThreadPool(6));
|
||||||
|
this.httpClient.setDispatcher(dispatcher);
|
||||||
|
NameFetcher.setHttpClient(httpClient);
|
||||||
|
UUIDFetcher.setHttpClient(httpClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -138,7 +152,7 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, Con
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlayerDataManager<Player> playerDataManager() {
|
public PlayerDataManager<Player, ?, ?, ?, ?, ?, ?> playerDataManager() {
|
||||||
return this.playerDataManager;
|
return this.playerDataManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,6 +217,7 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, Con
|
|||||||
return this.configuration;
|
return this.configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public LangConfiguration langConfiguration() {
|
public LangConfiguration langConfiguration() {
|
||||||
return this.langConfiguration;
|
return this.langConfiguration;
|
||||||
}
|
}
|
||||||
@@ -227,6 +242,15 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, Con
|
|||||||
return this.getProxy().getPlayer(player).map(Player::getUsername).orElse(null);
|
return this.getProxy().getPlayer(player).map(Player::getUsername).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handlePlatformKick(UUID uuid, Component message) {
|
||||||
|
Player player = getPlayer(uuid);
|
||||||
|
if (player == null) return false;
|
||||||
|
player.disconnect(message);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlayerServerName(Player player) {
|
public String getPlayerServerName(Player player) {
|
||||||
return player.getCurrentServer().map(serverConnection -> serverConnection.getServerInfo().getName()).orElse(null);
|
return player.getCurrentServer().map(serverConnection -> serverConnection.getServerInfo().getName()).orElse(null);
|
||||||
@@ -277,6 +301,8 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, Con
|
|||||||
if (heartbeatTask != null) {
|
if (heartbeatTask != null) {
|
||||||
heartbeatTask.cancel();
|
heartbeatTask.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.proxyDataManager.close();
|
this.proxyDataManager.close();
|
||||||
this.jedisSummoner.close();
|
this.jedisSummoner.close();
|
||||||
@@ -284,6 +310,13 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, Con
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.httpClient.getDispatcher().getExecutorService().shutdown();
|
||||||
|
try {
|
||||||
|
logInfo("waiting for httpclient thread-pool termination.....");
|
||||||
|
this.httpClient.getDispatcher().getExecutorService().awaitTermination(20, TimeUnit.SECONDS);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
if (commandManager != null) commandManager.unregisterCommands();
|
if (commandManager != null) commandManager.unregisterCommands();
|
||||||
logInfo("RedisBungee shutdown complete");
|
logInfo("RedisBungee shutdown complete");
|
||||||
}
|
}
|
||||||
@@ -341,11 +374,6 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, Con
|
|||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void kickPlayer(UUID player, Component message) {
|
|
||||||
this.playerDataManager.kickPlayer(player, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Logger getLogger() {
|
public Logger getLogger() {
|
||||||
return logger;
|
return logger;
|
||||||
}
|
}
|
||||||
@@ -357,9 +385,4 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player>, Con
|
|||||||
public InputStream getResourceAsStream(String name) {
|
public InputStream getResourceAsStream(String name) {
|
||||||
return this.getClass().getClassLoader().getResourceAsStream(name);
|
return this.getClass().getClassLoader().getResourceAsStream(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String platformId() {
|
|
||||||
return "velocity";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -11,8 +11,9 @@
|
|||||||
package com.imaginarycode.minecraft.redisbungee;
|
package com.imaginarycode.minecraft.redisbungee;
|
||||||
|
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.PlayerDataManager;
|
import com.imaginarycode.minecraft.redisbungee.api.PlayerDataManager;
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
||||||
|
import com.imaginarycode.minecraft.redisbungee.api.config.RedisBungeeConfiguration;
|
||||||
import com.imaginarycode.minecraft.redisbungee.events.PlayerChangedServerNetworkEvent;
|
import com.imaginarycode.minecraft.redisbungee.events.PlayerChangedServerNetworkEvent;
|
||||||
import com.imaginarycode.minecraft.redisbungee.events.PlayerJoinedNetworkEvent;
|
|
||||||
import com.imaginarycode.minecraft.redisbungee.events.PlayerLeftNetworkEvent;
|
import com.imaginarycode.minecraft.redisbungee.events.PlayerLeftNetworkEvent;
|
||||||
import com.imaginarycode.minecraft.redisbungee.events.PubSubMessageEvent;
|
import com.imaginarycode.minecraft.redisbungee.events.PubSubMessageEvent;
|
||||||
import com.velocitypowered.api.event.Continuation;
|
import com.velocitypowered.api.event.Continuation;
|
||||||
@@ -24,41 +25,33 @@ import com.velocitypowered.api.event.connection.PostLoginEvent;
|
|||||||
import com.velocitypowered.api.event.player.ServerConnectedEvent;
|
import com.velocitypowered.api.event.player.ServerConnectedEvent;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class VelocityPlayerDataManager extends PlayerDataManager<Player> {
|
public class VelocityPlayerDataManager extends PlayerDataManager<Player, PostLoginEvent, DisconnectEvent, PubSubMessageEvent, PlayerChangedServerNetworkEvent, PlayerLeftNetworkEvent, ServerConnectedEvent> {
|
||||||
|
public VelocityPlayerDataManager(RedisBungeePlugin<Player> plugin) {
|
||||||
private final RedisBungeeVelocityPlugin vplugin;
|
|
||||||
|
|
||||||
public VelocityPlayerDataManager(RedisBungeeVelocityPlugin plugin) {
|
|
||||||
super(plugin);
|
super(plugin);
|
||||||
this.vplugin = plugin;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onPlayerChangedServerNetworkEvent(PlayerChangedServerNetworkEvent event) {
|
public void onPlayerChangedServerNetworkEvent(PlayerChangedServerNetworkEvent event) {
|
||||||
handleNetworkPlayerServerChange(event);
|
handleNetworkPlayerServerChange(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onNetworkPlayerQuit(PlayerLeftNetworkEvent event) {
|
public void onNetworkPlayerQuit(PlayerLeftNetworkEvent event) {
|
||||||
handleNetworkPlayerQuit(event);
|
handleNetworkPlayerQuit(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Override
|
||||||
public void onNetworkPlayerJoin(PlayerJoinedNetworkEvent event) {
|
|
||||||
handleNetworkPlayerJoin(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onPubSubMessageEvent(PubSubMessageEvent event) {
|
public void onPubSubMessageEvent(PubSubMessageEvent event) {
|
||||||
handlePubSubMessageEvent(event);
|
handlePubSubMessageEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onServerConnectedEvent(ServerConnectedEvent event) {
|
public void onServerConnectedEvent(ServerConnectedEvent event) {
|
||||||
final String currentServer = event.getServer().getServerInfo().getName();
|
final String currentServer = event.getServer().getServerInfo().getName();
|
||||||
@@ -71,56 +64,30 @@ public class VelocityPlayerDataManager extends PlayerDataManager<Player> {
|
|||||||
super.playerChangedServer(event.getPlayer().getUniqueId(), oldServer, currentServer);
|
super.playerChangedServer(event.getPlayer().getUniqueId(), oldServer, currentServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static MiniMessage MINI_MESSAGE_SERIALIZER = MiniMessage.miniMessage();
|
|
||||||
@Override
|
|
||||||
public boolean handleSerializedKick(UUID uuid, String serializedMiniMessage) {
|
|
||||||
Player player = plugin.getPlayer(uuid);
|
|
||||||
if (player == null) return false;
|
|
||||||
// decode the adventure component
|
|
||||||
if (serializedMiniMessage == null) {
|
|
||||||
// kick the player too even if the message is invalid
|
|
||||||
player.disconnect(Component.empty());
|
|
||||||
plugin.logWarn("unable to decode serialized adventure component because its empty or null");
|
|
||||||
} else {
|
|
||||||
Component message = MINI_MESSAGE_SERIALIZER.deserialize(serializedMiniMessage);
|
|
||||||
player.disconnect(message);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void kickPlayer(UUID player, Component message) {
|
|
||||||
serializedPlayerKick(player, MINI_MESSAGE_SERIALIZER.serialize(message));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onLoginEvent(LoginEvent event, Continuation continuation) {
|
public void onLoginEvent(LoginEvent event, Continuation continuation) {
|
||||||
// check if online
|
// check if online
|
||||||
if (getLastOnline(event.getPlayer().getUniqueId()) == 0) {
|
if (getLastOnline(event.getPlayer().getUniqueId()) == 0) {
|
||||||
// because something can go wrong and proxy somehow does not update player data correctly on shutdown
|
if (plugin.configuration().kickWhenOnline()) {
|
||||||
// we have to check proxy if it has the player
|
kickPlayer(event.getPlayer().getUniqueId(), plugin.langConfiguration().messages().loggedInFromOtherLocation());
|
||||||
String proxyId = getProxyFor(event.getPlayer().getUniqueId());
|
// wait 3 seconds before releasing the event
|
||||||
if (proxyId == null || !plugin.proxyDataManager().isPlayerTrulyOnProxy(proxyId, event.getPlayer().getUniqueId())) {
|
plugin.executeAsyncAfter(continuation::resume, TimeUnit.SECONDS, 3);
|
||||||
continuation.resume();
|
|
||||||
} else {
|
} else {
|
||||||
if (plugin.configuration().kickWhenOnline()) {
|
event.setResult(ResultedEvent.ComponentResult.denied(plugin.langConfiguration().messages().alreadyLoggedIn()));
|
||||||
kickPlayer(event.getPlayer().getUniqueId(), vplugin.langConfiguration().messages().loggedInFromOtherLocation());
|
continuation.resume();
|
||||||
// wait 3 seconds before releasing the event
|
|
||||||
plugin.executeAsyncAfter(continuation::resume, TimeUnit.SECONDS, 3);
|
|
||||||
} else {
|
|
||||||
event.setResult(ResultedEvent.ComponentResult.denied(vplugin.langConfiguration().messages().alreadyLoggedIn()));
|
|
||||||
continuation.resume();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
continuation.resume();
|
continuation.resume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onLoginEvent(PostLoginEvent event) {
|
public void onLoginEvent(PostLoginEvent event) {
|
||||||
addPlayer(event.getPlayer().getUniqueId(), event.getPlayer().getUsername(), event.getPlayer().getRemoteAddress().getAddress());
|
addPlayer(event.getPlayer().getUniqueId(), event.getPlayer().getRemoteAddress().getAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onDisconnectEvent(DisconnectEvent event) {
|
public void onDisconnectEvent(DisconnectEvent event) {
|
||||||
if (event.getLoginStatus() == DisconnectEvent.LoginStatus.SUCCESSFUL_LOGIN || event.getLoginStatus() == DisconnectEvent.LoginStatus.PRE_SERVER_JOIN) {
|
if (event.getLoginStatus() == DisconnectEvent.LoginStatus.SUCCESSFUL_LOGIN || event.getLoginStatus() == DisconnectEvent.LoginStatus.PRE_SERVER_JOIN) {
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.imaginarycode.minecraft.redisbungee.api.config;
|
|
||||||
|
|
||||||
public enum HandleMotdOrder {
|
|
||||||
FIRST,
|
|
||||||
NORMAL,
|
|
||||||
LAST
|
|
||||||
}
|
|
||||||
0
build.gradle.kts
Normal file
0
build.gradle.kts
Normal file
@@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.imaginarycode.minecraft.redisbungee.commands;
|
|
||||||
|
|
||||||
import co.aikar.commands.CommandIssuer;
|
|
||||||
import co.aikar.commands.annotation.*;
|
|
||||||
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
|
|
||||||
import com.imaginarycode.minecraft.redisbungee.commands.utils.AdventureBaseCommand;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@CommandAlias("rbd|redisbungeedebug")
|
|
||||||
@CommandPermission("redisbungee.command.debug.use")
|
|
||||||
@Description("debug commands")
|
|
||||||
public class CommandRedisBungeeDebug extends AdventureBaseCommand {
|
|
||||||
|
|
||||||
private final RedisBungeePlugin<?> plugin;
|
|
||||||
|
|
||||||
public CommandRedisBungeeDebug(RedisBungeePlugin<?> plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subcommand("kickByName")
|
|
||||||
@Description("kicks a player from the network by name")
|
|
||||||
@Private
|
|
||||||
public void kick(CommandIssuer issuer, String playerName) {
|
|
||||||
plugin.playerDataManager().serializedPlayerKick(plugin.getUuidTranslator().getTranslatedUuid(playerName, false), "kicked using redisbungee api using name");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subcommand("kickByUUID")
|
|
||||||
@Description("kicks a player from the network by UUID")
|
|
||||||
@Private
|
|
||||||
public void kick(CommandIssuer issuer, UUID uuid) {
|
|
||||||
plugin.playerDataManager().serializedPlayerKick(uuid, "kicked using redisbungee api using uuid");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
group=com.imaginarycode.minecraft
|
group=com.imaginarycode.minecraft
|
||||||
version=0.13.0-SNAPSHOT
|
version=0.12.0-SNAPSHOT
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
[versions]
|
|
||||||
guava = "33.5.0-jre"
|
|
||||||
jedis = "5.2.0"
|
|
||||||
okhttp = "4.12.0"
|
|
||||||
configurateV3 = "3.7.3"
|
|
||||||
caffeine = "3.2.3"
|
|
||||||
adventure = "4.26.1"
|
|
||||||
adventure-bungeecord-platform = "4.4.1"
|
|
||||||
acf = "e2005dd62d"
|
|
||||||
bungeecordApi = "1.21-R0.5-SNAPSHOT"
|
|
||||||
velocity = "3.5.0-SNAPSHOT"
|
|
||||||
|
|
||||||
[plugins]
|
|
||||||
blossom = { id = "net.kyori.blossom", version = "2.2.0" }
|
|
||||||
indragit = {id = "net.kyori.indra.git", version="4.0.0"}
|
|
||||||
shadow = { id = "com.gradleup.shadow", version = "9.3.1" }
|
|
||||||
run-velocity = { id = "xyz.jpenilla.run-velocity", version = "2.3.1" }
|
|
||||||
|
|
||||||
[libraries]
|
|
||||||
guava = { module = "com.google.guava:guava", version.ref = "guava" }
|
|
||||||
jedis = { module = "redis.clients:jedis", version.ref = "jedis" }
|
|
||||||
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
|
|
||||||
configurateV3 = { module = "org.spongepowered:configurate-yaml", version.ref = "configurateV3" }
|
|
||||||
caffeine = { module = "com.github.ben-manes.caffeine:caffeine", version.ref = "caffeine" }
|
|
||||||
|
|
||||||
adventure-api = { module = "net.kyori:adventure-api", version.ref = "adventure" }
|
|
||||||
adventure-miniMessage = { module = "net.kyori:adventure-text-minimessage", version.ref = "adventure" }
|
|
||||||
|
|
||||||
acf-core = { module = "com.github.ProxioDev.commands:acf-core", version.ref = "acf" }
|
|
||||||
acf-bungeecord = { module = "com.github.ProxioDev.commands:acf-bungee", version.ref = "acf" }
|
|
||||||
acf-velocity = { module = "com.github.ProxioDev.commands:acf-velocity", version.ref = "acf" }
|
|
||||||
|
|
||||||
platform-bungeecord = { module = "net.md-5:bungeecord-api", version.ref = "bungeecordApi" }
|
|
||||||
adventure-platforms-bungeecord = { module = "net.kyori:adventure-platform-bungeecord", version.ref = "adventure-bungeecord-platform" }
|
|
||||||
|
|
||||||
platform-velocity = { module = "com.velocitypowered:velocity-api", version.ref = "velocity" }
|
|
||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|||||||
12
gradlew
vendored
12
gradlew
vendored
@@ -15,8 +15,6 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
@@ -57,7 +55,7 @@
|
|||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (3) This script is generated from the Groovy template
|
||||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
# within the Gradle project.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
@@ -86,7 +84,7 @@ done
|
|||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
@@ -114,7 +112,7 @@ case "$( uname )" in #(
|
|||||||
NONSTOP* ) nonstop=true ;;
|
NONSTOP* ) nonstop=true ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH="\\\"\\\""
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
@@ -205,7 +203,7 @@ fi
|
|||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Collect all arguments for the java command:
|
# Collect all arguments for the java command:
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
# and any embedded shellness will be escaped.
|
# and any embedded shellness will be escaped.
|
||||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
# treated as '${Hostname}' itself on the command line.
|
# treated as '${Hostname}' itself on the command line.
|
||||||
@@ -213,7 +211,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
-classpath "$CLASSPATH" \
|
-classpath "$CLASSPATH" \
|
||||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
# Stop when "xargs" is not available.
|
# Stop when "xargs" is not available.
|
||||||
|
|||||||
26
gradlew.bat
vendored
26
gradlew.bat
vendored
@@ -13,8 +13,6 @@
|
|||||||
@rem See the License for the specific language governing permissions and
|
@rem See the License for the specific language governing permissions and
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
@rem SPDX-License-Identifier: Apache-2.0
|
|
||||||
@rem
|
|
||||||
|
|
||||||
@if "%DEBUG%"=="" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@@ -45,11 +43,11 @@ set JAVA_EXE=java.exe
|
|||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if %ERRORLEVEL% equ 0 goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
echo location of your Java installation. 1>&2
|
echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
@@ -59,22 +57,22 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
echo location of your Java installation. 1>&2
|
echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
jdk:
|
jdk:
|
||||||
- openjdk21
|
- openjdk17
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
plugins {
|
|
||||||
`java-library`
|
|
||||||
`maven-publish`
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
compileOnly(project(":RedisBungee-API"))
|
|
||||||
compileOnly(libs.adventure.api)
|
|
||||||
compileOnly(libs.adventure.miniMessage)
|
|
||||||
}
|
|
||||||
|
|
||||||
description = "RedisBungee languages"
|
|
||||||
|
|
||||||
java {
|
|
||||||
withJavadocJar()
|
|
||||||
withSourcesJar()
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks {
|
|
||||||
// thanks again for paper too
|
|
||||||
withType<Javadoc> {
|
|
||||||
val options = options as StandardJavadocDocletOptions
|
|
||||||
options.use()
|
|
||||||
options.isDocFilesSubDirs = true
|
|
||||||
val adventureVersion = libs.adventure.api.get().version
|
|
||||||
options.links(
|
|
||||||
"https://jd.advntr.dev/api/$adventureVersion"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
compileJava {
|
|
||||||
options.encoding = Charsets.UTF_8.name()
|
|
||||||
options.release.set(17)
|
|
||||||
}
|
|
||||||
javadoc {
|
|
||||||
options.encoding = Charsets.UTF_8.name()
|
|
||||||
}
|
|
||||||
processResources {
|
|
||||||
filteringCharset = Charsets.UTF_8.name()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
publishing {
|
|
||||||
publications {
|
|
||||||
create<MavenPublication>("maven") {
|
|
||||||
from(components["java"])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
plugins {
|
|
||||||
`java-library`
|
|
||||||
`maven-publish`
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
api(project(":RedisBungee-API"))
|
|
||||||
compileOnly(libs.adventure.platforms.bungeecord)
|
|
||||||
compileOnly(libs.platform.bungeecord)
|
|
||||||
}
|
|
||||||
|
|
||||||
description = "RedisBungee Bungeecord API"
|
|
||||||
|
|
||||||
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://hub.spigotmc.org/jenkins/job/BungeeCord/ws/api/target/reports/apidocs", // bungeecord api
|
|
||||||
)
|
|
||||||
val apiDocs = File(rootProject.projectDir, "api/build/docs/javadoc")
|
|
||||||
options.linksOffline("https://ci.limework.net/ValioBungee/api/build/docs/javadoc", apiDocs.path)
|
|
||||||
}
|
|
||||||
compileJava {
|
|
||||||
options.encoding = Charsets.UTF_8.name()
|
|
||||||
options.release.set(17)
|
|
||||||
}
|
|
||||||
javadoc {
|
|
||||||
options.encoding = Charsets.UTF_8.name()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
publishing {
|
|
||||||
publications {
|
|
||||||
create<MavenPublication>("maven") {
|
|
||||||
from(components["java"])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user