Better java support
Matt-MX opened this issue · 1 comments
Matt-MX commented
Currently KtGui supports Java through Kotlin's native compatibility, but I've made no effort to actually add better Java useability.
Implementing Builder functions that we can chain, where Kotlin would have code blocks, could help.
GuiScreen gui = new GuiScreen(Component.text("Title"), 3)
.addChild(
new GuiButton<>(Material.DIRT)
.named(Component.text("Item")
.click(ClickType.LEFT, (event) -> event.getPlayer().sendMessage(Component.text("clicked!")))
.lore(Component.text("Lore line one"))
.lore(Component.text("Lore line two"))
.slot(3)
).addChild(...);
// Will need to add compat for signals, not as pretty as kotlin.
Signal<String> signalExample = gui.createSignal<String>("mattmx");
gui.effect(signalExample, () -> {
new GuiButton<>(Material.DIAMOND)
.named(Component.text(signalExample.get()))
.slot(5)
.childOf(gui);
});
gui.open((event) -> event.getPlayer().sendMessage(Component.text("opened.")));
gui.open(player);
Matt-MX commented
Features are currently not focused on Java support, but support will be added upon request.