Skip to content

Commit a572014

Browse files
committed
Revert spotless
1 parent 8240ca0 commit a572014

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+486
-642
lines changed

examples/src/main/kotlin/com/noxcrew/interfaces/example/CatalogueExampleInterface.kt

+10-12
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,17 @@ import org.bukkit.Material
1010
public class CatalogueExampleInterface : RegistrableInterface {
1111
override val subcommand: String = "catalogue"
1212

13-
override fun create(): Interface<*, *> =
14-
buildCombinedInterface {
15-
rows = 1
13+
override fun create(): Interface<*, *> = buildCombinedInterface {
14+
rows = 1
1615

17-
withTransform { pane, _ ->
18-
pane[3, 3] =
19-
StaticElement(
20-
Drawable.drawable(Material.STICK),
21-
) { (player) ->
22-
runBlocking {
23-
ChangingTitleExampleInterface().create().open(player)
24-
}
25-
}
16+
withTransform { pane, _ ->
17+
pane[3, 3] = StaticElement(
18+
Drawable.drawable(Material.STICK)
19+
) { (player) ->
20+
runBlocking {
21+
ChangingTitleExampleInterface().create().open(player)
22+
}
2623
}
2724
}
25+
}
2826
}

examples/src/main/kotlin/com/noxcrew/interfaces/example/ChangingTitleExampleInterface.kt

+16-18
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,29 @@ import org.bukkit.Material
1010
import org.bukkit.inventory.ItemStack
1111

1212
public class ChangingTitleExampleInterface : RegistrableInterface {
13-
override val subcommand: String = "changing-title"
1413

15-
override fun create(): Interface<*, *> =
16-
buildChestInterface {
17-
rows = 1
14+
override val subcommand: String = "changing-title"
1815

19-
// Allow clicking the player inventory but not anything in the top inventory
20-
allowClickingOwnInventoryIfClickingEmptySlotsIsPrevented = true
16+
override fun create(): Interface<*, *> = buildChestInterface {
17+
rows = 1
2118

22-
val numberProperty = interfaceProperty(0)
23-
var number by numberProperty
19+
// Allow clicking the player inventory but not anything in the top inventory
20+
allowClickingOwnInventoryIfClickingEmptySlotsIsPrevented = true
2421

25-
withTransform(numberProperty) { pane, view ->
26-
view.title(Component.text(number))
22+
val numberProperty = interfaceProperty(0)
23+
var number by numberProperty
2724

28-
val item =
29-
ItemStack(Material.STICK)
30-
.name("number -> $number")
25+
withTransform(numberProperty) { pane, view ->
26+
view.title(Component.text(number))
3127

32-
pane[0, 4] =
33-
StaticElement(drawable(item)) {
34-
number += 1
35-
}
28+
val item = ItemStack(Material.STICK)
29+
.name("number -> $number")
3630

37-
pane[0, 6] = StaticElement(drawable(Material.ACACIA_SIGN))
31+
pane[0, 4] = StaticElement(drawable(item)) {
32+
number += 1
3833
}
34+
35+
pane[0, 6] = StaticElement(drawable(Material.ACACIA_SIGN))
3936
}
37+
}
4038
}

examples/src/main/kotlin/com/noxcrew/interfaces/example/DelayedRequestExampleInterface.kt

+20-21
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,38 @@ import org.bukkit.Material
1313
import kotlin.time.Duration.Companion.seconds
1414

1515
public class DelayedRequestExampleInterface : RegistrableInterface {
16+
1617
private companion object {
1718
private val BACKING_ELEMENT = StaticElement(Drawable.drawable(Material.GRAY_CONCRETE))
1819
}
1920

2021
override val subcommand: String = "delayed"
2122

2223
@OptIn(DelicateCoroutinesApi::class)
23-
override fun create(): Interface<*, *> =
24-
buildChestInterface {
25-
initialTitle = text(subcommand)
26-
rows = 2
27-
28-
withTransform { pane, _ ->
29-
suspendingData().forEachIndexed { index, material ->
30-
pane[0, index] = StaticElement(Drawable.drawable(material))
31-
}
24+
override fun create(): Interface<*, *> = buildChestInterface {
25+
initialTitle = text(subcommand)
26+
rows = 2
27+
28+
withTransform { pane, _ ->
29+
suspendingData().forEachIndexed { index, material ->
30+
pane[0, index] = StaticElement(Drawable.drawable(material))
31+
}
32+
}
33+
34+
withTransform { pane, _ ->
35+
for (index in 0..8) {
36+
pane[1, index] = BACKING_ELEMENT
3237
}
3338

34-
withTransform { pane, _ ->
35-
for (index in 0..8) {
36-
pane[1, index] = BACKING_ELEMENT
39+
pane[0, 8] = StaticElement(Drawable.drawable(Material.ENDER_PEARL)) {
40+
// This is very unsafe, it's up to you to set up a way to reliably
41+
// launch coroutines per player in a click handler.
42+
GlobalScope.launch {
43+
it.view.back()
3744
}
38-
39-
pane[0, 8] =
40-
StaticElement(Drawable.drawable(Material.ENDER_PEARL)) {
41-
// This is very unsafe, it's up to you to set up a way to reliably
42-
// launch coroutines per player in a click handler.
43-
GlobalScope.launch {
44-
it.view.back()
45-
}
46-
}
4745
}
4846
}
47+
}
4948

5049
private suspend fun suspendingData(): List<Material> {
5150
delay(3.seconds)

examples/src/main/kotlin/com/noxcrew/interfaces/example/ExamplePlugin.kt

+68-85
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,16 @@ import org.incendo.cloud.kotlin.coroutines.extension.suspendingHandler
2222
import org.incendo.cloud.kotlin.extension.buildAndRegister
2323
import org.incendo.cloud.paper.LegacyPaperCommandManager
2424

25-
public class ExamplePlugin :
26-
JavaPlugin(),
27-
Listener {
25+
public class ExamplePlugin : JavaPlugin(), Listener {
26+
2827
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+
)
3735
}
3836

3937
private val counterProperty = interfaceProperty(5)
@@ -98,7 +96,7 @@ public class ExamplePlugin :
9896
counter++
9997
},
10098
0,
101-
1,
99+
1
102100
)
103101
}
104102

@@ -110,112 +108,97 @@ public class ExamplePlugin :
110108
runBlocking {
111109
playerInterface().open(e.player)
112110
}
113-
},
111+
}
114112
)
115113
}
116114

117-
private fun simpleInterface() =
118-
buildChestInterface {
119-
rows = 6
115+
private fun simpleInterface() = buildChestInterface {
116+
rows = 6
120117

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")
126122

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")
131125
}
126+
}
132127

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")
138132

139-
pane[5, 3] =
140-
StaticElement(drawable(item)) {
141-
completingLater = true
133+
pane[5, 3] = StaticElement(drawable(item)) {
134+
completingLater = true
142135

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+
}
148140
}
141+
}
149142

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
153146

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")
157149

158-
pane[row, column] = StaticElement(drawable(item))
159-
}
150+
pane[row, column] = StaticElement(drawable(item))
160151
}
161152
}
153+
}
162154

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
168159

