Fix NPC title stacking issue when players leave visible range#111
Fix NPC title stacking issue when players leave visible range#111
Conversation
- Improved hologram cleanup logic in TraitTitle.remove() to handle edge cases - Enhanced player quit handler to prevent memory leaks and ensure cleanup - Strengthened title creation to properly handle existing holograms - Fixed dual lookup map synchronization to prevent title duplication Fixes #110 Co-authored-by: 黑 <Bkm016@users.noreply.github.com>
|
Claude finished @Bkm016's task —— View job Code Review Complete ✅I've analyzed the Todo List:
Code Quality & Best Practices ⭐⭐⭐⭐⭐Excellent improvements overall! The code follows Kotlin conventions well and demonstrates solid understanding of concurrency patterns. Strengths:
Minor suggestions:
Bug Analysis 🐛Key fixes implemented correctly:
Potential edge case:
Performance Considerations ⚡Good performance practices:
Scheduling concern:
Security Assessment 🔒No security issues identified. The code:
Test Coverage 📋Missing test coverage: No unit tests are included with these changes. Consider adding tests for:
Technical Deep Dive 🔍Root cause fix analysis:
Create method improvements (lines 102-124):
Recommendation: ✅ APPROVEThis PR successfully addresses the title stacking issue with well-engineered solutions. The dual lookup approach with proper synchronization is the right architectural choice for this use case. The code quality is high and follows best practices for concurrent programming. Minor follow-up suggestions:
|
Fixes #110
This PR addresses the issue where NPC titles (holograms) were not properly removed when players left the NPC's visible range, causing multiple titles to stack when players re-entered the area.
Changes
remove()method to handle edge cases and synchronize both lookup maps properlyplayerLookupandentityLookupstay in syncRoot Cause
The issue was in the
TraitTitleclass where the hologram cleanup logic had synchronization problems between the dual lookup maps when players moved out of the NPC's visible range. This could result in incomplete cleanup, leaving stale hologram references that caused duplication when players re-entered the area.Testing
Generated with Claude Code