Innovating the way you make menus in minecraft java edition by using maps to render a custom UI and allowing the player to interact with it.
class SampleMenu(player: Player, manager: BukkitMenuManager) : BaseMenu(player, manager = manager) {
override fun Composable.getUi() {
Box(modifier = Modifier.fill().backgroundColor(Color.CYAN_4)) {
Box(
modifier = Modifier
.fixedSize(25)
.margin(top = 15, left = 15)
.backgroundColor(Color.RED_1)
.clickable {
owner.sendMessage("Clicou no vermelho!")
}
) {}
Box(
modifier = Modifier
.fixedSize(25)
.margin(top = 35, left = 35)
.backgroundColor(Color.GREEN_10)
.clickable {
owner.sendMessage("Clicou no verde!")
}
) {}
Column(modifier = Modifier.margin(top = 70, left = 15)) {
val fontStyle = FontStyle(font = MINECRAFTIA_24, Color.BLACK_1, Color.TRANSPARENT, Color.CYAN_8)
Label("Hello World", style = fontStyle)
}
}
}
}
Result:
In order to create menus you need a MenuManager
, it is responsible to handle the cursor updates and player interactions.
A single MenuManager
instance can be shared among multiple menus & players.
val manager = BukkitMenuManager(yourPlugin)
val menu = SampleMenu(player, manager)
menu.send()
// To close the menu just call the `Menu#destroy` method.
menu.destroy()
repositories {
maven("https://nexus.heroslender.com/repository/maven-public/")
}
dependencies {
implementation("com.heroslender:hmf-bukkit:0.0.1-SNAPSHOT")
}
<repository>
<id>heroslender-repo</id>
<url>https://nexus.heroslender.com/repository/maven-public/</url>
</repository>
<dependency>
<groupId>com.heroslender</groupId>
<artifactId>hmf-bukkit</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>