mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2025-04-20 01:27:07 +00:00
Made the code more efficient / performance.
This commit is contained in:
parent
289996088b
commit
e5dc4772d8
@ -29,10 +29,7 @@ import redis.clients.jedis.Response;
|
|||||||
import redis.clients.jedis.UnifiedJedis;
|
import redis.clients.jedis.UnifiedJedis;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
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> {
|
public abstract class PlayerDataManager<P, LE, DE, PS extends IPubSubMessageEvent, SC extends IPlayerChangedServerNetworkEvent, NJE extends IPlayerLeftNetworkEvent, CE, PJN extends IPlayerJoinedNetworkEvent> {
|
||||||
@ -267,9 +264,9 @@ public abstract class PlayerDataManager<P, LE, DE, PS extends IPubSubMessageEven
|
|||||||
public Multimap<String, UUID> doPooledPipeline(Pipeline pipeline) {
|
public Multimap<String, UUID> doPooledPipeline(Pipeline pipeline) {
|
||||||
HashMap<UUID, Response<String>> responses = new HashMap<>();
|
HashMap<UUID, Response<String>> responses = new HashMap<>();
|
||||||
for (UUID uuid : uuids) {
|
for (UUID uuid : uuids) {
|
||||||
Response<String> server = pipeline.hget("redis-bungee::" + networkId + "::player::" + uuid + "::data", "server");
|
Optional.ofNullable(pipeline.hget("redis-bungee::" + networkId + "::player::" + uuid + "::data", "server")).ifPresent(stringResponse -> {
|
||||||
if (server != null)
|
responses.put(uuid, stringResponse);
|
||||||
responses.put(uuid, pipeline.hget("redis-bungee::" + networkId + "::player::" + uuid + "::data", "server"));
|
});
|
||||||
}
|
}
|
||||||
pipeline.sync();
|
pipeline.sync();
|
||||||
responses.forEach((uuid, response) -> {
|
responses.forEach((uuid, response) -> {
|
||||||
@ -285,13 +282,14 @@ public abstract class PlayerDataManager<P, LE, DE, PS extends IPubSubMessageEven
|
|||||||
public Multimap<String, UUID> clusterPipeline(ClusterPipeline pipeline) {
|
public Multimap<String, UUID> clusterPipeline(ClusterPipeline pipeline) {
|
||||||
HashMap<UUID, Response<String>> responses = new HashMap<>();
|
HashMap<UUID, Response<String>> responses = new HashMap<>();
|
||||||
for (UUID uuid : uuids) {
|
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();
|
pipeline.sync();
|
||||||
responses.forEach((uuid, response) -> {
|
responses.forEach((uuid, response) -> {
|
||||||
String key = response.get();
|
String key = response.get();
|
||||||
if (key == null) return;
|
if (key == null) return;
|
||||||
|
|
||||||
builder.put(key, uuid);
|
builder.put(key, uuid);
|
||||||
});
|
});
|
||||||
return builder.build();
|
return builder.build();
|
||||||
|
Loading…
Reference in New Issue
Block a user