Add Seperate handler for Toxic Lists (#694)

This was causing an issue where toxic players were being labeled as scammers.
This commit is contained in:
Ganom
2019-06-21 23:32:42 -04:00
committed by Kyleeld
parent b33852f28a
commit e689fc0b7a

View File

@@ -27,12 +27,10 @@
package net.runelite.client.plugins.banlist; package net.runelite.client.plugins.banlist;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import javax.inject.Inject; import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.api.ChatMessageType; import net.runelite.api.ChatMessageType;
import net.runelite.api.ClanMember; import net.runelite.api.ClanMember;
@@ -159,10 +157,21 @@ public class BanListPlugin extends Plugin
public void onClanMemberJoined(ClanMemberJoined event) public void onClanMemberJoined(ClanMemberJoined event)
{ {
ClanMember member = event.getMember(); ClanMember member = event.getMember();
ListType listType = checkBanList(Text.standardize(member.getUsername())); ListType scamList = checkScamList(Text.standardize(member.getUsername()));
if (listType != null) ListType toxicList = checkToxicList(Text.standardize(member.getUsername()));
if (scamList != null)
{ {
sendWarning(Text.standardize(member.getUsername()), listType); sendWarning(Text.standardize(member.getUsername()), scamList);
if (config.highlightInClan())
{
highlightRedInCC();
}
}
if (toxicList != null)
{
sendWarning(Text.standardize(member.getUsername()), toxicList);
if (config.highlightInClan()) if (config.highlightInClan())
{ {
highlightRedInCC(); highlightRedInCC();
@@ -184,10 +193,14 @@ public class BanListPlugin extends Plugin
{ {
Widget tradingWith = client.getWidget(335, 31); Widget tradingWith = client.getWidget(335, 31);
String name = tradingWith.getText().replaceAll("Trading With: ", ""); String name = tradingWith.getText().replaceAll("Trading With: ", "");
if (checkBanList(name) != null) if (checkScamList(name) != null)
{ {
tradingWith.setText(tradingWith.getText().replaceAll(name, "<col=ff0000>" + name + " (Scammer)" + "</col>")); tradingWith.setText(tradingWith.getText().replaceAll(name, "<col=ff0000>" + name + " (Scammer)" + "</col>"));
} }
if (checkToxicList(name) != null)
{
tradingWith.setText(tradingWith.getText().replaceAll(name, "<col=ff6400>" + name + " (Toxic)" + "</col>"));
}
}); });
} }
} }
@@ -196,7 +209,7 @@ public class BanListPlugin extends Plugin
/** /**
* Compares player name to everything in the ban lists * Compares player name to everything in the ban lists
*/ */
private ListType checkBanList(String nameToBeChecked) private ListType checkScamList(String nameToBeChecked)
{ {
if (wdrScamArrayList.size() > 0 && config.enableWDR()) if (wdrScamArrayList.size() > 0 && config.enableWDR())
{ {
@@ -206,14 +219,6 @@ public class BanListPlugin extends Plugin
} }
} }
if (wdrToxicArrayList.size() > 0 && config.enableWDR())
{
if (wdrToxicArrayList.stream().anyMatch(nameToBeChecked::equalsIgnoreCase))
{
return ListType.WEDORAIDSTOXIC_LIST;
}
}
if (runeWatchArrayList.size() > 0 && config.enableRuneWatch()) if (runeWatchArrayList.size() > 0 && config.enableRuneWatch())
{ {
if (runeWatchArrayList.stream().anyMatch(nameToBeChecked::equalsIgnoreCase)) if (runeWatchArrayList.stream().anyMatch(nameToBeChecked::equalsIgnoreCase))
@@ -233,6 +238,20 @@ public class BanListPlugin extends Plugin
return null; return null;
} }
private ListType checkToxicList(String nameToBeChecked)
{
if (wdrToxicArrayList.size() > 0 && config.enableWDR())
{
if (wdrToxicArrayList.stream().anyMatch(nameToBeChecked::equalsIgnoreCase))
{
return ListType.WEDORAIDSTOXIC_LIST;
}
}
return null;
}
/** /**
* Sends a warning to our player, notifying them that a player is on a ban list * Sends a warning to our player, notifying them that a player is on a ban list
*/ */
@@ -393,12 +412,17 @@ public class BanListPlugin extends Plugin
Widget widget = client.getWidget(WidgetInfo.CLAN_CHAT_LIST); Widget widget = client.getWidget(WidgetInfo.CLAN_CHAT_LIST);
for (Widget widgetChild : widget.getDynamicChildren()) for (Widget widgetChild : widget.getDynamicChildren())
{ {
ListType listType = checkBanList(widgetChild.getText()); ListType scamList = checkScamList(widgetChild.getText());
ListType toxicList = checkToxicList(widgetChild.getText());
if (listType != null) if (scamList != null)
{ {
widgetChild.setText("<col=ff0000>" + widgetChild.getText() + "</col>"); widgetChild.setText("<col=ff0000>" + widgetChild.getText() + "</col>");
} }
else if (toxicList != null)
{
widgetChild.setText("<col=ff6400>" + widgetChild.getText() + "</col>");
}
} }
}); });
} }