diff --git a/src/main/kotlin/net/axay/kspigot/gui/GUIBuilder.kt b/src/main/kotlin/net/axay/kspigot/gui/GUIBuilder.kt index 11ecb5cb..67f85a41 100644 --- a/src/main/kotlin/net/axay/kspigot/gui/GUIBuilder.kt +++ b/src/main/kotlin/net/axay/kspigot/gui/GUIBuilder.kt @@ -179,6 +179,14 @@ class GUIPageBuilder( ) ) + /** + * Creates a new compound, holding simple compound elements. + */ + fun createSimpleCompound() = createCompound>( + iconGenerator = { it.icon }, + onClick = { clickEvent, element -> element.onClick?.invoke(clickEvent) } + ) + /** * Creates a new compound, holding data which can be displayed * in any compound space. @@ -204,8 +212,28 @@ class GUIPageBuilder( } /** - * Creates a new compound, holding data which can be displayed - * in any compound space. + * Creates a new compound, holding simple compound elements. + * This compound is strictly a rectangle. + * The space is automatically defined. + * + * This method sets the element type to + * [GUICompoundElement]. The iconGenerator and onClick callback + * are automatically defined. + */ + fun createSimpleRectCompound( + fromSlot: SingleInventorySlot, + toSlot: SingleInventorySlot + ) = createRectCompound>( + + fromSlot, toSlot, + + iconGenerator = { it.icon }, + onClick = { clickEvent, element -> element.onClick?.invoke(clickEvent) } + + ) + + /** + * Creates a new compound, holding custom element data. * This compound is strictly a rectangle. * The space is automatically defined. */ diff --git a/src/main/kotlin/net/axay/kspigot/gui/elements/GUISpaceCompound.kt b/src/main/kotlin/net/axay/kspigot/gui/elements/GUISpaceCompound.kt index 1d6937fa..c5476d35 100644 --- a/src/main/kotlin/net/axay/kspigot/gui/elements/GUISpaceCompound.kt +++ b/src/main/kotlin/net/axay/kspigot/gui/elements/GUISpaceCompound.kt @@ -163,4 +163,16 @@ abstract class AbstractGUISpaceCompound internal constructo } -} \ No newline at end of file +} + +/** + * A simple compound element, covering the most common + * compound use cases. + * + * @see GUIPageBuilder.createSimpleCompound + * @see GUIPageBuilder.createSimpleRectCompound + */ +class GUICompoundElement( + internal val icon: ItemStack, + internal val onClick: ((GUIClickEvent) -> Unit)? = null +) \ No newline at end of file