File tree Expand file tree Collapse file tree 2 files changed +26
-9
lines changed
surf-npc-bukkit/src/main/kotlin/dev/slne/surf/npc/bukkit/listener Expand file tree Collapse file tree 2 files changed +26
-9
lines changed Original file line number Diff line number Diff line change 11kotlin.code.style =official
22kotlin.stdlib.default.dependency =false
33org.gradle.parallel =true
4- version =1.21.7-1.2.0 -SNAPSHOT
4+ version =1.21.7-1.2.1 -SNAPSHOT
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package dev.slne.surf.npc.bukkit.listener
33import com.github.retrooper.packetevents.event.PacketListener
44import com.github.retrooper.packetevents.event.PacketReceiveEvent
55import com.github.retrooper.packetevents.protocol.packettype.PacketType
6+ import com.github.retrooper.packetevents.protocol.player.InteractionHand
67import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity
78import com.github.shynixn.mccoroutine.folia.entityDispatcher
89import com.github.shynixn.mccoroutine.folia.launch
@@ -59,15 +60,31 @@ class NpcListener : PacketListener {
5960 val packet = WrapperPlayClientInteractEntity (event)
6061 val npc = npcController.getNpc(packet.entityId) ? : return
6162
62- if (packet.action != WrapperPlayClientInteractEntity .InteractAction .ATTACK ) {
63- return
64- }
63+ when (packet.action) {
64+ WrapperPlayClientInteractEntity .InteractAction .ATTACK -> {
65+ plugin.launch(plugin.entityDispatcher(player)) {
66+ NpcInteractEvent (
67+ npc,
68+ player
69+ ).callEvent()
70+ }
71+ }
72+
73+ WrapperPlayClientInteractEntity .InteractAction .INTERACT -> {
74+ if (packet.hand != InteractionHand .MAIN_HAND ) {
75+ return
76+ }
6577
66- plugin.launch(plugin.entityDispatcher(player)) {
67- NpcInteractEvent (
68- npc,
69- player
70- ).callEvent()
78+ plugin.launch(plugin.entityDispatcher(player)) {
79+ NpcInteractEvent (
80+ npc,
81+ player
82+ ).callEvent()
83+ }
84+ }
85+ WrapperPlayClientInteractEntity .InteractAction .INTERACT_AT -> {
86+ // This is already handled by INTERACT action, so we can ignore it.
87+ }
7188 }
7289 }
7390 }
You can’t perform that action at this time.
0 commit comments