Added dynamic-size components
This commit is contained in:
@@ -25,6 +25,24 @@ public interface GUIComponent {
|
||||
*/
|
||||
int getColumns();
|
||||
|
||||
/**
|
||||
* Initialize the component.
|
||||
* <p>
|
||||
* This is called before getRows / getColumns is queried,
|
||||
* and allows for dynamically sized components.
|
||||
* <p>
|
||||
* getRows and getColumns can return values bigger than this,
|
||||
* it will simply prevent the component from being added at
|
||||
* this position (for minimum-sized components).
|
||||
*
|
||||
* @param maxRows The maximum number of rows.
|
||||
* @param maxColumns The maximum number of columns.
|
||||
*/
|
||||
default void init(final int maxRows,
|
||||
final int maxColumns) {
|
||||
// Most components will not require initialization.
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the slot at a certain position in the component.
|
||||
* <p>
|
||||
|
||||
@@ -161,7 +161,7 @@ public interface MenuBuilder extends PageBuilder {
|
||||
* @param action The action.
|
||||
* @return THe builder.
|
||||
*/
|
||||
default MenuBuilder onSignalReceive(@NotNull final SignalHandler action) {
|
||||
default MenuBuilder onSignal(@NotNull final SignalHandler action) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -142,9 +142,9 @@ fun MenuBuilder.addPage(page: Int, creation: PageBuilder.() -> Unit): MenuBuilde
|
||||
return this.addPage(Page(page, builder.build()))
|
||||
}
|
||||
|
||||
/** @see MenuBuilder.onSignalReceive */
|
||||
inline fun <reified T : Signal> MenuBuilder.onSignalReceive(crossinline handler: (Player, Menu, T) -> Unit): MenuBuilder {
|
||||
return this.onSignalReceive(object : SignalHandler<T>(T::class.java) {
|
||||
/** @see MenuBuilder.onSignal */
|
||||
inline fun <reified T : Signal> MenuBuilder.onSignal(crossinline handler: (Player, Menu, T) -> Unit): MenuBuilder {
|
||||
return this.onSignal(object : SignalHandler<T>(T::class.java) {
|
||||
override fun handle(player: Player, menu: Menu, signal: T) =
|
||||
handler(player, menu, signal)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user