diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/banlist/BanListPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/banlist/BanListPlugin.java index 8363960a15..92371331cc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/banlist/BanListPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/banlist/BanListPlugin.java @@ -27,12 +27,10 @@ package net.runelite.client.plugins.banlist; import com.google.inject.Provides; - import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import javax.inject.Inject; - import lombok.extern.slf4j.Slf4j; import net.runelite.api.ChatMessageType; import net.runelite.api.ClanMember; @@ -62,12 +60,12 @@ import okhttp3.Request; import okhttp3.Response; @PluginDescriptor( - name = "Ban List", - 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", - tags = {"PVM", "WDR", "RuneWatch"}, - type = PluginType.UTILITY, - enabledByDefault = false + name = "Ban List", + 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", + tags = {"PVM", "WDR", "RuneWatch"}, + type = PluginType.UTILITY, + enabledByDefault = false ) @Slf4j @@ -137,10 +135,10 @@ public class BanListPlugin extends Plugin public void onWidgetHiddenChanged(WidgetHiddenChanged widgetHiddenChanged) { if (client.getGameState() != GameState.LOGGED_IN - || client.getWidget(WidgetInfo.LOGIN_CLICK_TO_PLAY_SCREEN) != null - || client.getViewportWidget() == null - || client.getWidget(WidgetInfo.CLAN_CHAT) == null - || !config.highlightInClan()) + || client.getWidget(WidgetInfo.LOGIN_CLICK_TO_PLAY_SCREEN) != null + || client.getViewportWidget() == null + || client.getWidget(WidgetInfo.CLAN_CHAT) == null + || !config.highlightInClan()) { return; } @@ -159,10 +157,21 @@ public class BanListPlugin extends Plugin public void onClanMemberJoined(ClanMemberJoined event) { ClanMember member = event.getMember(); - ListType listType = checkBanList(Text.standardize(member.getUsername())); - if (listType != null) + ListType scamList = checkScamList(Text.standardize(member.getUsername())); + 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()) { highlightRedInCC(); @@ -184,10 +193,14 @@ public class BanListPlugin extends Plugin { Widget tradingWith = client.getWidget(335, 31); String name = tradingWith.getText().replaceAll("Trading With: ", ""); - if (checkBanList(name) != null) + if (checkScamList(name) != null) { tradingWith.setText(tradingWith.getText().replaceAll(name, "" + name + " (Scammer)" + "")); } + if (checkToxicList(name) != null) + { + tradingWith.setText(tradingWith.getText().replaceAll(name, "" + name + " (Toxic)" + "")); + } }); } } @@ -196,7 +209,7 @@ public class BanListPlugin extends Plugin /** * 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()) { @@ -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.stream().anyMatch(nameToBeChecked::equalsIgnoreCase)) @@ -233,6 +238,20 @@ public class BanListPlugin extends Plugin 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 */ @@ -242,53 +261,53 @@ public class BanListPlugin extends Plugin { case WEDORAIDSSCAM_LIST: final String wdr__scam_message = new ChatMessageBuilder() - .append(ChatColorType.HIGHLIGHT) - .append("Warning! " + playerName + " is on WeDoRaids\' scammer list!") - .build(); + .append(ChatColorType.HIGHLIGHT) + .append("Warning! " + playerName + " is on WeDoRaids\' scammer list!") + .build(); chatMessageManager.queue( - QueuedMessage.builder() - .type(ChatMessageType.CONSOLE) - .runeLiteFormattedMessage(wdr__scam_message) - .build()); + QueuedMessage.builder() + .type(ChatMessageType.CONSOLE) + .runeLiteFormattedMessage(wdr__scam_message) + .build()); break; case WEDORAIDSTOXIC_LIST: final String wdr__toxic_message = new ChatMessageBuilder() - .append(ChatColorType.HIGHLIGHT) - .append("Warning! " + playerName + " is on WeDoRaids\' toxic list!") - .build(); + .append(ChatColorType.HIGHLIGHT) + .append("Warning! " + playerName + " is on WeDoRaids\' toxic list!") + .build(); chatMessageManager.queue( - QueuedMessage.builder() - .type(ChatMessageType.CONSOLE) - .runeLiteFormattedMessage(wdr__toxic_message) - .build()); + QueuedMessage.builder() + .type(ChatMessageType.CONSOLE) + .runeLiteFormattedMessage(wdr__toxic_message) + .build()); break; case RUNEWATCH_LIST: final String rw_message = new ChatMessageBuilder() - .append(ChatColorType.HIGHLIGHT) - .append("Warning! " + playerName + " is on the Runewatch\'s scammer list!") - .build(); + .append(ChatColorType.HIGHLIGHT) + .append("Warning! " + playerName + " is on the Runewatch\'s scammer list!") + .build(); chatMessageManager.queue( - QueuedMessage.builder() - .type(ChatMessageType.CONSOLE) - .runeLiteFormattedMessage(rw_message) - .build()); + QueuedMessage.builder() + .type(ChatMessageType.CONSOLE) + .runeLiteFormattedMessage(rw_message) + .build()); break; case MANUAL_LIST: final String manual_message = new ChatMessageBuilder() - .append(ChatColorType.HIGHLIGHT) - .append("Warning! " + playerName + " is on your manual scammer list!") - .build(); + .append(ChatColorType.HIGHLIGHT) + .append("Warning! " + playerName + " is on your manual scammer list!") + .build(); chatMessageManager.queue( - QueuedMessage.builder() - .type(ChatMessageType.CONSOLE) - .runeLiteFormattedMessage(manual_message) - .build()); + QueuedMessage.builder() + .type(ChatMessageType.CONSOLE) + .runeLiteFormattedMessage(manual_message) + .build()); break; } } @@ -299,8 +318,8 @@ public class BanListPlugin extends Plugin private void fetchFromWebsites() { Request request = new Request.Builder() - .url("https://wdrdev.github.io/index") - .build(); + .url("https://wdrdev.github.io/index") + .build(); RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback() { @Override @@ -327,8 +346,8 @@ public class BanListPlugin extends Plugin Request secondRequest = new Request.Builder() - .url("https://runewatch.com/incident-index-page/") - .build(); + .url("https://runewatch.com/incident-index-page/") + .build(); RuneLiteAPI.CLIENT.newCall(secondRequest).enqueue(new Callback() { @Override @@ -356,8 +375,8 @@ public class BanListPlugin extends Plugin }); Request thirdRequest = new Request.Builder() - .url("https://wdrdev.github.io/toxic") - .build(); + .url("https://wdrdev.github.io/toxic") + .build(); RuneLiteAPI.CLIENT.newCall(thirdRequest).enqueue(new Callback() { @Override @@ -393,13 +412,18 @@ public class BanListPlugin extends Plugin Widget widget = client.getWidget(WidgetInfo.CLAN_CHAT_LIST); 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("" + widgetChild.getText() + ""); } + else if (toxicList != null) + { + widgetChild.setText("" + widgetChild.getText() + ""); + } } }); } -} \ No newline at end of file +}