Class Workflows
java.lang.Object
privbot.hooks.Workflows
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 TypeMethodDescriptionvoidcancel()Requests cancellation of the currently running async workflow.booleanReturns true if a workflow with the given name exists.static booleanReturns true if any Workflows instance currently has an async workflow running.booleanReturns true if an async workflow is currently running.booleanReturns the result of the last completed workflow (true = success).booleanRuns a workflow by display name (blocking).booleanrun(String workflowName, BooleanSupplier isCancelled) Runs a workflow by display name (blocking) with cancellation support.booleanrun(String workflowName, BooleanSupplier isCancelled, Consumer<String> onStatus) Runs a workflow by display name (blocking) with cancellation and status logging.booleanRuns a workflow by name asynchronously on a background thread.booleanRuns a workflow asynchronously with a completion callback.booleanRuns a workflow asynchronously with completion callback and status logging.
-
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
Runs a workflow by display name (blocking). Returns true if the workflow completed successfully, false if not found, invalid, or failed. -
run
Runs a workflow by display name (blocking) with cancellation support. -
run
Runs a workflow by display name (blocking) with cancellation and status logging. -
runAsync
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
-
runAsync
-
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
Returns true if a workflow with the given name exists.
-