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(
opts = MenuOptions.builder {
width = 4
height = 3
privateFor(player)
},
manager = manager,
) {
private val counterState = mutableStateOf(0)
@Composable
override fun getUi() {
Column(modifier = Modifier.fillSize().background(Color.CYAN_7)) {
var counter by counterState
Box(
modifier = Modifier
.padding(10)
.size(50, 50)
.clickable {
counter++
whoCLicked.sendMessage("${ChatColor.GREEN}Counter incremented to ${counter.value}!")
}
.border(Color.BLACK_1)
.background(Color.GREEN_10)
)
Box(
modifier = Modifier
.padding(0, 10)
.size(50, 50)
.clickable {
counter--
whoCLicked.sendMessage("${ChatColor.RED}Counter decremented to ${counter.value}!")
}
.border(Color.BLACK_1)
.background(Color.RED_1)
)
Label(
"Couter value: $counter",
style = FontStyle(
font = UBUNTU_MONO_16,
color = Color.BLACK_1,
shadowColor = Color.GRAY_13
),
modifier = Modifier.padding(10)
)
}
}
}
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#close` method.
menu.close()
// or if inside a click modifier
closeMenu()
repositories {
maven("https://nexus.heroslender.com/repository/maven-public/")
}
dependencies {
implementation("com.heroslender:hmf-bukkit:{version}")
}
<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>{version}</version>
<scope>compile</scope>
</dependency>