@@ -18,6 +18,7 @@ import com.noxcrew.interfaces.utilities.InterfacesCoroutineDetails
18
18
import com.noxcrew.interfaces.utilities.forEachInGrid
19
19
import kotlinx.coroutines.CoroutineScope
20
20
import kotlinx.coroutines.Job
21
+ import kotlinx.coroutines.isActive
21
22
import kotlinx.coroutines.launch
22
23
import kotlinx.coroutines.sync.Mutex
23
24
import kotlinx.coroutines.withTimeout
@@ -32,6 +33,7 @@ import org.slf4j.LoggerFactory
32
33
import java.util.WeakHashMap
33
34
import java.util.concurrent.ConcurrentLinkedQueue
34
35
import java.util.concurrent.atomic.AtomicBoolean
36
+ import kotlin.coroutines.coroutineContext
35
37
import kotlin.time.Duration
36
38
import kotlin.time.Duration.Companion.seconds
37
39
@@ -180,7 +182,7 @@ public abstract class AbstractInterfaceView<I : InterfacesInventory, T : Interfa
180
182
181
183
override suspend fun open () {
182
184
// Don't open an interface for an offline player
183
- if (! player.isConnected) return
185
+ if (! player.isConnected || ! coroutineContext.isActive ) return
184
186
185
187
// Indicate that the menu should be opened after the next time rendering completes
186
188
// and that it should be open right now
@@ -430,6 +432,9 @@ public abstract class AbstractInterfaceView<I : InterfacesInventory, T : Interfa
430
432
false
431
433
}
432
434
435
+ // Exit if the coroutine context is no longer active
436
+ if (! coroutineContext.isActive) return
437
+
433
438
// Draw the contents of the inventory synchronously because
434
439
// we don't want it to happen in between ticks and show
435
440
// a half-finished inventory.
0 commit comments