diff --git a/src/main/java/com/botdetector/BotDetectorConfig.java b/src/main/java/com/botdetector/BotDetectorConfig.java
index cb06b1ac..44fa0950 100644
--- a/src/main/java/com/botdetector/BotDetectorConfig.java
+++ b/src/main/java/com/botdetector/BotDetectorConfig.java
@@ -52,6 +52,8 @@ public interface BotDetectorConfig extends Config
String ANONYMOUS_UUID_KEY = "anonymousUUID";
String ACKNOWLEDGED_HARASSMENT_WARNING_KEY = "acknowledgedHarassmentWarning";
+ String HIDE_PANEL_NAVIGATION_BUTTON_KEY = "hidePanelNavigationButton";
+
int AUTO_SEND_MINIMUM_MINUTES = 5;
int AUTO_SEND_MAXIMUM_MINUTES = 360;
@@ -222,6 +224,21 @@ default PanelFontType panelFontType()
return PanelFontType.NORMAL;
}
+ @ConfigItem(
+ position = 6,
+ keyName = HIDE_PANEL_NAVIGATION_BUTTON_KEY,
+ name = "Hide Panel Navigation Button",
+ description = "Hides the panel navigation button on the Runelite sidebar when not in use.",
+ warning = "WARNING: This feature is experimental, please report any issues on our github!" +
+ "
If the panel navigation button is hidden, the only way to use the plugin side panel is to use some variation" +
+ "
of the right-click 'Predict' option or to input the ::BDOpenPanel or ::BDOpen command in chat.",
+ section = panelSection
+ )
+ default boolean hidePanelNavigationButton()
+ {
+ return false;
+ }
+
@ConfigItem(
position = 1,
keyName = ADD_PREDICT_PLAYER_OPTION_KEY,
diff --git a/src/main/java/com/botdetector/BotDetectorPlugin.java b/src/main/java/com/botdetector/BotDetectorPlugin.java
index af3726ab..4a3073ef 100644
--- a/src/main/java/com/botdetector/BotDetectorPlugin.java
+++ b/src/main/java/com/botdetector/BotDetectorPlugin.java
@@ -25,6 +25,7 @@
*/
package com.botdetector;
+import com.botdetector.events.BotDetectorPanelDeactivated;
import com.botdetector.http.BotDetectorClient;
import com.botdetector.http.UnauthorizedTokenException;
import com.botdetector.http.ValidationException;
@@ -167,6 +168,8 @@ public class BotDetectorPlugin extends Plugin
private static final String CLEAR_AUTH_TOKEN_COMMAND = COMMAND_PREFIX + "ClearToken";
private static final String TOGGLE_SHOW_DISCORD_VERIFICATION_ERRORS_COMMAND = COMMAND_PREFIX + "ToggleShowDiscordVerificationErrors";
private static final String TOGGLE_SHOW_DISCORD_VERIFICATION_ERRORS_COMMAND_ALIAS = COMMAND_PREFIX + "ToggleDVE";
+ private static final String OPEN_PANEL_COMMAND = COMMAND_PREFIX + "OpenPanel";
+ private static final String OPEN_PANEL_COMMAND_ALIAS = COMMAND_PREFIX + "Open";
/** Command to method map to be used in {@link #onCommandExecuted(CommandExecuted)}. **/
private final ImmutableMap> commandConsumerMap =
@@ -180,6 +183,8 @@ public class BotDetectorPlugin extends Plugin
.put(wrap(CLEAR_AUTH_TOKEN_COMMAND), s -> clearAuthTokenCommand())
.put(wrap(TOGGLE_SHOW_DISCORD_VERIFICATION_ERRORS_COMMAND), s -> toggleShowDiscordVerificationErrors())
.put(wrap(TOGGLE_SHOW_DISCORD_VERIFICATION_ERRORS_COMMAND_ALIAS), s -> toggleShowDiscordVerificationErrors())
+ .put(wrap(OPEN_PANEL_COMMAND), s -> openSidePanel())
+ .put(wrap(OPEN_PANEL_COMMAND_ALIAS), s -> openSidePanel())
.build();
private static final int MANUAL_FLUSH_COOLDOWN_SECONDS = 60;
@@ -350,7 +355,10 @@ protected void startUp()
.priority(90)
.build();
- clientToolbar.addNavigation(navButton);
+ if (!config.hidePanelNavigationButton())
+ {
+ clientToolbar.addNavigation(navButton);
+ }
if (config.addPredictPlayerOption() && client != null)
{
@@ -587,6 +595,15 @@ private void onBotDetectorPanelActivated(BotDetectorPanelActivated event)
}
}
+ @Subscribe
+ private void onBotDetectorPanelDeactivated(BotDetectorPanelDeactivated event)
+ {
+ if (config.hidePanelNavigationButton())
+ {
+ clientToolbar.removeNavigation(navButton);
+ }
+ }
+
@Subscribe
private void onConfigChanged(ConfigChanged event)
{
@@ -632,6 +649,16 @@ private void onConfigChanged(ConfigChanged event)
case BotDetectorConfig.ONLY_SEND_AT_LOGOUT_KEY:
updateTimeToAutoSend();
break;
+ case BotDetectorConfig.HIDE_PANEL_NAVIGATION_BUTTON_KEY:
+ if (config.hidePanelNavigationButton())
+ {
+ clientToolbar.removeNavigation(navButton);
+ }
+ else
+ {
+ clientToolbar.addNavigation(navButton);
+ }
+ break;
}
}
@@ -1088,11 +1115,8 @@ private void onWorldChanged(WorldChanged event)
*/
public void predictPlayer(String playerName)
{
- SwingUtilities.invokeLater(() ->
- {
- clientToolbar.openPanel(navButton);
- panel.predictPlayer(playerName);
- });
+ openSidePanel();
+ SwingUtilities.invokeLater(() -> panel.predictPlayer(playerName));
}
/**
@@ -1393,6 +1417,24 @@ private void toggleShowDiscordVerificationErrors()
}
}
+ /**
+ * Opens the side panel if it's not already open
+ */
+ private void openSidePanel()
+ {
+ if (panel.isActive())
+ {
+ return;
+ }
+
+ if (config.hidePanelNavigationButton())
+ {
+ clientToolbar.addNavigation(navButton);
+ }
+
+ SwingUtilities.invokeLater(() -> clientToolbar.openPanel(navButton));
+ }
+
//endregion
diff --git a/src/main/java/com/botdetector/events/BotDetectorPanelDeactivated.java b/src/main/java/com/botdetector/events/BotDetectorPanelDeactivated.java
new file mode 100644
index 00000000..6d6776d9
--- /dev/null
+++ b/src/main/java/com/botdetector/events/BotDetectorPanelDeactivated.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2021, Ferrariic, Seltzer Bro, Cyborger1
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.botdetector.events;
+
+/**s
+ * Event for when the {@link com.botdetector.ui.BotDetectorPanel} is deactivated.
+ */
+public class BotDetectorPanelDeactivated
+{
+}
diff --git a/src/main/java/com/botdetector/ui/BotDetectorPanel.java b/src/main/java/com/botdetector/ui/BotDetectorPanel.java
index 846dec80..cf681b7d 100644
--- a/src/main/java/com/botdetector/ui/BotDetectorPanel.java
+++ b/src/main/java/com/botdetector/ui/BotDetectorPanel.java
@@ -29,6 +29,7 @@
import com.botdetector.BotDetectorPlugin;
import static com.botdetector.BotDetectorPlugin.normalizeAndWrapPlayerName;
import com.botdetector.events.BotDetectorPanelActivated;
+import com.botdetector.events.BotDetectorPanelDeactivated;
import com.botdetector.http.BotDetectorClient;
import com.botdetector.model.CaseInsensitiveString;
import com.botdetector.model.FeedbackValue;
@@ -297,14 +298,15 @@ public void shutdown()
@Override
public void onActivate()
{
- eventBus.post(new BotDetectorPanelActivated());
isActive = true;
+ eventBus.post(new BotDetectorPanelActivated());
}
@Override
public void onDeactivate()
{
isActive = false;
+ eventBus.post(new BotDetectorPanelDeactivated());
}
/**