Denizen Script Events


Events are a way to listen to things that happened on your server and respond to them through a script. These usually pair with 'world' script containers.
Learn about how events work in The Beginner's Guide.


Showing all 17 events...

Categories:

Core | input | Player | User Interface | Error: Missing Group | Server



Category: Core


Nameconsole output
Event Lines console output
Triggerswhen any message is printed to console. (Requires Mechanism:system.redirect_logging be set true.)
Generated Examplesafter console output:
Contexts<context.message> returns the message that is being printed to console.
CancellableTrue - This adds <context.cancelled> and determine 'cancelled' or 'cancelled:false'
GroupCore
Sourcehttps://github.com/DenizenScript/Denizen-Core/blob/master/src/main/java/com/denizenscript/denizencore/events/core/ConsoleOutputScriptEvent.java#L9

Namecustom event
Event Lines custom event
Triggerswhen called by a script using Command:customevent.
Example
on custom event id:my_custom_event:
- narrate <context.my_custom_info>
Has PlayerWhen the command is used with a player link. - this adds switches 'flagged:<flag name>' + 'permission:<node>', in addition to the '<player>' link.
Has NPCWhen the command is used with an NPC link.
Switchesid:<id> to only run the event if the given ID is used. This should almost always be specified.
data:<key>:<value> to only run the event if the given data key matches the given value, using advanced matchers for the given object type (note: the 'customevent' command call has to be careful about object type for this).
Contexts<context.id> returns the ID that was used.
<context.data> returns the MapTag of input data (if any! some events don't have context data).
<context.(key)> returns the value of the input data key, if available.
Determine"OUTPUT:<Anything>" to add that value to the output list (note this is an ADD, not a SET).
GroupCore
Sourcehttps://github.com/DenizenScript/Denizen-Core/blob/master/src/main/java/com/denizenscript/denizencore/events/core/CustomScriptEvent.java#L16

Namedelta time hourly|minutely|secondly
Event Lines delta time hourly|minutely|secondly
Triggersevery <count> seconds, minutes, or hours of game calculation time. Default repetitions count of 1.
This is specifically based on the rate of time advancement in the game server,
which is not necessarily equivalent to the real passage of time (for example, this event may fire slower if the server is lagging).
For real time, see Event:system time.
Generated Exampleson delta time minutely:
Switchesevery:<count> to only run the event every *count* times (like "on delta time secondly every:5" for every 5 seconds).
Contexts<context.second> returns the exact delta time since system start.
GroupCore
Sourcehttps://github.com/DenizenScript/Denizen-Core/blob/master/src/main/java/com/denizenscript/denizencore/events/core/DeltaTimeScriptEvent.java#L10

Namepre script reload
Event Lines pre script reload
Triggersimmediately before Denizen scripts are reloaded.
Generated Examplesafter pre script reload:
on pre script reload:
GroupCore
Sourcehttps://github.com/DenizenScript/Denizen-Core/blob/master/src/main/java/com/denizenscript/denizencore/events/core/PreScriptReloadScriptEvent.java#L7

Nameredis pubsub message
Event Lines redis pubsub message
Triggerswhen a subscribed redis connection receives a published message, see Command:Redis.
Generated Examplesafter redis pubsub message:
on redis pubsub message:
Switcheschannel:<channel> to only fire on events advanced-matching the given channel.
Contexts<context.redis_id> returns the connection id that saw this message.
<context.pattern> returns the redis pattern that matched the channel.
<context.channel> returns the actual channel matched.
<context.message> returns the published message.
GroupCore
Sourcehttps://github.com/DenizenScript/Denizen-Core/blob/master/src/main/java/com/denizenscript/denizencore/events/core/RedisPubSubMessageScriptEvent.java#L9

Namereload scripts
Event Lines reload scripts
script reload
Triggerswhen Denizen scripts are reloaded. Not triggered on initial load.
Generated Exampleson reload scripts:
after script reload:
after reload scripts:
Switcheshad_error:true/false to only process the event if there either was or was not an error message.
Contexts<context.had_error> returns an ElementTag(Boolean) whether there was an error.
GroupCore
Sourcehttps://github.com/DenizenScript/Denizen-Core/blob/master/src/main/java/com/denizenscript/denizencore/events/core/ReloadScriptsScriptEvent.java#L9

Namescripts loaded
Event Lines scripts loaded
Triggerswhen Denizen scripts are loaded, but on reloaded and on initial load.
Generated Examplesafter scripts loaded:
Switcheshad_error:true/false to only process the event if there either was or was not an error message.
Contexts<context.had_error> returns an ElementTag(Boolean) whether there was an error.
GroupCore
Sourcehttps://github.com/DenizenScript/Denizen-Core/blob/master/src/main/java/com/denizenscript/denizencore/events/core/ScriptsLoadedScriptEvent.java#L9

Namesystem time hh:mm
Event Lines system time <HH:MM>
system time hourly|minutely|secondly
Triggerswhen the system time changes to the specified value.
The system time is the real world time set in the server's operating system.
It is not necessarily in sync with the game server time, which may vary (for example, when the server is lagging).
For events based on in-game time passage, use Event:delta time or Command:wait.
Example
on system time hourly:
- announce "Whoa an hour passed!"
Example
on system time 12:00:
- announce "Whoa it's noon!"
Example
on system time 03:00:
- announce "Daily restart in 5 minutes!"
- wait 5m
- adjust server restart
Switchesevery:<count> to only run the event every *count* times (like "on system time secondly every:5" for every 5 seconds).
Contexts<context.hour> returns the exact hour of the system time.
<context.minute> returns the exact minute of the system time.
Synonyms (Search Aid)cron
GroupCore
Sourcehttps://github.com/DenizenScript/Denizen-Core/blob/master/src/main/java/com/denizenscript/denizencore/events/core/SystemTimeScriptEvent.java#L11

Namewebserver web request
Event Lines webserver web request
Triggerswhen a webserver opened by Command:webserver receives a connection request.
Example
# This example supplies a manual response to any of the "/", "/index", or "/index.html" paths.
my_world_script:
    type: world
    data:
        index:
        - <!DOCTYPE html>
        - <html><head><title>Welcome to my site</title></head>
        - <body><h1>Hi!</h1></body></html>
    events:
        on webserver web request port:8080 path:/|/index|/index.html method:get:
        - determine code:200 passively
        - determine headers:[Content-Type=text/html] passively
        - determine raw_text_content:<script.data_key[data.index].separated_by[<n>]>
Example
# This example gives a default response to any pages not handled on port 8080.
on webserver web request port:8080 priority:1000 has_response:false:
- determine code:404 passively
- determine headers:[Content-Type=text/plain] passively
- determine "raw_text_content:Invalid path"
Example
# This example serves a favicon from the local file path "plugins/Denizen/webroot/favicon.ico" with RAM caching to any open web ports.
on webserver web request path:/favicon.ico:
- determine code:200 passively
- determine cached_file:favicon.ico
Switchesport:<#> to only handle requests to a specific port.
path:<path> to only handle requests that match the given advanced-matcher for the path.
method:<method> to only handle requests with the specific method (such as GET or POST).
has_response:<true/false> to only handle requests that do or don't have a response already.
Contexts<context.method> returns the method that was used (such as GET or POST).
<context.path> returns the path requested (such as "/index.html").
<context.port> returns the port connected to.
<context.remote_address> returns the IP address that connected.
<context.query> returns a MapTag of the query data (if no query, returns empty map).
<context.raw_query> returns the raw query input (if no query, returns null).
<context.raw_user_info> returns the raw user info input (if any) (this is a historical HTTP system that allows sending username/password over query).
<context.headers> returns a MapTag of all input headers, where the key is the header name and the value is a ListTag of header values for that name.
<context.body> returns the text content of the body that was sent, if any. Particularly for POST requests.
<context.body_binary> returns the raw binary content body that was sent, if any. Particularly for POST requests.
<context.has_response> returns true if a response body determination (raw_text_content, file, or cached_file) was applied, or false if not.
Determine"CODE:<Element(Number)>" to set a standard web response code, such as 'code:200' for 'OK', or 'code:404' for 'File Not Found'
"HEADERS": + MapTag to set a map of headers, where map keys are the header name and map values are the text of the value, for example headers:[Content-Type=text/html] ... note that header are sometimes case-sensitive.
"RAW_TEXT_CONTENT:<ElementTag>" to set a raw text content body in response. You may determine only one response - raw text, raw binary, a file, or a cached file. You cannot use multiple.
"RAW_BINARY_CONTENT:<BinaryTag>" to set a raw binary content body in response.
"FILE:<ElementTag>" to set a path to a file to send in response. File path must be within the web-root path configured in Denizen/config.yml. Files will be read async.
"CACHED_FILE:<ElementTag>" to set a path to a file to send in response. The content of the file will be cached in RAM until the server restarts. This is useful for files that definitely won't change. First file read will be sync, all others are instant.
"PARSED_FILE:<ElementTag>" - like "FILE:", but this file will be parsed for tags using syntax like "<{util.pi}>" to separate tags from HTML entries.
"CACHED_PARSED_FILE:<ElementTag>" - like "PARSED_FILE" and "CACHED_FILE" combined. Note that the file will be cached, but the results of tags will be handled at runtime still.
GroupCore
Sourcehttps://github.com/DenizenScript/Denizen-Core/blob/master/src/main/java/com/denizenscript/denizencore/events/core/WebserverWebRequestScriptEvent.java#L29

Namescript generates error
Event Lines script generates error
Triggerswhen a script generates an error.
Generated Examplesafter script generates error:
on script generates error:
Contexts<context.message> returns the error message.
<context.queue> returns the queue that caused the error, if any.
<context.script> returns the script that caused the error, if any.
<context.line> returns the line number within the script file that caused the error, if any.
CancellableTrue - This adds <context.cancelled> and determine 'cancelled' or 'cancelled:false'
GroupCore
Warning(s)Abusing this event can cause significant failures in the Denizen debug system. Use only with extreme caution.
Sourcehttps://github.com/DenizenScript/Denizen-Core/blob/master/src/main/java/com/denizenscript/denizencore/events/core/ScriptGeneratesErrorScriptEvent.java#L13

Nameserver generates exception
Event Lines server generates exception
Triggerswhen an exception occurs on the server.
Generated Examplesafter server generates exception:
on server generates exception:
Contexts<context.message> returns the Exception message.
<context.full_trace> returns the full exception trace+message output details.
<context.type> returns the type of the error. (EG, NullPointerException).
<context.queue> returns the queue that caused the exception, if any.
<context.script> returns the script that caused the exception, if any.
<context.line> returns the line number within the script file that caused the exception, if any.
CancellableTrue - This adds <context.cancelled> and determine 'cancelled' or 'cancelled:false'
GroupCore
Warning(s)Abusing this event can cause significant failures in the Denizen debug system. Use only with extreme caution.
Sourcehttps://github.com/DenizenScript/Denizen-Core/blob/master/src/main/java/com/denizenscript/denizencore/events/core/ServerGeneratesExceptionScriptEvent.java#L14

Nametick
Event Lines tick
Triggersevery single tick.
Generated Exampleson tick:
after tick:
Switchesevery:<count> to only run the event every *count* times (like "every:5" for every 5 ticks).
Contexts<context.tick> how many ticks have passed since the server started.
GroupCore
Warning(s)This event fires very rapidly and is usually not the most ideal way to handle things. Generally, prefer Event:delta time.
Sourcehttps://github.com/DenizenScript/Denizen-Core/blob/master/src/main/java/com/denizenscript/denizencore/events/core/TickScriptEvent.java#L9



Category: input


Nameinput_device key pressed|released|toggled
Event Lines <input_device> key pressed|released|toggled
Triggerswhen a keyboard/mouse key is pressed.
Example
# Will send the server an event when the 'K' key is pressed
on keyboard key pressed name:k:
- serverevent id:activate_ability
Example
# Will listen to all presses on the keypad
on keyboard key pressed name:KEYPAD_*:
- narrate "You pressed the <context.key> key on your keypad!"
Switchesname:<key> to only process the event if the pressed key's name matches the specified matcher.
Contexts<context.key> returns an ElementTag of the pressed key's name.
<context.device> returns an ElementTag of the device used, will be either KEYBOARD or MOUSE.
<context.key_code> returns an ElementTag(Number) of the pressed key's raw key code.
Groupinput
Sourcehttps://github.com/DenizenScript/Clientizen/blob/master/src/main/java/com/denizenscript/clientizen/events/KeyPressReleaseScriptEvent.java#L13



Category: Player


Nameplayer starts|stops|toggles sprinting
Event Lines player starts|stops|toggles sprinting
Triggerswhen the client player starts/stops sprinting. Does not trigger for other entities/players currently.
Example
# Will block the player from sprinting
on player starts sprinting:
- determine cancelled
Contexts<context.entity> returns an EntityTag of the client player.
<context.sprinting> returns an ElementTag(Boolean) of whether the client player is sprinting.
CancellableTrue - This adds <context.cancelled> and determine 'cancelled' or 'cancelled:false'
GroupPlayer
Sourcehttps://github.com/DenizenScript/Clientizen/blob/master/src/main/java/com/denizenscript/clientizen/events/PlayerSprintScriptEvent.java#L11



Category: User Interface


Namescreen opened|closed
Event Lines screen opened|closed
Triggerswhen a screen is opened or closed.
Generated Exampleson screen opened:
Switchestype:<screen_type> to only process the event if the type of screen opened matches the specified matcher.
from:<screen_type> to only process the event if the screen was opened from a different screen and that screen's type matches the specified matcher.
Contexts<context.screen_type> returns an ElementTag of the screen type that opened/closed.
<context.previous_screen_type> returns an ElementTag of the screen type this screen was opened from, if any.
GroupUser Interface
Sourcehttps://github.com/DenizenScript/Clientizen/blob/master/src/main/java/com/denizenscript/clientizen/events/ScreenOpenCloseEvent.java#L12



Category: Error: Missing Group


Nameentity starts|stops rendering
Event Lines <entity> starts|stops rendering
Triggerswhen an entity is rendered by the client. This does not mean the entity will always be visible, but within the camera's viewing frustum.
Generated Examplesafter entity starts rendering:
after entity stops rendering:
Contexts<context.entity> returns an EntityTag of the entity being rendered.
<context.rendering> returns an ElementTag(Boolean) of whether the entity is being rendered.
Warning(s)This event may fire very rapidly when the client's camera moves around a lot.
Sourcehttps://github.com/DenizenScript/Clientizen/blob/master/src/main/java/com/denizenscript/clientizen/events/EntityStartsStopsRenderingScriptEvent.java#L11



Category: Server


Nameshutdown
Event Lines shutdown
Triggerswhen the server is shutting down.
Example
# This *might* show a message in logs during shutdown. No guarantee.
on shutdown:
- announce to_console "Last message in the logs from Denizen probably!"
GroupServer
Warning(s)not all plugins will be loaded and delayed scripts will be dropped.
Also note that this event is not guaranteed to always run (eg if the server crashes).
Sourcehttps://github.com/DenizenScript/Denizen-Core/blob/master/src/main/java/com/denizenscript/denizencore/events/core/ShutdownScriptEvent.java#L7