Only trigger click on mouse click action - else cancel
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package net.axay.kspigot.inventory
|
package net.axay.kspigot.inventory
|
||||||
|
|
||||||
import net.axay.kspigot.event.listen
|
import net.axay.kspigot.event.listen
|
||||||
|
import org.bukkit.event.inventory.InventoryAction
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent
|
import org.bukkit.event.inventory.InventoryClickEvent
|
||||||
|
|
||||||
object InventoryGUIHolder : AutoCloseable {
|
object InventoryGUIHolder : AutoCloseable {
|
||||||
@@ -28,11 +29,10 @@ object InventoryGUIHolder : AutoCloseable {
|
|||||||
return@listen
|
return@listen
|
||||||
}
|
}
|
||||||
|
|
||||||
val invPage = inv.currentPageInt
|
if (it.action.isGUIClick)
|
||||||
|
inv.currentPage.slots[it.slot]?.onClick(InventoryGUIClickEvent(it, inv)) ?: kotlin.run {
|
||||||
val slot = inv.data.pages[invPage]?.slots?.get(it.slot)
|
it.isCancelled = true
|
||||||
if (slot != null)
|
}
|
||||||
slot.onClick(InventoryGUIClickEvent(it, inv))
|
|
||||||
else
|
else
|
||||||
it.isCancelled = true
|
it.isCancelled = true
|
||||||
|
|
||||||
@@ -45,3 +45,6 @@ object InventoryGUIHolder : AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val InventoryAction.isGUIClick
|
||||||
|
get() = this == InventoryAction.PICKUP_ALL || this == InventoryAction.PICKUP_HALF
|
Reference in New Issue
Block a user