169-
// Prioritise block interactions!
170-
prioritiseBlockInteractions = true
160+
// Prioritise block interactions!
161+
prioritiseBlockInteractions = true
171162

172-
withTransform { pane, _ ->
173-
val item = ItemStack(Material.COMPASS).name("interfaces example")
163+
withTransform { pane, _ ->
164+
val item = ItemStack(Material.COMPASS).name("interfaces example")
174165

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+
}
179169

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+
}
184173

185-
val armor = ItemStack(Material.STICK)
174+
val armor = ItemStack(Material.STICK)
186175

187-
pane.armor.helmet = StaticElement(drawable(armor.name("helmet").clone()))
176+
pane.armor.helmet = StaticElement(drawable(armor.name("helmet").clone()))
188177

189-
pane.armor.chest = StaticElement(drawable(armor.name("chest").clone()))
178+
pane.armor.chest = StaticElement(drawable(armor.name("chest").clone()))
190179

191-
pane.armor.leggings = StaticElement(drawable(armor.name("leggings").clone()))
180+
pane.armor.leggings = StaticElement(drawable(armor.name("leggings").clone()))
192181

193-
pane.armor.boots = StaticElement(drawable(armor.name("boots").clone()))
194-
}
182+
pane.armor.boots = StaticElement(drawable(armor.name("boots").clone()))
195183
}
184+
}
196185

197-
private fun combinedInterface() =
198-
buildCombinedInterface {
199-
rows = 6
186+
private fun combinedInterface() = buildCombinedInterface {
187+
rows = 6
200188

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")
206193

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")
211196
}
212197
}
213198
}
199+
}
214200

215-
private fun runAsync(
216-
delay: Int,
217-
runnable: Runnable,
218-
) {
201+
private fun runAsync(delay: Int, runnable: Runnable) {
219202
Bukkit.getScheduler().runTaskLaterAsynchronously(this, runnable, delay * 20L)
220203
}
221204
}

examples/src/main/kotlin/com/noxcrew/interfaces/example/ExampleUtilities.kt

+6-8
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@ import net.kyori.adventure.text.Component
44
import org.bukkit.inventory.ItemStack
55

66
public fun ItemStack.name(name: String): ItemStack {
7-
itemMeta =
8-
itemMeta.also { meta ->
9-
meta.displayName(Component.text(name))
10-
}
7+
itemMeta = itemMeta.also { meta ->
8+
meta.displayName(Component.text(name))
9+
}
1110
return this
1211
}
1312

1413
public fun ItemStack.description(description: String): ItemStack {
15-
itemMeta =
16-
itemMeta.also { meta ->
17-
meta.lore(listOf(Component.text(description)))
18-
}
14+
itemMeta = itemMeta.also { meta ->
15+
meta.lore(listOf(Component.text(description)))
16+
}
1917
return this
2018
}

0 commit comments

Comments
 (0)