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:
@@ -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;
|
||||||
@@ -62,12 +60,12 @@ import okhttp3.Request;
|
|||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "Ban List",
|
name = "Ban List",
|
||||||
description = "Displays warning in chat when you join a" +
|
description = "Displays warning in chat when you join a" +
|
||||||
"clan chat/new member join your clan chat and he is in a WDR/RuneWatch/Manual List",
|
"clan chat/new member join your clan chat and he is in a WDR/RuneWatch/Manual List",
|
||||||
tags = {"PVM", "WDR", "RuneWatch"},
|
tags = {"PVM", "WDR", "RuneWatch"},
|
||||||
type = PluginType.UTILITY,
|
type = PluginType.UTILITY,
|
||||||
enabledByDefault = false
|
enabledByDefault = false
|
||||||
)
|
)
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -137,10 +135,10 @@ public class BanListPlugin extends Plugin
|
|||||||
public void onWidgetHiddenChanged(WidgetHiddenChanged widgetHiddenChanged)
|
public void onWidgetHiddenChanged(WidgetHiddenChanged widgetHiddenChanged)
|
||||||
{
|
{
|
||||||
if (client.getGameState() != GameState.LOGGED_IN
|
if (client.getGameState() != GameState.LOGGED_IN
|
||||||
|| client.getWidget(WidgetInfo.LOGIN_CLICK_TO_PLAY_SCREEN) != null
|
|| client.getWidget(WidgetInfo.LOGIN_CLICK_TO_PLAY_SCREEN) != null
|
||||||
|| client.getViewportWidget() == null
|
|| client.getViewportWidget() == null
|
||||||
|| client.getWidget(WidgetInfo.CLAN_CHAT) == null
|
|| client.getWidget(WidgetInfo.CLAN_CHAT) == null
|
||||||
|| !config.highlightInClan())
|
|| !config.highlightInClan())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -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
|
||||||
*/
|
*/
|
||||||
@@ -242,53 +261,53 @@ public class BanListPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
case WEDORAIDSSCAM_LIST:
|
case WEDORAIDSSCAM_LIST:
|
||||||
final String wdr__scam_message = new ChatMessageBuilder()
|
final String wdr__scam_message = new ChatMessageBuilder()
|
||||||
.append(ChatColorType.HIGHLIGHT)
|
.append(ChatColorType.HIGHLIGHT)
|
||||||
.append("Warning! " + playerName + " is on WeDoRaids\' scammer list!")
|
.append("Warning! " + playerName + " is on WeDoRaids\' scammer list!")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
chatMessageManager.queue(
|
chatMessageManager.queue(
|
||||||
QueuedMessage.builder()
|
QueuedMessage.builder()
|
||||||
.type(ChatMessageType.CONSOLE)
|
.type(ChatMessageType.CONSOLE)
|
||||||
.runeLiteFormattedMessage(wdr__scam_message)
|
.runeLiteFormattedMessage(wdr__scam_message)
|
||||||
.build());
|
.build());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WEDORAIDSTOXIC_LIST:
|
case WEDORAIDSTOXIC_LIST:
|
||||||
final String wdr__toxic_message = new ChatMessageBuilder()
|
final String wdr__toxic_message = new ChatMessageBuilder()
|
||||||
.append(ChatColorType.HIGHLIGHT)
|
.append(ChatColorType.HIGHLIGHT)
|
||||||
.append("Warning! " + playerName + " is on WeDoRaids\' toxic list!")
|
.append("Warning! " + playerName + " is on WeDoRaids\' toxic list!")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
chatMessageManager.queue(
|
chatMessageManager.queue(
|
||||||
QueuedMessage.builder()
|
QueuedMessage.builder()
|
||||||
.type(ChatMessageType.CONSOLE)
|
.type(ChatMessageType.CONSOLE)
|
||||||
.runeLiteFormattedMessage(wdr__toxic_message)
|
.runeLiteFormattedMessage(wdr__toxic_message)
|
||||||
.build());
|
.build());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RUNEWATCH_LIST:
|
case RUNEWATCH_LIST:
|
||||||
final String rw_message = new ChatMessageBuilder()
|
final String rw_message = new ChatMessageBuilder()
|
||||||
.append(ChatColorType.HIGHLIGHT)
|
.append(ChatColorType.HIGHLIGHT)
|
||||||
.append("Warning! " + playerName + " is on the Runewatch\'s scammer list!")
|
.append("Warning! " + playerName + " is on the Runewatch\'s scammer list!")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
chatMessageManager.queue(
|
chatMessageManager.queue(
|
||||||
QueuedMessage.builder()
|
QueuedMessage.builder()
|
||||||
.type(ChatMessageType.CONSOLE)
|
.type(ChatMessageType.CONSOLE)
|
||||||
.runeLiteFormattedMessage(rw_message)
|
.runeLiteFormattedMessage(rw_message)
|
||||||
.build());
|
.build());
|
||||||
break;
|
break;
|
||||||
case MANUAL_LIST:
|
case MANUAL_LIST:
|
||||||
final String manual_message = new ChatMessageBuilder()
|
final String manual_message = new ChatMessageBuilder()
|
||||||
.append(ChatColorType.HIGHLIGHT)
|
.append(ChatColorType.HIGHLIGHT)
|
||||||
.append("Warning! " + playerName + " is on your manual scammer list!")
|
.append("Warning! " + playerName + " is on your manual scammer list!")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
chatMessageManager.queue(
|
chatMessageManager.queue(
|
||||||
QueuedMessage.builder()
|
QueuedMessage.builder()
|
||||||
.type(ChatMessageType.CONSOLE)
|
.type(ChatMessageType.CONSOLE)
|
||||||
.runeLiteFormattedMessage(manual_message)
|
.runeLiteFormattedMessage(manual_message)
|
||||||
.build());
|
.build());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -299,8 +318,8 @@ public class BanListPlugin extends Plugin
|
|||||||
private void fetchFromWebsites()
|
private void fetchFromWebsites()
|
||||||
{
|
{
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url("https://wdrdev.github.io/index")
|
.url("https://wdrdev.github.io/index")
|
||||||
.build();
|
.build();
|
||||||
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
|
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@@ -327,8 +346,8 @@ public class BanListPlugin extends Plugin
|
|||||||
|
|
||||||
|
|
||||||
Request secondRequest = new Request.Builder()
|
Request secondRequest = new Request.Builder()
|
||||||
.url("https://runewatch.com/incident-index-page/")
|
.url("https://runewatch.com/incident-index-page/")
|
||||||
.build();
|
.build();
|
||||||
RuneLiteAPI.CLIENT.newCall(secondRequest).enqueue(new Callback()
|
RuneLiteAPI.CLIENT.newCall(secondRequest).enqueue(new Callback()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@@ -356,8 +375,8 @@ public class BanListPlugin extends Plugin
|
|||||||
});
|
});
|
||||||
|
|
||||||
Request thirdRequest = new Request.Builder()
|
Request thirdRequest = new Request.Builder()
|
||||||
.url("https://wdrdev.github.io/toxic")
|
.url("https://wdrdev.github.io/toxic")
|
||||||
.build();
|
.build();
|
||||||
RuneLiteAPI.CLIENT.newCall(thirdRequest).enqueue(new Callback()
|
RuneLiteAPI.CLIENT.newCall(thirdRequest).enqueue(new Callback()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@@ -393,13 +412,18 @@ 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>");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user