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

move PlayerUtils and change the name

This commit is contained in:
mohammed jasem alaajel 2022-07-26 12:49:44 +04:00
parent 92f5e04edf
commit 81a8fd218e
5 changed files with 16 additions and 18 deletions

View File

@ -1,6 +1,6 @@
package com.imaginarycode.minecraft.redisbungee.api.tasks; package com.imaginarycode.minecraft.redisbungee.api.tasks;
import com.imaginarycode.minecraft.redisbungee.api.GenericPlayerUtils; import com.imaginarycode.minecraft.redisbungee.api.util.player.PlayerUtils;
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin; import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
import redis.clients.jedis.Jedis; import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisCluster; import redis.clients.jedis.JedisCluster;
@ -9,9 +9,7 @@ import redis.clients.jedis.Pipeline;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
public abstract class IntegrityCheckTask extends RedisTask<Void> { public abstract class IntegrityCheckTask extends RedisTask<Void> {
@ -37,7 +35,7 @@ public abstract class IntegrityCheckTask extends RedisTask<Void> {
if (!laggedPlayers.isEmpty()) { if (!laggedPlayers.isEmpty()) {
plugin.logInfo("Cleaning up lagged proxy " + s + " (" + laggedPlayers.size() + " players)..."); plugin.logInfo("Cleaning up lagged proxy " + s + " (" + laggedPlayers.size() + " players)...");
for (String laggedPlayer : laggedPlayers) { for (String laggedPlayer : laggedPlayers) {
GenericPlayerUtils.cleanUpPlayer(laggedPlayer, jedis, true); PlayerUtils.cleanUpPlayer(laggedPlayer, jedis, true);
} }
} }
} }
@ -58,7 +56,7 @@ public abstract class IntegrityCheckTask extends RedisTask<Void> {
} }
} }
if (!found) { if (!found) {
GenericPlayerUtils.cleanUpPlayer(member, jedis, false); PlayerUtils.cleanUpPlayer(member, jedis, false);
plugin.logWarn("Player found in set that was not found locally and globally: " + member); plugin.logWarn("Player found in set that was not found locally and globally: " + member);
} else { } else {
jedis.srem("proxy:" + plugin.getConfiguration().getProxyId() + ":usersOnline", member); jedis.srem("proxy:" + plugin.getConfiguration().getProxyId() + ":usersOnline", member);
@ -96,7 +94,7 @@ public abstract class IntegrityCheckTask extends RedisTask<Void> {
if (!laggedPlayers.isEmpty()) { if (!laggedPlayers.isEmpty()) {
plugin.logInfo("Cleaning up lagged proxy " + s + " (" + laggedPlayers.size() + " players)..."); plugin.logInfo("Cleaning up lagged proxy " + s + " (" + laggedPlayers.size() + " players)...");
for (String laggedPlayer : laggedPlayers) { for (String laggedPlayer : laggedPlayers) {
GenericPlayerUtils.cleanUpPlayer(laggedPlayer, jedisCluster, true); PlayerUtils.cleanUpPlayer(laggedPlayer, jedisCluster, true);
} }
} }
} }
@ -117,7 +115,7 @@ public abstract class IntegrityCheckTask extends RedisTask<Void> {
} }
} }
if (!found) { if (!found) {
GenericPlayerUtils.cleanUpPlayer(member, jedisCluster, false); PlayerUtils.cleanUpPlayer(member, jedisCluster, false);
plugin.logWarn("Player found in set that was not found locally and globally: " + member); plugin.logWarn("Player found in set that was not found locally and globally: " + member);
} else { } else {
jedisCluster.srem("proxy:" + plugin.getConfiguration().getProxyId() + ":usersOnline", member); jedisCluster.srem("proxy:" + plugin.getConfiguration().getProxyId() + ":usersOnline", member);

View File

@ -1,6 +1,6 @@
package com.imaginarycode.minecraft.redisbungee.api.tasks; package com.imaginarycode.minecraft.redisbungee.api.tasks;
import com.imaginarycode.minecraft.redisbungee.api.GenericPlayerUtils; import com.imaginarycode.minecraft.redisbungee.api.util.player.PlayerUtils;
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin; import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
import redis.clients.jedis.Jedis; import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisCluster; import redis.clients.jedis.JedisCluster;
@ -17,7 +17,7 @@ public class ShutdownUtils {
if (jedis.scard("proxy:" + plugin.getConfiguration().getProxyId() + ":usersOnline") > 0) { if (jedis.scard("proxy:" + plugin.getConfiguration().getProxyId() + ":usersOnline") > 0) {
Set<String> players = jedis.smembers("proxy:" + plugin.getConfiguration().getProxyId() + ":usersOnline"); Set<String> players = jedis.smembers("proxy:" + plugin.getConfiguration().getProxyId() + ":usersOnline");
for (String member : players) for (String member : players)
GenericPlayerUtils.cleanUpPlayer(member, jedis, true); PlayerUtils.cleanUpPlayer(member, jedis, true);
} }
return null; return null;
} }
@ -28,7 +28,7 @@ public class ShutdownUtils {
if (jedisCluster.scard("proxy:" + plugin.getConfiguration().getProxyId() + ":usersOnline") > 0) { if (jedisCluster.scard("proxy:" + plugin.getConfiguration().getProxyId() + ":usersOnline") > 0) {
Set<String> players = jedisCluster.smembers("proxy:" + plugin.getConfiguration().getProxyId() + ":usersOnline"); Set<String> players = jedisCluster.smembers("proxy:" + plugin.getConfiguration().getProxyId() + ":usersOnline");
for (String member : players) for (String member : players)
GenericPlayerUtils.cleanUpPlayer(member, jedisCluster, true); PlayerUtils.cleanUpPlayer(member, jedisCluster, true);
} }
return null; return null;
} }

