Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update monster-monitor to 1.3.0 #6851

Merged
merged 35 commits into from
Oct 29, 2024

Conversation

ChunkyAtlas
Copy link
Contributor

@ChunkyAtlas ChunkyAtlas commented Oct 23, 2024

feat: Improve UI, background tasks, and better despawn handling

  • Wrapped all UI updates like repaint() in SwingUtilities.invokeLater() to ensure smooth, flicker-free interactions.
  • Made logging more efficient by using BufferedWriter and moving save operations to a background thread with saveLogAsync().
  • Cleaned up the onMenuOpened() logic in MonsterMonitorMenuHandler by breaking it into smaller methods—easier to read and tweak.
  • Refactored the MonsterMonitorBox to make the UI layout code more modular. It’s now much easier to follow.
  • Improved despawn handling in DeathTracker by splitting out conditions into helper methods—makes it easier to understand and modify.
  • Made sure that the overlay updates properly whenever NPC data changes.
  • Improved number formatting—big numbers are now displayed as "1k" or "1.5m" for easier reading.
  • Updated the font to 'SansSerif' for a cleaner, more modern look.
  • Tweaked the kill limit spinner to handle large numbers better while staying compact.
  • Enhanced the logger to automatically update old logs with any missing information required for new features.
  • Made the startup process smoother, ensuring the overlay is in the right state from the start.
  • Cleaned up the options panel layout for a more polished overall look and feel.
  • Added a new ProgressBar that tracks progress towards NPC kill limits:
    • The bar changes color as you get closer to your goal, shifting from red to orange to green.
  • Fixed a bug where bosses with large areas (like Tempoross) would count as a kill when they moved out of view—now it only counts when you actually kill them.
  • Adjusted Giant Mole tracking to ignore its digging phases—only the final phase counts as a kill.
  • Added right-click options to "Ignore" or "Monitor" NPCs directly from the game interface.
  • Added a config option for toggling these right-click menu entries.
  • Fixed an issue where the overlay and progress bar wouldn’t snap like other overlays.

Tracks NPC kills and allows setting kill limits
Updated runelite-plugin.properties
Few minor updates, a few more tests. no functional changes
- Fixed issue with double notifications for NPC kills with a set limit.
- Ensured notifications play correctly for NPCs with unknown death animations.
- Adjusted the MonsterMonitorPanel to push NPCs added from UnknownDeathAnimations to the top of the panel, similar to normal NPCs.
- Refined the logic for handling and sorting NPCs in the panel to ensure consistent behavior.
- Ensured that the MonsterMonitorLogger handles unknown animations and logs them consistently with regular NPCs.
forgot to uncomment a few lines in DeathAnimationIDS after some tests.
Fix runelite-plugin.properties again
Enhance Monster Monitor Plugin with Interaction Timer, Duplicate Logging Prevention, and Prioritization of Last Killed NPC

Interaction Timer: Implemented a 4-second interaction timeout to ensure that NPC kills are accurately tracked during combat, especially for ranged and magic attacks where interactions may briefly pause.

Immediate Logging After Health Reaches Zero: Introduced a mechanism to capture and log the last valid animation immediately after an NPC's health reaches zero. This ensures that all NPC deaths, especially those with complex animations, are logged accurately and on time.

Duplicate Logging Prevention: Refined and optimized the logging logic to prevent duplicate entries of NPC deaths. The cleanup of NPC tracking data is now delayed until the NPC has fully despawned, preventing premature data clearing and missed logs.

Prioritization of Last Killed NPC: Updated the UI panel and overlay to prioritize the display of the most recently killed NPC at the top, regardless of whether the death animation is known or unknown. This change ensures that the most recent activity is always immediately visible to the user.

Refactor and Code Cleanup: Consolidated and cleaned up the codebase for better consistency and reliability across various NPC types and combat scenarios. The plugin has been fine-tuned to function correctly in both continuous and intermittent interactions.

Bug Fixes: Addressed issues where the plugin would stop logging kills after the first kill or fail to log certain NPC deaths. These fixes ensure that all NPC kills are tracked and displayed as expected.

This update significantly improves the reliability, accuracy, and user experience of the Monster Monitor Plugin, making it more robust in handling various edge cases and ensuring comprehensive NPC kill tracking and display.
Improve redundancy and accuracy in capturing NPC death animations

