Spigot library with Kotlin for easy inventory creation and event handling
repositories {
mavenCentral()
}
dependencies {
implementation("dev.s7a:ktInventory:2.1.0")
}class SimpleMenu(
context: KtInventoryPluginContext,
) : KtInventory(context, 1) {
constructor(plugin: Plugin) : this(KtInventoryPluginContext(plugin))
override fun title() = "&0&lSelect where to teleport"
init {
button(3, ItemStack(Material.RED_BED)) { event, _ ->
val player = event.whoClicked as? Player ?: return@button
val respawnLocation = player.respawnLocation
if (respawnLocation != null) {
player.teleport(respawnLocation)
} else {
player.sendMessage("Not found respawnLocation")
}
player.closeInventory()
}
button(5, ItemStack(Material.COMPASS)) { event, _ ->
val player = event.whoClicked as? Player ?: return@button
player.teleport(player.world.spawnLocation)
player.closeInventory()
}
}
}class SimpleMenu(
context: KtInventoryPluginContext,
) : KtInventoryAdventure(context, 1) {
constructor(plugin: Plugin) : this(KtInventoryPluginContext(plugin))
override fun title() = Component.text("Select where to teleport").color(NamedTextColor.BLACK).decorate(TextDecoration.BOLD)
init {
button(3, ItemStack(Material.RED_BED)) { event, _ ->
val player = event.whoClicked as? Player ?: return@button
val respawnLocation = player.respawnLocation
if (respawnLocation != null) {
player.teleport(respawnLocation)
} else {
player.sendMessage("Not found respawnLocation")
}
player.closeInventory()
}
button(5, ItemStack(Material.COMPASS)) { event, _ ->
val player = event.whoClicked as? Player ?: return@button
player.teleport(player.world.spawnLocation)
player.closeInventory()
}
}
}