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:
parent
c787c76eca
commit
f274301036
@ -10,30 +10,35 @@ import static com.imaginarycode.minecraft.redisbungee.api.util.payload.PayloadUt
|
|||||||
public class GenericPlayerUtils {
|
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.srem("proxy:" + RedisBungeeAPI.getRedisBungeeApi().getProxyId() + ":usersOnline", uuid);
|
||||||
rsc.hdel("player:" + uuid, "server", "ip", "proxy");
|
rsc.hdel("player:" + uuid, "server", "ip", "proxy");
|
||||||
long timestamp = System.currentTimeMillis();
|
long timestamp = System.currentTimeMillis();
|
||||||
rsc.hset("player:" + uuid, "online", String.valueOf(timestamp));
|
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.srem("proxy:" + RedisBungeeAPI.getRedisBungeeApi().getProxyId() + ":usersOnline", uuid);
|
||||||
rsc.hdel("player:" + uuid, "server", "ip", "proxy");
|
rsc.hdel("player:" + uuid, "server", "ip", "proxy");
|
||||||
long timestamp = System.currentTimeMillis();
|
long timestamp = System.currentTimeMillis();
|
||||||
rsc.hset("player:" + uuid, "online", String.valueOf(timestamp));
|
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.srem("proxy:" + RedisBungeeAPI.getRedisBungeeApi().getProxyId() + ":usersOnline", uuid);
|
||||||
rsc.hdel("player:" + uuid, "server", "ip", "proxy");
|
rsc.hdel("player:" + uuid, "server", "ip", "proxy");
|
||||||
long timestamp = System.currentTimeMillis();
|
long timestamp = System.currentTimeMillis();
|
||||||
rsc.hset("player:" + uuid, "online", String.valueOf(timestamp));
|
rsc.hset("player:" + uuid, "online", String.valueOf(timestamp));
|
||||||
playerQuitPayload(uuid, rsc, timestamp);
|
if (firePayload) {
|
||||||
|
playerQuitPayload(uuid, rsc, timestamp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ public class RedisBungeeBungeeListener extends AbstractRedisBungeeListener<Login
|
|||||||
@Override
|
@Override
|
||||||
public Void jedisTask(Jedis jedis) {
|
public Void jedisTask(Jedis jedis) {
|
||||||
Pipeline pipeline = jedis.pipelined();
|
Pipeline pipeline = jedis.pipelined();
|
||||||
GenericPlayerUtils.cleanUpPlayer(event.getPlayer().getUniqueId().toString(), pipeline);
|
GenericPlayerUtils.cleanUpPlayer(event.getPlayer().getUniqueId().toString(), pipeline, true);
|
||||||
pipeline.sync();
|
pipeline.sync();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ public class RedisBungeeBungeeListener extends AbstractRedisBungeeListener<Login
|
|||||||
@Override
|
@Override
|
||||||
public Void clusterJedisTask(JedisCluster jedisCluster) {
|
public Void clusterJedisTask(JedisCluster jedisCluster) {
|
||||||
// Due some reason JedisCluster does not support pipeline, use instance instead
|
// 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;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -624,7 +624,7 @@ public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin
|
|||||||
if (!laggedPlayers.isEmpty()) {
|
if (!laggedPlayers.isEmpty()) {
|
||||||
getLogger().info("Cleaning up lagged proxy " + s + " (" + laggedPlayers.size() + " players)...");
|
getLogger().info("Cleaning up lagged proxy " + s + " (" + laggedPlayers.size() + " players)...");
|
||||||
for (String laggedPlayer : laggedPlayers) {
|
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) {
|
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);
|
getLogger().warning("Player found in set that was not found locally and globally: " + member);
|
||||||
} else {
|
} else {
|
||||||
jedis.srem("proxy:" + configuration.getProxyId() + ":usersOnline", member);
|
jedis.srem("proxy:" + configuration.getProxyId() + ":usersOnline", member);
|
||||||
@ -663,7 +663,7 @@ public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin
|
|||||||
if (proxiedPlayer == null)
|
if (proxiedPlayer == null)
|
||||||
continue; // We'll deal with it later.
|
continue; // We'll deal with it later.
|
||||||
|
|
||||||
BungeePlayerUtils.createPlayer(proxiedPlayer, pipeline, true);
|
BungeePlayerUtils.createPlayer(proxiedPlayer, pipeline, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
pipeline.sync();
|
pipeline.sync();
|
||||||
@ -687,7 +687,7 @@ public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin
|
|||||||
if (!laggedPlayers.isEmpty()) {
|
if (!laggedPlayers.isEmpty()) {
|
||||||
getLogger().info("Cleaning up lagged proxy " + s + " (" + laggedPlayers.size() + " players)...");
|
getLogger().info("Cleaning up lagged proxy " + s + " (" + laggedPlayers.size() + " players)...");
|
||||||
for (String laggedPlayer : laggedPlayers) {
|
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) {
|
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);
|
getLogger().warning("Player found in set that was not found locally and globally: " + member);
|
||||||
} else {
|
} else {
|
||||||
jedisCluster.srem("proxy:" + configuration.getProxyId() + ":usersOnline", member);
|
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) {
|
if (jedis.scard("proxy:" + configuration.getProxyId() + ":usersOnline") > 0) {
|
||||||
Set<String> players = jedis.smembers("proxy:" + configuration.getProxyId() + ":usersOnline");
|
Set<String> players = jedis.smembers("proxy:" + configuration.getProxyId() + ":usersOnline");
|
||||||
for (String member : players)
|
for (String member : players)
|
||||||
GenericPlayerUtils.cleanUpPlayer(member, jedis);
|
GenericPlayerUtils.cleanUpPlayer(member, jedis, true);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -788,7 +788,7 @@ public class RedisBungeeBungeePlugin extends Plugin implements RedisBungeePlugin
|
|||||||
if (jedisCluster.scard("proxy:" + configuration.getProxyId() + ":usersOnline") > 0) {
|
if (jedisCluster.scard("proxy:" + configuration.getProxyId() + ":usersOnline") > 0) {
|
||||||
Set<String> players = jedisCluster.smembers("proxy:" + configuration.getProxyId() + ":usersOnline");
|
Set<String> players = jedisCluster.smembers("proxy:" + configuration.getProxyId() + ":usersOnline");
|
||||||
for (String member : players)
|
for (String member : players)
|
||||||
GenericPlayerUtils.cleanUpPlayer(member, jedisCluster);
|
GenericPlayerUtils.cleanUpPlayer(member, jedisCluster, true);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -139,14 +139,14 @@ public class RedisBungeeVelocityListener extends AbstractRedisBungeeListener<Log
|
|||||||
@Override
|
@Override
|
||||||
public Void jedisTask(Jedis jedis) {
|
public Void jedisTask(Jedis jedis) {
|
||||||
Pipeline pipeline = jedis.pipelined();
|
Pipeline pipeline = jedis.pipelined();
|
||||||
GenericPlayerUtils.cleanUpPlayer(event.getPlayer().getUniqueId().toString(), pipeline);
|
GenericPlayerUtils.cleanUpPlayer(event.getPlayer().getUniqueId().toString(), pipeline, true);
|
||||||
pipeline.sync();
|
pipeline.sync();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void clusterJedisTask(JedisCluster jedisCluster) {
|
public Void clusterJedisTask(JedisCluster jedisCluster) {
|
||||||
GenericPlayerUtils.cleanUpPlayer(event.getPlayer().getUniqueId().toString(), jedisCluster);
|
GenericPlayerUtils.cleanUpPlayer(event.getPlayer().getUniqueId().toString(), jedisCluster, true);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -652,7 +652,7 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player> {
|
|||||||
if (!laggedPlayers.isEmpty()) {
|
if (!laggedPlayers.isEmpty()) {
|
||||||
getLogger().info("Cleaning up lagged proxy {} ({} players)...", s, laggedPlayers.size());
|
getLogger().info("Cleaning up lagged proxy {} ({} players)...", s, laggedPlayers.size());
|
||||||
for (String laggedPlayer : laggedPlayers) {
|
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) {
|
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);
|
getLogger().warn("Player found in set that was not found locally and globally: {}", member);
|
||||||
} else {
|
} else {
|
||||||
jedis.srem("proxy:" + configuration.getProxyId() + ":usersOnline", member);
|
jedis.srem("proxy:" + configuration.getProxyId() + ":usersOnline", member);
|
||||||
@ -715,7 +715,7 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player> {
|
|||||||
if (!laggedPlayers.isEmpty()) {
|
if (!laggedPlayers.isEmpty()) {
|
||||||
getLogger().info("Cleaning up lagged proxy {} ({} players)...", s, laggedPlayers.size());
|
getLogger().info("Cleaning up lagged proxy {} ({} players)...", s, laggedPlayers.size());
|
||||||
for (String laggedPlayer : laggedPlayers) {
|
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) {
|
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);
|
getLogger().warn("Player found in set that was not found locally and globally: {}", member);
|
||||||
} else {
|
} else {
|
||||||
jedisCluster.srem("proxy:" + configuration.getProxyId() + ":usersOnline", member);
|
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) {
|
if (jedis.scard("proxy:" + configuration.getProxyId() + ":usersOnline") > 0) {
|
||||||
Set<String> players = jedis.smembers("proxy:" + configuration.getProxyId() + ":usersOnline");
|
Set<String> players = jedis.smembers("proxy:" + configuration.getProxyId() + ":usersOnline");
|
||||||
for (String member : players)
|
for (String member : players)
|
||||||
GenericPlayerUtils.cleanUpPlayer(member, jedis);
|
GenericPlayerUtils.cleanUpPlayer(member, jedis, true);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -810,7 +810,7 @@ public class RedisBungeeVelocityPlugin implements RedisBungeePlugin<Player> {
|
|||||||
if (jedisCluster.scard("proxy:" + configuration.getProxyId() + ":usersOnline") > 0) {
|
if (jedisCluster.scard("proxy:" + configuration.getProxyId() + ":usersOnline") > 0) {
|
||||||
Set<String> players = jedisCluster.smembers("proxy:" + configuration.getProxyId() + ":usersOnline");
|
Set<String> players = jedisCluster.smembers("proxy:" + configuration.getProxyId() + ":usersOnline");
|
||||||
for (String member : players)
|
for (String member : players)
|
||||||
GenericPlayerUtils.cleanUpPlayer(member, jedisCluster);
|
GenericPlayerUtils.cleanUpPlayer(member, jedisCluster, true);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user