Skip to content

Commit 77050d0

Browse files
committed
fix: Ensure parent views aren't re-opened from a back() call when it is simultaniously closed by a different thread
1 parent f5755d4 commit 77050d0

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

interfaces/src/main/kotlin/com/noxcrew/interfaces/view/AbstractInterfaceView.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,12 @@ public abstract class AbstractInterfaceView<I : InterfacesInventory, T : Interfa
372372

373373
override suspend fun back() {
374374
val parent = parent()
375-
if (parent == null) {
375+
376+
// If the state is not valid, don't do anything!
377+
if (!coroutineContext.isActive || Bukkit.isStopping() || !player.isConnected) return
378+
379+
// If the parent has been requested to close, don't open any menu!
380+
if (parent == null || !parent.isTreeOpened) {
376381
close()
377382
} else {
378383
parent.open(reload = false)

0 commit comments

Comments
 (0)