Merge pull request #8271 from deathbeam/fix-twitch
Properly check for empty strings in Twitch plugin and always close twitch client on connect
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.twitch;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.inject.Provides;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Map;
|
||||
@@ -98,9 +99,16 @@ public class TwitchPlugin extends Plugin implements TwitchListener, ChatboxInput
|
||||
|
||||
private synchronized void connect()
|
||||
{
|
||||
if (twitchConfig.username() != null
|
||||
&& twitchConfig.oauthToken() != null
|
||||
&& twitchConfig.channel() != null)
|
||||
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()))
|
||||
{
|
||||
String channel = twitchConfig.channel().toLowerCase();
|
||||
if (!channel.startsWith("#"))
|
||||
@@ -110,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(),
|
||||
|
||||
Reference in New Issue
Block a user