@@ -22,16 +22,18 @@ import org.incendo.cloud.kotlin.coroutines.extension.suspendingHandler
22
22
import org.incendo.cloud.kotlin.extension.buildAndRegister
23
23
import org.incendo.cloud.paper.LegacyPaperCommandManager
24
24
25
- public class ExamplePlugin : JavaPlugin (), Listener {
26
-
25
+ public class ExamplePlugin :
26
+ JavaPlugin (),
27
+ Listener {
27
28
private companion object {
28
- private val INTERFACES = listOf (
29
- DelayedRequestExampleInterface (),
30
- ChangingTitleExampleInterface (),
31
- CatalogueExampleInterface (),
32
- MovingExampleInterface (),
33
- TabbedExampleInterface (),
34
- )
29
+ private val INTERFACES =
30
+ listOf (
31
+ DelayedRequestExampleInterface (),
32
+ ChangingTitleExampleInterface (),
33
+ CatalogueExampleInterface (),
34
+ MovingExampleInterface (),
35
+ TabbedExampleInterface (),
36
+ )
35
37
}
36
38
37
39
private val counterProperty = interfaceProperty(5 )
@@ -112,93 +114,108 @@ public class ExamplePlugin : JavaPlugin(), Listener {
112
114
)
113
115
}
114
116
115
- private fun simpleInterface () = buildChestInterface {
116
- rows = 6
117
+ private fun simpleInterface () =
118
+ buildChestInterface {
119
+ rows = 6
117
120
118
- withTransform(counterProperty) { pane, _ ->
119
- val item = ItemStack (Material .BEE_NEST )
120
- .name(" it's been $counter 's ticks" )
121
- .description(" click to see the ticks now" )
121
+ withTransform(counterProperty) { pane, _ ->
122
+ val item =
123
+ ItemStack (Material .BEE_NEST )
124
+ .name(" it's been $counter 's ticks" )
125
+ .description(" click to see the ticks now" )
122
126
123
- pane[3 , 3 ] = StaticElement (drawable(item)) {
124
- it.player.sendMessage(" it's been $counter 's ticks" )
127
+ pane[3 , 3 ] =
128
+ StaticElement (drawable(item)) {
129
+ it.player.sendMessage(" it's been $counter 's ticks" )
130
+ }
125
131
}
126
- }
127
132
128
- withTransform { pane, _ ->
129
- val item = ItemStack (Material .BEE_NEST )
130
- .name(" block the interface" )
131
- .description(" block interaction and message in 5 seconds" )
133
+ withTransform { pane, _ ->
134
+ val item =
135
+ ItemStack (Material .BEE_NEST )
136
+ .name(" block the interface" )
137
+ .description(" block interaction and message in 5 seconds" )
132
138
133
- pane[5 , 3 ] = StaticElement (drawable(item)) {
134
- completingLater = true
139
+ pane[5 , 3 ] =
140
+ StaticElement (drawable(item)) {
141
+ completingLater = true
135
142
136
- runAsync(5 ) {
137
- it.player.sendMessage(" after blocking, it has been $counter 's ticks" )
138
- complete()
139
- }
143
+ runAsync(5 ) {
144
+ it.player.sendMessage(" after blocking, it has been $counter 's ticks" )
145
+ complete()
146
+ }
147
+ }
140
148
}
141
- }
142
149
143
- withTransform { pane, _ ->
144
- forEachInGrid(6 , 9 ) { row, column ->
145
- if (pane.has(row, column)) return @forEachInGrid
150
+ withTransform { pane, _ ->
151
+ forEachInGrid(6 , 9 ) { row, column ->
152
+ if (pane.has(row, column)) return @forEachInGrid
146
153
147
- val item = ItemStack (Material .WHITE_STAINED_GLASS_PANE )
148
- .name(" row: $row , column: $column " )
154
+ val item =
155
+ ItemStack (Material .WHITE_STAINED_GLASS_PANE )
156
+ .name(" row: $row , column: $column " )
149
157
150
- pane[row, column] = StaticElement (drawable(item))
158
+ pane[row, column] = StaticElement (drawable(item))
159
+ }
151
160
}
152
161
}
153
- }
154
162
155
- private fun playerInterface () = buildPlayerInterface {
156
- // Use modern logic to only cancel the item interaction and not block interactions while
157
- // using this interface
158
- onlyCancelItemInteraction = true
163
+ private fun playerInterface () =
164
+ buildPlayerInterface {
165
+ // Use modern logic to only cancel the item interaction and not block interactions while
166
+ // using this interface
167
+ onlyCancelItemInteraction = true
159
168
160
- // Prioritise block interactions!
161
- prioritiseBlockInteractions = true
169
+ // Prioritise block interactions!
170
+ prioritiseBlockInteractions = true
162
171
163
- withTransform { pane, _ ->
164
- val item = ItemStack (Material .COMPASS ).name(" interfaces example" )
172
+ withTransform { pane, _ ->
173
+ val item = ItemStack (Material .COMPASS ).name(" interfaces example" )
165
174
166
- pane.hotbar[3 ] = StaticElement (drawable(item)) { (player) ->
167
- player.sendMessage(" hello" )
168
- }
175
+ pane.hotbar[3 ] =
176
+ StaticElement (drawable(item)) { (player) ->
177
+ player.sendMessage(" hello" )
178
+ }
169
179
170
- pane.offHand = StaticElement (drawable(item)) { (player) ->
171
- player.sendMessage(" hey" )
172
- }
180
+ pane.offHand =
181
+ StaticElement (drawable(item)) { (player) ->
182
+ player.sendMessage(" hey" )
183
+ }
173
184
174
- val armor = ItemStack (Material .STICK )
185
+ val armor = ItemStack (Material .STICK )
175
186
176
- pane.armor.helmet = StaticElement (drawable(armor.name(" helmet" ).clone()))
187
+ pane.armor.helmet = StaticElement (drawable(armor.name(" helmet" ).clone()))
177
188
178
- pane.armor.chest = StaticElement (drawable(armor.name(" chest" ).clone()))
189
+ pane.armor.chest = StaticElement (drawable(armor.name(" chest" ).clone()))
179
190
180
- pane.armor.leggings = StaticElement (drawable(armor.name(" leggings" ).clone()))
191
+ pane.armor.leggings = StaticElement (drawable(armor.name(" leggings" ).clone()))
181
192
182
- pane.armor.boots = StaticElement (drawable(armor.name(" boots" ).clone()))
193
+ pane.armor.boots = StaticElement (drawable(armor.name(" boots" ).clone()))
194
+ }
183
195
}
184
- }
185
196
186
- private fun combinedInterface () = buildCombinedInterface {
187
- rows = 6
197
+ private fun combinedInterface () =
198
+ buildCombinedInterface {
199
+ rows = 6
188
200
189
- withTransform { pane, _ ->
190
- forEachInGrid(10 , 9 ) { row, column ->
191
- val item = ItemStack (Material .WHITE_STAINED_GLASS_PANE )
192
- .name(" row: $row , column: $column " )
201
+ withTransform { pane, _ ->
202
+ forEachInGrid(10 , 9 ) { row, column ->
203
+ val item =
204
+ ItemStack (Material .WHITE_STAINED_GLASS_PANE )
205
+ .name(" row: $row , column: $column " )
193
206
194
- pane[row, column] = StaticElement (drawable(item)) { (player) ->
195
- player.sendMessage(" row: $row , column: $column " )
207
+ pane[row, column] =
208
+ StaticElement (drawable(item)) { (player) ->
209
+ player.sendMessage(" row: $row , column: $column " )
210
+ }
196
211
}
197
212
}
198
213
}
199
- }
200
214
201
- private fun runAsync (delay : Int , runnable : Runnable ) {
215
+ private fun runAsync (
216
+ delay : Int ,
217
+ runnable : Runnable ,
218
+ ) {
202
219
Bukkit .getScheduler().runTaskLaterAsynchronously(this , runnable, delay * 20L )
203
220
}
204
221
}
0 commit comments