HyperScript
Docs

← All of the Docs Commands and events

Event values

expressionattackersince 1.5.0

%event.attacker% · entity damage · Who dealt the damage: a player's name or a mob type; for a projectile, whoever shot it; unset if nobody did

on entity damage:
    if attacker is set and victim is "villager":
        cancel event
Try it
expressionvictimsince 1.5.0

%event.victim% · entity damage · Who was hurt: a player's name or a mob type

send action bar "&aFall damage negated!" to victim
Try it
expressiondamagesince 1.5.0

%event.damage% · entity damage · Damage taken after armour; 2 is one heart

on entity damage:
    if damage >= 10:
        send "&cThat hit hard!" to victim
Try it
expressioncausesince 1.5.0

%event.cause% · entity damage · FALL, FIRE, ENTITY_ATTACK, PROJECTILE and so on

if cause is "ENDER_PEARL" and region at event's location contains "spawn":
    cancel event
    send "&cNo pearling into spawn."
Try it
expressioncausesince 1.5.0

%event.cause% · player death · What killed the player, in the same words

if cause is "ENDER_PEARL" and region at event's location contains "spawn":
    cancel event
    send "&cNo pearling into spawn."
Try it
expressionmessagesince 1.5.0

%event.message% · player chat · The chat message

if message contains "badword":
    cancel event
    send "&cPlease keep chat friendly!" to player
Try it
expressionmessagesince 1.5.0

%event.message% · player death · The death message everyone will see

if message contains "badword":
    cancel event
    send "&cPlease keep chat friendly!" to player
Try it
expressionmessagesince 1.5.0

%event.message% · player command · The whole line as typed, e.g. /home set base

if message contains "badword":
    cancel event
    send "&cPlease keep chat friendly!" to player
Try it
expressioncommandsince 1.5.6

%event.command% · player command · The command without the slash, in lower case: home

on player command:
    if command is "plugins":
        cancel event
Try it
expressionamountsince 1.5.6

%event.amount% · item pickup, item drop · How many items are in the stack

on item pickup:
    send "&7Picked up %event.amount% %event.item%"
Try it
expression%event.gamemode%since 1.7.0

gamemode change · The mode being changed to

if event.gamemode is "creative" and player does not have permission "build.creative":
    cancel event
Try it
expression%event.effect%since 1.7.0

effect gained, effect ended · The potion effect

send action bar "&7%event.effect% wore off" to player
Try it
expression%event.advancement%since 1.7.0

advancement · The advancement's id

if event.advancement is "story/mine_diamond":
    broadcast "&b%player.name% found diamonds!"
Try it
expression%event.weather%since 1.7.0

weather change · rain or clear

if event.weather is "rain":
    cancel event
Try it
expression%event.inventory%since 1.7.0

inventory open, inventory close · The kind of container

if event.inventory is "ender_chest" and {%player%.in_combat}:
    cancel event
Try it
expression%event.region%since 1.5.8

region enter, region leave · The name of the region

on region enter:
    send action bar "&7Entering &f%event.region%" to player
Try it
expression%event.opponent%since 1.7.50

combat start · The name of the other player; unset when a script started the fight

on combat start:
    send "&cYou are fighting %event.opponent%. Logging out now counts as a death."
Try it
expression%event.streak%since 1.7.52

kill streak · How many players they have killed in a row since they last died

on kill streak:
    if event.streak is 5:
        broadcast "&6%player.name% is on a killing spree!"
Try it
expression%event.word%since 1.7.55

blocked word · The blocked word that was found in what the player wrote

on blocked word:
    log "%player.name% wrote the blocked word %event.word%"
Try it
expression%event.lines%since 1.5.8

sign change · A list of the sign's lines, top to bottom

on sign change:
    log "%player.name% wrote: %event.lines%"
Try it
expression%event.clicked%since 1.5.8

entity click · A player's name if a player was clicked, otherwise the entity type

