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

Commit 893dcd7

Browse files
committed
Merge remote-tracking branch 'origin/v3' into v3
2 parents 958d721 + d9b2eb2 commit 893dcd7

4 files changed

Lines changed: 47 additions & 2 deletions

File tree

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ You are able to listen after the following events, which directly map to the eve
7575
| Join | `join` | A player joined the server |
7676
| Leave | `leave` | A player left the server |
7777
| Death | `death` | A player died |
78+
| World change | `world_change` | A player changed worlds |
7879
| AFK | `afk` | A player went AFK |
7980
| AFK return | `afk_return` | A player returned from being AFK |
8081
| Restart scheduled | `server_restart_scheduled` | The server will restart soon |
@@ -167,6 +168,17 @@ The event received when a player dies in-game.
167168
- user - `User` that died
168169
- source - `User` | `null` that killed the user. Only set if they were killed by another player
169170

171+
### World change
172+
173+
([Websocket API docs](https://docs.sc3.io/chatbox/websocket.html#world-change-event) –
174+
[API reference](https://docs.sc3.io/library/switchchat/interfaces/WorldChange.html))
175+
176+
The event received when a player changes worlds.
177+
178+
- user - `User` that changed worlds
179+
- origin - `string` of the world the player moved from
180+
- destination - `string` of the world the player is now in
181+
170182
### AFK
171183

172184
([Websocket API docs](https://docs.sc3.io/chatbox/websocket.html#afk-event) –

src/Client.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import WebSocket from "ws";
55
import {Capability, FormattingMode, User} from "./types";
66
import {Data, Hello, Players, Success, RequestError, Closing} from "./packets";
77
import {
8-
ChatboxChatMessage, ChatboxCommand, DiscordChatMessage, IngameChatMessage, Leave, Join, Death, AFKReturn, AFK,
9-
ServerRestartCancelled, ServerRestartScheduled, BaseEvent
8+
ChatboxChatMessage, ChatboxCommand, DiscordChatMessage, IngameChatMessage, Leave, Join, Death, WorldChange,
9+
AFKReturn, AFK, ServerRestartCancelled, ServerRestartScheduled, BaseEvent
1010
} from "./events";
1111
import {QueueMessage} from "./types/QueueMessage";
1212
import ChatboxError from "./errors/ChatboxError";
@@ -165,6 +165,12 @@ export declare interface Client {
165165
*/
166166
on(event: "death", listener: (death: Death) => void): this;
167167

168+
/**
169+
* The event received when a player changes world.
170+
* @event
171+
*/
172+
on(event: "world_change", listener: (worldChange: WorldChange) => void): this;
173+
168174
/**
169175
* The event received when a player goes AFK in-game.
170176
* @event

src/events/WorldChange.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import {BaseEvent} from "./BaseEvent";
2+
import {User, RenderedTextObject} from "../types";
3+
4+
/** The event received when a player changes worlds. */
5+
export interface WorldChange extends BaseEvent {
6+
/** The in-game player who changed worlds. */
7+
user: User;
8+
9+
/**
10+
* The world the player has moved from. It will be a Minecraft namespaced registry key, for example:
11+
*
12+
* - `minecraft:overworld` - The overworld
13+
* - `minecraft:the_nether` - The Nether
14+
* - `minecraft:the_end` - The End
15+
*/
16+
origin: string;
17+
18+
/**
19+
* The world the player is now in. It will be a Minecraft namespaced registry key, for example:
20+
*
21+
* - `minecraft:overworld` - The overworld
22+
* - `minecraft:the_nether` - The Nether
23+
* - `minecraft:the_end` - The End
24+
*/
25+
destination: string;
26+
}

src/events/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export * from "./BaseEvent";
44
export * from "./ChatboxChatMessage";
55
export * from "./ChatboxCommand";
66
export * from "./Death";
7+
export * from "./WorldChange";
78
export * from "./DiscordChatMessage";
89
export * from "./IngameChatMessage";
910
export * from "./Join";

0 commit comments

Comments
 (0)