mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2026-04-09 00:20:26 +00:00
move PlayerUtils code from platforms to the api
This commit is contained in:
@@ -3,6 +3,12 @@ package com.imaginarycode.minecraft.redisbungee.api.util.player;
|
||||
import com.imaginarycode.minecraft.redisbungee.AbstractRedisBungeeAPI;
|
||||
import redis.clients.jedis.UnifiedJedis;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.imaginarycode.minecraft.redisbungee.api.util.payload.PayloadUtils.playerJoinPayload;
|
||||
import static com.imaginarycode.minecraft.redisbungee.api.util.payload.PayloadUtils.playerQuitPayload;
|
||||
|
||||
public class PlayerUtils {
|
||||
@@ -17,5 +23,22 @@ public class PlayerUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void createPlayer(UUID uuid, UnifiedJedis unifiedJedis, String currentServer, InetAddress hostname, boolean fireEvent) {
|
||||
if (currentServer != null) {
|
||||
unifiedJedis.hset("player:" + uuid, "server", currentServer);
|
||||
}
|
||||
Map<String, String> playerData = new HashMap<>(4);
|
||||
playerData.put("online", "0");
|
||||
playerData.put("ip", hostname.getHostName());
|
||||
playerData.put("proxy", AbstractRedisBungeeAPI.getAbstractRedisBungeeAPI().getProxyId());
|
||||
|
||||
unifiedJedis.sadd("proxy:" + AbstractRedisBungeeAPI.getAbstractRedisBungeeAPI().getProxyId() + ":usersOnline", uuid.toString());
|
||||
unifiedJedis.hmset("player:" + uuid, playerData);
|
||||
|
||||
if (fireEvent) {
|
||||
playerJoinPayload(uuid, unifiedJedis, hostname);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user