You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/API.md
+23-12Lines changed: 23 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ automatically logged in and validated against mojang's auth.
12
12
* kickTimeout : default to `10*1000` (10s), kick client that doesn't answer to keepalive after that time
13
13
* checkTimeoutInterval : default to `4*1000` (4s), send keepalive packet at that period
14
14
* online-mode : default to true
15
-
* beforePing : allow customisation of the answer to ping the server does.
15
+
* beforePing : allow customisation of the answer to ping the server does.
16
16
It takes a function with argument response and client, response is the default json response, and client is client who sent a ping.
17
17
It can take as third argument a callback. If the callback is passed, the function should pass its result to the callback, if not it should return.
18
18
If the result is `false` instead of a response object then the connection is terminated and no ping is returned to the client.
@@ -34,7 +34,8 @@ automatically logged in and validated against mojang's auth.
34
34
* enforceSecureProfile (optional) : Kick clients that do not have chat signing keys from Mojang (1.19+)
35
35
* generatePreview (optional) : Function to generate chat previews. Takes the raw message string and should return the message preview as a string. (1.19-1.19.2)
36
36
* socketType (optional) : either `tcp` or `ipc`. Switches from a tcp connection to a ipc socket connection (or named pipes on windows). With the `ipc` option `host` becomes the path off the ipc connection on the local filesystem. Example: `\\.\pipe\minecraft-ipc` (Windows) `/tmp/minecraft-ipc.sock` (unix based systems). See the ipcConnection example for an example.
37
-
37
+
* Server : You can pass a custom server class to use instead of the default one.
38
+
38
39
## mc.Server(version,[customPackets])
39
40
40
41
Create a server instance for `version` of minecraft.
@@ -88,6 +89,11 @@ Called when a client connects, but before any login has happened. Takes a
88
89
89
90
Called when a client is logged in against server. Takes a `Client` parameter.
90
91
92
+
### `playerJoin` event
93
+
94
+
Emitted after a player joins and enters the PLAY protocol state and can send and recieve game packets. This is emitted after the `login` event. On 1.20.2 and above after we emit the `login` event, the player will enter a CONFIG state, as opposed to the PLAY state (where game packets can be sent), so you must instead now wait for `playerJoin`.
95
+
96
+
91
97
### `listening` event
92
98
93
99
Called when the server is listening for connections. This means that the server is ready to accept incoming connections.
@@ -112,7 +118,7 @@ Returns a `Client` instance and perform login.
112
118
is blank, and `profilesFolder` is specified, we auth with the tokens there instead.
113
119
If neither `password` or `profilesFolder` are specified, we connect in offline mode.
114
120
* host : default to localhost
115
-
* session : An object holding clientToken, accessToken and selectedProfile. Generated after logging in using username + password with mojang auth or after logging in using microsoft auth. `clientToken`, `accessToken` and `selectedProfile: {name: '<username>', id: '<selected profile uuid>'}` can be set inside of `session` when using createClient to login with a client and access Token instead of a password. `session` is also emitted by the `Client` instance with the event 'session' after successful authentication.
121
+
* session : An object holding clientToken, accessToken and selectedProfile. Generated after logging in using username + password with mojang auth or after logging in using microsoft auth. `clientToken`, `accessToken` and `selectedProfile: {name: '<username>', id: '<selected profile uuid>'}` can be set inside of `session` when using createClient to login with a client and access Token instead of a password. `session` is also emitted by the `Client` instance with the event 'session' after successful authentication.
116
122
* clientToken : generated if a password is given or can be set when when using createClient
117
123
* accessToken : generated if a password or microsoft account is given or can be set when using createBot
118
124
* selectedProfile : generated if a password or microsoft account is given. Can be set as a object with property `name` and `id` that specifies the selected profile.
@@ -129,21 +135,22 @@ Returns a `Client` instance and perform login.
129
135
* hideErrors : do not display errors, default to false
130
136
* skipValidation : do not try to validate given session, defaults to false
131
137
* stream : a stream to use as connection
132
-
* connect : a function taking the client as parameter and that should client.setSocket(socket)
138
+
* connect : a function taking the client as parameter and that should client.setSocket(socket)
133
139
and client.emit('connect') when appropriate (see the proxy examples for an example of use)
134
-
* agent : a http agent that can be used to set proxy settings for yggdrasil authentication (see proxy-agent on npm)
140
+
* agent : a http agent that can be used to set proxy settings for yggdrasil authentication (see proxy-agent on npm)
135
141
* fakeHost : (optional) hostname to send to the server in the set_protocol packet
136
142
* profilesFolder : optional
137
-
* (mojang account) the path to the folder that contains your `launcher_profiles.json`. defaults to your minecraft folder if it exists, otherwise the local directory. set to `false` to disable managing profiles
143
+
* (mojang account) the path to the folder that contains your `launcher_profiles.json`. defaults to your minecraft folder if it exists, otherwise the local directory. set to `false` to disable managing profiles
138
144
* (microsoft account) the path to store authentication caches, defaults to .minecraft
139
145
* onMsaCode(data) : (optional) callback called when signing in with a microsoft account
140
146
with device code auth. `data` is an object documented [here](https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-device-code#device-authorization-response)
141
147
* id : a numeric client id used for referring to multiple clients in a server
142
148
* validateChannelProtocol (optional) : whether or not to enable protocol validation for custom protocols using plugin channels. Defaults to true
* realms : An object which should contain one of the following properties: `realmId` or `pickRealm`. When defined will attempt to join a Realm without needing to specify host/port. **The authenticated account must either own the Realm or have been invited to it**
145
-
* realmId : The id of the Realm to join.
146
-
* pickRealm(realms) : A function which will have an array of the user Realms (joined/owned) passed to it. The function should return a Realm.
150
+
* realms : An object which should contain one of the following properties: `realmId` or `pickRealm`. When defined will attempt to join a Realm without needing to specify host/port. **The authenticated account must either own the Realm or have been invited to it**
151
+
* realmId : The id of the Realm to join.
152
+
* pickRealm(realms) : A function which will have an array of the user Realms (joined/owned) passed to it. The function should return a Realm.
153
+
* Client : You can pass a custom client class to use instead of the default one, which would allow you to create completely custom communication. Also note that you can use the `stream` option instead where you can supply custom duplex, but this will still use serialization/deserialization of packets.
147
154
148
155
149
156
## mc.Client(isServer,version,[customPackets])
@@ -231,11 +238,11 @@ The client's protocol version
231
238
232
239
### client.version
233
240
234
-
The client's version
241
+
The client's version, as a string
235
242
236
243
### `packet` event
237
244
238
-
Called with every packet parsed. Takes four paramaters, the JSON data we parsed, the packet metadata (name, state), the buffer (raw data) and the full buffer (includes surplus data and may include the data of following packets on versions below 1.8)
245
+
Called with every packet parsed. Takes four paramaters, the JSON data we parsed, the packet metadata (name, state), the buffer (raw data) and the full buffer (includes surplus data and may include the data of following packets on versions below 1.8)
239
246
240
247
### `raw` event
241
248
@@ -259,6 +266,10 @@ Called when user authentication is resolved. Takes session data as parameter.
259
266
Called when the protocol changes state. Takes the new state and old state as
260
267
parameters.
261
268
269
+
### `playerJoin` event
270
+
271
+
Emitted after the player enters the PLAY protocol state and can send and recieve game packets
272
+
262
273
### `error` event
263
274
264
275
Called when an error occurs within the client. Takes an Error as parameter.
@@ -272,7 +283,7 @@ Called when a chat message from another player arrives. The emitted object conta
272
283
* type -- the message type - on 1.19, which format string to use to render message ; below, the place where the message is displayed (for example chat or action bar)
273
284
* sender -- the UUID of the player sending the message
274
285
* senderTeam -- scoreboard team of the player (pre 1.19)
275
-
* senderName -- Name of the sender
286
+
* senderName -- Name of the sender
276
287
* targetName -- Name of the target (for outgoing commands like /tell). Only in 1.19.2+
277
288
* verified -- true if message is signed, false if not signed, undefined on versions prior to 1.19
Copy file name to clipboardExpand all lines: docs/HISTORY.md
+19Lines changed: 19 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,24 @@
1
1
# History
2
2
3
+
## 1.47.0
4
+
*[1.20.3 / 1.20.4 support (#1275)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/1d9a38253a28a515d82fffa13806cb0874c5b36c) (thanks @wgaylord)
5
+
6
+
## 1.46.0
7
+
*[Ensure `onReady` in client is called once (#1287)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/85a26a52944c89af273bc974380b438073280981) (thanks @extremeheat)
8
+
*[Acknowledge returning to configuration state if in play state. (#1284)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/092e10c53d33a7b9be52b5cbb67b1e3e55ac2690) (thanks @wgaylord)
9
+
*[Allow commands not to be signed (#1277)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/21240f8ab2fd41c76f50b64e3b3a945f50b25b5e) (thanks @forester302)
10
+
*[Add test to make sure version that are tested are mentioned in the RE… (#1276)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/80d038bd61d1933daa1e5e3251635be9ce2116b6) (thanks @rom1504)
11
+
*[Print if there is a diff in packets in the cycle packet test (#1273)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/614be919d0f20a43e238751c829a6d584ae636cd) (thanks @rom1504)
12
+
*[Align supported versions with mineflayer (#1272)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/ccaf538ffd2ab1e25dabd752d721f97bd8bd188f) (thanks @rom1504)
*[Improve CI setup for per version tests (#1267)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/1740124c4722c2c49f8aed0d708ff5ebecc7743c) (thanks @rom1504)
17
+
*[Allow to create custom client & communication between clients (#1254)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/9e991094761d51243cb28a33bb45630f3064511d) (thanks @zardoy)
18
+
*[Fixed 'unsignedContent' field using nonexistent 'packet.unsignedContent' when emitting 'playerChat' event. (#1263)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/066a2b3646cb8bef6be1fa974597b975aaf08d42) (thanks @Ynfuien)
19
+
*[Add chat typing to client (#1260)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/788bff289030fa66c980de82d82cb953bf76332b) (thanks @IceTank)
20
+
*[chat: Only sign command args when profile keys defined (#1257)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/0ac8c087a28b3ccc73f8eea5941e4902e33c494e) (thanks @evan-goode)
21
+
3
22
## 1.44.0
4
23
*[Send chat commands as chat commands instead of chat messages for 1.19.3-1.20.1 (#1241)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/41f9e4ac4a35b0ce241264a3f964c4874d96a119) (thanks @lkwilson)
5
24
*[Fix end bundle bundle_delimiter packet not being emitted (#1248)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/35b2aa536a4739c11fe78f6e8e5c591abd0b0498) (thanks @PondWader)
0 commit comments