/menu-framework

Yet another menu framework for bukkit, but, using maps this time.

Primary LanguageKotlinMIT LicenseMIT

HMF - Heroslender Menu Framework

GitHub Workflow Status Maven metadata URL GitHub stars GitHub issues GitHub last commit Open Source Love

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.

Sample

Creating a new menu

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:

Render Result

Sending the menu to the player

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()

Dependency

Gradle kts

repositories {
    maven("https://nexus.heroslender.com/repository/maven-public/")
}

dependencies {
    implementation("com.heroslender:hmf-bukkit:0.0.1-SNAPSHOT")
}

Maven

<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>