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

revert payloads due mass errors

This commit is contained in:
mohammed jasem alaajel 2022-04-14 01:40:16 +04:00
parent d3889d8bd9
commit 08c7d89749
3 changed files with 16 additions and 20 deletions

View File

@ -171,11 +171,11 @@ public abstract class DataManager<P, PL, PD, PS> {
switch (action) { switch (action) {
case JOIN: case JOIN:
final DataManagerMessage message1 = gson.fromJson(jsonObject, new TypeToken<DataManagerMessage>() { final DataManagerMessage<LoginPayload> message1 = gson.fromJson(jsonObject, new TypeToken<DataManagerMessage<LoginPayload>>() {
}.getType()); }.getType());
proxyCache.put(message1.getTarget(), message1.getSource()); proxyCache.put(message1.getTarget(), message1.getSource());
lastOnlineCache.put(message1.getTarget(), (long) 0); lastOnlineCache.put(message1.getTarget(), (long) 0);
ipCache.put(message1.getTarget(), ((LoginPayload) message1.getPayload()).getAddress()); ipCache.put(message1.getTarget(), message1.getPayload().getAddress());
plugin.executeAsync(new Runnable() { plugin.executeAsync(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -191,10 +191,10 @@ public abstract class DataManager<P, PL, PD, PS> {
}); });
break; break;
case LEAVE: case LEAVE:
final DataManagerMessage message2 = gson.fromJson(jsonObject, new TypeToken<DataManagerMessage>() { final DataManagerMessage<LogoutPayload> message2 = gson.fromJson(jsonObject, new TypeToken<DataManagerMessage<LogoutPayload>>() {
}.getType()); }.getType());
invalidate(message2.getTarget()); invalidate(message2.getTarget());
lastOnlineCache.put(message2.getTarget(), ((LogoutPayload) message2.getPayload()).getTimestamp()); lastOnlineCache.put(message2.getTarget(), message2.getPayload().getTimestamp());
plugin.executeAsync(new Runnable() { plugin.executeAsync(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -209,9 +209,9 @@ public abstract class DataManager<P, PL, PD, PS> {
}); });
break; break;
case SERVER_CHANGE: case SERVER_CHANGE:
final DataManagerMessage message3 = gson.fromJson(jsonObject, new TypeToken<DataManagerMessage>() { final DataManagerMessage<ServerChangePayload> message3 = gson.fromJson(jsonObject, new TypeToken<DataManagerMessage<ServerChangePayload>>() {
}.getType()); }.getType());
serverCache.put(message3.getTarget(), ((ServerChangePayload) message3.getPayload()).getServer()); serverCache.put(message3.getTarget(), message3.getPayload().getServer());
plugin.executeAsync(new Runnable() { plugin.executeAsync(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -228,13 +228,13 @@ public abstract class DataManager<P, PL, PD, PS> {
} }
} }
public static class DataManagerMessage { public static class DataManagerMessage<T> {
private final UUID target; private final UUID target;
private final String source; private final String source;
private final Action action; // for future use! private final Action action; // for future use!
private final Payload payload; private final T payload;
public DataManagerMessage(UUID target, String source, Action action, Payload payload) { public DataManagerMessage(UUID target, String source, Action action, T payload) {
this.target = target; this.target = target;
this.source = source; this.source = source;
this.action = action; this.action = action;
@ -253,7 +253,7 @@ public abstract class DataManager<P, PL, PD, PS> {
return action; return action;
} }
public Payload getPayload() { public T getPayload() {
return payload; return payload;
} }
@ -264,11 +264,7 @@ public abstract class DataManager<P, PL, PD, PS> {
} }
} }
public static abstract class Payload { public static class LoginPayload {
}
public static class LoginPayload extends Payload {
private final InetAddress address; private final InetAddress address;
public LoginPayload(InetAddress address) { public LoginPayload(InetAddress address) {
@ -280,7 +276,7 @@ public abstract class DataManager<P, PL, PD, PS> {
} }
} }
public static class ServerChangePayload extends Payload { public static class ServerChangePayload{
private final String server; private final String server;
private final String oldServer; private final String oldServer;
@ -299,7 +295,7 @@ public abstract class DataManager<P, PL, PD, PS> {
} }
public static class LogoutPayload extends Payload { public static class LogoutPayload {
private final long timestamp; private final long timestamp;
public LogoutPayload(long timestamp) { public LogoutPayload(long timestamp) {

View File

@ -17,7 +17,7 @@ public class RedisUtil {
rsc.hdel("player:" + player, "server", "ip", "proxy"); rsc.hdel("player:" + player, "server", "ip", "proxy");
long timestamp = System.currentTimeMillis(); long timestamp = System.currentTimeMillis();
rsc.hset("player:" + player, "online", String.valueOf(timestamp)); rsc.hset("player:" + player, "online", String.valueOf(timestamp));
rsc.publish("redisbungee-data", gson.toJson(new DataManager.DataManagerMessage( rsc.publish("redisbungee-data", gson.toJson(new DataManager.DataManagerMessage<>(
UUID.fromString(player), RedisBungeeAPI.getRedisBungeeApi().getServerId(), DataManager.DataManagerMessage.Action.LEAVE, UUID.fromString(player), RedisBungeeAPI.getRedisBungeeApi().getServerId(), DataManager.DataManagerMessage.Action.LEAVE,
new DataManager.LogoutPayload(timestamp)))); new DataManager.LogoutPayload(timestamp))));
} }
@ -27,7 +27,7 @@ public class RedisUtil {
rsc.hdel("player:" + player, "server", "ip", "proxy"); rsc.hdel("player:" + player, "server", "ip", "proxy");
long timestamp = System.currentTimeMillis(); long timestamp = System.currentTimeMillis();
rsc.hset("player:" + player, "online", String.valueOf(timestamp)); rsc.hset("player:" + player, "online", String.valueOf(timestamp));
rsc.publish("redisbungee-data", gson.toJson(new DataManager.DataManagerMessage( rsc.publish("redisbungee-data", gson.toJson(new DataManager.DataManagerMessage<>(
UUID.fromString(player), RedisBungeeAPI.getRedisBungeeApi().getServerId(), DataManager.DataManagerMessage.Action.LEAVE, UUID.fromString(player), RedisBungeeAPI.getRedisBungeeApi().getServerId(), DataManager.DataManagerMessage.Action.LEAVE,
new DataManager.LogoutPayload(timestamp)))); new DataManager.LogoutPayload(timestamp))));
} }

View File

@ -29,7 +29,7 @@ public class RBUtils {
pipeline.hmset("player:" + connection.getUniqueId().toString(), playerData); pipeline.hmset("player:" + connection.getUniqueId().toString(), playerData);
if (fireEvent) { if (fireEvent) {
pipeline.publish("redisbungee-data", gson.toJson(new DataManager.DataManagerMessage( pipeline.publish("redisbungee-data", gson.toJson(new DataManager.DataManagerMessage<>(
connection.getUniqueId(), RedisBungeeAPI.getRedisBungeeApi().getServerId(), DataManager.DataManagerMessage.Action.JOIN, connection.getUniqueId(), RedisBungeeAPI.getRedisBungeeApi().getServerId(), DataManager.DataManagerMessage.Action.JOIN,
new DataManager.LoginPayload(connection.getAddress().getAddress())))); new DataManager.LoginPayload(connection.getAddress().getAddress()))));
} }