2022-07-19 11:30:45 +00:00
|
|
|
package com.imaginarycode.minecraft.redisbungee.api.util.payload;
|
|
|
|
|
|
|
|
import com.google.gson.Gson;
|
2022-07-27 13:43:51 +00:00
|
|
|
import com.imaginarycode.minecraft.redisbungee.AbstractRedisBungeeAPI;
|
2022-07-19 11:30:45 +00:00
|
|
|
import com.imaginarycode.minecraft.redisbungee.api.AbstractDataManager;
|
2022-07-26 13:47:18 +00:00
|
|
|
import redis.clients.jedis.UnifiedJedis;
|
2022-07-19 11:30:45 +00:00
|
|
|
|
2022-07-20 08:32:04 +00:00
|
|
|
import java.net.InetAddress;
|
2022-07-19 11:30:45 +00:00
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
public class PayloadUtils {
|
|
|
|
private static final Gson gson = new Gson();
|
|
|
|
|
2022-07-26 13:47:18 +00:00
|
|
|
public static void playerJoinPayload(UUID uuid, UnifiedJedis unifiedJedis, InetAddress inetAddress) {
|
|
|
|
unifiedJedis.publish("redisbungee-data", gson.toJson(new AbstractDataManager.DataManagerMessage<>(
|
2022-07-27 13:43:51 +00:00
|
|
|
uuid, AbstractRedisBungeeAPI.getAbstractRedisBungeeAPI().getProxyId(), AbstractDataManager.DataManagerMessage.Action.JOIN,
|
2022-07-20 08:32:04 +00:00
|
|
|
new AbstractDataManager.LoginPayload(inetAddress))));
|
|
|
|
}
|
|
|
|
|
2022-07-19 11:30:45 +00:00
|
|
|
|
2022-07-26 13:47:18 +00:00
|
|
|
public static void playerQuitPayload(String uuid, UnifiedJedis unifiedJedis, long timestamp) {
|
|
|
|
unifiedJedis.publish("redisbungee-data", gson.toJson(new AbstractDataManager.DataManagerMessage<>(
|
2022-07-27 13:43:51 +00:00
|
|
|
UUID.fromString(uuid), AbstractRedisBungeeAPI.getAbstractRedisBungeeAPI().getProxyId(), AbstractDataManager.DataManagerMessage.Action.LEAVE,
|
2022-07-19 11:30:45 +00:00
|
|
|
new AbstractDataManager.LogoutPayload(timestamp))));
|
|
|
|
}
|
|
|
|
|
2022-07-20 08:32:04 +00:00
|
|
|
|
|
|
|
|
2022-07-26 13:47:18 +00:00
|
|
|
public static void playerServerChangePayload(UUID uuid, UnifiedJedis unifiedJedis, String newServer, String oldServer) {
|
|
|
|
unifiedJedis.publish("redisbungee-data", gson.toJson(new AbstractDataManager.DataManagerMessage<>(
|
2022-07-27 13:43:51 +00:00
|
|
|
uuid, AbstractRedisBungeeAPI.getAbstractRedisBungeeAPI().getProxyId(), AbstractDataManager.DataManagerMessage.Action.SERVER_CHANGE,
|
2022-07-20 08:32:04 +00:00
|
|
|
new AbstractDataManager.ServerChangePayload(newServer, oldServer))));
|
|
|
|
}
|
|
|
|
|
2022-07-19 11:30:45 +00:00
|
|
|
|
2022-07-26 13:47:18 +00:00
|
|
|
public static void kickPlayerPayload(UUID uuid, String message, UnifiedJedis unifiedJedis) {
|
|
|
|
unifiedJedis.publish("redisbungee-data", gson.toJson(new AbstractDataManager.DataManagerMessage<>(
|
2022-07-27 13:43:51 +00:00
|
|
|
uuid, AbstractRedisBungeeAPI.getAbstractRedisBungeeAPI().getProxyId(), AbstractDataManager.DataManagerMessage.Action.KICK,
|
2022-07-19 11:30:45 +00:00
|
|
|
new AbstractDataManager.KickPayload(message))));
|
|
|
|
}
|
|
|
|
}
|