Foundation for building shared and non-shared inventory GUIs
This commit is contained in:
@@ -7,11 +7,13 @@ import org.bukkit.inventory.ItemStack
|
|||||||
|
|
||||||
fun <T : ForInventory> kSpigotGUI(
|
fun <T : ForInventory> kSpigotGUI(
|
||||||
type: InventoryType<T>,
|
type: InventoryType<T>,
|
||||||
|
shared: Boolean = true,
|
||||||
builder: InventoryGUIBuilder<T>.() -> Unit,
|
builder: InventoryGUIBuilder<T>.() -> Unit,
|
||||||
) = InventoryGUIBuilder(type).apply(builder).build()
|
) = InventoryGUIBuilder(type, shared).apply(builder).build()
|
||||||
|
|
||||||
class InventoryGUIBuilder<T : ForInventory>(
|
class InventoryGUIBuilder<T : ForInventory>(
|
||||||
val type: InventoryType<T>
|
val type: InventoryType<T>,
|
||||||
|
val shared: Boolean
|
||||||
) {
|
) {
|
||||||
|
|
||||||
var title: String = ""
|
var title: String = ""
|
||||||
@@ -36,9 +38,12 @@ class InventoryGUIBuilder<T : ForInventory>(
|
|||||||
onClickElement = onClick
|
onClickElement = onClick
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun build() = InventoryGUIShared(
|
internal fun build(): InventoryGUI<T> {
|
||||||
InventoryGUIData(type, title, guiSlots, transitionTo, transitionFrom, onClickElement)
|
val guiData = InventoryGUIData(type, title, guiSlots, transitionTo, transitionFrom, onClickElement)
|
||||||
).apply { register() }
|
val gui =
|
||||||
|
if (shared) InventoryGUIShared(guiData) else TODO("Currently, there is no non-shared GUI implementation available.")
|
||||||
|
return gui.apply { register() }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user