Skip to content

Commit

Permalink
misc: send fake InventoryClickEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
DebitCardz committed Aug 19, 2023
1 parent 5a281a7 commit 4c84740
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/kotlin/me/tech/mcchestui/GUIListener.kt
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,19 @@ internal class GUIListener(private val gui: GUI): Listener {
}

gui.onPlaceItem?.let { uiEvent ->
uiEvent(this, whoClicked as Player, itemStack, slotIndex).let { outcome ->
// TODO: Look for better method of handling this.
val fakeEvent = InventoryClickEvent(
view,
InventoryType.SlotType.CONTAINER,
slotIndex,
if(type == DragType.SINGLE) ClickType.RIGHT else ClickType.LEFT,
InventoryAction.PLACE_ALL
)

uiEvent(fakeEvent, whoClicked as Player, itemStack, slotIndex).let { outcome ->
isCancelled = outcome
}
}

return
}

Expand Down

0 comments on commit 4c84740

Please sign in to comment.