diff --git a/src/main/kotlin/com/github/rushyverse/api/gui/GUI.kt b/src/main/kotlin/com/github/rushyverse/api/gui/GUI.kt index ad0f2f63..fb354055 100644 --- a/src/main/kotlin/com/github/rushyverse/api/gui/GUI.kt +++ b/src/main/kotlin/com/github/rushyverse/api/gui/GUI.kt @@ -288,7 +288,7 @@ public abstract class GUI( * @param key Key to create the inventory for. * @return New created inventory. */ - protected abstract fun createInventory(key: T): Inventory + protected abstract suspend fun createInventory(key: T): Inventory /** * Create a new flow of [Item][ItemStack] to fill the inventory with. diff --git a/src/main/kotlin/com/github/rushyverse/api/gui/PlayerGUI.kt b/src/main/kotlin/com/github/rushyverse/api/gui/PlayerGUI.kt index c94ca7ae..d0238193 100644 --- a/src/main/kotlin/com/github/rushyverse/api/gui/PlayerGUI.kt +++ b/src/main/kotlin/com/github/rushyverse/api/gui/PlayerGUI.kt @@ -42,7 +42,7 @@ public abstract class PlayerGUI( * @param key The client to create the inventory for. * @return The inventory for the client. */ - override fun createInventory(key: Client): Inventory { + override suspend fun createInventory(key: Client): Inventory { val player = key.requirePlayer() return createInventory(player, key) } @@ -54,7 +54,7 @@ public abstract class PlayerGUI( * @param client The client to create the inventory for. * @return The inventory for the client. */ - protected abstract fun createInventory(owner: InventoryHolder, client: Client): Inventory + protected abstract suspend fun createInventory(owner: InventoryHolder, client: Client): Inventory override suspend fun closeClient(client: Client, closeInventory: Boolean): Boolean { val (inventory, job) = mutex.withLock { inventories.remove(client) } ?: return false diff --git a/src/main/kotlin/com/github/rushyverse/api/gui/SingleGUI.kt b/src/main/kotlin/com/github/rushyverse/api/gui/SingleGUI.kt index ba9a2817..47b5ae5e 100644 --- a/src/main/kotlin/com/github/rushyverse/api/gui/SingleGUI.kt +++ b/src/main/kotlin/com/github/rushyverse/api/gui/SingleGUI.kt @@ -44,7 +44,7 @@ public abstract class SingleGUI( return scope + SupervisorJob(scope.coroutineContext.job) } - override fun createInventory(key: Unit): Inventory { + override suspend fun createInventory(key: Unit): Inventory { return createInventory() } @@ -52,7 +52,7 @@ public abstract class SingleGUI( * Create the inventory. * @return New created inventory. */ - protected abstract fun createInventory(): Inventory + protected abstract suspend fun createInventory(): Inventory /** * Update the inventory. diff --git a/src/test/kotlin/com/github/rushyverse/api/gui/LocalePlayerGUITest.kt b/src/test/kotlin/com/github/rushyverse/api/gui/LocalePlayerGUITest.kt index 940d583e..4249e861 100644 --- a/src/test/kotlin/com/github/rushyverse/api/gui/LocalePlayerGUITest.kt +++ b/src/test/kotlin/com/github/rushyverse/api/gui/LocalePlayerGUITest.kt @@ -206,7 +206,7 @@ private abstract class AbstractLocaleGUITest( animation: InventoryLoadingAnimation? = null ) : LocaleGUI(plugin, animation) { - override fun createInventory(key: Locale): Inventory { + override suspend fun createInventory(key: Locale): Inventory { return serverMock.createInventory(null, type) } diff --git a/src/test/kotlin/com/github/rushyverse/api/gui/PlayerGUITest.kt b/src/test/kotlin/com/github/rushyverse/api/gui/PlayerGUITest.kt index 5213edae..3672cda5 100644 --- a/src/test/kotlin/com/github/rushyverse/api/gui/PlayerGUITest.kt +++ b/src/test/kotlin/com/github/rushyverse/api/gui/PlayerGUITest.kt @@ -174,7 +174,7 @@ private abstract class AbstractPlayerGUITest( loadingAnimation: InventoryLoadingAnimation? = null ) : PlayerGUI(loadingAnimation) { - override fun createInventory(owner: InventoryHolder, client: Client): Inventory { + override suspend fun createInventory(owner: InventoryHolder, client: Client): Inventory { return serverMock.createInventory(owner, type) } diff --git a/src/test/kotlin/com/github/rushyverse/api/gui/SingleGUITest.kt b/src/test/kotlin/com/github/rushyverse/api/gui/SingleGUITest.kt index 38634edd..51601e76 100644 --- a/src/test/kotlin/com/github/rushyverse/api/gui/SingleGUITest.kt +++ b/src/test/kotlin/com/github/rushyverse/api/gui/SingleGUITest.kt @@ -192,7 +192,7 @@ private abstract class AbstractSingleGUITest( animation: InventoryLoadingAnimation? = null ) : SingleGUI(plugin, animation) { - override fun createInventory(): Inventory { + override suspend fun createInventory(): Inventory { return serverMock.createInventory(null, type) }