Skip to content

Commit

Permalink
Fixed null when fetching server id. (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
MassiveLag authored Sep 16, 2024
1 parent af80e20 commit 219a4ab
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,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<P, LE, DE, PS extends IPubSubMessageEvent, SC extends IPlayerChangedServerNetworkEvent, NJE extends IPlayerLeftNetworkEvent, CE, PJN extends IPlayerJoinedNetworkEvent> {
Expand Down Expand Up @@ -267,7 +264,9 @@ protected Multimap<String, UUID> serversToPlayersBuilder(Object o) {
public Multimap<String, UUID> doPooledPipeline(Pipeline pipeline) {
HashMap<UUID, Response<String>> 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) -> {
Expand All @@ -283,13 +282,14 @@ public Multimap<String, UUID> doPooledPipeline(Pipeline pipeline) {
public Multimap<String, UUID> clusterPipeline(ClusterPipeline pipeline) {
HashMap<UUID, Response<String>> 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();
Expand Down

0 comments on commit 219a4ab

Please sign in to comment.