View File

@ -1,4 +1,4 @@
package com.imaginarycode.minecraft.redisbungee.api; package com.imaginarycode.minecraft.redisbungee.api.util.player;
import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI; import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI;
import redis.clients.jedis.Jedis; import redis.clients.jedis.Jedis;
@ -7,7 +7,7 @@ import redis.clients.jedis.Pipeline;
import static com.imaginarycode.minecraft.redisbungee.api.util.payload.PayloadUtils.playerQuitPayload; import static com.imaginarycode.minecraft.redisbungee.api.util.payload.PayloadUtils.playerQuitPayload;
public class GenericPlayerUtils { public class PlayerUtils {
public static void cleanUpPlayer(String uuid, Jedis rsc, boolean firePayload) { public static void cleanUpPlayer(String uuid, Jedis rsc, boolean firePayload) {

View File

@ -7,7 +7,7 @@ import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import com.imaginarycode.minecraft.redisbungee.api.AbstractRedisBungeeListener; import com.imaginarycode.minecraft.redisbungee.api.AbstractRedisBungeeListener;
import com.imaginarycode.minecraft.redisbungee.api.GenericPlayerUtils; import com.imaginarycode.minecraft.redisbungee.api.util.player.PlayerUtils;
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin; import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
import com.imaginarycode.minecraft.redisbungee.api.tasks.RedisTask; import com.imaginarycode.minecraft.redisbungee.api.tasks.RedisTask;
import com.imaginarycode.minecraft.redisbungee.api.util.payload.PayloadUtils; import com.imaginarycode.minecraft.redisbungee.api.util.payload.PayloadUtils;
@ -144,7 +144,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, true); PlayerUtils.cleanUpPlayer(event.getPlayer().getUniqueId().toString(), pipeline, true);
pipeline.sync(); pipeline.sync();
return null; return null;
} }
@ -152,7 +152,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, true); PlayerUtils.cleanUpPlayer(event.getPlayer().getUniqueId().toString(), jedisCluster, true);
return null; return null;
} }
}); });

View File

@ -7,7 +7,7 @@ import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams; import com.google.common.io.ByteStreams;
import com.imaginarycode.minecraft.redisbungee.api.AbstractRedisBungeeListener; import com.imaginarycode.minecraft.redisbungee.api.AbstractRedisBungeeListener;
import com.imaginarycode.minecraft.redisbungee.api.GenericPlayerUtils; import com.imaginarycode.minecraft.redisbungee.api.util.player.PlayerUtils;
import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin; import com.imaginarycode.minecraft.redisbungee.api.RedisBungeePlugin;
import com.imaginarycode.minecraft.redisbungee.api.tasks.RedisTask; import com.imaginarycode.minecraft.redisbungee.api.tasks.RedisTask;
import com.imaginarycode.minecraft.redisbungee.api.util.payload.PayloadUtils; import com.imaginarycode.minecraft.redisbungee.api.util.payload.PayloadUtils;
@ -138,14 +138,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, true); PlayerUtils.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, true); PlayerUtils.cleanUpPlayer(event.getPlayer().getUniqueId().toString(), jedisCluster, true);
return null; return null;
} }