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

Create monster-monitor #6505

Merged
merged 25 commits into from
Oct 20, 2024

Conversation

ChunkyAtlas
Copy link
Contributor

@ChunkyAtlas ChunkyAtlas commented Aug 24, 2024

Tracks NPC kills regardless of item drops and allows setting kill limits with optional notifications

Tracks NPC kills and allows setting kill limits
@runelite-github-app
Copy link

runelite-github-app bot commented Aug 24, 2024

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
@ChunkyAtlas ChunkyAtlas marked this pull request as draft August 28, 2024 20:48
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.
@ChunkyAtlas ChunkyAtlas marked this pull request as ready for review September 2, 2024 20:26
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.
@ChunkyAtlas ChunkyAtlas changed the title Create monster-monitor Create monster-monitor Sep 20, 2024
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.
@ChunkyAtlas
Copy link
Contributor Author

ChunkyAtlas commented Sep 29, 2024

Hate to be a bother, but if any maintainers have a minute or two, could you take a look at this please! Thank you!

@raiyni
Copy link
Member

raiyni commented Sep 29, 2024

This plugin looks like it logging every animation from an npc and always saving it?

@ChunkyAtlas
Copy link
Contributor Author

ChunkyAtlas commented Sep 29, 2024

This plugin looks like it logging every animation from an npc and always saving it?

It buffers animations when interacting with an NPC only buffering unique animations that are not -1. Upon despawn it logs the last animation as the Death Animation. then does a clean up of the buffer.

@LlemonDuck
Copy link
Contributor

Can't you use something like onActorDeath instead of logging and tracking all this animation stuff? https://static.runelite.net/api/runelite-api/net/runelite/api/events/ActorDeath.html

This just sounds like asking for a nightmare every time a new piece of content comes out.

@ChunkyAtlas
Copy link
Contributor Author

Can't you use something like onActorDeath instead of logging and tracking all this animation stuff? https://static.runelite.net/api/runelite-api/net/runelite/api/events/ActorDeath.html

This just sounds like asking for a nightmare every time a new piece of content comes out.

I could’ve used onActorDeath instead of tracking NPC animations with an array, but I chose this approach to get more accuracy and detail when logging NPC deaths. By capturing the death animations, I’m also hoping to help fill in some of the missing animation IDs within RuneLite. As the plugin grows and we identify more death animation IDs, I plan to eventually move away from tracking animations altogether and rely on the DeathAnimationIDs class for logging.

@raiyni
Copy link
Member

raiyni commented Oct 15, 2024

That doesn't really make sense as llemonduck mentioned.

@ChunkyAtlas
Copy link
Contributor Author

That doesn't really make sense as llemonduck mentioned.

I understand! I'll make the corrections right now and utilize onActorDeath instead of the mess I made for tracking animations.

@LlemonDuck LlemonDuck added the waiting for author waiting for the pr author to make changes or respond to questions label Oct 15, 2024
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.
@runelite-github-app runelite-github-app bot removed the waiting for author waiting for the pr author to make changes or respond to questions label Oct 19, 2024
@ChunkyAtlas
Copy link
Contributor Author

@raiyni @LlemonDuck Updated per your suggestions

@iProdigy
Copy link
Member

DeathTracker is not being unregistered from the EventBus on plugin shutDown

@Felanbird Felanbird added the waiting for author waiting for the pr author to make changes or respond to questions label Oct 19, 2024
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.
@runelite-github-app runelite-github-app bot removed the waiting for author waiting for the pr author to make changes or respond to questions label Oct 20, 2024
@ChunkyAtlas
Copy link
Contributor Author

DeathTracker is not being unregistered from the EventBus on plugin shutDown

@raiyni @Felanbird @LlemonDuck @iProdigy Changes made

@raiyni
Copy link
Member

raiyni commented Oct 20, 2024

You don't need to ping everyone every time you update it.

@iProdigy
Copy link
Member

This isn't a blocker for merging but: if someone stops and starts the plugin, the DeathTracker won't be re-registered with the eventbus. Personally I'd just do the register/unregister calls within the plugin startUp/shutDown methods (and then you don't need to inject EventBus into DeathTracker)

@iProdigy
Copy link
Member

@iProdigy iProdigy added the waiting for author waiting for the pr author to make changes or respond to questions label Oct 20, 2024
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.
@runelite-github-app runelite-github-app bot removed the waiting for author waiting for the pr author to make changes or respond to questions label Oct 20, 2024
@LlemonDuck
Copy link
Contributor

@LlemonDuck LlemonDuck added the waiting for author waiting for the pr author to make changes or respond to questions label Oct 20, 2024
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.
@runelite-github-app runelite-github-app bot removed the waiting for author waiting for the pr author to make changes or respond to questions label Oct 20, 2024
@LlemonDuck
Copy link
Contributor

Sorry to bounce you back and forth a bit, but my last request is that you should remove uses of Exception#printStackTrace

@LlemonDuck LlemonDuck added the waiting for author waiting for the pr author to make changes or respond to questions label Oct 20, 2024
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.
@runelite-github-app runelite-github-app bot removed the waiting for author waiting for the pr author to make changes or respond to questions label Oct 20, 2024
@ChunkyAtlas
Copy link
Contributor Author

Sorry to bounce you back and forth a bit, but my last request is that you should remove uses of Exception#printStackTrace

no worries! I appreciate you going through it all!

@LlemonDuck LlemonDuck merged commit 9fee235 into runelite:master Oct 20, 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.

5 participants