Skip to content

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

License

Notifications You must be signed in to change notification settings

ktcraft/menu-framework

 
 

Repository files navigation

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() {
        Column(modifier = Modifier.fillSize().background(Color.CYAN_7)) {
            Box(
                modifier = Modifier
                    .padding(10)
                    .size(50, 50)
                    .clickable {
                        counter.value++
                        owner.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.value--
                        owner.sendMessage("${ChatColor.RED}Counter decremented to ${counter.value}!")
                    }
                    .border(Color.BLACK_1)
                    .background(Color.RED_1)
            )

            // Bind the state to this component, so that the
            // component updates with it.
            val count = withState(counter)
            Label(
                "Couter value: $count",
                style = FontStyle(
                    font = UBUNTU_MONO_16,
                    color = Color.BLACK_1,
                    shadowColor = Color.GRAY_13
                ),
                modifier = Modifier.padding(10)
            )
        }
    }
}

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>

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Kotlin 100.0%