Skip to content

Add config to set panel nav button priority #175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Identifies bots by sending nearby players' information to a third-party machine
| Panel Settings | Show Feedback Textbox | Adds a textbox to the prediction feedback panel, so you can explain your choice in up to 250 characters. Make sure you type your feedback *before* you make your choice! |
| Panel Settings | Panel Default Stats Tab | Sets panel default stats tab when the Plugin turns on. |
| Panel Settings | Panel Font Size | Sets the font size of most of the Plugin's Panel elements. |
| Panel Settings | Panel Button Priority | Sets the priority level of the panel navigation button, changing its placement in the sidebar. Higher means further down the list. |
| 'Predict' Settings | Right-click 'Predict' Players | Allows you to right-click predict players, instead of having to type their name in the Plugin's panel manually. |
| 'Predict' Settings | 'Predict' on Right-click 'Report' | If you right-click Report someone via Jagex's official in-game report system, the player will be automatically predicted in the Plugin's Panel. |
| 'Predict' Settings | 'Predict' Copy Name to Clipboard | Copies the predicted player's name to your clipboard when right-click predicting. |
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/botdetector/BotDetectorConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public interface BotDetectorConfig extends Config
String SHOW_FEEDBACK_TEXTBOX = "showFeedbackTextbox";
String SHOW_DISCORD_VERIFICATION_ERRORS = "showDiscordVerificationErrors";
String ANONYMOUS_UUID_KEY = "anonymousUUID";
String PANEL_NAVIGATION_BUTTON_PRIORITY_KEY = "panelNavigationButtonPriority";

int AUTO_SEND_MINIMUM_MINUTES = 5;
int AUTO_SEND_MAXIMUM_MINUTES = 360;
Expand Down Expand Up @@ -195,6 +196,20 @@ default PanelFontType panelFontType()
return PanelFontType.NORMAL;
}

@ConfigItem(
position = 6,
keyName = PANEL_NAVIGATION_BUTTON_PRIORITY_KEY,
name = "Panel Button Priority",
description = "Sets the priority level of the panel navigation button, changing its placement in the sidebar." +
"<br>A higher number means the button will appear further down the list.",
section = panelSection
)
@Range(max = 10000)
default int panelNavigationButtonPriority()
{
return 90;
}

@ConfigItem(
position = 1,
keyName = ADD_PREDICT_OPTION_KEY,
Expand Down
25 changes: 16 additions & 9 deletions src/main/java/com/botdetector/BotDetectorPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.regex.Pattern;
import javax.swing.JEditorPane;
import javax.swing.JOptionPane;
Expand Down Expand Up @@ -300,6 +301,15 @@ BotDetectorConfig provideConfig(ConfigManager configManager)
@Getter
private final Map<CaseInsensitiveString, Boolean> flaggedPlayers = new ConcurrentHashMap<>();

private final BufferedImage navButtonIcon = ImageUtil.loadImageResource(getClass(), "bot-icon.png");
private final Supplier<NavigationButton> navButtonSupplier = () ->
NavigationButton.builder()
.panel(panel)
.tooltip("Bot Detector")
.icon(navButtonIcon)
.priority(config.panelNavigationButtonPriority())
.build();

@Override
protected void startUp()
{
Expand Down Expand Up @@ -342,15 +352,7 @@ protected void startUp()

processCurrentWorld();

final BufferedImage icon = ImageUtil.loadImageResource(getClass(), "bot-icon.png");

navButton = NavigationButton.builder()
.panel(panel)
.tooltip("Bot Detector")
.icon(icon)
.priority(90)
.build();

navButton = navButtonSupplier.get();
clientToolbar.addNavigation(navButton);

if (config.addPredictOption() && client != null)
Expand Down Expand Up @@ -627,6 +629,11 @@ private void onConfigChanged(ConfigChanged event)
case BotDetectorConfig.ONLY_SEND_AT_LOGOUT_KEY:
updateTimeToAutoSend();
break;
case BotDetectorConfig.PANEL_NAVIGATION_BUTTON_PRIORITY_KEY:
clientToolbar.removeNavigation(navButton);
navButton = navButtonSupplier.get();
clientToolbar.addNavigation(navButton);
break;
}
}

Expand Down