Support Mojangian UUIDs

This commit is contained in:
Tux 2014-05-23 10:53:38 -04:00
parent 730b77f227
commit 0136699b40
2 changed files with 7 additions and 1 deletions

View File

@ -70,7 +70,7 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
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));
}

View File

@ -26,6 +26,7 @@ public class UUIDTranslator {
private final RedisBungee plugin;
private BiMap<String, UUID> uuidMap = Maps.synchronizedBiMap(HashBiMap.<String, UUID>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);