From 25b50953759c75adb89ea193b31506c26fc28d28 Mon Sep 17 00:00:00 2001 From: Tomas Slusny Date: Wed, 20 Mar 2019 14:23:46 +0100 Subject: [PATCH] Always close twitch client in connect() method In case user cleared their crendentials this method should still at least close the client so it will not be running forever. Signed-off-by: Tomas Slusny --- .../runelite/client/plugins/twitch/TwitchPlugin.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/twitch/TwitchPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/twitch/TwitchPlugin.java index 7cd617a8cc..275eea5d54 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/twitch/TwitchPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/twitch/TwitchPlugin.java @@ -99,6 +99,13 @@ public class TwitchPlugin extends Plugin implements TwitchListener, ChatboxInput private synchronized void connect() { + if (twitchIRCClient != null) + { + log.debug("Terminating Twitch client {}", twitchIRCClient); + twitchIRCClient.close(); + twitchIRCClient = null; + } + if (!Strings.isNullOrEmpty(twitchConfig.username()) && !Strings.isNullOrEmpty(twitchConfig.oauthToken()) && !Strings.isNullOrEmpty(twitchConfig.channel())) @@ -111,11 +118,6 @@ public class TwitchPlugin extends Plugin implements TwitchListener, ChatboxInput log.debug("Connecting to Twitch as {}", twitchConfig.username()); - if (twitchIRCClient != null) - { - twitchIRCClient.close(); - } - twitchIRCClient = new TwitchIRCClient( this, twitchConfig.username(),