- Implemented immediate health check to start tracking NPCs as awaiting death animation when their health drops to zero.
- Added aggressive death animation tracking with multiple attempts to capture or log death animations.
- Enhanced despawn logging to ensure the last valid animation is logged or marked as unknown if missed.
- Updated NPC tracking methods to improve reliability and prevent unnecessary logging.
- Added Another Unknown DeathAnimationIDs
Add NpcAnimationTracker for improved NPC interaction tracking and logging

- Introduced `NpcAnimationTracker.java`, a new class dedicated to tracking NPC animations and interactions, significantly improving how the plugin monitors NPC behavior.
- `NpcAnimationTracker` registers for several in-game events, including `InteractingChanged`, `NpcDespawned`, `GameTick`, and `HitsplatApplied`, to accurately track when the player interacts with NPCs.
- Added logic to buffer unique NPC animations, enabling the plugin to distinguish between different types of animations, such as death animations, and ensuring accurate logging of relevant events.
- Implemented a grace period mechanism within `NpcAnimationTracker` to handle NPCs that despawn shortly after interaction, ensuring that the last known animations are accurately recorded and logged.
- Updated the handling of interaction timeouts, allowing the plugin to clear out expired interactions and prevent stale data from affecting ongoing tracking.
- Integrated `NpcAnimationTracker` with the existing logging mechanisms in `MonsterMonitorPlugin`, ensuring that all tracked interactions and animations are logged with precise timing and context.
- Provided detailed comments and documentation within `NpcAnimationTracker.java` to explain the purpose of each method and how the class contributes to the overall functionality of the plugin.
- Refactored parts of `MonsterMonitorPlugin` and related classes to utilize `NpcAnimationTracker` for more granular and accurate tracking, enhancing the plugin's ability to monitor NPC kills and associated events.
- Ensured that the new tracking system remains performant and reliable, even during high-intensity gameplay, by carefully managing resources and minimizing unnecessary processing.
Update build.gradle for Monster Monitor plugin

- Added Gson dependency for JSON handling, enabling serialization and deserialization in MonsterMonitorLogger.
- Included Lombok dependency and annotation processor to support annotations like @getter, @Setter, @NoArgsConstructor, etc., used throughout the plugin.
- Maintained existing dependencies for RuneLite client compatibility.
Forgot to upload the NpcAnimationTracker.java
Bug fixes and improved UI/Panel visual - Refine UI and add MonsterMonitorBox for enhanced NPC tracking - Added more config options

- Improved the design and layout of MonsterMonitorPanel.
- Created MonsterMonitorBox to handle individual NPC tracking, including setting kill limits and notifications.
- Fixed bug where the last killed NPC was not being correctly displayed at the top of the NPC panel.
- Updated MonsterMonitorOverlay to maintain design consistency with the panel and improve user readability.
- Retained all existing functionality while enhancing the visual and interactive elements of the plugin.

- Added configuration options to MonsterMonitorConfig for default kill limits, chat notifications, custom notification messages, unknown death animation notifications, and sound alerts.
- Enhanced MonsterMonitorPlugin to listen for ConfigChanged events and apply configuration updates immediately.
- Ensured that sound alerts and chat notifications are toggled based on user preferences, providing immediate feedback without requiring plugin restart.
Fix layout issues in MonsterMonitorPanel and MonsterMonitorBox, Added config option functionality :

- Implemented dynamic resizing for NPCListPanel using GridBagLayout, ensuring proper layout adjustments as NPCs are added or removed.
- Removed redundant JScrollPane nesting, allowing the ScrollPane to fill the available space within PluginPanel and improving scrolling performance.
- Introduced a dynamic filler panel at the bottom of the NPCListPanel that adjusts its height based on the number of NPCs, ensuring proper vertical expansion and contraction.
- Added dropdown persistence in MonsterMonitorBox to maintain the expanded/collapsed state of NPC dropdowns during panel refresh.
- Ensured the title panel remains static at the top while enabling smooth scrolling for the NPC list in the ScrollPane.
- Configurations now control kill limit notifications, sound alerts, and chat notifications for NPC kills and unknown death animations, with logic to notify only once per unknown death animation.
fix: replace deprecated OverlayPriority usage with integer-based priority system

