From 17fd7271755bfbe84a0ad113b95956f5c6b4e9c2 Mon Sep 17 00:00:00 2001 From: Tech Date: Tue, 20 Feb 2024 15:11:32 -0500 Subject: [PATCH] fix: offhand swap --- README.md | 4 ++-- build.gradle.kts | 2 +- .../mcchestui/listeners/GUISlotClickListener.kt | 13 +++++++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index cad9085..24ff170 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ repositories { } dependencies { - implementation("com.github.DebitCardz:mc-chestui-plus:1.4.7") + implementation("com.github.DebitCardz:mc-chestui-plus:1.4.9") } ``` ### Maven @@ -34,7 +34,7 @@ dependencies { com.github.DebitCardz mc-chestui-plus - 1.4.7 + 1.4.9 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 4da2fff..948cb28 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ val githubActor = project.findProperty("gpr.user") as String? ?: System.getenv(" val githubToken = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN") group = "me.tech" -version = "1.4.7" +version = "1.4.9" repositories { mavenCentral() diff --git a/src/main/kotlin/me/tech/mcchestui/listeners/GUISlotClickListener.kt b/src/main/kotlin/me/tech/mcchestui/listeners/GUISlotClickListener.kt index 54bc9a8..d394e2e 100644 --- a/src/main/kotlin/me/tech/mcchestui/listeners/GUISlotClickListener.kt +++ b/src/main/kotlin/me/tech/mcchestui/listeners/GUISlotClickListener.kt @@ -17,9 +17,10 @@ internal class GUISlotClickListener(gui: GUI) : GUIEventListener(gui) { val guiSlot = gui.slots.getOrNull(slot) ?: return // handle cancellation of task in onPlace. - if(click == ClickType.DROP || click == ClickType.CONTROL_DROP) { - if(!guiSlot.allowPickup) { + if(click in PICKUP_CLICK_ACTIONS) { + if(!gui.allowItemPickup) { isCancelled = true + return } } @@ -27,4 +28,12 @@ internal class GUISlotClickListener(gui: GUI) : GUIEventListener(gui) { uiEvent(this, whoClicked as Player) } } + + companion object { + private val PICKUP_CLICK_ACTIONS = setOf( + ClickType.DROP, + ClickType.CONTROL_DROP, + ClickType.SWAP_OFFHAND + ) + } } \ No newline at end of file