Skip to content

Commit 8b1ed37

Browse files
authored
Setting for coloring the Report right-click option (#167)
1 parent 80f2d51 commit 8b1ed37

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Identifies bots by sending nearby players' information to a third-party machine
4545
| 'Predict' Settings | 'Predict' Copy Name to Clipboard | Copies the predicted player's name to your clipboard when right-click predicting. |
4646
| 'Predict' Settings | 'Predict' Default Color | If set, highlights unflagged/unfeedbacked players' 'Predict' option in the given color so that you can easily spot it on the in-game menu. |
4747
| 'Predict' Settings | 'Predict' Voted/Flagged Color | If set, highlights flagged/feedbacked players' 'Predict' option in the given color so that you can easily spot it on the in-game menu. |
48+
| 'Predict' Settings | Apply Colors to 'Report' | If set, applies the above 'Predict' color options to the in-game 'Report' option as well.<br>⚠️ May cause issues with other plugins that rely on the 'Report' option being unchanged.⚠️ |
4849
| Other Settings | Enable Chat Status Messages | Inserts chat messages in your chatbox to inform you about your uploads being sent. |
4950
| Other Settings | '!bdstats' Chat Command Detail Level | Enable processing the '!bdstats' command when it appears in the chatbox, which will fetch the message author's plugin stats and display them. Disable to reduce spam. |
5051

src/main/java/com/botdetector/BotDetectorConfig.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,19 @@ default boolean predictOptionCopyName()
249249
)
250250
Color predictOptionFlaggedColor();
251251

252+
@ConfigItem(
253+
position = 6,
254+
keyName = "applyPredictColorsOnReportOption",
255+
name = "Apply Colors to 'Report'",
256+
description = "Applies the above 'Predict' color options to the in-game 'Report' option as well.",
257+
section = predictSection,
258+
warning = "Enabling this setting may cause issues with other plugins that rely on the 'Report' option being unchanged."
259+
)
260+
default boolean applyPredictColorsOnReportOption()
261+
{
262+
return false;
263+
}
264+
252265
@ConfigItem(
253266
position = 1,
254267
keyName = "enableChatNotifications",

src/main/java/com/botdetector/BotDetectorPlugin.java

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,7 @@ private void onMenuOpened(MenuOpened event)
996996
return;
997997
}
998998

999+
boolean changeReportOption = config.applyPredictColorsOnReportOption();
9991000
// Do this once when the menu opens
10001001
// Avoids having to loop the menu entries on every 'added' event
10011002
MenuEntry[] menuEntries = event.getMenuEntries();
@@ -1016,16 +1017,28 @@ private void onMenuOpened(MenuOpened event)
10161017
entry.setOption(getPredictOption(player.getName()));
10171018
}
10181019
}
1020+
1021+
// Check for Report option
1022+
if (changeReportOption && entry.getOption().equals(REPORT_OPTION)
1023+
&& (PLAYER_MENU_ACTIONS.contains(entry.getType()) || entry.getType() == MenuAction.CC_OP_LOW_PRIORITY))
1024+
{
1025+
Player player = client.getCachedPlayers()[entry.getIdentifier()];
1026+
if (player != null)
1027+
{
1028+
entry.setOption(getReportOption(player.getName()));
1029+
}
1030+
}
10191031
}
10201032
}
10211033

10221034
@Subscribe
10231035
private void onMenuOptionClicked(MenuOptionClicked event)
10241036
{
1037+
String optionText = Text.removeTags(event.getMenuOption());
10251038
if (((event.getMenuAction() == MenuAction.RUNELITE || event.getMenuAction() == MenuAction.RUNELITE_PLAYER)
1026-
&& event.getMenuOption().endsWith(PREDICT_OPTION))
1039+
&& optionText.equals(PREDICT_OPTION))
10271040
|| (config.predictOnReport() && (PLAYER_MENU_ACTIONS.contains(event.getMenuAction()) || event.getMenuAction() == MenuAction.CC_OP_LOW_PRIORITY)
1028-
&& event.getMenuOption().equals(REPORT_OPTION)))
1041+
&& optionText.equals(REPORT_OPTION)))
10291042
{
10301043
String name;
10311044
if (event.getMenuAction() == MenuAction.RUNELITE_PLAYER
@@ -1167,12 +1180,32 @@ public String getUploaderName(boolean useAnonymousUUIDFormat)
11671180
* @return A variant of {@link #PREDICT_OPTION} prepended or not with some color.
11681181
*/
11691182
private String getPredictOption(String playerName)
1183+
{
1184+
return getMenuOption(playerName, PREDICT_OPTION);
1185+
}
1186+
1187+
/**
1188+
* Gets the correct variant of {@link #REPORT_OPTION} to show for the given {@code player}.
1189+
* @param playerName The player to get the menu option string for.
1190+
* @return A variant of {@link #REPORT_OPTION} prepended or not with some color.
1191+
*/
1192+
private String getReportOption(String playerName)
1193+
{
1194+
return getMenuOption(playerName, REPORT_OPTION);
1195+
}
1196+
1197+
/**
1198+
* Gets the correct variant of the given option string to show for the given {@code player}.
1199+
* @param playerName The player to get the menu option string for.
1200+
* @return A variant of the option string prepended or not with some color.
1201+
*/
1202+
private String getMenuOption(String playerName, String option)
11701203
{
11711204
CaseInsensitiveString name = normalizeAndWrapPlayerName(playerName);
11721205
Color prepend = (feedbackedPlayers.containsKey(name) || flaggedPlayers.containsKey(name)) ?
11731206
config.predictOptionFlaggedColor() : config.predictOptionDefaultColor();
11741207

1175-
return prepend != null ? ColorUtil.prependColorTag(PREDICT_OPTION, prepend) : PREDICT_OPTION;
1208+
return prepend != null ? ColorUtil.prependColorTag(option, prepend) : option;
11761209
}
11771210

11781211
/**

0 commit comments

Comments
 (0)