在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):DevSrSouza/KotlinBukkitAPI开源软件地址(OpenSource Url):https://github.com/DevSrSouza/KotlinBukkitAPI开源编程语言(OpenSource Language):Kotlin 100.0%开源软件介绍(OpenSource Introduction):KotlinBukkitAPIKotlinBukkitAPI is an API for Bukkit/SpigotAPI using the cool and nifty features Kotlin has to make your life more easier. Contents:SamplesKotlinBukkitAPI goes beyond this samples, and you can find all of it in the wiki/documentation. Event DSL sample plugin.events {
event<PlayerJoinEvent> {
player.msg("&3Welcome ${player.name}".translateColor())
}
event<PlayerQuitEvent> {
broadcast("&eThe player &c${player.name} &eleft :(".translateColor())
}
} Simple Command DSL example plugin.simpleCommand("twitter") {
sender.msg("&eFollow me on Twitter :D &ahttps://twitter.com/DevSrSouza".translateColor())
} Item meta DSL and other stuff val gem = item(Material.DIAMOND).apply {
amount = 5
meta<ItemMeta> {
displayName = "&bGem".translateColor()
}
}
val encbook = item(Material.ENCHANTED_BOOK).meta<EnchantmentStorageMeta> {
displayName = "&4&lThe powerful BOOK".translateColor()
addStoredEnchant(Enchantment.DAMAGE_ALL, 10, true) // putting sharpness 10 to the book
} Another approach:
Menu creator DSL val myMenu = menu(+"&cWarps", 3, true) {
val arenaPvP = item(Material.DIAMOND_SWORD) {
addEnchant(Enchantment.DAMAGE_ALL, 5, true)
displayName = "&4Arena PvP".translateColor()
}
slot(2, 4, arenaPvP) { // Line, Slot
onClick {
player.teleport(Location(player.world, 250, 70, -355))
close() // close the menu
}
}
slot(2, 6, item(Material.GOLD).displayName("&6Shop".translateColor())) {
onClick {
player.teleport(Location(player.world, 2399, 70, -1234))
close() // close the menu
}
}
// when the menu renders to a player, will show the Paper item with their name.
slot(3, 9, item(Material.PAPER).displayName("Hello {player}")) {
onRender {
showingItem?.meta<ItemMeta> {
displayName = displayName.replace("{player}", player.name)
}
}
}
}
// open to player
myMenu.openToPlayer(player) You can find more examples in the Documentation ProjectDependencies
Dependencies EmbedIf you shade your plugin or use PDM, this dependencies should not be loaded be your plugin, you should let the KotlinBukkitAPI provide it at runtime to prevent conflicts. More about how to setup a project with KotlinBukkitAPI here.
Modules
Consider donate |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论