banlist: add tob functionality, config options (#945)
* banlist add tob functionality, config options * Checkstyle Fixes * Widget Info * Various White spaces removed.
This commit is contained in:
committed by
Lucwousin
parent
b861ce4121
commit
aaaa7845ef
@@ -9,11 +9,10 @@ import net.runelite.client.config.ConfigItem;
|
||||
public interface BanListConfig extends Config
|
||||
{
|
||||
@ConfigItem(
|
||||
keyName = "bannedPlayers",
|
||||
name = "Manual Scammer List",
|
||||
description = "Players you add to this list will be shown when you join a clan.",
|
||||
position = 0
|
||||
|
||||
keyName = "bannedPlayers",
|
||||
name = "Manual Scammer List",
|
||||
description = "Manually add players seperated by commas that you wish to be warned about while in a clan/cox/tob party",
|
||||
position = 0
|
||||
)
|
||||
default String getBannedPlayers()
|
||||
{
|
||||
@@ -21,28 +20,39 @@ public interface BanListConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "bannedPlayers",
|
||||
name = "",
|
||||
description = ""
|
||||
keyName = "bannedPlayers",
|
||||
name = "",
|
||||
description = ""
|
||||
)
|
||||
void setBannedPlayers(String key);
|
||||
|
||||
@ConfigItem(
|
||||
position = 1,
|
||||
keyName = "enableWDR",
|
||||
name = "Enable WDR Scammer List",
|
||||
description = "Incorporate WDR Scammer list"
|
||||
position = 1,
|
||||
keyName = "enableWDRScam",
|
||||
name = "Enable WDR Scammer List",
|
||||
description = "Incorporate WDR Scammer list"
|
||||
)
|
||||
default boolean enableWDR()
|
||||
default boolean enableWDRScam()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 2,
|
||||
keyName = "enableRuneWatch",
|
||||
name = "Enable RuneWatch Scammer List",
|
||||
description = "Incorporate RuneWatch Scammer list"
|
||||
position = 2,
|
||||
keyName = "enableWDRToxic",
|
||||
name = "Enable WDR Toxic List",
|
||||
description = "Incorporate WDR Toxic list"
|
||||
)
|
||||
default boolean enableWDRToxic()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 3,
|
||||
keyName = "enableRuneWatch",
|
||||
name = "Enable RuneWatch List",
|
||||
description = "Incorporate RuneWatch potential scammer list"
|
||||
)
|
||||
default boolean enableRuneWatch()
|
||||
{
|
||||
@@ -50,10 +60,10 @@ public interface BanListConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 3,
|
||||
keyName = "highlightInClan",
|
||||
name = "Highlight red in Clan Chat",
|
||||
description = "Highlights Scammer\'s name in your current clan chat."
|
||||
position = 4,
|
||||
keyName = "highlightInClan",
|
||||
name = "Highlight red in Clan Chat",
|
||||
description = "Highlights Scammer\'s name in your current clan chat."
|
||||
)
|
||||
default boolean highlightInClan()
|
||||
{
|
||||
@@ -61,14 +71,13 @@ public interface BanListConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 4,
|
||||
keyName = "highlightInTrade",
|
||||
name = "Highlight red in trade screen",
|
||||
description = "Highlights Scammer\'s name in your trade window"
|
||||
position = 5,
|
||||
keyName = "highlightInTrade",
|
||||
name = "Highlight red in trade screen",
|
||||
description = "Highlights Scammer\'s name in your trade window"
|
||||
)
|
||||
default boolean highlightInTrade()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -41,8 +41,10 @@ import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.ClanMember;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.Varbits;
|
||||
import net.runelite.api.events.ClanMemberJoined;
|
||||
import net.runelite.api.events.ConfigChanged;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.events.WidgetHiddenChanged;
|
||||
import net.runelite.api.events.WidgetLoaded;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
@@ -77,22 +79,24 @@ import okhttp3.Response;
|
||||
@Slf4j
|
||||
public class BanListPlugin extends Plugin
|
||||
{
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private ClientThread clientThread;
|
||||
|
||||
@Inject
|
||||
private BanListConfig config;
|
||||
|
||||
@Inject
|
||||
private ChatMessageManager chatMessageManager;
|
||||
|
||||
private final Set<String> wdrScamSet = new HashSet<>();
|
||||
private final Set<String> wdrToxicSet = new HashSet<>();
|
||||
private final Set<String> runeWatchSet = new HashSet<>();
|
||||
private final Set<String> manualBans = new HashSet<>();
|
||||
@Inject
|
||||
private Client client;
|
||||
@Inject
|
||||
private ClientThread clientThread;
|
||||
@Inject
|
||||
private BanListConfig config;
|
||||
@Inject
|
||||
private ChatMessageManager chatMessageManager;
|
||||
private String tobNames = "";
|
||||
private boolean enableWDRScam;
|
||||
private boolean enableWDRToxic;
|
||||
private boolean enableRuneWatch;
|
||||
private boolean highlightInClan;
|
||||
private boolean highlightInTrade;
|
||||
|
||||
@Provides
|
||||
BanListConfig getConfig(ConfigManager configManager)
|
||||
@@ -100,12 +104,6 @@ public class BanListPlugin extends Plugin
|
||||
return configManager.getConfig(BanListConfig.class);
|
||||
}
|
||||
|
||||
// save config values
|
||||
private boolean enableWDR;
|
||||
private boolean enableRuneWatch;
|
||||
private boolean highlightInClan;
|
||||
private boolean highlightInTrade;
|
||||
|
||||
@Override
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
@@ -151,7 +149,8 @@ public class BanListPlugin extends Plugin
|
||||
|
||||
private void updateConfig()
|
||||
{
|
||||
this.enableWDR = config.enableWDR();
|
||||
this.enableWDRScam = config.enableWDRScam();
|
||||
this.enableWDRToxic = config.enableWDRToxic();
|
||||
this.enableRuneWatch = config.enableRuneWatch();
|
||||
this.highlightInClan = config.highlightInClan();
|
||||
this.highlightInTrade = config.highlightInTrade();
|
||||
@@ -234,12 +233,63 @@ public class BanListPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onGameTick(GameTick event)
|
||||
{
|
||||
|
||||
if (client.getWidget(WidgetInfo.THEATRE_OF_BLOOD_RAIDING_PARTY) == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Widget raidingParty = client.getWidget(WidgetInfo.THEATRE_OF_BLOOD_RAIDING_PARTY);
|
||||
String allNames = raidingParty.getText();
|
||||
|
||||
if (allNames.equalsIgnoreCase(tobNames))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
tobNames = allNames;
|
||||
|
||||
String[] split = allNames.split("<br>");
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
String name = split[i];
|
||||
if (!name.equalsIgnoreCase("-"))
|
||||
{
|
||||
ListType scamList = checkScamList(Text.standardize(name));
|
||||
|
||||
if (scamList != null)
|
||||
{
|
||||
sendWarning(name, scamList);
|
||||
}
|
||||
|
||||
ListType toxicList = checkToxicList(Text.standardize(name));
|
||||
|
||||
if (toxicList != null)
|
||||
{
|
||||
sendWarning(name, toxicList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
boolean inTobParty()
|
||||
{
|
||||
return client.getVar(Varbits.THEATRE_OF_BLOOD) == 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compares player name to everything in the ban lists
|
||||
*/
|
||||
private ListType checkScamList(String nameToBeChecked)
|
||||
{
|
||||
if (wdrScamSet.size() > 0 && this.enableWDR && wdrScamSet.contains(nameToBeChecked))
|
||||
if (wdrScamSet.size() > 0 && this.enableWDRScam && wdrScamSet.contains(nameToBeChecked))
|
||||
{
|
||||
return ListType.WEDORAIDSSCAM_LIST;
|
||||
}
|
||||
@@ -260,7 +310,7 @@ public class BanListPlugin extends Plugin
|
||||
private ListType checkToxicList(String nameToBeChecked)
|
||||
{
|
||||
|
||||
if (wdrToxicSet.size() > 0 && this.enableWDR && wdrToxicSet.contains(nameToBeChecked))
|
||||
if (wdrToxicSet.size() > 0 && this.enableWDRToxic && wdrToxicSet.contains(nameToBeChecked))
|
||||
{
|
||||
return ListType.WEDORAIDSTOXIC_LIST;
|
||||
}
|
||||
@@ -304,7 +354,7 @@ public class BanListPlugin extends Plugin
|
||||
case RUNEWATCH_LIST:
|
||||
final String rw_message = new ChatMessageBuilder()
|
||||
.append(ChatColorType.HIGHLIGHT)
|
||||
.append("Warning! " + playerName + " is on the Runewatch\'s scammer list!")
|
||||
.append("Warning! " + playerName + " is on the Runewatch\'s potential scammer list!")
|
||||
.build();
|
||||
|
||||
chatMessageManager.queue(
|
||||
|
||||
Reference in New Issue
Block a user