- Updated setPriority(OverlayPriority.HIGH) to setPriority(50) to adhere to the integer-based priority system.
Update verification-metadata.xml with updated dependency checksums
Update Gson version to 2.8.5 and update verification-metadata with new checksums
fix: Inject client's Gson instance instead of creating a new one

- Removed the direct instantiation of Gson in MonsterMonitorLogger.

- Injected the client's Gson instance using @Inject annotation.
Update Monster Monitor: Refactor to use DeathTracker, handle multi-phase NPCs, improve death logging logic

- Replaced NpcAnimationTracker with DeathTracker to log deaths based on interactions.
- Included final phase IDs for multi-phase bosses such as Verzik, Vorkath, Zulrah, and others.
- Removed animation-based logic and unknown death animation notifications.
- Added interaction validation to ensure only relevant NPC deaths are logged.
- Cleaned up code, removed unused methods, and optimized NPC tracking.
Improve NPC engagement tracking and proper EventBus unregistration

- Added `wasNpcEngaged` map to track whether an NPC has been engaged through hitsplats or damage, ensuring that only NPCs that have been properly interacted with are logged upon despawn.
- Updated `onInteractingChanged` method to reset engagement status when a new interaction with an NPC starts, ensuring accurate tracking.
- Updated `onHitsplatApplied` to mark NPCs as engaged when a hitsplat is applied, indicating active combat engagement.
- Refined `onNpcDespawned` to only log NPCs as dead if they were actively engaged in combat before despawning, avoiding false positives from mere clicks.
- Ensured cleanup of engagement status and related states after logging to maintain memory efficiency and avoid stale data.
- Added proper unregistration of the `EventBus` in the `unregister` method to ensure clean shutdown of the plugin, preventing potential memory leaks and ensuring a smooth disable process.
Fix: Inject EventBus into MonsterMonitorPlugin for proper event registration

- Added EventBus injection to MonsterMonitorPlugin to enable registration and unregistration of DeathTracker during plugin startUp and shutDown.
- Ensured proper lifecycle management of DeathTracker events to maintain consistency when the plugin is restarted.
fix: move scrollbar UI updates to Swing thread

Used SwingUtilities.invokeLater() for setting up the custom scrollbar UI to make sure it's done on the correct thread.
refactor: use logger.error() instead of printStackTrace()

- Swapped out all instances of e.printStackTrace() with logger.error() for better logging.
- This should make errors easier to track in the RuneLite logs and keep things cleaner.
feat: Improve UI, background tasks, and better despawn handling

- Wrapped all UI updates like `repaint()` in `SwingUtilities.invokeLater()` to ensure smooth, flicker-free interactions.
- Made logging more efficient by using `BufferedWriter` and moving save operations to a background thread with `saveLogAsync()`.
- Cleaned up the `onMenuOpened()` logic in `MonsterMonitorMenuHandler` by breaking it into smaller methods—easier to read and tweak.
- Refactored the `MonsterMonitorBox` to make the UI layout code more modular. It’s now much easier to follow.
- Improved despawn handling in `DeathTracker` by splitting out conditions into helper methods—makes it easier to understand and modify.
- Fine-tuned the logic for tracking multi-phase bosses and ignoring non-combat NPC despawns.
- Made sure that the overlay updates properly whenever NPC data changes.
- Improved number formatting—big numbers are now displayed as "1k" or "1.5m" for easier reading.
- Updated the font to 'SansSerif' for a cleaner, more modern look.
- Tweaked the kill limit spinner to handle large numbers better while staying compact.
- Added checks in the logger to ensure the overlay visibility updates properly when NPC data is adjusted.
- Enhanced the logger to automatically update old logs with any missing information required for new features.
- Made the startup process smoother, ensuring the overlay is in the right state from the start.
- Cleaned up the options panel layout for a more polished overall look and feel.
- Added a new `ProgressBar` that tracks progress towards NPC kill limits:
  - The bar changes color as you get closer to your goal, shifting from red to orange to green.
