Class PluginUi

java.lang.Object
privbot.ui.PluginUi

public final class PluginUi extends Object
The plugin-side wiring every sidebar needed: build the panel on the EDT, add the navigation button, and take both down again on shutDown().

 // startUp()
 ui = PluginUi.attach(clientToolbar, "Scurrius", () -> PrivBotPanel.builder("Scurrius")
         .startStop(this::start, this::stop, this::isEnabled)
         .settings(this::openStudio)
         .stat("Kills", this::getKillCount)
         .build(), ScurriusPlugin.class, "/privbot/scurrius/icon.png");
 // shutDown()
 if (ui != null) { ui.detach(); ui = null; }
 

The panel supplier runs on the EDT (inline when already there, else invokeAndWait); the icon falls back to the shared PrivBot mark when the resource is missing, so a plugin without art still gets a button.

  • Method Details

    • attach

      public static PluginUi attach(net.runelite.client.ui.ClientToolbar toolbar, String title, Supplier<PrivBotPanel> panelFactory, Class<?> resourceOwner, String iconResource)
      Build the panel on the EDT and add its navigation button.
      Parameters:
      toolbar - the injected ClientToolbar
      title - tooltip / display name
      panelFactory - builds the panel; runs on the EDT
      resourceOwner - class whose classloader resolves iconResource
      iconResource - absolute resource path of the icon, or null for the shared mark
    • attach

      public static PluginUi attach(net.runelite.client.ui.ClientToolbar toolbar, String title, PrivBotPanel panel, Class<?> resourceOwner, String iconResource)
    • panel

      public PrivBotPanel panel()
      The sidebar panel this handle attached.
    • button

      public net.runelite.client.ui.NavigationButton button()
      The navigation button added to the client toolbar.
    • detach

      public void detach()
      Remove the navigation button and stop the panel's timers; safe to call twice.
    • onEdt

      public static <T> T onEdt(Supplier<T> work)
      Run work on the EDT and return its result (inline when already on the EDT).