fix: store uuid
This commit is contained in:
parent
37b1d5bd0c
commit
571ed1d31d
1 changed files with 6 additions and 4 deletions
|
@ -65,14 +65,15 @@ public class MojangAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<String> getUUIDFromMojang(String name) throws IOException {
|
private Optional<String> getUUIDFromMojang(String name) throws IOException {
|
||||||
// TODO (Ineanto, 7/6/23): store uuid
|
|
||||||
final String parametrizedUrl = URL_NAME.replace("{name}", name);
|
final String parametrizedUrl = URL_NAME.replace("{name}", name);
|
||||||
final JsonObject object = getRequestToUrl(parametrizedUrl);
|
final JsonObject object = getRequestToUrl(parametrizedUrl);
|
||||||
if (hasNoError(object)) {
|
if (hasNoError(object)) {
|
||||||
final JsonElement idObject = object.get("id");
|
final JsonElement idObject = object.get("id");
|
||||||
final String id = idObject.getAsString();
|
final String uuid = idObject.getAsString();
|
||||||
uuidToName.put(id, name);
|
final Optional<String> uuidOptional = Optional.of(uuid);
|
||||||
return Optional.of(id);
|
uuidCache.put(name, uuidOptional);
|
||||||
|
uuidToName.put(uuid, name);
|
||||||
|
return uuidOptional;
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
@ -80,6 +81,7 @@ public class MojangAPI {
|
||||||
public void eraseFromCache(String uuid) {
|
public void eraseFromCache(String uuid) {
|
||||||
skinCache.invalidate(uuid);
|
skinCache.invalidate(uuid);
|
||||||
uuidToName.remove(uuid);
|
uuidToName.remove(uuid);
|
||||||
|
uuidCache.invalidate(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<MojangSkin> getSkinFromMojang(String uuid) throws IOException {
|
private Optional<MojangSkin> getSkinFromMojang(String uuid) throws IOException {
|
||||||
|
|
Loading…
Add table
Reference in a new issue