2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2024-11-22 20:28:00 +00:00

add firePayload for cleanup as its used in integerty check

This commit is contained in:
mohammed jasem alaajel 2022-07-21 09:36:10 +04:00
parent c787c76eca
commit f274301036
5 changed files with 29 additions and 24 deletions

View File

@ -10,30 +10,35 @@ import static com.imaginarycode.minecraft.redisbungee.api.util.payload.PayloadUt
public class GenericPlayerUtils {
public static void cleanUpPlayer(String uuid, Jedis rsc) {
public static void cleanUpPlayer(String uuid, Jedis rsc, boolean firePayload) {
rsc.srem("proxy:" + RedisBungeeAPI.getRedisBungeeApi().getProxyId() + ":usersOnline", uuid);
rsc.hdel("player:" + uuid, "server", "ip", "proxy");
long timestamp = System.currentTimeMillis();
rsc.hset("player:" + uuid, "online", String.valueOf(timestamp));
playerQuitPayload(uuid, rsc, timestamp);
if (firePayload) {
playerQuitPayload(uuid, rsc, timestamp);
}
}
public static void cleanUpPlayer(String uuid, Pipeline rsc) {
public static void cleanUpPlayer(String uuid, Pipeline rsc, boolean firePayload) {
rsc.srem("proxy:" + RedisBungeeAPI.getRedisBungeeApi().getProxyId() + ":usersOnline", uuid);
rsc.hdel("player:" + uuid, "server", "ip", "proxy");
long timestamp = System.currentTimeMillis();
rsc.hset("player:" + uuid, "online", String.valueOf(timestamp));
playerQuitPayload(uuid, rsc, timestamp);
if (firePayload) {
playerQuitPayload(uuid, rsc, timestamp);
}
}
public static void cleanUpPlayer(String uuid, JedisCluster rsc) {
public static void cleanUpPlayer(String uuid, JedisCluster rsc, boolean firePayload) {
rsc.srem("proxy:" + RedisBungeeAPI.getRedisBungeeApi().getProxyId() + ":usersOnline", uuid);
rsc.hdel("player:" + uuid, "server", "ip", "proxy");
long timestamp = System.currentTimeMillis();
rsc.hset("player:" + uuid, "online", String.valueOf(timestamp));
playerQuitPayload(uuid, rsc, timestamp);
if (firePayload) {
playerQuitPayload(uuid, rsc, timestamp);
}
}

View File

@ -147,7 +147,7 @@ public class RedisBungeeBungeeListener extends AbstractRedisBungeeListener<Login
@Override
public Void jedisTask(Jedis jedis) {
Pipeline pipeline = jedis.pipelined();
GenericPlayerUtils.cleanUpPlayer(event.getPlayer().getUniqueId().toString(), pipeline);
GenericPlayerUtils.cleanUpPlayer(event.getPlayer().getUniqueId().toString(), pipeline, true);
pipeline.sync();
return null;
}
@ -155,7 +155,7 @@ public class RedisBungeeBungeeListener extends AbstractRedisBungeeListener<Login
@Override
public Void clusterJedisTask(JedisCluster jedisCluster) {
// Due some reason JedisCluster does not support pipeline, use instance instead
GenericPlayerUtils.cleanUpPlayer(event.getPlayer().getUniqueId().toString(), jedisCluster);
GenericPlayerUtils.cleanUpPlayer(event.getPlayer().getUniqueId().toString(), jedisCluster, true);
return null;
}
});

View File

@ -624,7 +624,7 @@ public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin
if (!laggedPlayers.isEmpty()) {
getLogger().info("Cleaning up lagged proxy " + s + " (" + laggedPlayers.size() + " players)...");
for (String laggedPlayer : laggedPlayers) {
GenericPlayerUtils.cleanUpPlayer(laggedPlayer, jedis);
GenericPlayerUtils.cleanUpPlayer(laggedPlayer, jedis, true);
}
}
}
@ -645,7 +645,7 @@ public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin
}
}
if (!found) {
GenericPlayerUtils.cleanUpPlayer(member, jedis);
GenericPlayerUtils.cleanUpPlayer(member, jedis, false);
getLogger().warning("Player found in set that was not found locally and globally: " + member);
} else {
jedis.srem("proxy:" + configuration.getProxyId() + ":usersOnline", member);
@ -663,7 +663,7 @@ public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin
if (proxiedPlayer == null)
continue; // We'll deal with it later.
BungeePlayerUtils.createPlayer(proxiedPlayer, pipeline, true);
BungeePlayerUtils.createPlayer(proxiedPlayer, pipeline, false);
}
pipeline.sync();
@ -687,7 +687,7 @@ public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin
if (!laggedPlayers.isEmpty()) {
getLogger().info("Cleaning up lagged proxy " + s + " (" + laggedPlayers.size() + " players)...");
for (String laggedPlayer : laggedPlayers) {
GenericPlayerUtils.cleanUpPlayer(laggedPlayer, jedisCluster);
GenericPlayerUtils.cleanUpPlayer(laggedPlayer, jedisCluster, true);
}
}
}
@ -708,7 +708,7 @@ public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin
}
}
if (!found) {
GenericPlayerUtils.cleanUpPlayer(member, jedisCluster);
GenericPlayerUtils.cleanUpPlayer(member, jedisCluster, false);
getLogger().warning("Player found in set that was not found locally and globally: " + member);
} else {
jedisCluster.srem("proxy:" + configuration.getProxyId() + ":usersOnline", member);
@ -777,7 +777,7 @@ public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin
if (jedis.scard("proxy:" + configuration.getProxyId() + ":usersOnline") > 0) {
Set<String> players = jedis.smembers("proxy:" + configuration.getProxyId() + ":usersOnline");
for (String member : players)
GenericPlayerUtils.cleanUpPlayer(member, jedis);
GenericPlayerUtils.cleanUpPlayer(member, jedis, true);
}
return null;
}
@ -788,7 +788,7 @@ public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin
if (jedisCluster.scard("proxy:" + configuration.getProxyId() + ":usersOnline") > 0) {
Set<String> players = jedisCluster.smembers("proxy:" + configuration.getProxyId() + ":usersOnline");
for (String member : players)
GenericPlayerUtils.cleanUpPlayer(member, jedisCluster);
GenericPlayerUtils.cleanUpPlayer(member, jedisCluster, true);
}
return null;
}

