Skip to main content

Hooks

Hooks are basic methods of scripting api. They are executed during script loading, so can be called only during root scope execution. This means, that hooks can be declared in root scope or in methods, which are being called from root scope.

There are several hooks, each of which we will discuss in more detail later. Hooks define the behavior and functionality of the script, here is an example of writing a script with a command hook:

scripts/Example.js
console.log("Hello world") // This message will be printed during plugin loading

command("hello_wolrd", () => { // Calling the hook
console.log("Hello!")
})

Here is the full list of existing hooks:

HookDescription
manifestDeclares script manifest
playerJoinSetups event listener for new player connection
commandRegisters new console command in MCmdLogger