The execute java section

Execute Java within a Skript event or command.

Syntax

command /javahello:
    trigger:
        execute java:
            sender.sendMessage("Hello from Java!");
            setVar("_numbers::*", List.of(1, 2, 3));

The section body is Java, not Skript expressions. It is a method body: use Java statements and semicolons. You do not need to declare a wrapper class.

Context

Name Purpose
event Original Bukkit Event; cast to a specific event type for specialized methods
sender Command sender, event player, or console fallback
context Event, bindings and variable bridge
getVar, setVar Read and write Skript variables
getList, getMap Read lists and variable trees
callback, consumer Access a registered Skript section

Values such as player, victim, attacker, and damage are available through context.get("name") when applicable. They are not automatically declared Java variables or methods.

Lifecycle

Script parsing captures a source snapshot and submits compilation. The resulting class is reused, while each invocation receives a fresh instance and context. Pending or failed blocks stop the current trigger invocation.

See imports and context and compilation and cache.

Type a query to search the guide.