Added GUIInstance structure; GUIIndividual now available

This commit is contained in:
bluefireoly
2020-10-25 10:54:52 +01:00
parent 9ff49ad624
commit 6db78d08f4
13 changed files with 192 additions and 153 deletions

View File

@@ -7,14 +7,14 @@ import org.bukkit.inventory.ItemStack
import kotlin.math.absoluteValue
fun <T : ForInventory> kSpigotGUI(
type: GUIType<T>,
shared: Boolean = true,
builder: GUIBuilder<T>.() -> Unit,
) = GUIBuilder(type, shared).apply(builder).build()
type: GUIType<T>,
guiCreator: GUICreator<T>,
builder: GUIBuilder<T>.() -> Unit,
) = GUIBuilder(type, guiCreator).apply(builder).build()
class GUIBuilder<T : ForInventory>(
val type: GUIType<T>,
val shared: Boolean
val type: GUIType<T>,
private val guiCreator: GUICreator<T>
) {
var title: String = ""
@@ -39,18 +39,15 @@ class GUIBuilder<T : ForInventory>(
onClickElement = onClick
}
internal fun build(): GUI<T> {
val guiData = GUIData(type, title, guiSlots, transitionTo, transitionFrom, onClickElement)
val gui =
if (shared) GUIShared(guiData) else TODO("Currently, there is no non-shared GUI implementation available.")
return gui.apply { register() }
}
internal fun build() = guiCreator.createInstance(
GUIData(type, title, guiSlots, transitionTo, transitionFrom, onClickElement)
)
}
class GUIPageBuilder<T : ForInventory>(
private val type: GUIType<T>,
val page: Int
private val type: GUIType<T>,
val page: Int
) {
private val guiSlots = HashMap<Int, GUISlot<T>>()