From 80f45ac804eccaa3b405803aa093cf086bef6f42 Mon Sep 17 00:00:00 2001 From: brachy84 Date: Sat, 7 Sep 2024 14:03:22 +0200 Subject: [PATCH] fix closeIfOpen() crash when panel is not open --- .../java/com/cleanroommc/modularui/screen/ModularPanel.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/cleanroommc/modularui/screen/ModularPanel.java b/src/main/java/com/cleanroommc/modularui/screen/ModularPanel.java index 4ac6eb99..76d3e892 100644 --- a/src/main/java/com/cleanroommc/modularui/screen/ModularPanel.java +++ b/src/main/java/com/cleanroommc/modularui/screen/ModularPanel.java @@ -107,12 +107,13 @@ public boolean isOpen() { * @param animate true if the closing animation should play first. */ public void closeIfOpen(boolean animate) { + if (!isOpen()) return; closeSubPanels(); if (!animate || !shouldAnimate()) { this.screen.getPanelManager().closePanel(this); return; } - if (isOpen() && !isOpening() && !isClosing()) { + if (!isOpening() && !isClosing()) { if (isMainPanel()) { // if this is the main panel, start closing animation for all panels for (ModularPanel panel : getScreen().getPanelManager().getOpenPanels()) {