Class Workflows

java.lang.Object
privbot.hooks.Workflows

public final class Workflows extends Object
Workflow execution hook — the simplest way to run workflows from plugin code.

Added to PrivContext as ctx.workflow, following the same pattern as ctx.dialogue, ctx.inventory, etc.

Usage:


 // Blocking — waits for workflow to finish
 boolean ok = ctx.workflow.run("Travel to Bank");

 // Async — returns immediately, runs on background thread
 ctx.workflow.runAsync("Travel to Bank", () -> bankTravelDone = true);

 // With cancellation
 ctx.workflow.run("Travel to Bank", () -> pluginStopped);

 // Check if a workflow is currently running
 if (ctx.workflow.isRunning()) { ... }

 // Cancel the running workflow
 ctx.workflow.cancel();
 
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Requests cancellation of the currently running async workflow.
    boolean
    exists(String workflowName)
    Returns true if a workflow with the given name exists.
    static boolean
    Returns true if any Workflows instance currently has an async workflow running.
    boolean
    Returns true if an async workflow is currently running.
    boolean
    Returns the result of the last completed workflow (true = success).
    boolean
    run(String workflowName)
    Runs a workflow by display name (blocking).
    boolean
    run(String workflowName, BooleanSupplier isCancelled)
    Runs a workflow by display name (blocking) with cancellation support.
    boolean
    run(String workflowName, BooleanSupplier isCancelled, Consumer<String> onStatus)
    Runs a workflow by display name (blocking) with cancellation and status logging.
    boolean
    runAsync(String workflowName)
    Runs a workflow by name asynchronously on a background thread.
    boolean
    runAsync(String workflowName, Runnable onComplete)
    Runs a workflow asynchronously with a completion callback.
    boolean
    runAsync(String workflowName, Runnable onComplete, Consumer<String> onStatus)
    Runs a workflow asynchronously with completion callback and status logging.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • isAnyWorkflowRunning

      public static boolean isAnyWorkflowRunning()
      Returns true if any Workflows instance currently has an async workflow running. Other systems (e.g. AntiBanHandler) should check this before auto-dismissing dialogues.
    • run

      public boolean run(String workflowName)
      Runs a workflow by display name (blocking). Returns true if the workflow completed successfully, false if not found, invalid, or failed.
    • run

      public boolean run(String workflowName, BooleanSupplier isCancelled)
      Runs a workflow by display name (blocking) with cancellation support.
    • run

      public boolean run(String workflowName, BooleanSupplier isCancelled, Consumer<String> onStatus)
      Runs a workflow by display name (blocking) with cancellation and status logging.
    • runAsync

      public boolean runAsync(String workflowName)
      Runs a workflow by name asynchronously on a background thread. Only one async workflow can run at a time — returns false immediately if one is already running.
    • runAsync

      public boolean runAsync(String workflowName, Runnable onComplete)
      Runs a workflow asynchronously with a completion callback.
    • runAsync

      public boolean runAsync(String workflowName, Runnable onComplete, Consumer<String> onStatus)
      Runs a workflow asynchronously with completion callback and status logging. Returns false if a workflow is already running or the workflow wasn't found.
    • isRunning

      public boolean isRunning()
      Returns true if an async workflow is currently running.
    • lastResult

      public boolean lastResult()
      Returns the result of the last completed workflow (true = success).
    • cancel

      public void cancel()
      Requests cancellation of the currently running async workflow.
    • exists

      public boolean exists(String workflowName)
      Returns true if a workflow with the given name exists.