Skip to content
This repository has been archived by the owner on Oct 12, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/v3' into v3
Browse files Browse the repository at this point in the history
  • Loading branch information
Ale32bit committed May 10, 2023
2 parents 958d721 + d9b2eb2 commit 893dcd7
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ You are able to listen after the following events, which directly map to the eve
| Join | `join` | A player joined the server |
| Leave | `leave` | A player left the server |
| Death | `death` | A player died |
| World change | `world_change` | A player changed worlds |
| AFK | `afk` | A player went AFK |
| AFK return | `afk_return` | A player returned from being AFK |
| Restart scheduled | `server_restart_scheduled` | The server will restart soon |
Expand Down Expand Up @@ -167,6 +168,17 @@ The event received when a player dies in-game.
- user - `User` that died
- source - `User` | `null` that killed the user. Only set if they were killed by another player

### World change

([Websocket API docs](https://docs.sc3.io/chatbox/websocket.html#world-change-event) –
[API reference](https://docs.sc3.io/library/switchchat/interfaces/WorldChange.html))

The event received when a player changes worlds.

- user - `User` that changed worlds
- origin - `string` of the world the player moved from
- destination - `string` of the world the player is now in

### AFK

([Websocket API docs](https://docs.sc3.io/chatbox/websocket.html#afk-event) –
Expand Down
10 changes: 8 additions & 2 deletions src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import WebSocket from "ws";
import {Capability, FormattingMode, User} from "./types";
import {Data, Hello, Players, Success, RequestError, Closing} from "./packets";
import {
ChatboxChatMessage, ChatboxCommand, DiscordChatMessage, IngameChatMessage, Leave, Join, Death, AFKReturn, AFK,
ServerRestartCancelled, ServerRestartScheduled, BaseEvent
ChatboxChatMessage, ChatboxCommand, DiscordChatMessage, IngameChatMessage, Leave, Join, Death, WorldChange,
AFKReturn, AFK, ServerRestartCancelled, ServerRestartScheduled, BaseEvent
} from "./events";
import {QueueMessage} from "./types/QueueMessage";
import ChatboxError from "./errors/ChatboxError";
Expand Down Expand Up @@ -165,6 +165,12 @@ export declare interface Client {
*/
on(event: "death", listener: (death: Death) => void): this;

/**
* The event received when a player changes world.
* @event
*/
on(event: "world_change", listener: (worldChange: WorldChange) => void): this;

/**
* The event received when a player goes AFK in-game.
* @event
Expand Down
26 changes: 26 additions & 0 deletions src/events/WorldChange.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {BaseEvent} from "./BaseEvent";
import {User, RenderedTextObject} from "../types";

/** The event received when a player changes worlds. */
export interface WorldChange extends BaseEvent {
/** The in-game player who changed worlds. */
user: User;

/**
* The world the player has moved from. It will be a Minecraft namespaced registry key, for example:
*
* - `minecraft:overworld` - The overworld
* - `minecraft:the_nether` - The Nether
* - `minecraft:the_end` - The End
*/
origin: string;

/**
* The world the player is now in. It will be a Minecraft namespaced registry key, for example:
*
* - `minecraft:overworld` - The overworld
* - `minecraft:the_nether` - The Nether
* - `minecraft:the_end` - The End
*/
destination: string;
}
1 change: 1 addition & 0 deletions src/events/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export * from "./BaseEvent";
export * from "./ChatboxChatMessage";
export * from "./ChatboxCommand";
export * from "./Death";
export * from "./WorldChange";
export * from "./DiscordChatMessage";
export * from "./IngameChatMessage";
export * from "./Join";
Expand Down

0 comments on commit 893dcd7

Please sign in to comment.