mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-11-22 20:28:00 +00:00
add JedisCLuster methods to the api
This commit is contained in:
parent
b910fa5eb6
commit
81a2af8179
@ -4,6 +4,7 @@ import com.google.common.annotations.VisibleForTesting;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI;
|
import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI;
|
||||||
import redis.clients.jedis.Jedis;
|
import redis.clients.jedis.Jedis;
|
||||||
|
import redis.clients.jedis.JedisCluster;
|
||||||
import redis.clients.jedis.Pipeline;
|
import redis.clients.jedis.Pipeline;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -31,6 +32,15 @@ public class RedisUtil {
|
|||||||
UUID.fromString(player), RedisBungeeAPI.getRedisBungeeApi().getServerId(), AbstractDataManager.DataManagerMessage.Action.LEAVE,
|
UUID.fromString(player), RedisBungeeAPI.getRedisBungeeApi().getServerId(), AbstractDataManager.DataManagerMessage.Action.LEAVE,
|
||||||
new AbstractDataManager.LogoutPayload(timestamp))));
|
new AbstractDataManager.LogoutPayload(timestamp))));
|
||||||
}
|
}
|
||||||
|
public static void cleanUpPlayer(String player, JedisCluster rsc) {
|
||||||
|
rsc.srem("proxy:" + RedisBungeeAPI.getRedisBungeeApi().getServerId() + ":usersOnline", player);
|
||||||
|
rsc.hdel("player:" + player, "server", "ip", "proxy");
|
||||||
|
long timestamp = System.currentTimeMillis();
|
||||||
|
rsc.hset("player:" + player, "online", String.valueOf(timestamp));
|
||||||
|
rsc.publish("redisbungee-data", gson.toJson(new AbstractDataManager.DataManagerMessage<>(
|
||||||
|
UUID.fromString(player), RedisBungeeAPI.getRedisBungeeApi().getServerId(), AbstractDataManager.DataManagerMessage.Action.LEAVE,
|
||||||
|
new AbstractDataManager.LogoutPayload(timestamp))));
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isRedisVersionRight(String redisVersion) {
|
public static boolean isRedisVersionRight(String redisVersion) {
|
||||||
// Need to use >=6.2 to use Lua optimizations.
|
// Need to use >=6.2 to use Lua optimizations.
|
||||||
|
@ -275,6 +275,12 @@ public final class UUIDTranslator {
|
|||||||
jedis.hmset("uuid-cache", ImmutableMap.of(name.toLowerCase(), json, uuid.toString(), json));
|
jedis.hmset("uuid-cache", ImmutableMap.of(name.toLowerCase(), json, uuid.toString(), json));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void persistInfo(String name, UUID uuid, Pipeline pipeline) {
|
||||||
|
addToMaps(name, uuid);
|
||||||
|
String json = gson.toJson(uuidToNameMap.get(uuid));
|
||||||
|
pipeline.hmset("uuid-cache", ImmutableMap.of(name.toLowerCase(), json, uuid.toString(), json));
|
||||||
|
}
|
||||||
|
|
||||||
public void persistInfo(String name, UUID uuid, JedisCluster jedisCluster) {
|
public void persistInfo(String name, UUID uuid, JedisCluster jedisCluster) {
|
||||||
addToMaps(name, uuid);
|
addToMaps(name, uuid);
|
||||||
String json = gson.toJson(uuidToNameMap.get(uuid));
|
String json = gson.toJson(uuidToNameMap.get(uuid));
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
# RedisBungee configuration file.
|
# RedisBungee configuration file.
|
||||||
# PLEASE READ THE WIKI: https://github.com/ProxioDev/RedisBungee/wiki
|
# PLEASE READ THE WIKI: https://github.com/ProxioDev/RedisBungee/wiki
|
||||||
|
|
||||||
# Cluster Mode its in different config file redis-cluster.yml
|
# Cluster Mode
|
||||||
# enabling this option will ignore redis config of this file
|
# enabling this option will enable cluster mode.
|
||||||
cluster-mode-enabled: false
|
cluster-mode-enabled: false
|
||||||
|
|
||||||
# The Redis server you use.
|
# The Redis server you use.
|
||||||
|
Loading…
Reference in New Issue
Block a user