View File

@ -139,14 +139,14 @@ public class RedisBungeeVelocityListener extends AbstractRedisBungeeListener<Log
@Override
public Void jedisTask(Jedis jedis) {
Pipeline pipeline = jedis.pipelined();
GenericPlayerUtils.cleanUpPlayer(event.getPlayer().getUniqueId().toString(), pipeline);
GenericPlayerUtils.cleanUpPlayer(event.getPlayer().getUniqueId().toString(), pipeline, true);
pipeline.sync();
return null;
}
@Override
public Void clusterJedisTask(JedisCluster jedisCluster) {
GenericPlayerUtils.cleanUpPlayer(event.getPlayer().getUniqueId().toString(), jedisCluster);
GenericPlayerUtils.cleanUpPlayer(event.getPlayer().getUniqueId().toString(), jedisCluster, true);
return null;
}

View File

@ -652,7 +652,7 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player> {
if (!laggedPlayers.isEmpty()) {
getLogger().info("Cleaning up lagged proxy {} ({} players)...", s, laggedPlayers.size());
for (String laggedPlayer : laggedPlayers) {
GenericPlayerUtils.cleanUpPlayer(laggedPlayer, jedis);
GenericPlayerUtils.cleanUpPlayer(laggedPlayer, jedis, true);
}
}
}
@ -673,7 +673,7 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player> {
}
}
if (!found) {
GenericPlayerUtils.cleanUpPlayer(member, jedis);
GenericPlayerUtils.cleanUpPlayer(member, jedis, false);
getLogger().warn("Player found in set that was not found locally and globally: {}", member);
} else {
jedis.srem("proxy:" + configuration.getProxyId() + ":usersOnline", member);
@ -715,7 +715,7 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player> {
if (!laggedPlayers.isEmpty()) {
getLogger().info("Cleaning up lagged proxy {} ({} players)...", s, laggedPlayers.size());
for (String laggedPlayer : laggedPlayers) {
GenericPlayerUtils.cleanUpPlayer(laggedPlayer, jedisCluster);
GenericPlayerUtils.cleanUpPlayer(laggedPlayer, jedisCluster, true);
}
}
}
@ -736,7 +736,7 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player> {
}
}
if (!found) {
GenericPlayerUtils.cleanUpPlayer(member, jedisCluster);
GenericPlayerUtils.cleanUpPlayer(member, jedisCluster, false);
getLogger().warn("Player found in set that was not found locally and globally: {}", member);
} else {
jedisCluster.srem("proxy:" + configuration.getProxyId() + ":usersOnline", member);
@ -799,7 +799,7 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player> {
if (jedis.scard("proxy:" + configuration.getProxyId() + ":usersOnline") > 0) {
Set<String> players = jedis.smembers("proxy:" + configuration.getProxyId() + ":usersOnline");
for (String member : players)
GenericPlayerUtils.cleanUpPlayer(member, jedis);
GenericPlayerUtils.cleanUpPlayer(member, jedis, true);
}
return null;
}
@ -810,7 +810,7 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player> {
if (jedisCluster.scard("proxy:" + configuration.getProxyId() + ":usersOnline") > 0) {
Set<String> players = jedisCluster.smembers("proxy:" + configuration.getProxyId() + ":usersOnline");
for (String member : players)
GenericPlayerUtils.cleanUpPlayer(member, jedisCluster);
GenericPlayerUtils.cleanUpPlayer(member, jedisCluster, true);
}
return null;
}