execute java

The execute java section's syntax and the context available inside a block.

The execute java: section is compiled once at script parse time and cached by the hash of its source (SHA-256) — identical blocks aren’t recompiled.

Context inside a block

Name Type Notes
event Event The triggering Bukkit event (may be null)
sender CommandSender Player/console for player events, ServerCommandEvent, and Skript command triggers; console otherwise
getVar(String) Object Reads a Skript variable, local scope first
setVar(String, Object) void Writes a Skript variable, converting the value
context SkBeeJavaContext Full context, including context.get("attacker")

Example

on damage:
    execute java:
        if (victim() instanceof Player) {
            setVar("last_damage", event.getDamage());
        }

Variable names in getVar/setVar accept name, {name}, and %name% interchangeably.