Custom
custom/code
Custom Code
Executes user-written Groovy code. Provides up to 4 typed inputs (in0–in3) and 4 outputs (out0–out3), plus bindings for the Bukkit server, logger, plugin, and execution context.
Note: The script has access to the full Apache Groovy runtime and can call any Bukkit/Paper API. When async is enabled, the graph continues immediately without waiting for the script to finish and outputs are not emitted.
Inputs
| Name | Type | Optional | Description |
|---|---|---|---|
exec |
exec | Incoming execution. | |
in0 |
any | ✓ | Input 0 — accessible as in0 in the script. |
in1 |
any | ✓ | Input 1 — accessible as in1 in the script. |
in2 |
any | ✓ | Input 2 — accessible as in2 in the script. |
in3 |
any | ✓ | Input 3 — accessible as in3 in the script. |
Outputs
| Name | Type | Description |
|---|---|---|
exec |
exec | Continues after execution. |
out0 |
any | Output 0 — set as out0 in the script. |
out1 |
any | Output 1 — set as out1 in the script. |
out2 |
any | Output 2 — set as out2 in the script. |
out3 |
any | Output 3 — set as out3 in the script. |
Properties
| Key | Type | Default | Description |
|---|---|---|---|
code |
textarea | "// Inputs: in0, in1, in2, in3\n// Set outputs: out0 = ...\n// Bindings: server, logger, ctx, plugin\n\nout0 = in0" |
Groovy Code |
async |
boolean | false |
Run off the main thread. Outputs are not forwarded in async mode. |
Examples
Hello World
Set out0 to a greeting.
out0 = "Hello, " + in0 + "!"
Get player UUID
Get the UUID of a player passed as in0.
out0 = in0?.getUniqueId()?.toString()
Format balance
Format a number as a currency string.
out0 = String.format("$%,.2f", (double) in0)
List all online player names
Collect all online player names into a list.
out0 = server.onlinePlayers.collect { it.name }
Check time of day
Return whether it is daytime in a world.
def world = server.getWorld("world")
def time = world?.time ?: 0
out0 = (time >= 0 && time < 12000) ? "day" : "night"
Send title with custom colours
Build and send a title using Adventure API.
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.format.NamedTextColor
def player = in0
def title = Component.text("Welcome!").color(NamedTextColor.GOLD)
def sub = Component.text("Enjoy your stay").color(NamedTextColor.GRAY)
player?.showTitle(
net.kyori.adventure.title.Title.title(title, sub)
)
Simple HTTP request (async)
Fetch data from an API asynchronously (enable async mode).
import groovy.json.JsonSlurper
def url = new URL("https://api.example.com/data")
def response = new JsonSlurper().parse(url)
logger.info("Got response: ${response}")
Math and conditions
Compute a tax amount and decide a category.
def income = (double) in0
def tax = income > 1000 ? income * 0.2 : income * 0.1
out0 = tax
out1 = tax > 200 ? "high" : "low"