mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2026-05-03 11:40:29 +00:00
Compare commits
8 Commits
0.12.3-SNA
...
0.12.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
e0bca62cdb
|
|||
|
|
9ebfafbeef | ||
|
70eebdc9ec
|
|||
|
e85e18dad8
|
|||
|
995c9045df
|
|||
|
2485150ddc
|
|||
|
32735466d6
|
|||
|
e8715e5399
|
@@ -224,7 +224,7 @@ public abstract class AbstractRedisBungeeAPI {
|
||||
* @since 0.2.5
|
||||
* @deprecated to avoid confusion between A server and A proxy see #getProxyId()
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(forRemoval = true)
|
||||
public final String getServerId() {
|
||||
return getProxyId();
|
||||
}
|
||||
@@ -248,7 +248,7 @@ public abstract class AbstractRedisBungeeAPI {
|
||||
* @since 0.2.5
|
||||
* @deprecated to avoid confusion between A server and A proxy see see {@link #getAllProxies()}
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(forRemoval = true)
|
||||
public final List<String> getAllServers() {
|
||||
return getAllProxies();
|
||||
}
|
||||
@@ -260,7 +260,7 @@ public abstract class AbstractRedisBungeeAPI {
|
||||
* @since 0.3
|
||||
* @deprecated No longer required
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(forRemoval = true)
|
||||
public final void registerPubSubChannels(String... channels) {
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ public abstract class AbstractRedisBungeeAPI {
|
||||
* @since 0.3
|
||||
* @deprecated No longer required
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(forRemoval = true)
|
||||
public final void unregisterPubSubChannels(String... channels) {
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ public abstract class AbstractRedisBungeeAPI {
|
||||
* @since 0.8.0
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(forRemoval = true)
|
||||
public void kickPlayer(String playerName, String message) {
|
||||
kickPlayer(getUuidFromName(playerName), message);
|
||||
}
|
||||
@@ -365,7 +365,7 @@ public abstract class AbstractRedisBungeeAPI {
|
||||
* @since 0.8.0
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(forRemoval = true)
|
||||
public void kickPlayer(UUID playerUUID, String 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}
|
||||
* @see #getJedisPool()
|
||||
* @since 0.7.0
|
||||
* @deprecated use {@link #getSummoner() }
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public Jedis requestJedis() {
|
||||
if (getMode() == RedisBungeeMode.SINGLE) {
|
||||
return getJedisPool().getResource();
|
||||
@@ -438,7 +440,9 @@ public abstract class AbstractRedisBungeeAPI {
|
||||
* @return {@link redis.clients.jedis.JedisCluster}
|
||||
* @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#CLUSTER}
|
||||
* @since 0.8.0
|
||||
* @deprecated use {@link #getSummoner()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public JedisCluster requestClusterJedis() {
|
||||
if (getMode() == RedisBungeeMode.CLUSTER) {
|
||||
return ((JedisClusterSummoner) this.plugin.getSummoner()).obtainResource();
|
||||
@@ -454,7 +458,9 @@ public abstract class AbstractRedisBungeeAPI {
|
||||
* @return {@link redis.clients.jedis.JedisPooled}
|
||||
* @throws IllegalStateException if the {@link #getMode()} is not equal to {@link RedisBungeeMode#SINGLE}
|
||||
* @since 0.8.0
|
||||
* @deprecated use {@link #getSummoner()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public JedisPooled requestJedisPooled() {
|
||||
if (getMode() == RedisBungeeMode.SINGLE) {
|
||||
return ((JedisPooledSummoner) this.plugin.getSummoner()).obtainResource();
|
||||
|
||||
@@ -37,15 +37,16 @@ import java.util.concurrent.TimeUnit;
|
||||
public abstract class PlayerDataManager<P, LE, DE, PS extends IPubSubMessageEvent, SC extends IPlayerChangedServerNetworkEvent, NJE extends IPlayerLeftNetworkEvent, CE> {
|
||||
|
||||
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 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;
|
||||
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) {
|
||||
this.plugin = plugin;
|
||||
@@ -69,16 +70,21 @@ public abstract class PlayerDataManager<P, LE, DE, PS extends IPubSubMessageEven
|
||||
|
||||
public abstract void onDisconnectEvent(DE event);
|
||||
|
||||
|
||||
protected void handleNetworkPlayerServerChange(IPlayerChangedServerNetworkEvent event) {
|
||||
this.serverCache.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) {
|
||||
this.proxyCache.invalidate(event.getUuid());
|
||||
this.serverCache.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) {
|
||||
@@ -140,8 +146,6 @@ public abstract class PlayerDataManager<P, LE, DE, PS extends IPubSubMessageEven
|
||||
handleServerChangeRedis(uuid, to);
|
||||
}
|
||||
|
||||
private final JSONComponentSerializer COMPONENT_SERIALIZER =JSONComponentSerializer.json();
|
||||
|
||||
public void kickPlayer(UUID uuid, Component message) {
|
||||
if (!plugin.handlePlatformKick(uuid, message)) { // handle locally before SENDING a message
|
||||
JSONObject data = new JSONObject();
|
||||
@@ -213,6 +217,7 @@ public abstract class PlayerDataManager<P, LE, DE, PS extends IPubSubMessageEven
|
||||
public String getLastServerFor(UUID uuid) {
|
||||
return this.lastServerCache.get(uuid);
|
||||
}
|
||||
|
||||
public String getServerFor(UUID uuid) {
|
||||
return this.serverCache.get(uuid);
|
||||
}
|
||||
|
||||
@@ -88,6 +88,9 @@ public abstract class ProxyDataManager implements Runnable {
|
||||
|
||||
public synchronized void sendCommandTo(String proxyToRun, String command) {
|
||||
if (isClosed()) return;
|
||||
if (proxyToRun.equals("allservers") || proxyToRun.equals(this.proxyId())) {
|
||||
handlePlatformCommandExecution(command);
|
||||
}
|
||||
publishPayload(new RunCommandPayload(this.proxyId, proxyToRun, command));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
group=com.imaginarycode.minecraft
|
||||
version=0.12.3-SNAPSHOT
|
||||
version=0.12.4
|
||||
@@ -26,7 +26,6 @@ import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import com.velocitypowered.api.proxy.server.ServerPing;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -146,8 +145,11 @@ public class RedisBungeeListener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// ServerConnection throws IllegalStateException when connection dies somehow so just ignore :/
|
||||
((ServerConnection) event.getSource()).sendPluginMessage(event.getIdentifier(), out.toByteArray());
|
||||
} catch (IllegalStateException ignored) {
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user