mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2026-05-03 03:30:26 +00:00
Compare commits
19 Commits
0.12.3-SNA
...
0.12.6
| Author | SHA1 | Date | |
|---|---|---|---|
|
f27d54beb8
|
|||
|
91ea0b08dc
|
|||
|
199c1c7135
|
|||
|
dab5f26e2c
|
|||
|
c622bc7b63
|
|||
|
881691a92d
|
|||
| 079606c9da | |||
|
ea54a0bc49
|
|||
|
69e91c3e42
|
|||
|
|
d8704c8a8f
|
||
|
|
981d42d4a8
|
||
|
e0bca62cdb
|
|||
|
|
9ebfafbeef | ||
|
70eebdc9ec
|
|||
|
e85e18dad8
|
|||
|
995c9045df
|
|||
|
2485150ddc
|
|||
|
32735466d6
|
|||
|
e8715e5399
|
10
.github/workflows/gradle.yml
vendored
10
.github/workflows/gradle.yml
vendored
@@ -5,9 +5,9 @@ name: RedisBungee Build
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main ]
|
branches: [ stable, develop ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ main ]
|
branches: [ stable, develop ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@@ -24,19 +24,19 @@ jobs:
|
|||||||
- name: Build with gradle
|
- name: Build with gradle
|
||||||
run: ./gradlew shadowJar
|
run: ./gradlew shadowJar
|
||||||
- name: Upload Bungee
|
- name: Upload Bungee
|
||||||
uses: actions/upload-artifact@v2.2.3
|
uses: actions/upload-artifact@v4.4.0
|
||||||
with:
|
with:
|
||||||
# Artifact name
|
# Artifact name
|
||||||
name: RedisBungee-Bungee
|
name: RedisBungee-Bungee
|
||||||
# Destination path
|
# Destination path
|
||||||
path: proxies/bungeecord/build/libs/*
|
path: proxies/bungeecord/build/libs/*
|
||||||
- name: Upload Velocity
|
- name: Upload Velocity
|
||||||
uses: actions/upload-artifact@v2.2.3
|
uses: actions/upload-artifact@v4.4.0
|
||||||
with:
|
with:
|
||||||
name: RedisBungee-Velocity
|
name: RedisBungee-Velocity
|
||||||
path: proxies/velocity/build/libs/*
|
path: proxies/velocity/build/libs/*
|
||||||
- name: Upload API
|
- name: Upload API
|
||||||
uses: actions/upload-artifact@v2.2.3
|
uses: actions/upload-artifact@v4.4.0
|
||||||
with:
|
with:
|
||||||
name: RedisBungee-API
|
name: RedisBungee-API
|
||||||
path: api/build/libs/*
|
path: api/build/libs/*
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ public abstract class AbstractRedisBungeeAPI {
|
|||||||
* @since 0.2.5
|
* @since 0.2.5
|
||||||
* @deprecated to avoid confusion between A server and A proxy see #getProxyId()
|
* @deprecated to avoid confusion between A server and A proxy see #getProxyId()
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated(forRemoval = true)
|
||||||
public final String getServerId() {
|
public final String getServerId() {
|
||||||
return getProxyId();
|
return getProxyId();
|
||||||
}
|
}
|
||||||
@@ -248,7 +248,7 @@ public abstract class AbstractRedisBungeeAPI {
|
|||||||
* @since 0.2.5
|
* @since 0.2.5
|
||||||
* @deprecated to avoid confusion between A server and A proxy see see {@link #getAllProxies()}
|
* @deprecated to avoid confusion between A server and A proxy see see {@link #getAllProxies()}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated(forRemoval = true)
|
||||||
public final List<String> getAllServers() {
|
public final List<String> getAllServers() {
|
||||||
return getAllProxies();
|
return getAllProxies();
|
||||||
}
|
}
|
||||||
@@ -260,7 +260,7 @@ public abstract class AbstractRedisBungeeAPI {
|
|||||||
* @since 0.3
|
* @since 0.3
|
||||||
* @deprecated No longer required
|
* @deprecated No longer required
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated(forRemoval = true)
|
||||||
public final void registerPubSubChannels(String... channels) {
|
public final void registerPubSubChannels(String... channels) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,7 +271,7 @@ public abstract class AbstractRedisBungeeAPI {
|
|||||||
* @since 0.3
|
* @since 0.3
|
||||||
* @deprecated No longer required
|
* @deprecated No longer required
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated(forRemoval = true)
|
||||||
public final void unregisterPubSubChannels(String... channels) {
|
public final void unregisterPubSubChannels(String... channels) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,7 +352,7 @@ public abstract class AbstractRedisBungeeAPI {
|
|||||||
* @since 0.8.0
|
* @since 0.8.0
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated(forRemoval = true)
|
||||||
public void kickPlayer(String playerName, String message) {
|
public void kickPlayer(String playerName, String message) {
|
||||||
kickPlayer(getUuidFromName(playerName), message);
|
kickPlayer(getUuidFromName(playerName), message);
|
||||||
}
|
}
|
||||||
@@ -365,7 +365,7 @@ public abstract class AbstractRedisBungeeAPI {
|
|||||||
* @since 0.8.0
|
* @since 0.8.0
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated(forRemoval = true)
|
||||||
public void kickPlayer(UUID playerUUID, String message) {
|
public void kickPlayer(UUID playerUUID, String message) {
|
||||||
kickPlayer(playerUUID, Component.text(message));
|
kickPlayer(playerUUID, Component.text(message));
|
||||||
}
|
}
|
||||||
@@ -402,7 +402,9 @@ public abstract class AbstractRedisBungeeAPI {
|
|||||||
* @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#SINGLE}
|
* @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#SINGLE}
|
||||||
* @see #getJedisPool()
|
* @see #getJedisPool()
|
||||||
* @since 0.7.0
|
* @since 0.7.0
|
||||||
|
* @deprecated use {@link #getSummoner() }
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
public Jedis requestJedis() {
|
public Jedis requestJedis() {
|
||||||
if (getMode() == RedisBungeeMode.SINGLE) {
|
if (getMode() == RedisBungeeMode.SINGLE) {
|
||||||
return getJedisPool().getResource();
|
return getJedisPool().getResource();
|
||||||
@@ -438,7 +440,9 @@ public abstract class AbstractRedisBungeeAPI {
|
|||||||
* @return {@link redis.clients.jedis.JedisCluster}
|
* @return {@link redis.clients.jedis.JedisCluster}
|
||||||
* @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#CLUSTER}
|
* @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#CLUSTER}
|
||||||
* @since 0.8.0
|
* @since 0.8.0
|
||||||
|
* @deprecated use {@link #getSummoner()}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
public JedisCluster requestClusterJedis() {
|
public JedisCluster requestClusterJedis() {
|
||||||
if (getMode() == RedisBungeeMode.CLUSTER) {
|
if (getMode() == RedisBungeeMode.CLUSTER) {
|
||||||
return ((JedisClusterSummoner) this.plugin.getSummoner()).obtainResource();
|
return ((JedisClusterSummoner) this.plugin.getSummoner()).obtainResource();
|
||||||
@@ -454,7 +458,9 @@ public abstract class AbstractRedisBungeeAPI {
|
|||||||
* @return {@link redis.clients.jedis.JedisPooled}
|
* @return {@link redis.clients.jedis.JedisPooled}
|
||||||
* @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#SINGLE}
|
* @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#SINGLE}
|
||||||
* @since 0.8.0
|
* @since 0.8.0
|
||||||
|
* @deprecated use {@link #getSummoner()}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
public JedisPooled requestJedisPooled() {
|
public JedisPooled requestJedisPooled() {
|
||||||
if (getMode() == RedisBungeeMode.SINGLE) {
|
if (getMode() == RedisBungeeMode.SINGLE) {
|
||||||
return ((JedisPooledSummoner) this.plugin.getSummoner()).obtainResource();
|
return ((JedisPooledSummoner) this.plugin.getSummoner()).obtainResource();
|
||||||
|
|||||||
@@ -28,24 +28,22 @@ 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.HashMap;
|
import java.util.*;
|
||||||
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, LE, DE, PS extends IPubSubMessageEvent, SC extends IPlayerChangedServerNetworkEvent, NJE extends IPlayerLeftNetworkEvent, CE> {
|
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 LoadingCache<UUID, String> serverCache = Caffeine.newBuilder().expireAfterWrite(1, TimeUnit.MINUTES).build(this::getServerFromRedis);
|
|
||||||
private final LoadingCache<UUID, String> lastServerCache = Caffeine.newBuilder().expireAfterWrite(1, TimeUnit.MINUTES).build(this::getLastServerFromRedis);
|
|
||||||
private final LoadingCache<UUID, String> proxyCache = Caffeine.newBuilder().expireAfterWrite(1, TimeUnit.MINUTES).build(this::getProxyFromRedis);
|
|
||||||
private final LoadingCache<UUID, InetAddress> ipCache = Caffeine.newBuilder().expireAfterWrite(1, TimeUnit.MINUTES).build(this::getIpAddressFromRedis);
|
|
||||||
private final Object SERVERS_TO_PLAYERS_KEY = new Object();
|
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 UnifiedJedis unifiedJedis;
|
private final UnifiedJedis unifiedJedis;
|
||||||
private final String proxyId;
|
private final String proxyId;
|
||||||
private final String networkId;
|
private final String networkId;
|
||||||
|
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> 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<Object, Multimap<String, UUID>> serverToPlayersCache = Caffeine.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES).build(this::serversToPlayersBuilder);
|
||||||
|
private final JSONComponentSerializer COMPONENT_SERIALIZER = JSONComponentSerializer.json();
|
||||||
|
|
||||||
public PlayerDataManager(RedisBungeePlugin<P> plugin) {
|
public PlayerDataManager(RedisBungeePlugin<P> plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
@@ -56,29 +54,34 @@ public abstract class PlayerDataManager<P, LE, DE, PS extends IPubSubMessageEven
|
|||||||
|
|
||||||
// handle network wide
|
// handle network wide
|
||||||
// server change
|
// server change
|
||||||
public abstract void onPlayerChangedServerNetworkEvent(SC event);
|
//l public abstract void onPlayerChangedServerNetworkEvent(SC event);
|
||||||
|
|
||||||
public abstract void onNetworkPlayerQuit(NJE event);
|
// public abstract void onNetworkPlayerQuit(NJE event);
|
||||||
|
|
||||||
// local events
|
// local events
|
||||||
public abstract void onPubSubMessageEvent(PS event);
|
//public abstract void onPubSubMessageEvent(PS event);
|
||||||
|
|
||||||
public abstract void onServerConnectedEvent(CE event);
|
//public abstract void onServerConnectedEvent(CE event);
|
||||||
|
|
||||||
public abstract void onLoginEvent(LE event);
|
//public abstract void onLoginEvent(LE event);
|
||||||
|
|
||||||
public abstract void onDisconnectEvent(DE event);
|
|
||||||
|
|
||||||
|
//public abstract void onDisconnectEvent(DE event);
|
||||||
|
|
||||||
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) {
|
||||||
this.proxyCache.invalidate(event.getUuid());
|
this.proxyCache.invalidate(event.getUuid());
|
||||||
this.serverCache.invalidate(event.getUuid());
|
this.serverCache.invalidate(event.getUuid());
|
||||||
this.ipCache.invalidate(event.getUuid());
|
this.ipCache.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) {
|
||||||
@@ -140,8 +143,6 @@ public abstract class PlayerDataManager<P, LE, DE, PS extends IPubSubMessageEven
|
|||||||
handleServerChangeRedis(uuid, to);
|
handleServerChangeRedis(uuid, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final JSONComponentSerializer COMPONENT_SERIALIZER =JSONComponentSerializer.json();
|
|
||||||
|
|
||||||
public void kickPlayer(UUID uuid, Component message) {
|
public void kickPlayer(UUID uuid, Component message) {
|
||||||
if (!plugin.handlePlatformKick(uuid, message)) { // handle locally before SENDING a message
|
if (!plugin.handlePlatformKick(uuid, message)) { // handle locally before SENDING a message
|
||||||
JSONObject data = new JSONObject();
|
JSONObject data = new JSONObject();
|
||||||
@@ -213,6 +214,7 @@ public abstract class PlayerDataManager<P, LE, DE, PS extends IPubSubMessageEven
|
|||||||
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);
|
||||||
}
|
}
|
||||||
@@ -243,10 +245,17 @@ public abstract class PlayerDataManager<P, LE, DE, PS extends IPubSubMessageEven
|
|||||||
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) {
|
||||||
responses.put(uuid, pipeline.hget("redis-bungee::" + networkId + "::player::" + uuid + "::data", "server"));
|
Optional.ofNullable(pipeline.hget("redis-bungee::" + networkId + "::player::" + uuid + "::data", "server")).ifPresent(stringResponse -> {
|
||||||
|
responses.put(uuid, stringResponse);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
pipeline.sync();
|
pipeline.sync();
|
||||||
responses.forEach((uuid, response) -> builder.put(response.get(), uuid));
|
responses.forEach((uuid, response) -> {
|
||||||
|
String key = response.get();
|
||||||
|
if (key == null) return;
|
||||||
|
|
||||||
|
builder.put(key, uuid);
|
||||||
|
});
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,10 +263,16 @@ public abstract class PlayerDataManager<P, LE, DE, PS extends IPubSubMessageEven
|
|||||||
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) {
|
||||||
responses.put(uuid, pipeline.hget("redis-bungee::" + networkId + "::player::" + uuid + "::data", "server"));
|
Optional.ofNullable(pipeline.hget("redis-bungee::" + networkId + "::player::" + uuid + "::data", "server")).ifPresent(stringResponse -> {
|
||||||
|
responses.put(uuid, stringResponse);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
pipeline.sync();
|
pipeline.sync();
|
||||||
responses.forEach((uuid, response) -> builder.put(response.get(), uuid));
|
responses.forEach((uuid, response) -> {
|
||||||
|
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,12 +82,22 @@ 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
group=com.imaginarycode.minecraft
|
group=com.imaginarycode.minecraft
|
||||||
version=0.12.3-SNAPSHOT
|
version=0.12.6
|
||||||
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-8.5-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|||||||
7
gradlew
vendored
7
gradlew
vendored
@@ -15,6 +15,8 @@
|
|||||||
# 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
|
||||||
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
@@ -55,7 +57,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/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/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/.
|
||||||
@@ -84,7 +86,8 @@ 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 "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||||
|
' "$PWD" ) || 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
|
||||||
|
|||||||
22
gradlew.bat
vendored
22
gradlew.bat
vendored
@@ -13,6 +13,8 @@
|
|||||||
@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 ##########################################################################
|
||||||
@@ -43,11 +45,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.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
@@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||||
echo.
|
echo. 1>&2
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
echo location of your Java installation.
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ 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")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ 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.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.serializer.bungeecord.BungeeComponentSerializer;
|
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
|
||||||
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;
|
||||||
@@ -35,25 +34,21 @@ public class BungeePlayerDataManager extends PlayerDataManager<ProxiedPlayer, Po
|
|||||||
super(plugin);
|
super(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@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();
|
||||||
@@ -66,14 +61,21 @@ public class BungeePlayerDataManager extends PlayerDataManager<ProxiedPlayer, Po
|
|||||||
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) {
|
||||||
if (plugin.configuration().kickWhenOnline()) {
|
// because something can go wrong and proxy somehow does not update player data correctly on shutdown
|
||||||
kickPlayer(event.getConnection().getUniqueId(), plugin.langConfiguration().messages().loggedInFromOtherLocation());
|
// we have to check proxy if it has the player
|
||||||
// wait 3 seconds before releasing the event
|
String proxyId = getProxyFor(event.getConnection().getUniqueId());
|
||||||
plugin.executeAsyncAfter(() -> event.completeIntent((Plugin) plugin), TimeUnit.SECONDS, 3);
|
if (proxyId == null || !plugin.proxyDataManager().isPlayerTrulyOnProxy(proxyId, event.getConnection().getUniqueId())) {
|
||||||
} else {
|
|
||||||
event.setCancelled(true);
|
|
||||||
event.setCancelReason(BungeeComponentSerializer.get().serialize(plugin.langConfiguration().messages().alreadyLoggedIn()));
|
|
||||||
event.completeIntent((Plugin) plugin);
|
event.completeIntent((Plugin) plugin);
|
||||||
|
} else {
|
||||||
|
if (plugin.configuration().kickWhenOnline()) {
|
||||||
|
kickPlayer(event.getConnection().getUniqueId(), plugin.langConfiguration().messages().loggedInFromOtherLocation());
|
||||||
|
// wait 3 seconds before releasing the event
|
||||||
|
plugin.executeAsyncAfter(() -> event.completeIntent((Plugin) plugin), TimeUnit.SECONDS, 3);
|
||||||
|
} else {
|
||||||
|
event.setCancelled(true);
|
||||||
|
event.setCancelReason(BungeeComponentSerializer.get().serialize(plugin.langConfiguration().messages().alreadyLoggedIn()));
|
||||||
|
event.completeIntent((Plugin) plugin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
event.completeIntent((Plugin) plugin);
|
event.completeIntent((Plugin) plugin);
|
||||||
@@ -81,13 +83,11 @@ public class BungeePlayerDataManager extends PlayerDataManager<ProxiedPlayer, Po
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@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().getName(), 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());
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ 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;
|
||||||
@@ -146,8 +145,11 @@ public class RedisBungeeListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
((ServerConnection) event.getSource()).sendPluginMessage(event.getIdentifier(), out.toByteArray());
|
// ServerConnection throws IllegalStateException when connection dies somehow so just ignore :/
|
||||||
|
((ServerConnection) event.getSource()).sendPluginMessage(event.getIdentifier(), out.toByteArray());
|
||||||
|
} catch (IllegalStateException ignored) {
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,25 +33,21 @@ public class VelocityPlayerDataManager extends PlayerDataManager<Player, PostLog
|
|||||||
super(plugin);
|
super(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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@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();
|
||||||
@@ -68,26 +64,31 @@ public class VelocityPlayerDataManager extends PlayerDataManager<Player, PostLog
|
|||||||
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) {
|
||||||
if (plugin.configuration().kickWhenOnline()) {
|
// because something can go wrong and proxy somehow does not update player data correctly on shutdown
|
||||||
kickPlayer(event.getPlayer().getUniqueId(), plugin.langConfiguration().messages().loggedInFromOtherLocation());
|
// we have to check proxy if it has the player
|
||||||
// wait 3 seconds before releasing the event
|
String proxyId = getProxyFor(event.getPlayer().getUniqueId());
|
||||||
plugin.executeAsyncAfter(continuation::resume, TimeUnit.SECONDS, 3);
|
if (proxyId == null || !plugin.proxyDataManager().isPlayerTrulyOnProxy(proxyId, event.getPlayer().getUniqueId())) {
|
||||||
} else {
|
|
||||||
event.setResult(ResultedEvent.ComponentResult.denied(plugin.langConfiguration().messages().alreadyLoggedIn()));
|
|
||||||
continuation.resume();
|
continuation.resume();
|
||||||
|
} else {
|
||||||
|
if (plugin.configuration().kickWhenOnline()) {
|
||||||
|
kickPlayer(event.getPlayer().getUniqueId(), plugin.langConfiguration().messages().loggedInFromOtherLocation());
|
||||||
|
// wait 3 seconds before releasing the event
|
||||||
|
plugin.executeAsyncAfter(continuation::resume, TimeUnit.SECONDS, 3);
|
||||||
|
} else {
|
||||||
|
event.setResult(ResultedEvent.ComponentResult.denied(plugin.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().getUsername(), 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) {
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ dependencyResolutionManagement {
|
|||||||
val caffeineVersion = "3.1.8"
|
val caffeineVersion = "3.1.8"
|
||||||
val adventureVersion = "4.16.0"
|
val adventureVersion = "4.16.0"
|
||||||
val acf = "0.5.1-SNAPSHOT"
|
val acf = "0.5.1-SNAPSHOT"
|
||||||
val bungeecordApiVersion = "1.20-R0.1-SNAPSHOT"
|
val bungeecordApiVersion = "1.21-R0.1-SNAPSHOT"
|
||||||
val velocityVersion = "3.3.0-SNAPSHOT";
|
val velocityVersion = "3.3.0-SNAPSHOT";
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user