From b526aba84e07a8bbe361317189887ad01b1ad6d5 Mon Sep 17 00:00:00 2001 From: blank_dvth Date: Sat, 13 Jan 2024 12:35:45 -0500 Subject: [PATCH] Fix FlatLaf compatability (#178) --- .../java/com/botdetector/BotDetectorPlugin.java | 14 ++++++++------ .../java/com/botdetector/ui/BotDetectorPanel.java | 7 +++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/botdetector/BotDetectorPlugin.java b/src/main/java/com/botdetector/BotDetectorPlugin.java index fc59b5fd..99fce91f 100644 --- a/src/main/java/com/botdetector/BotDetectorPlugin.java +++ b/src/main/java/com/botdetector/BotDetectorPlugin.java @@ -73,6 +73,7 @@ import javax.swing.SwingUtilities; import javax.swing.event.HyperlinkEvent; import lombok.Getter; +import lombok.Setter; import lombok.extern.slf4j.Slf4j; import net.runelite.api.ChatMessageType; import net.runelite.api.Client; @@ -229,6 +230,10 @@ public class BotDetectorPlugin extends Plugin private BotDetectorPanel panel; private NavigationButton navButton; + @Getter + @Setter + private boolean navButtonIsSelected; + @Provides BotDetectorConfig provideConfig(ConfigManager configManager) { @@ -344,6 +349,7 @@ protected void startUp() final BufferedImage icon = ImageUtil.loadImageResource(getClass(), "bot-icon.png"); + this.navButtonIsSelected = false; navButton = NavigationButton.builder() .panel(panel) .tooltip("Bot Detector") @@ -517,7 +523,7 @@ public synchronized void refreshPlayerStats(boolean forceRefresh) { Instant now = Instant.now(); // Only perform non-manual refreshes when a player is not anon, logged in and the panel is open - if (config.enableAnonymousUploading() || loggedPlayerName == null || !navButton.isSelected() + if (config.enableAnonymousUploading() || loggedPlayerName == null || !navButtonIsSelected || now.isBefore(lastStatsRefresh.plusSeconds(AUTO_REFRESH_STATS_COOLDOWN_SECONDS)) || now.isBefore(lastFlush.plusSeconds(AUTO_REFRESH_LAST_FLUSH_GRACE_PERIOD_SECONDS))) { @@ -1083,11 +1089,7 @@ public void predictPlayer(String playerName) { SwingUtilities.invokeLater(() -> { - if (!navButton.isSelected()) - { - navButton.getOnSelect().run(); - } - + clientToolbar.openPanel(navButton); panel.predictPlayer(playerName); }); } diff --git a/src/main/java/com/botdetector/ui/BotDetectorPanel.java b/src/main/java/com/botdetector/ui/BotDetectorPanel.java index f88765d9..2ae6d656 100644 --- a/src/main/java/com/botdetector/ui/BotDetectorPanel.java +++ b/src/main/java/com/botdetector/ui/BotDetectorPanel.java @@ -291,6 +291,13 @@ public void shutdown() public void onActivate() { eventBus.post(new BotDetectorPanelActivated()); + plugin.setNavButtonIsSelected(true); + } + + @Override + public void onDeactivate() + { + plugin.setNavButtonIsSelected(false); } /**