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;
|
package net.runelite.client.plugins.twitch;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -98,9 +99,16 @@ public class TwitchPlugin extends Plugin implements TwitchListener, ChatboxInput
|
|||||||
|
|
||||||
private synchronized void connect()
|
private synchronized void connect()
|
||||||
{
|
{
|
||||||
if (twitchConfig.username() != null
|
if (twitchIRCClient != null)
|
||||||
&& twitchConfig.oauthToken() != null
|
{
|
||||||
&& twitchConfig.channel() != 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();
|
String channel = twitchConfig.channel().toLowerCase();
|
||||||
if (!channel.startsWith("#"))
|
if (!channel.startsWith("#"))
|
||||||
@@ -110,11 +118,6 @@ public class TwitchPlugin extends Plugin implements TwitchListener, ChatboxInput
|
|||||||
|
|
||||||
log.debug("Connecting to Twitch as {}", twitchConfig.username());
|
log.debug("Connecting to Twitch as {}", twitchConfig.username());
|
||||||
|
|
||||||
if (twitchIRCClient != null)
|
|
||||||
{
|
|
||||||
twitchIRCClient.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
twitchIRCClient = new TwitchIRCClient(
|
twitchIRCClient = new TwitchIRCClient(
|
||||||
this,
|
this,
|
||||||
twitchConfig.username(),
|
twitchConfig.username(),
|
||||||
|
|||||||
Reference in New Issue
Block a user