Events¶
Two ways to subscribe. They are the same mechanism underneath, so priorities, unsubscription and error handling behave identically whichever you use.
By name. A top-level function called onSomething is subscribed to something:
Explicitly, when you need a priority, a conditional subscription, two handlers on one event, or the ability to unsubscribe:
var handler = function (e) { /* … */ };
events.on('chat', handler, events.HIGHEST);
events.off('chat', handler); // must be the same function object
events.once('gameStart', function (e) { /* … */ });
Priorities: events.HIGHEST (2), HIGH, NORMAL (0), LOW, LOWEST. Higher runs first. Handlers at the same priority run in registration order.
Cancelling is e.cancel() (or e.cancelled = true), never a return value. A handler's return value is ignored. e.cancellable says whether cancelling this event does anything.
events.list() returns every event name this build can fire. It is the authority, not this page. An unknown name passed to events.on throws, with your file and line.
The catalogue¶
If an event is listed, it fires.
| name | payload | cancels | fires when |
|---|---|---|---|
tick |
none | no | every client tick (20 a second) |
renderWorld |
partialTicks |
no | each frame, while the world is drawn |
renderHud |
width, height |
no | each frame, while the HUD is drawn; see the note below |
chat |
message, formatted; message settable |
yes | a chat line arrives |
chatSend |
message, settable |
yes | you send a chat line |
playerChat |
name, rank, message |
no | a player says something in Hypixel chat |
worldLoad |
none | no | you enter a world |
worldUnload |
none | no | you leave a world |
gameStart |
game, mode, map, source |
no | a match starts |
gameEnd |
game, outcome |
no | a match ends |
playerJoin |
name, uuid |
no | a player appears in the tab list |
lobbyJoin |
name, players, maxPlayers, fresh |
no | a player joins your pre-game lobby ("X has joined (4/16)!") |
partyJoin |
members, names, size |
no | a party joins your lobby |
whoRoster |
names, size |
no | a /who reply arrives |
blockBreak |
x, y, z, block, status, creative |
no | you start, finish or cancel breaking a block |
key |
code, char, key |
yes¹ | you press a key |
¹ On some clients key cannot be cancelled and e.char is empty. The event still fires once per press with the right code. e.cancellable tells you which you have, and /fkdr script hooks prints it.
On some clients renderHud stops firing while the HUD module is off. /fkdr script hooks says whether yours is one of them.
Events that are not here¶
packetIn, packetOut, attackEntity, preMotion, playerInput, mouse, guiOpen and entitySpawn are not available to JavaScript scripts. If you need one, suggest it.
Rewriting a chat message¶
Assigning e.message in a chat handler hides the original line and prints yours in its place. The rewritten line loses the server's hover text and click actions (a rank tooltip, a click-to-accept party invite). Rewriting a plain line costs nothing.
In chatSend, assigning e.message changes what the server receives, and e.cancel() stops the line being sent.