From 460134cc1e186ee18b6c2f91b7a59de1eeaab9aa Mon Sep 17 00:00:00 2001 From: Burning_TNT Date: Sun, 5 Oct 2025 20:12:51 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=90=E8=97=8F=E7=A9=BA=E7=9A=84=20Terracot?= =?UTF-8?q?ta=20=E7=8E=A9=E5=AE=B6=E5=88=97=E8=A1=A8=20(#4609)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../terracotta/TerracottaControllerPage.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/terracotta/TerracottaControllerPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/terracotta/TerracottaControllerPage.java index a8e00cf49..eb79487e6 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/terracotta/TerracottaControllerPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/terracotta/TerracottaControllerPage.java @@ -309,7 +309,11 @@ public class TerracottaControllerPage extends StackPane { nodesProperty.setAll(room); } else if (state instanceof TerracottaState.HostOK hostOK) { if (hostOK.isForkOf(legacyState)) { - ((PlayerProfileUI) nodesProperty.get(nodesProperty.size() - 1)).updateProfiles(hostOK.getProfiles()); + if (nodesProperty.get(nodesProperty.size() - 1) instanceof PlayerProfileUI profileUI) { + profileUI.updateProfiles(hostOK.getProfiles()); + } else { // Should NOT happen + nodesProperty.add(new PlayerProfileUI(hostOK.getProfiles())); + } return; } else { String cs = hostOK.getCode(); @@ -363,7 +367,11 @@ public class TerracottaControllerPage extends StackPane { } }); - nodesProperty.setAll(code, copy, back, new PlayerProfileUI(hostOK.getProfiles())); + if (hostOK.getProfiles().isEmpty()) { + nodesProperty.setAll(code, copy, back); + } else { + nodesProperty.setAll(code, copy, back, new PlayerProfileUI(hostOK.getProfiles())); + } } } else if (state instanceof TerracottaState.GuestStarting) { statusProperty.set(i18n("terracotta.status.guest_starting")); @@ -383,7 +391,11 @@ public class TerracottaControllerPage extends StackPane { nodesProperty.setAll(room); } else if (state instanceof TerracottaState.GuestOK guestOK) { if (guestOK.isForkOf(legacyState)) { - ((PlayerProfileUI) nodesProperty.get(nodesProperty.size() - 1)).updateProfiles(guestOK.getProfiles()); + if (nodesProperty.get(nodesProperty.size() - 1) instanceof PlayerProfileUI profileUI) { + profileUI.updateProfiles(guestOK.getProfiles()); + } else { // Should NOT happen + nodesProperty.add(new PlayerProfileUI(guestOK.getProfiles())); + } return; } else { statusProperty.set(i18n("terracotta.status.guest_ok")); @@ -404,7 +416,11 @@ public class TerracottaControllerPage extends StackPane { } }); - nodesProperty.setAll(tutorial, back, new PlayerProfileUI(guestOK.getProfiles())); + if (guestOK.getProfiles().isEmpty()) { + nodesProperty.setAll(tutorial, back); + } else { + nodesProperty.setAll(tutorial, back, new PlayerProfileUI(guestOK.getProfiles())); + } } } else if (state instanceof TerracottaState.Exception exception) { statusProperty.set(i18n("terracotta.status.exception.desc." + exception.getType().name().toLowerCase(Locale.ROOT)));