From 9484bc1ce5f7cd19a5b69f2bd55992fde29d65fa Mon Sep 17 00:00:00 2001 From: bluefireoly Date: Wed, 21 Oct 2020 15:45:00 +0200 Subject: [PATCH] Foundation for building shared and non-shared inventory GUIs --- .../axay/kspigot/inventory/InventoryGUIBuilder.kt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/net/axay/kspigot/inventory/InventoryGUIBuilder.kt b/src/main/kotlin/net/axay/kspigot/inventory/InventoryGUIBuilder.kt index 6c29f6f9..1a287aaf 100644 --- a/src/main/kotlin/net/axay/kspigot/inventory/InventoryGUIBuilder.kt +++ b/src/main/kotlin/net/axay/kspigot/inventory/InventoryGUIBuilder.kt @@ -7,11 +7,13 @@ import org.bukkit.inventory.ItemStack fun kSpigotGUI( type: InventoryType, + shared: Boolean = true, builder: InventoryGUIBuilder.() -> Unit, -) = InventoryGUIBuilder(type).apply(builder).build() +) = InventoryGUIBuilder(type, shared).apply(builder).build() class InventoryGUIBuilder( - val type: InventoryType + val type: InventoryType, + val shared: Boolean ) { var title: String = "" @@ -36,9 +38,12 @@ class InventoryGUIBuilder( onClickElement = onClick } - internal fun build() = InventoryGUIShared( - InventoryGUIData(type, title, guiSlots, transitionTo, transitionFrom, onClickElement) - ).apply { register() } + internal fun build(): InventoryGUI { + val guiData = InventoryGUIData(type, title, guiSlots, transitionTo, transitionFrom, onClickElement) + val gui = + if (shared) InventoryGUIShared(guiData) else TODO("Currently, there is no non-shared GUI implementation available.") + return gui.apply { register() } + } }