on entity click:
    send "&7You clicked &f%event.clicked%"
Try it
expression%event.level%, %event.old_level%since 1.5.8

level up · The level reached, and the one before

on level up:
    send "&aLevel %event.old_level% -> %event.level%"
Try it
expression%event.name%since 1.5.7

player login · The name of whoever is logging in

on player login:
    log "%event.name% is connecting from %event.address%"
Try it
expression%event.uuid%since 1.5.7

player login · Their account id

on player login:
    log "%event.name% has the id %event.uuid%"
Try it
expression%event.address%since 1.5.7

player login, server ping · The address they are connecting from

on player login:
    log "%event.name% is connecting from %event.address%"
Try it
expression%event.from%since 1.5.6

world change · The name of the world the player left

on world change:
    send "&7You left %event.from% for %player.world%"
Try it
expressionblocksince 1.5.0

%event.block% · block break, right click · The block type, e.g. diamond_ore

on block break:
    if block is "diamond_ore":
        broadcast "&b%player.name% found diamonds!"
Try it
expression%event.power%since 1.7.63

redstone · The power the block has now, 0 to 15

if event.power > 0:
    log "A lamp was lit at %event's location%"
Try it
expressionentitysince 1.5.0

%event.entity% · entity damage, entity death, mob spawn · The entity type, e.g. zombie

on entity damage:
    if event.cause is "FALL":
        if player has permission "hyperscript.nofall":
            cancel event
            send action bar "&aFall damage negated!" to victim
Try it
expressionkillersince 1.5.0

%event.killer% · entity death, player death · Name of the player who made the kill

if killer is set:
    send "&6You slew a %event.entity%" to player
Try it
expressionreasonsince 1.5.0

%event.reason% · mob spawn · NATURAL, SPAWNER, SPAWNER_EGG, BREEDING, CUSTOM and so on

if entity is "phantom" and reason is "NATURAL":
    cancel event
Try it
expressionslotsince 1.5.0

%event.slot% · inventory click · The slot clicked, counting from 1 like the slots of open gui

on inventory click:
    if slot is 1:
        send "&7You clicked the first slot."
Try it
expressionitemsince 1.5.0

%event.item% · inventory click, right click, item pickup, item drop · The item type clicked, held, picked up or dropped

on right click:
    if item is "compass":
        send "&bYou are in %player.world%"
Try it
expression%event.click_type%since 1.5.4

inventory click · LEFT, RIGHT, SHIFT_LEFT, MIDDLE, DROP and so on

on inventory click:
    if event.click_type is "SHIFT_LEFT":
        cancel event
Try it
expression%event.recipients%since 1.5.4

player chat · A list of the names of the players who will see the message

on player chat:
    log "%player.name% wrote to: %event.recipients%"
Try it
expression%event.drops%since 1.5.4

block break, entity death · A list of the items that are about to drop

broadcast "&b%player.name% found diamonds! Drops: %event.drops%"
Try it
expression%event.location%since 1.5.4

block break, right click, entity damage, mob spawn, player jump · Where it happened, as a location; also written event's location

on block break:
    spawn particle "flame" at event's location
Try it
Guide and examples

Each event makes its details available inside its block. Every value has a placeholder, and the common ones also have a one-word short form.

on entity damage:
    if event.cause is "FALL":
        if player has permission "hyperscript.nofall":
            cancel event
            send action bar "&aFall damage negated!" to victim

on player chat:
    if message contains "badword":
        cancel event
        send "&cPlease keep chat friendly!" to player
