Skip to content

Commit 04f9a1e

Browse files
committed
Use raw slot for click slot logic
1 parent a34724b commit 04f9a1e

File tree

3 files changed

+3
-13
lines changed

3 files changed

+3
-13
lines changed

build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ val javaVersion: Int = 21
1515

1616
allprojects {
1717
group = "com.noxcrew.interfaces"
18-
version = "1.1.5-SNAPSHOT"
18+
version = "1.1.6-SNAPSHOT"
1919

2020
tasks.withType<JavaCompile> {
2121
sourceCompatibility = javaVersion.toString()

interfaces/src/main/kotlin/com/noxcrew/interfaces/InterfacesListeners.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public class InterfacesListeners private constructor(private val plugin: Plugin)
197197
val holder = event.inventory.holder
198198
val view = convertHolderToInterfaceView(holder) ?: return
199199
for (slot in event.rawSlots) {
200-
val clickedPoint = GridPoint.fromCombinedSlot(event.view.topInventory.size / 9, slot) ?: continue
200+
val clickedPoint = GridPoint.fromBukkitChestSlot(slot) ?: continue
201201
if (!canFreelyMove(view, clickedPoint)) {
202202
event.isCancelled = true
203203
return
@@ -325,7 +325,7 @@ public class InterfacesListeners private constructor(private val plugin: Plugin)
325325
if (event.inventory.holder is Player) {
326326
return GridPoint.fromBukkitPlayerSlot(event.slot)
327327
}
328-
return GridPoint.fromBukkitChestSlot(event.slot)
328+
return GridPoint.fromBukkitChestSlot(event.rawSlot)
329329
}
330330

331331
/**

interfaces/src/main/kotlin/com/noxcrew/interfaces/grid/GridPoint.kt

-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.noxcrew.interfaces.grid
22

3-
import com.noxcrew.interfaces.pane.CombinedPane
43
import com.noxcrew.interfaces.pane.PlayerPane
54

65
/** A 2-dimensional vector storing integer components. */
@@ -13,15 +12,6 @@ public data class GridPoint(val x: Int, val y: Int) {
1312
/** The slot index used to indicate a click was outside the UI. */
1413
public const val OUTSIDE_CHEST_INDEX: Int = -999
1514

16-
/** Returns the grid point for a [slot] in a player inventory. */
17-
public fun fromCombinedSlot(rows: Int, slot: Int): GridPoint? {
18-
if (slot !in PLAYER_INVENTORY_RANGE) return null
19-
val x = slot / 9
20-
val mappings = CombinedPane.createMappings(rows)
21-
val adjustedX = mappings.indexOf(x)
22-
return GridPoint(adjustedX, slot % 9)
23-
}
24-
2515
/** Returns the grid point for a [slot] in a player inventory. */
2616
public fun fromBukkitPlayerSlot(slot: Int): GridPoint? {
2717
if (slot !in PLAYER_INVENTORY_RANGE) return null

0 commit comments

Comments
 (0)