Skip to content

Commit 2ee5b67

Browse files
committed
Menu sample
1 parent 9d44df7 commit 2ee5b67

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed

README.md

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ command("twitter") {
9999
// args - Array<String>
100100

101101
sender.sendMessage(+"&eFollow me on Twitter :D &atwitter.com/DevSrSouza")
102+
}
102103
```
103104

104105
Item meta DSL and another stuffs
@@ -107,12 +108,12 @@ command("some-name") {
107108

108109
if(sender is Player) { // checking if CommandSender is a player
109110
val player = sender as Player
110-
player.vault.economy.deposit(2500) // you can see more about the vault api on KVault.kt
111+
player.vault.economy.deposit(2500.0) // you can see more about the vault api on KVault.kt
111112

112113
// lets make a item more easy with kotlin and ItemMeta DSL
113114
val gem = ItemStack(Material.DIAMOND).apply {
114115
amount = 5
115-
meta<ItemMeta> { // here you can put any meta type you wont, like BannerMeta(if the item isso a banner)
116+
meta<ItemMeta> { // here you can put any meta type you wont, like BannerMeta(if the item is a banner)
116117
// here is the same idea of event block but here you only que put the ItemMeta type, like BannerMeta, BookMeta
117118
displayName = +"&bGem"
118119
}
@@ -136,4 +137,51 @@ command("some-name") {
136137
}
137138
```
138139

140+
Menu creator DSL
141+
```kotlin
142+
// okay, lets make a Menu
143+
// fun createMenu(displayname: String, lines: Int = 3, cancel: Boolean = false, block: Menu.() -> Unit)
144+
val myMenu = createMenu(+"&cWarps", cancel = true) { // cancel true to cancel player interact with inventory by default
145+
// this menu will be a menu with 3 lines (27 slots) and the name "Warps" in red
146+
// this block is a Menu
147+
148+
// registering a slot
149+
slot(2, 4) { // Line, Slot
150+
// inside of this block will be a Slot
151+
item = ItemStack(Material.DIAMOND_SWORD).apply {
152+
addEnchantment(Enchantment.DAMAGE_ALL, 5)
153+
154+
meta<ItemMeta> {
155+
displayName = +"&4Arena PvP"
156+
}
157+
}
158+
159+
onClick {
160+
player.teleport(Location(player.world, 250, 70, -355))
161+
close() // close the menu
162+
}
163+
}
164+
165+
slot(2, 6) {
166+
item = ItemStack(Material.GOLD).apply {
167+
meta<ItemMeta> {
168+
displayName = +"&6Shop"
169+
}
170+
}
171+
172+
onClick {
173+
player.teleport(Location(player.world, 2399, 70, -1234))
174+
close() // close the menu
175+
}
176+
}
177+
178+
// now we need a command to open the menu to the player
179+
command("warps") {
180+
if(sender is Player) {
181+
val player = sender as Player
182+
myMenu.openToPlayer(player) // here we open the menu to de Player
183+
}
184+
}
185+
```
186+
139187

0 commit comments

Comments
 (0)