/** * Construct a new game profile with the given properties. * <p> * Note that this constructor is very lenient when parsing UUIDs for backwards compatibility reasons. * IDs that cannot be parsed as an UUID will be hashed and form a version 3 UUID instead. * <p> * This method is deprecated for Minecraft 1.7.8 and above. * * @param id - the UUID of the player. * @param name - the name of the player. */ @Deprecated public WrappedGameProfile(String id, String name) { super(GAME_PROFILE); if (CREATE_STRING_STRING != null) { setHandle(CREATE_STRING_STRING.invoke(id, name)); } else if (CREATE_UUID_STRING != null) { setHandle(CREATE_UUID_STRING.invoke(parseUUID(id), name)); } else { throw new IllegalArgumentException("Unsupported GameProfile constructor."); } }
/** * Retrieve the UUID of the player. * <p> * Note that Minecraft 1.7.5 and earlier doesn't use UUIDs internally, and it may not be possible to convert the string to an UUID. * <p> * We use the same lax conversion as in {@link #WrappedGameProfile(String, String)}. * * @return The UUID, or NULL if the UUID is NULL. * @throws IllegalStateException If we cannot parse the internal ID as an UUID. */ public UUID getUUID() { UUID uuid = parsedUUID; if (uuid == null) { try { if (GET_UUID_STRING != null) { uuid = parseUUID(getId()); } else if (GET_ID != null) { uuid = (UUID) GET_ID.invoke(handle); } else { throw new IllegalStateException("Unsupported getId() method"); } // Cache for later parsedUUID = uuid; } catch (IllegalArgumentException e) { throw new IllegalStateException("Cannot parse ID " + getId() + " as an UUID in player profile " + getName(), e); } } return uuid; }