From de0a14a5899a0a3676ab2a5cedbe8d11675f4408 Mon Sep 17 00:00:00 2001 From: iTruth Date: Wed, 20 Apr 2022 21:14:18 +0800 Subject: [PATCH] Fix playerOpt is always throw an exception when it's null --- src/main/java/emu/grasscutter/server/game/GameServer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/emu/grasscutter/server/game/GameServer.java b/src/main/java/emu/grasscutter/server/game/GameServer.java index b42ced55c..b99063cb6 100644 --- a/src/main/java/emu/grasscutter/server/game/GameServer.java +++ b/src/main/java/emu/grasscutter/server/game/GameServer.java @@ -145,7 +145,7 @@ public final class GameServer extends MihoyoKcpServer { public Account getAccountByName(String username) { Optional 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);