Skip to content

Commit

Permalink
Fix FlatLaf compatability (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
blankdvth committed Jan 13, 2024
1 parent 0e2a828 commit b526aba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/main/java/com/botdetector/BotDetectorPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)))
{
Expand Down Expand Up @@ -1083,11 +1089,7 @@ public void predictPlayer(String playerName)
{
SwingUtilities.invokeLater(() ->
{
if (!navButton.isSelected())
{
navButton.getOnSelect().run();
}

clientToolbar.openPanel(navButton);
panel.predictPlayer(playerName);
});
}
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/botdetector/ui/BotDetectorPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,13 @@ public void shutdown()
public void onActivate()
{
eventBus.post(new BotDetectorPanelActivated());
plugin.setNavButtonIsSelected(true);
}

@Override
public void onDeactivate()
{
plugin.setNavButtonIsSelected(false);
}

/**
Expand Down

0 comments on commit b526aba

Please sign in to comment.