Merge pull request #52 from iTruth/development

Fix playerOpt is always throw an exception when it's null
This commit is contained in:
Melledy 2022-04-20 06:25:00 -07:00 committed by GitHub
commit 0811c52f75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -145,7 +145,7 @@ public final class GameServer extends MihoyoKcpServer {
public Account getAccountByName(String username) {
Optional<GenshinPlayer> playerOpt = getPlayers().values().stream().filter(player -> player.getAccount().getUsername().equals(username)).findFirst();
if (playerOpt.get() != null) {
if (playerOpt.isPresent()) {
return playerOpt.get().getAccount();
}
return DatabaseHelper.getAccountByName(username);