- Simplified how large numbers are displayed—now it's "1k" instead of "1000" or "1.5m" for "1,500,000".
- Fixed a bug where bosses with large areas (like Tempoross) would count as a kill when they moved out of view—now it only counts when you actually kill them.
- Adjusted Giant Mole tracking to ignore its digging phases—only the final phase counts as a kill.
- Added right-click options to "Ignore" or "Monitor" NPCs directly from the game interface.
- Added a config option for toggling these right-click menu entries.
- Fixed an issue where the overlay and progress bar wouldn’t snap like other overlays.
@runelite-github-app
Copy link

runelite-github-app bot commented Oct 23, 2024

removed unused class
feat: reintroduce onActorDeath for accurate NPC death tracking

After further testing, re-added `onActorDeath` to improve the accuracy of NPC death tracking. This event provides direct confirmation of an NPC's death, especially useful for multi-phase bosses and high-frequency encounters. 

Previously, `onActorDeath` was removed due to concerns about potential conflicts with `NpcDespawned` handling. However, it became evident that relying solely on despawn events and engagement tracking via `HitsplatApplied` and `InteractingChanged` resulted in occasional missed kills, particularly for bosses with complex despawn behaviors.
Update DeathTracker exclusions, final phase tracking, and thread safety for multi-phase NPCs

- Added missing NPC IDs to DESPAWN_EXCLUSION_IDS to exclude intermediate phases and specific non-combat encounters:
  - Tempoross (10530)
  - Wintertodt (6503, 6504)
  - Intermediate phases of Zulrah (2042, 2043), Giant Mole (963), Zalcano (8360, 8361), and Alchemical Hydra (8615, 8616, 8617)
  - Crystalline Hunllef (9021, 9022), and Crystalline Dark Beast & Dragon (9033, 9034)

- Ensured final phases of multi-phase bosses are correctly tracked in MULTI_PHASE_FINAL_IDS:
  - Final phases for Zulrah (2044), Giant Mole (965), Zalcano (8362), Grotesque Guardians (8060), Alchemical Hydra (8618), Verzik Vitur (9034), and others.

- Added thread-safety improvements:
  - Converted lastKnownNpcName, lastInteractionTicks, and wasNpcEngaged in DeathTracker to ConcurrentHashMap for safe concurrent access.
  - Synchronized access to npcLog in MonsterMonitorLogger to prevent concurrent modification issues.
  - Verified that all UI updates in MonsterMonitorPanel and MonsterMonitorBox are wrapped in SwingUtilities.invokeLater().

This update refines DeathTracker to accurately track only final kills and skip intermediate or non-kill phases, while also ensuring thread safety across all relevant components.
Remove final phase for Zulrah (2044) from exclusion list in DESPAWN_EXCLUSION_IDS
fix: Resolve "Reset NPC Data" context menu issue and add `removeNpcFromLog`

- Fixed an issue with "Reset NPC Data" in the context menu that prevented NPC data from being properly removed.
- Added `removeNpcFromLog` method to allow direct removal of NPC entries from the log.
- Updated the `Reset NPC Data` menu item to use the new method for cleaner and more reliable behavior.
Fix Set Limit functionality: Clear kill limit and disable Notify checkbox when Set Limit is unchecked
@ChunkyAtlas
Copy link
Contributor Author

Should be the last fix (Unless you guys find something I messed up)

Refactor DeathTracker: Remove despawn event tracking and multi-phase boss handling for improved accuracy and simplicity

* Removed MULTI_PHASE_BOSS_IDS, MULTI_PHASE_FINAL_IDS, and DESPAWN_EXCLUSION_IDS sets.
* Simplified kill logging to rely solely on interactions and hitsplats.
* Deleted onNpcDespawned() handler, as despawn tracking is no longer necessary.
* Refactored onActorDeath() to only log kills based on recent player interactions and hitsplats.
@ChunkyAtlas
Copy link
Contributor Author

Should be the last fix (Unless you guys find something I messed up)

Okay for real this time

@Adam-
Copy link
Member

Adam- commented Oct 28, 2024

Please remove your com.google.code.gson:gson:2.8.5 dependency. This is already a transitive dependency via the client and redefining it is causing gson to get repacked with your plugin.

remove GSON dependency
@ChunkyAtlas
Copy link
Contributor Author

Please remove your com.google.code.gson:gson:2.8.5 dependency. This is already a transitive dependency via the client and redefining it is causing gson to get repacked with your plugin.

Removed! Sorry about that

@Adam- Adam- merged commit a9abd43 into runelite:master Oct 29, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants