Repository navigation
fix(playermonitor): create click log dir before saving on stop (1.0.5) - #637
Merged
Merged
Conversation
saveMouseClicks wrote to ~/.runelite/PlayerMonitor/click_count.log without creating the directory, which is only created by loadMouseClicks and is skipped in lite mode. Stopping the plugin then threw FileNotFoundException and aborted shutDown before the listener and script were cleaned up. Create the parent directory before writing, close the writer with try-with-resources, and catch the IOException in shutDown so cleanup runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LjtEMzQHGuq4M1Mpqk9pPV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Error telemetry group 1642 (PlayerMonitorPlugin 1.0.4, Microbot 2.6.30): 2 occurrences across 1 report, first seen 2026-10-13. Stopping the plugin threw
java.io.FileNotFoundException("The system cannot find the path specified"). PluginManager logged it as "Error during starting/stopping plugin".Because of the exception, the mouse-listener unregister and
playerMonitorScript.shutdown()that follow it inshutDownnever ran.Root cause
saveMouseClicks()opened aFileWriteron~/.runelite/PlayerMonitor/click_count.logwithout creating the directory first. OnlyloadMouseClicks()createsCLICK_TOTAL_DIR, andstartUpskips that call in liteMode. So when the directory does not exist, every save fails: on shutdown, inonGameStateChanged(where the exception escapes an event subscriber), and every 50 clicks inonMenuOptionClickedandresetMouseClickCounterListener.Change
saveMouseClicks()now calls a new package-private helper,writeClickCount(File, int). The helper creates the parent directory if it is missing (and throwsIOExceptionif it cannot) and writes the count with try-with-resources. The oldcreateNewFilestep, which did nothing useful, is removed. All four callers go through the helper.shutDowncatchesIOExceptionfromsaveMouseClicks()and logs a warning, so listener and script cleanup always run.Validation
PlayerMonitorPluginTest(@TempDir) has two cases. One checks that the helper creates a missing directory and writes the count. The other checks that it overwrites an existing file../gradlew test --tests 'net.runelite.client.plugins.microbot.playermonitor.*' --tests 'net.runelite.client.plugins.microbot.PluginManifestVersionTest' -PpluginList=PlayerMonitorPlugin: BUILD SUCCESSFUL (3/3)../gradlew build -PpluginList=PlayerMonitorPlugin -x test: BUILD SUCCESSFUL.Known gaps
startUpnever loads the saved count, so stopping overwrites a previously saved count with the in-memory counter.🤖 Generated with Claude Code
https://claude.ai/code/session_01LjtEMzQHGuq4M1Mpqk9pPV