Class PrivBotPanel

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
net.runelite.client.ui.PluginPanel
privbot.ui.PrivBotPanel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, net.runelite.client.ui.Activatable

public class PrivBotPanel extends net.runelite.client.ui.PluginPanel
Reusable sidebar panel for PrivBot plugins.

Provides a consistent layout with:

  • Header section with plugin name and status badge
  • Action buttons (start/stop, open settings, etc.)
  • Live stats area with configurable key-value rows
  • Auto-refresh timer support

Usage:


 PrivBotPanel panel = new PrivBotPanel("Auto Slayer");
 panel.addActionButton("Start", ModernTheme.ACCENT_SUCCESS, e -> startScript());
 panel.addActionButton("Settings", ModernTheme.ACCENT_PRIMARY, e -> openSettings());
 panel.setStat("Runtime", "00:00:00");
 panel.setStat("Kills/hr", "0");
 panel.setStatusBadge("Stopped", ModernTheme.ACCENT_DANGER);
 panel.startRefreshTimer(1000, () -> updateStats());
 
  • Field Details

    • SETTINGS_LABEL

      public static final String SETTINGS_LABEL
      The one label for the settings button, so every plugin's sidebar reads the same.
      See Also:
  • Constructor Details

    • PrivBotPanel

      public PrivBotPanel(String pluginName)
      Creates a sidebar panel with the given plugin name.
      Parameters:
      pluginName - the display name shown in the header
  • Method Details

    • builder

      public static PrivBotPanel.Builder builder(String pluginName)
      A sidebar described rather than assembled: Start/Stop that polls the plugin's own state, the standard Settings button, and stats read from suppliers by the refresh timer.
      
       PrivBotPanel panel = PrivBotPanel.builder("Scurrius")
               .startStop(plugin::start, plugin::stop, plugin::isEnabled)
               .settings(plugin::openStudio)
               .stat("Kills", plugin::getKillCount)
               .runtime("Runtime", plugin::getStartTime)
               .build();
       
    • pollNow

      public void pollNow()
      Run every registered poller once (stats and running state); called by the refresh timer.
    • addActionButton

      public ModernTheme.ModernButton addActionButton(String text, Color color, ActionListener listener)
      Adds an action button to the button row.
      Parameters:
      text - button text
      color - accent color
      listener - click handler
      Returns:
      the created button
    • installStartStop

      public void installStartStop(Runnable onStart, Runnable onStop)
      Installs the standardized prominent Start/Stop control at the top of the panel.

      This is the framework-standard "one click to start" affordance — every plugin that calls this gets the same green Start / red Stop button plus an auto-synced status badge. Toggle visual state with setRunning(boolean) (call it from the plugin's refresh hook so the panel stays in sync if the plugin starts/stops by other means).

      Parameters:
      onStart - invoked when the user clicks Start
      onStop - invoked when the user clicks Stop
    • installSettingsButton

      public ModernTheme.ModernButton installSettingsButton(Runnable openStudio)
      The standard settings button (SETTINGS_LABEL), always the same label and colour.
    • setRunning

      public void setRunning(boolean running)
      Updates the Start/Stop button and status badge to reflect the running state. No-op if installStartStop(java.lang.Runnable, java.lang.Runnable) was never called.
      Parameters:
      running - whether the plugin is currently running
    • setStatus

      public void setStatus(PanelStatus status, String text)
      Show a state with its glyph (never colour alone): ● RUNNING, ▲ WARNING ...
      Parameters:
      text - an optional word replacing the default label, e.g. "BANKING"
    • getStatus

      public PanelStatus getStatus()
    • isRunning

      public boolean isRunning()
      Returns:
      whether the panel currently shows the running state.
    • setStat

      public void setStat(String key, String value)
      Sets a stat value. Creates the row if it doesn't exist.
      Parameters:
      key - stat name (e.g., "Runtime", "Kills/hr")
      value - stat value (e.g., "01:23:45", "156")
    • setStatusBadge

      public void setStatusBadge(String text, Color color)
      Updates the status badge text and color.
      Parameters:
      text - status text (e.g., "Running", "Stopped", "Error")
      color - accent color
    • setPluginTitle

      public void setPluginTitle(String title)
      Sets the plugin title text.
    • startRefreshTimer

      public void startRefreshTimer(int intervalMs, Runnable callback)
      Starts a periodic refresh timer.
      Parameters:
      intervalMs - interval in milliseconds
      callback - action to run each interval
    • stopRefreshTimer

      public void stopRefreshTimer()
      Stops the refresh timer.
    • getStatsPanel

      public JPanel getStatsPanel()
      Returns the stats panel for adding custom content.
    • getButtonRow

      public JPanel getButtonRow()
      Returns the button row for adding custom buttons.