From 0136699b40166927ebcc780313dccfcf8c6a17b3 Mon Sep 17 00:00:00 2001 From: Tux Date: Fri, 23 May 2014 10:53:38 -0400 Subject: [PATCH] Support Mojangian UUIDs --- .../minecraft/redisbungee/util/UUIDFetcher.java | 2 +- .../minecraft/redisbungee/util/UUIDTranslator.java | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/imaginarycode/minecraft/redisbungee/util/UUIDFetcher.java b/src/main/java/com/imaginarycode/minecraft/redisbungee/util/UUIDFetcher.java index 031a2fb..d65f7ec 100644 --- a/src/main/java/com/imaginarycode/minecraft/redisbungee/util/UUIDFetcher.java +++ b/src/main/java/com/imaginarycode/minecraft/redisbungee/util/UUIDFetcher.java @@ -70,7 +70,7 @@ public class UUIDFetcher implements Callable> { return connection; } - private static UUID getUUID(String id) { + public static UUID getUUID(String id) { return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" + id.substring(20, 32)); } diff --git a/src/main/java/com/imaginarycode/minecraft/redisbungee/util/UUIDTranslator.java b/src/main/java/com/imaginarycode/minecraft/redisbungee/util/UUIDTranslator.java index 3658ee3..4faf5e8 100644 --- a/src/main/java/com/imaginarycode/minecraft/redisbungee/util/UUIDTranslator.java +++ b/src/main/java/com/imaginarycode/minecraft/redisbungee/util/UUIDTranslator.java @@ -26,6 +26,7 @@ public class UUIDTranslator { private final RedisBungee plugin; private BiMap uuidMap = Maps.synchronizedBiMap(HashBiMap.create()); public static final Pattern UUID_PATTERN = Pattern.compile("[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}"); + public static final Pattern MOJANGIAN_UUID_PATTERN = Pattern.compile("[a-fA-F0-9]{32}"); public UUID getTranslatedUuid(String player) { if (ProxyServer.getInstance().getPlayer(player) != null) @@ -39,6 +40,11 @@ public class UUIDTranslator { return UUID.fromString(player); } + if (MOJANGIAN_UUID_PATTERN.matcher(player).find()) { + // Reconstruct the UUID + return UUIDFetcher.getUUID(player); + } + if (!plugin.getProxy().getConfig().isOnlineMode()) { uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + player).getBytes(Charsets.UTF_8)); uuidMap.put(player, uuid);