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