Skip to content

fix(playermonitor): create click log dir before saving on stop (1.0.5) - #637

Merged
chsami merged 1 commit into
developmentfrom
claude/err-playermonitor-stop-missing-dir
Oct 15, 2026
Merged

chsami merged 1 commit into
developmentfrom
claude/err-playermonitor-stop-missing-dir

Conversation

@chsami

@chsami chsami commented Oct 15, 2026

Copy link
Copy Markdown
Owner

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".

java.io.FileWriter.<init>:96
PlayerMonitorPlugin.saveMouseClicks:285
PlayerMonitorPlugin.shutDown:218
PluginManager.stopPlugin:469

Because of the exception, the mouse-listener unregister and playerMonitorScript.shutdown() that follow it in shutDown never ran.

Root cause

saveMouseClicks() opened a FileWriter on ~/.runelite/PlayerMonitor/click_count.log without creating the directory first. Only loadMouseClicks() creates CLICK_TOTAL_DIR, and startUp skips that call in liteMode. So when the directory does not exist, every save fails: on shutdown, in onGameStateChanged (where the exception escapes an event subscriber), and every 50 clicks in onMenuOptionClicked and resetMouseClickCounterListener.

Change

  • saveMouseClicks() now calls a new package-private helper, writeClickCount(File, int). The helper creates the parent directory if it is missing (and throws IOException if it cannot) and writes the count with try-with-resources. The old createNewFile step, which did nothing useful, is removed. All four callers go through the helper.
  • shutDown catches IOException from saveMouseClicks() and logs a warning, so listener and script cleanup always run.
  • Plugin version: 1.0.4 -> 1.0.5.

Validation

  • New 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

  • Not tested live in a client.
  • Pre-existing and unchanged: in liteMode, startUp never 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

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
@chsami
chsami merged commit f20ac8b into development Oct 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant