Fix IllegalAccessError: tried to access protected method

This commit is contained in:
Glavo 2021-10-25 16:49:11 +08:00 committed by Yuhui Huang
parent a320fe4cc4
commit 026239903d

View File

@ -94,9 +94,16 @@ public class YggdrasilServer extends HttpServer {
if (!request.getQuery().containsKey("username")) {
return badRequest();
}
return findCharacterByName(request.getQuery().get("username"))
.map(character -> ok(character.toCompleteResponse(getRootUrl())))
.orElseGet(HttpServer::noContent);
Optional<Character> character = findCharacterByName(request.getQuery().get("username"));
//Workaround for JDK-8138667
//noinspection OptionalIsPresent
if (character.isPresent()) {
return ok(character.get().toCompleteResponse(getRootUrl()));
} else {
return HttpServer.noContent();
}
}
private Response joinServer(Request request) {
@ -106,9 +113,15 @@ public class YggdrasilServer extends HttpServer {
private Response profile(Request request) {
String uuid = request.getPathVariables().group("uuid");
return findCharacterByUuid(UUIDTypeAdapter.fromString(uuid))
.map(character -> ok(character.toCompleteResponse(getRootUrl())))
.orElseGet(HttpServer::noContent);
Optional<Character> character = findCharacterByUuid(UUIDTypeAdapter.fromString(uuid));
//Workaround for JDK-8138667
//noinspection OptionalIsPresent
if (character.isPresent()) {
return ok(character.get().toCompleteResponse(getRootUrl()));
} else {
return HttpServer.noContent();
}
}
private Response texture(Request request) {