From 6c8bdaac027ec54f3ef377cec8da9441f2d0794a Mon Sep 17 00:00:00 2001 From: iProdigy Date: Sun, 25 Aug 2024 01:44:39 -0700 Subject: [PATCH] fix: flush writer on client shutdown --- src/main/java/actionlogger/ActionLoggerPlugin.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/actionlogger/ActionLoggerPlugin.java b/src/main/java/actionlogger/ActionLoggerPlugin.java index 3cbb1e7..32a6bdc 100644 --- a/src/main/java/actionlogger/ActionLoggerPlugin.java +++ b/src/main/java/actionlogger/ActionLoggerPlugin.java @@ -7,6 +7,8 @@ import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import net.runelite.client.eventbus.EventBus; +import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.events.ClientShutdown; import net.runelite.client.input.KeyManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; @@ -56,4 +58,13 @@ protected void shutDown() throws IOException { log.debug("Shut down Action Logger"); } + + @Subscribe + protected void onClientShutdown(ClientShutdown event) { + try { + writer.close(); + } catch (Exception e) { + log.warn("Failed to close writer", e); + } + } }