Denovo

Events

Every script starts with one of these. The blocks under it run each time that thing happens in the game.

when the server starts

when the server startsworld

Runs when the scripts are loaded: when the server starts, after /denovo reload, and whenever a script is switched on from the /denovos menu. Each time, every start script that is switched on runs again, not only the new one.

Event valueTypeWhat it is
event.worldWorldThe server's first world, usually the overworld.
def onStart(event) { }

when the command /[text] is run

when the command /mycommand is runplayerargs

Runs when a player types the command. The command exists for as long as the script is loaded, so there is nothing else to set up. Only players can use it, not the server console.

SlotTakesWhat it is for
1textThe command name without the slash. Letters, numbers, - and _ only, up to 32 characters.
Event valueTypeWhat it is
event.playerPlayerThe player who typed the command.
event.argstextEverything typed after the command, as one text with the words separated by spaces. Empty when nothing was typed.
@command("mycommand")
def onCommand(event) { }

when a player joins

when a player joinsplayerjoinMessage

Runs when a player joins the server.

Event valueTypeWhat it is
event.playerPlayerThe player who joined.
event.joinMessageComponentThe join message shown in chat, as styled text. Use plain text of to read it as text.
def onPlayerJoin(event) { }

when a player leaves

when a player leavesplayerquitMessage

Runs when a player leaves the server, just before they are removed from it.

Event valueTypeWhat it is
event.playerPlayerThe player who is leaving.
event.quitMessageComponentThe leave message shown in chat, as styled text.
def onPlayerQuit(event) { }

when a player chats

when a player chatsplayermessage

Runs when a player sends a chat message. The blocks under it run on the next tick, after the message has been handled.

Event valueTypeWhat it is
event.playerPlayerThe player who wrote the message.
event.messageComponentWhat they wrote, as styled text. Use plain text of to turn it into text you can compare.
def onChat(event) { }

when a player runs a command

when a player runs a commandplayermessage

Runs when a player types any command, before the command itself runs.

Event valueTypeWhat it is
event.playerPlayerThe player who typed the command.
event.messagetextThe whole line they typed, slash included, for example /home 2.
def onPlayerCommandPreprocess(event) { }

when a player moves

when a player movesplayerfromto

Runs every time a player moves or turns their head, which can be many times a second, so keep the blocks under it short. Offset by changes the location it is given, so use it on location of the player rather than on from or to.

Event valueTypeWhat it is
event.playerPlayerThe player who is moving.
event.fromLocationWhere the player was before this move.
event.toLocationWhere the player is moving to.
def onPlayerMove(event) { }

when a player teleports

when a player teleportsplayerfromto

Runs when a player is teleported, whether by a command, an ender pearl, a portal or a script.

Event valueTypeWhat it is
event.playerPlayerThe player being teleported.
event.fromLocationWhere they are teleported from.
event.toLocationWhere they are teleported to.
def onPlayerTeleport(event) { }

when a player changes world

when a player changes worldplayerfrom

Runs after a player has moved into another world, for example through a nether portal.

Event valueTypeWhat it is
event.playerPlayerThe player who changed world.
event.fromWorldThe world they came from.
def onPlayerChangedWorld(event) { }

when a player dies

when a player diesplayerdeathMessagedroppedExpnewLevel

Runs when a player dies.

Event valueTypeWhat it is
event.playerPlayerThe player who died.
event.deathMessageComponentThe death message shown in chat, as styled text.
event.droppedExpnumberHow much experience the player drops.
event.newLevelnumberThe experience level the player will have after respawning.
def onPlayerDeath(event) { }

when a player respawns

when a player respawnsplayerrespawnLocation

Runs when a player respawns after dying, just before they appear in the world.

Event valueTypeWhat it is
event.playerPlayerThe player who is respawning.
event.respawnLocationLocationWhere the player will appear.
def onPlayerRespawn(event) { }

when a player interacts

when a player interactsplayeractionclickedBlockblockFacehandmaterial

Runs when a player clicks with either mouse button, on a block or into the air, and when they step on something like a pressure plate. A right click can run it twice, once for each hand, so check hand or material when that matters.

Event valueTypeWhat it is
event.playerPlayerThe player who clicked.
event.actionActionWhat kind of click it was: LEFT_CLICK_BLOCK, RIGHT_CLICK_BLOCK, LEFT_CLICK_AIR, RIGHT_CLICK_AIR, or PHYSICAL for stepping on something.
event.clickedBlockBlockThe block that was clicked. It is empty when the player clicked into the air, and using an empty block stops the script, so check action first.
event.blockFaceBlockFaceWhich side of the block was clicked.
event.handEquipmentSlotWhich hand this run is for: HAND or OFF_HAND.
event.materialMaterialThe material of the item in that hand. AIR when the hand is empty.
def onPlayerInteract(event) { }

when a player eats or drinks

when a player eats or drinksplayerhand

Runs when a player finishes eating food or drinking a potion or milk.

Event valueTypeWhat it is
event.playerPlayerThe player eating or drinking.
event.handEquipmentSlotThe hand holding the item.
def onPlayerItemConsume(event) { }

when a player enters a bed

when a player enters a bedplayerbed

Runs when a player tries to get into a bed.

Event valueTypeWhat it is
event.playerPlayerThe player getting into bed.
event.bedBlockThe bed block.
def onPlayerBedEnter(event) { }

when a player starts or stops sneaking

when a player starts or stops sneakingplayersneaking

Runs when a player starts or stops sneaking.

Event valueTypeWhat it is
event.playerPlayerThe player.
event.sneakingtrue/falsetrue when they start sneaking, false when they stop.
def onPlayerToggleSneak(event) { }

when a player starts or stops sprinting

when a player starts or stops sprintingplayersprinting

Runs when a player starts or stops sprinting.

Event valueTypeWhat it is
event.playerPlayerThe player.
event.sprintingtrue/falsetrue when they start sprinting, false when they stop.
def onPlayerToggleSprint(event) { }

when a player's level changes

when a player's level changesplayeroldLevelnewLevel

Runs when a player's experience level goes up or down.

Event valueTypeWhat it is
event.playerPlayerThe player.
event.oldLevelnumberThe level they had before.
event.newLevelnumberThe level they have now.
def onPlayerLevelChange(event) { }

when a player gains experience

when a player gains experienceplayeramount

Runs when a player is about to get experience, for example from an orb.

Event valueTypeWhat it is
event.playerPlayerThe player.
event.amountnumberHow much experience they are getting.
def onPlayerExpChange(event) { }

when a player's game mode changes

when a player's game mode changesplayernewGameMode

Runs when a player's game mode is about to change.

Event valueTypeWhat it is
event.playerPlayerThe player.
event.newGameModeGameModeThe game mode they are switching to.
def onPlayerGameModeChange(event) { }

when a block is broken

when a block is brokenplayerblockexpToDrop

Runs when a player breaks a block.

Event valueTypeWhat it is
event.playerPlayerThe player breaking the block.
event.blockBlockThe block being broken. It still has its old material while the blocks under this event run.
event.expToDropnumberHow much experience the block will drop.
def onBlockBreak(event) { }

when a block is placed

when a block is placedplayerblockblockAgainsthand

Runs when a player places a block.

Event valueTypeWhat it is
event.playerPlayerThe player placing the block.
event.blockBlockThe block that was placed, already of its new material.
event.blockAgainstBlockThe block it was placed against.
event.handEquipmentSlotThe hand the block was placed from.
def onBlockPlace(event) { }

On this page