From d8704c8a8f8ef204fc7cee7f93afb76ddcb94073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20=7C=20NoPermission?= Date: Mon, 16 Sep 2024 13:44:35 +0200 Subject: [PATCH] Fixed null when fetching server id. (#118) (cherry picked from commit 219a4ab360a982d37b96558edc523d2ad0653676) --- .../redisbungee/api/PlayerDataManager.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/api/src/main/java/com/imaginarycode/minecraft/redisbungee/api/PlayerDataManager.java b/api/src/main/java/com/imaginarycode/minecraft/redisbungee/api/PlayerDataManager.java index 12f360d3..71a9196d 100644 --- a/api/src/main/java/com/imaginarycode/minecraft/redisbungee/api/PlayerDataManager.java +++ b/api/src/main/java/com/imaginarycode/minecraft/redisbungee/api/PlayerDataManager.java @@ -28,10 +28,7 @@ import redis.clients.jedis.UnifiedJedis; import java.net.InetAddress; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.UUID; +import java.util.*; import java.util.concurrent.TimeUnit; public abstract class PlayerDataManager { @@ -248,7 +245,9 @@ protected Multimap serversToPlayersBuilder(Object o) { public Multimap doPooledPipeline(Pipeline pipeline) { HashMap> responses = new HashMap<>(); for (UUID uuid : uuids) { - responses.put(uuid, pipeline.hget("redis-bungee::" + networkId + "::player::" + uuid + "::data", "server")); + Optional.ofNullable(pipeline.hget("redis-bungee::" + networkId + "::player::" + uuid + "::data", "server")).ifPresent(stringResponse -> { + responses.put(uuid, stringResponse); + }); } pipeline.sync(); responses.forEach((uuid, response) -> { @@ -264,13 +263,14 @@ public Multimap doPooledPipeline(Pipeline pipeline) { public Multimap clusterPipeline(ClusterPipeline pipeline) { HashMap> responses = new HashMap<>(); for (UUID uuid : uuids) { - responses.put(uuid, pipeline.hget("redis-bungee::" + networkId + "::player::" + uuid + "::data", "server")); + Optional.ofNullable(pipeline.hget("redis-bungee::" + networkId + "::player::" + uuid + "::data", "server")).ifPresent(stringResponse -> { + responses.put(uuid, stringResponse); + }); } pipeline.sync(); responses.forEach((uuid, response) -> { String key = response.get(); if (key == null) return; - builder.put(key, uuid); }); return builder.build();