@@ -81,7 +81,7 @@ public class InterfacesListeners private constructor(private val plugin: Plugin)
81
81
MaterialTags .WOODEN_DOORS ,
82
82
MaterialTags .WOODEN_TRAPDOORS ,
83
83
MaterialTags .FENCE_GATES ,
84
- MaterialSetTag .BUTTONS ,
84
+ MaterialSetTag .BUTTONS
85
85
)
86
86
// Add blocks with inventories
87
87
.add(
@@ -96,7 +96,7 @@ public class InterfacesListeners private constructor(private val plugin: Plugin)
96
96
Material .LOOM ,
97
97
Material .CARTOGRAPHY_TABLE ,
98
98
Material .ENCHANTING_TABLE ,
99
- Material .SMITHING_TABLE ,
99
+ Material .SMITHING_TABLE
100
100
)
101
101
.add(Material .LEVER )
102
102
.add(Material .CAKE )
@@ -105,25 +105,25 @@ public class InterfacesListeners private constructor(private val plugin: Plugin)
105
105
Material .COPPER_DOOR ,
106
106
Material .EXPOSED_COPPER_DOOR ,
107
107
Material .WEATHERED_COPPER_DOOR ,
108
- Material .OXIDIZED_COPPER_DOOR ,
108
+ Material .OXIDIZED_COPPER_DOOR
109
109
)
110
110
.add(
111
111
Material .WAXED_COPPER_DOOR ,
112
112
Material .WAXED_EXPOSED_COPPER_DOOR ,
113
113
Material .WAXED_WEATHERED_COPPER_DOOR ,
114
- Material .WAXED_OXIDIZED_COPPER_DOOR ,
114
+ Material .WAXED_OXIDIZED_COPPER_DOOR
115
115
)
116
116
.add(
117
117
Material .COPPER_TRAPDOOR ,
118
118
Material .EXPOSED_COPPER_TRAPDOOR ,
119
119
Material .WEATHERED_COPPER_TRAPDOOR ,
120
- Material .OXIDIZED_COPPER_TRAPDOOR ,
120
+ Material .OXIDIZED_COPPER_TRAPDOOR
121
121
)
122
122
.add(
123
123
Material .WAXED_COPPER_TRAPDOOR ,
124
124
Material .WAXED_EXPOSED_COPPER_TRAPDOOR ,
125
125
Material .WAXED_WEATHERED_COPPER_TRAPDOOR ,
126
- Material .WAXED_OXIDIZED_COPPER_TRAPDOOR ,
126
+ Material .WAXED_OXIDIZED_COPPER_TRAPDOOR
127
127
)
128
128
// You can click signs to edit them
129
129
.add(MaterialTags .SIGNS )
@@ -253,13 +253,23 @@ public class InterfacesListeners private constructor(private val plugin: Plugin)
253
253
if (view.backing.includesPlayerInventory) {
254
254
// If you use a number key we check if the item you're swapping with is
255
255
// protected.
256
- if (event.click == ClickType .NUMBER_KEY && ! canFreelyMove(view, view.backing.relativizePlayerInventorySlot(GridPoint .at(3 , event.hotbarButton)), true )) {
256
+ if (event.click == ClickType .NUMBER_KEY && ! canFreelyMove(
257
+ view,
258
+ view.backing.relativizePlayerInventorySlot(GridPoint .at(3 , event.hotbarButton)),
259
+ true
260
+ )
261
+ ) {
257
262
event.isCancelled = true
258
263
return
259
264
}
260
265
261
266
// If you try to swap with the off-hand we have to specifically check for that.
262
- if (event.click == ClickType .SWAP_OFFHAND && ! canFreelyMove(view, view.backing.relativizePlayerInventorySlot(GridPoint .at(4 , 4 )), true )) {
267
+ if (event.click == ClickType .SWAP_OFFHAND && ! canFreelyMove(
268
+ view,
269
+ view.backing.relativizePlayerInventorySlot(GridPoint .at(4 , 4 )),
270
+ true
271
+ )
272
+ ) {
263
273
event.isCancelled = true
264
274
return
265
275
}
@@ -274,14 +284,26 @@ public class InterfacesListeners private constructor(private val plugin: Plugin)
274
284
275
285
// Don't check top inventory if we're in the player inventory!
276
286
if (
277
- (! isInPlayerInventory && topInventory.withIndex().any { (index, it) ->
278
- // Check if any item is being collected that cannot be moved!
279
- it != null && it.isSimilar(clickedItem) && ! canFreelyMove(view, requireNotNull(GridPoint .fromBukkitChestSlot(index)), false )
280
- }) ||
287
+ (
288
+ ! isInPlayerInventory && topInventory.withIndex().any { (index, it) ->
289
+ // Check if any item is being collected that cannot be moved!
290
+ it != null && it.isSimilar(clickedItem) && ! canFreelyMove(
291
+ view,
292
+ requireNotNull(GridPoint .fromBukkitChestSlot(index)),
293
+ false
294
+ )
295
+ }
296
+ ) ||
281
297
bottomInventory.withIndex().any { (index, it) ->
282
298
it != null && it.isSimilar(clickedItem) &&
283
- // These slots are always in the player inventory and always need to be relativized!
284
- ! canFreelyMove(view, view.backing.relativizePlayerInventorySlot(requireNotNull(GridPoint .fromBukkitPlayerSlot(index))), true )
299
+ // These slots are always in the player inventory and always need to be relativized!
300
+ ! canFreelyMove(
301
+ view,
302
+ view.backing.relativizePlayerInventorySlot(
303
+ requireNotNull(GridPoint .fromBukkitPlayerSlot(index))
304
+ ),
305
+ true
306
+ )
285
307
}
286
308
) {
287
309
event.isCancelled = true
@@ -509,7 +531,11 @@ public class InterfacesListeners private constructor(private val plugin: Plugin)
509
531
isPlayerInventory : Boolean
510
532
): Boolean {
511
533
// If we don't allow clicking empty slots we never allow freely moving
512
- if (view.builder.preventClickingEmptySlots && ! (view.builder.allowClickingOwnInventoryIfClickingEmptySlotsIsPrevented && isPlayerInventory)) return false
534
+ if (view.builder.preventClickingEmptySlots &&
535
+ ! (view.builder.allowClickingOwnInventoryIfClickingEmptySlotsIsPrevented && isPlayerInventory)
536
+ ) {
537
+ return false
538
+ }
513
539
514
540
// If this inventory has no player inventory then the player inventory is always allowed to be edited
515
541
if (! view.backing.includesPlayerInventory && isPlayerInventory) return true
@@ -531,7 +557,9 @@ public class InterfacesListeners private constructor(private val plugin: Plugin)
531
557
532
558
// Optionally cancel clicking on other slots
533
559
if (raw == null ) {
534
- if (view.builder.preventClickingEmptySlots && ! (view.builder.allowClickingOwnInventoryIfClickingEmptySlotsIsPrevented && isPlayerInventory)) {
560
+ if (view.builder.preventClickingEmptySlots &&
561
+ ! (view.builder.allowClickingOwnInventoryIfClickingEmptySlotsIsPrevented && isPlayerInventory)
562
+ ) {
535
563
return true
536
564
}
537
565
return false
0 commit comments