File tree Expand file tree Collapse file tree
src/main/kotlin/cc/modlabs/kpaper/npc Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package cc.modlabs.kpaper.npc
22
33import cc.modlabs.kpaper.event.listen
44import cc.modlabs.kpaper.extensions.timer
5+ import cc.modlabs.kpaper.util.getLogger
56import org.bukkit.entity.Player
67import org.bukkit.event.entity.EntityDamageByEntityEvent
78import org.bukkit.event.player.PlayerAnimationEvent
@@ -41,6 +42,7 @@ object NPCEventListener {
4142 val npc = npcMap[entity] ? : return @listen
4243 val player = event.player
4344 val isSneaking = player.isSneaking
45+ getLogger().info(" Interacted with NPC $npc for player $player ($isSneaking ) - ${event.hand.name} " )
4446
4547 // Check if NPC has a conversation and start it (only on normal right-click, not shift-click)
4648 if (! isSneaking && npc.getConversation() != null ) {
Original file line number Diff line number Diff line change @@ -640,9 +640,6 @@ class NPCImpl(
640640 // Start monitoring task - this will run continuously every nearbyFollowCheckInterval ticks
641641 logDebug(" [NPC] followNearbyPlayers: Starting monitoring task with interval=$nearbyFollowCheckInterval ticks (${nearbyFollowCheckInterval * 50 } ms)" )
642642 nearbyFollowTask = timer(nearbyFollowCheckInterval, " NPCNearbyFollow" ) {
643- // Log every tick to confirm task is running
644- logDebug(" [NPC] NearbyFollow task: [TICK START] isFollowingNearbyPlayers=$isFollowingNearbyPlayers " )
645-
646643 // Wrap everything in try-catch to ensure task never stops on error
647644 try {
648645 // Only cancel if explicitly stopped
@@ -653,14 +650,13 @@ class NPCImpl(
653650 return @timer
654651 }
655652
656- val currentEntity = getMannequin() as ? LivingEntity
657- if (currentEntity == null || ! currentEntity.isValid) {
658- logDebug(" [NPC] NearbyFollow task: Entity invalid, but continuing to check" )
653+ if (! npcEntity.isValid) {
654+ logDebug(" [NPC] NearbyFollow task: Entity for ${npcEntity.name} invalid, but continuing to check" )
659655 // Don't stop the task, just skip this tick
660656 return @timer
661657 }
662658
663- val npcLocation = currentEntity .location
659+ val npcLocation = npcEntity .location
664660 val npcWorld = npcLocation.world
665661 if (npcWorld == null ) {
666662 logDebug(" [NPC] NearbyFollow task: World is null, but continuing to check" )
You can’t perform that action at this time.
0 commit comments