2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2024-11-23 04:28:01 +00:00

Better persistence of translated data

This commit is contained in:
Tux 2014-04-23 18:05:42 -04:00
parent 4aeb762c17
commit c5d35a2a1c

View File

@ -47,7 +47,8 @@ public class UUIDTranslator {
if (stored != null && UUID_PATTERN.matcher(stored).find()) { if (stored != null && UUID_PATTERN.matcher(stored).find()) {
// This is it! // This is it!
uuid = UUID.fromString(stored); uuid = UUID.fromString(stored);
uuidMap.put(player, UUID.fromString(stored)); storeInfo(player, uuid, jedis);
uuidMap.put(player, uuid);
return uuid; return uuid;
} }
@ -56,7 +57,7 @@ public class UUIDTranslator {
if (uuid != null) { if (uuid != null) {
uuidMap.put(player, uuid); uuidMap.put(player, uuid);
jedis.hset("uuids", player, uuid.toString()); storeInfo(player, uuid, jedis);
} }
return uuid; return uuid;
@ -91,8 +92,7 @@ public class UUIDTranslator {
name = new NameFetcher(Collections.singletonList(player)).call().get(player); name = new NameFetcher(Collections.singletonList(player)).call().get(player);
if (name != null) { if (name != null) {
jedis.hset("player:" + player, "name", name); storeInfo(name, player, jedis);
uuidMap.put(name, player);
return name; return name;
} }
@ -104,4 +104,9 @@ public class UUIDTranslator {
plugin.getPool().returnResource(jedis); plugin.getPool().returnResource(jedis);
} }
} }
private static void storeInfo(String name, UUID uuid, Jedis jedis) {
jedis.hset("uuids", name, uuid.toString());
jedis.hset("player:" + uuid, "name", name);
}
} }