Short formPlaceholderEventsMeaning
attacker%event.attacker%entity damageWho dealt the damage: a player's name or a mob type; for a projectile, whoever shot it; unset if nobody did
victim%event.victim%entity damageWho was hurt: a player's name or a mob type
damage%event.damage%entity damageDamage taken after armour; 2 is one heart
cause%event.cause%entity damageFALL, FIRE, ENTITY_ATTACK, PROJECTILE and so on
cause%event.cause%player deathWhat killed the player, in the same words
message%event.message%player chatThe chat message
message%event.message%player deathThe death message everyone will see
message%event.message%player commandThe whole line as typed, e.g. /home set base
command%event.command%player commandThe command without the slash, in lower case: home
amount%event.amount%item pickup, item dropHow many items are in the stack
%event.gamemode%gamemode changeThe mode being changed to
%event.effect%effect gained, effect endedThe potion effect
%event.advancement%advancementThe advancement's id
%event.weather%weather changerain or clear
%event.inventory%inventory open, inventory closeThe kind of container
%event.region%region enter, region leaveThe name of the region
%event.opponent%combat startThe name of the other player; unset when a script started the fight
%event.streak%kill streakHow many players they have killed in a row since they last died
%event.word%blocked wordThe blocked word that was found in what the player wrote
%event.lines%sign changeA list of the sign's lines, top to bottom
%event.clicked%entity clickA player's name if a player was clicked, otherwise the entity type
%event.level%, %event.old_level%level upThe level reached, and the one before
%event.name%player loginThe name of whoever is logging in
%event.uuid%player loginTheir account id
%event.address%player login, server pingThe address they are connecting from
%event.from%world changeThe name of the world the player left
block%event.block%block break, right clickThe block type, e.g. diamond_ore
%event.power%redstoneThe power the block has now, 0 to 15
entity%event.entity%entity damage, entity death, mob spawnThe entity type, e.g. zombie
killer%event.killer%entity death, player deathName of the player who made the kill
reason%event.reason%mob spawnNATURAL, SPAWNER, SPAWNER_EGG, BREEDING, CUSTOM and so on
slot%event.slot%inventory clickThe slot clicked, counting from 1 like the slots of open gui
item%event.item%inventory click, right click, item pickup, item dropThe item type clicked, held, picked up or dropped
%event.click_type%inventory clickLEFT, RIGHT, SHIFT_LEFT, MIDDLE, DROP and so on
%event.recipients%player chatA list of the names of the players who will see the message
%event.drops%block break, entity deathA list of the items that are about to drop
%event.location%block break, right click, entity damage, mob spawn, player jumpWhere it happened, as a location; also written event's location
  • A value that does not apply to the current event is unset.
  • Comparisons ignore case, so cause is "fall" and cause is "FALL" are the same.
  • item on its own is the event's item. Followed by a number it is still the list lookup item 2 of <list>.
  • player in on entity damage is the player who was hurt, or, if the victim is not a player, the player who dealt the damage. victim and attacker are always exact.
  • on player death can rewrite or remove the message everyone sees: set death message to "&c%player.name% fell over" and hide death message. on entity death fires for players too, with player being the killer; on player death is the one where player is who died.
  • on player command sees every command before the server does, including ones that do not exist. cancel event stops the command from running, which makes it the way to block commands:
on player command:
    if command is "plugins" and player does not have permission "server.admin":
        cancel event
        send "&cThat command is not available."
  • on region enter and on region leave fire when a player crosses the edge of a region made with create region, on foot or by teleport. Movement is only watched while a loaded script has one of these blocks, and only when a player steps into a different block. Neither can be cancelled; to keep someone out, teleport them back.
  • block, item, entity and cause also work in the newer events: the block placed, the item crafted, eaten or caught, the entity clicked, and why a teleport is happening.
  • on entity damage and on mob spawn fire extremely often. Put the cheapest test first, as the example does, so that most runs end after one line.
  • on player jump works on Spigot and Paper. Cancelling it snaps the player back to where they were; because the jump has already started on their screen, a small hop may be visible.
  • on inventory click fires for every inventory, including the player's own and GUIs opened by scripts. Cancelling it means the click moves nothing.

The Docs page of the documentation site lists every event with its values, whether it can be cancelled, a working example, and a box for trying the values out. The same information is published for other tools as events_metadata.json.