Skip to content
This repository was archived by the owner on Nov 15, 2022. It is now read-only.

Commit af64aa9

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents c39f3c9 + 010d6b2 commit af64aa9

File tree

23 files changed

+304
-652
lines changed

23 files changed

+304
-652
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
mcVersion: ['1.7', '1.8', '1.9', '1.10', '1.11.2', '1.12.2', '1.13.2', '1.14.4', '1.15.2', '1.16.5', '1.17']
16+
mcVersion: ['1.7', '1.8', '1.9', '1.10', '1.11.2', '1.12.2', '1.13.2', '1.14.4', '1.15.2', '1.16.5', '1.17', '1.17.1', '1.18']
1717

1818
steps:
1919
- uses: actions/checkout@v2
@@ -24,7 +24,7 @@ jobs:
2424
- name: Setup Java JDK
2525
uses: actions/[email protected]
2626
with:
27-
java-version: '16'
27+
java-version: '17'
2828
distribution: 'adopt'
2929
- name: Install dependencies
3030
run: npm install

docs/API.md

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,13 @@ Returns a `Client` instance and perform login.
104104
* connect : a function taking the client as parameter and that should client.setSocket(socket)
105105
and client.emit('connect') when appropriate (see the proxy examples for an example of use)
106106
* agent : a http agent that can be used to set proxy settings for yggdrasil authentication (see proxy-agent on npm)
107+
* fakeHost : (optional) hostname to send to the server in the set_protocol packet
107108
* profilesFolder : optional
108109
* (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
109110
* (microsoft account) the path to store authentication caches, defaults to .minecraft
110111
* onMsaCode(data) : (optional) callback called when signing in with a microsoft account
111112
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)
113+
* id : a numeric client id used for referring to multiple clients in a server
112114

113115

114116
## mc.Client(isServer,version,[customPackets])
@@ -120,13 +122,37 @@ Takes a minecraft `version` as second argument.
120122

121123
write a packet
122124

125+
### client.writeRaw(buffer)
126+
127+
write a raw buffer as a packet
128+
123129
### client.end(reason, fullReason)
124130

125131
Ends the connection with `reason` or `fullReason`
126132
If `fullReason` is not defined, then the `reason` will be used.
127133

128134
`fullReason` is a JSON object, which represents [chat](https://wiki.vg/Chat) message.
129135

136+
### client.connect(port, host)
137+
138+
Used by the [Client Class](https://github.com/PrismarineJS/node-minecraft-protocol/blob/d9d01c8be4921bb38e7b59d9c18afd771615ba22/src/client.js) to connect to a server, done by createClient automatically
139+
140+
### client.setSocket(socket)
141+
142+
Sets the client's connection socket.
143+
144+
### client.registerChannel(name, typeDefinition, custom)
145+
146+
Registers a plugin channel with the given `name` and protodef `typeDefinition`
147+
148+
### client.unregisterChannel(name)
149+
150+
Unregisters a plugin channel.
151+
152+
### client.writeChannel(channel, params)
153+
154+
Write to [Plugin Channels](https://wiki.vg/Plugin_channels)
155+
130156
### client.state
131157

132158
The internal state that is used to figure out which protocol state we are in during
@@ -137,7 +163,6 @@ packet parsing. This is one of the protocol.states.
137163
True if this is a connection going from the server to the client,
138164
False if it is a connection from client to server.
139165

140-
141166
### client.socket
142167

143168
Returns the internal nodejs Socket used to communicate with this client.
@@ -163,24 +188,47 @@ The player's profile, as returned by the Yggdrasil system. (only server-side)
163188

164189
The latency of the client, in ms. Updated at each keep alive.
165190

191+
### client.customPackets
192+
193+
An object index by version/state/direction/name, see client_custom_packet for an example
194+
195+
### client.protocolVersion
196+
197+
The client's protocol version
198+
199+
### client.version
200+
201+
The client's version
202+
166203
### `packet` event
167204

168-
Called with every packet parsed. Takes three params, the JSON data we parsed,
169-
, the packet metadata (name, state) and the initial buffer
205+
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)
170206

171207
### `raw` event
172208

173209
Called with every packet, but as a buffer. Takes two params, the buffer
174210
and the packet metadata (name, state)
175211

212+
### `connect` event
213+
214+
when the socket connects to the server, this is emitted
215+
216+
### `end` event
217+
218+
Called when the client's connection is disconnected. Takes the reason as parameter
219+
220+
### `session` event
221+
222+
Called when user authentication is resolved. Takes session data as parameter.
223+
176224
### `state` event
177225

178226
Called when the protocol changes state. Takes the new state and old state as
179227
parameters.
180228

181-
### `session` event
229+
### `error` event
182230

183-
Called when user authentication is resolved. Takes session data as parameter.
231+
Called when an error occurs within the client. Takes an Error as parameter.
184232

185233
### per-packet events
186234

@@ -228,9 +276,9 @@ correct data type. You can figure out the types [here](http://wiki.vg/Entities#E
228276
## mc.ping(options, callback)
229277

230278
`options` is an object containing the following:
231-
* host : default too locahost
232-
* port : default too 25565
233-
* version: default too most recent version
279+
* host : default to localhost
280+
* port : default to 25565
281+
* version: default to most recent version
234282

235283
Ping a minecraft server and return a promise or use an optional callback containing the information about it
236284

docs/HISTORY.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,69 @@
11
# History
22

3+
## 1.29.0
4+
5+
* 1.18.0 support
6+
7+
## 1.28.1
8+
9+
* Fix microsoft auth error condition handling (@extremeheat)
10+
11+
## 1.28.0
12+
13+
* Fixed TypeScript error TS2769 when authenticating with mojang (#922) (@liquiddevelopmentnet)
14+
* Update prismarine-auth usage (#923) (@extremeheat)
15+
* types(Client): fix events (#918) (@muchnameless and Robert Hartmann)
16+
* add default for authTitle (#920) (@U5B)
17+
* Update ping function return type and make callback optional (#909) (@ShayBox)
18+
* Fixed typo's (#915) (@OscarNOW)
19+
* Add the ability to send a fake hostname in set_protocol (#913) (@GhqstMC and u9g)
20+
21+
## 1.27.2
22+
23+
* try again to enable prismarine-auth
24+
25+
## 1.27.1
26+
27+
* revert prismarine-auth usage for now (see https://github.com/panva/jose/issues/307)
28+
29+
## 1.27.0
30+
31+
* use prismarine-auth
32+
33+
## 1.26.6
34+
35+
* Lazily generate serverKey
36+
* Make all events have promiselike returns for async
37+
38+
## 1.26.5
39+
40+
* update Online Mode Exceptions
41+
42+
## 1.26.4
43+
44+
* add once to typescript types for all events
45+
46+
## 1.26.3
47+
48+
* fix typescript types
49+
50+
## 1.26.2
51+
52+
* fix typescript types
53+
54+
## 1.26.1
55+
56+
* temporarily revert prismarine-auth
57+
58+
## 1.26.0
59+
60+
* move microsoft auth to prismarine-auth (@Kashalls)
61+
* Add beforeLogin function option on server (@rob9315)
62+
* Make cache path creation recursive (@DecentralisedTech)
63+
* Mc.ping return a promise and use callbacks (@AngeryFrog)
64+
* Add a way to encode a packet only once and send it to multiple clients (@GroobleDierne)
65+
* launcher_accounts.json account corruption fix (@Moondarker)
66+
367
## 1.25.0
468

569
* add fullBuffer to packet event

docs/README.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Parse and serialize minecraft packets, plus authentication and encryption.
1313

1414
* Supports Minecraft PC version 1.7.10, 1.8.8, 1.9 (15w40b, 1.9, 1.9.1-pre2, 1.9.2, 1.9.4),
1515
1.10 (16w20a, 1.10-pre1, 1.10, 1.10.1, 1.10.2), 1.11 (16w35a, 1.11, 1.11.2), 1.12 (17w15a, 17w18b, 1.12-pre4, 1.12, 1.12.1, 1.12.2), and 1.13 (17w50a, 1.13, 1.13.1, 1.13.2-pre1, 1.13.2-pre2, 1.13.2), 1.14 (1.14, 1.14.1, 1.14.3, 1.14.4)
16-
, 1.15 (1.15, 1.15.1, 1.15.2) and 1.16 (20w13b, 20w14a, 1.16-rc1, 1.16, 1.16.1, 1.16.2, 1.16.3, 1.16.4), 1.17 (21w07a, 1.17)
16+
, 1.15 (1.15, 1.15.1, 1.15.2) and 1.16 (20w13b, 20w14a, 1.16-rc1, 1.16, 1.16.1, 1.16.2, 1.16.3, 1.16.4), 1.17 (21w07a, 1.17, 1.17.1), 1.18
1717
* Parses all packets and emits events with packet fields as JavaScript
1818
objects.
1919
* Send a packet by supplying fields as a JavaScript object.
@@ -44,15 +44,27 @@ node-minecraft-protocol is pluggable.
4444

4545
## Projects Using node-minecraft-protocol
4646

47-
* [mineflayer](https://github.com/PrismarineJS/mineflayer/) - create minecraft
47+
* [mineflayer](https://github.com/PrismarineJS/mineflayer/) - Create minecraft
4848
bots with a stable, high level API.
49-
* [mcserve](https://github.com/andrewrk/mcserve) - runs and monitors your
49+
* [mcserve](https://github.com/andrewrk/mcserve) - Runs and monitors your
5050
minecraft server, provides real-time web interface, allow your users to
5151
create bots.
52-
* [flying-squid](https://github.com/PrismarineJS/flying-squid) create minecraft
52+
* [flying-squid](https://github.com/PrismarineJS/flying-squid) - Create minecraft
5353
servers with a high level API, also a minecraft server by itself.
54-
* [pakkit](https://github.com/Heath123/pakkit) To monitor your packets
55-
* [minecraft-packet-debugger](https://github.com/wvffle/minecraft-packet-debugger) to easily debug your minecraft packets
54+
* [pakkit](https://github.com/Heath123/pakkit) - A GUI tool to monitor Minecraft packets in real time, allowing you to view their data and interactively edit and resend them
55+
* [minecraft-packet-debugger](https://github.com/wvffle/minecraft-packet-debugger) - A tool to capture Minecraft packets in a buffer then view them in a browser
56+
* [aresrpg](https://github.com/aresrpg/aresrpg) - An open-source mmorpg minecraft server
57+
* and [several thousands others](https://github.com/PrismarineJS/node-minecraft-protocol/network/dependents?package_id=UGFja2FnZS0xODEzMDk0OQ%3D%3D)
58+
59+
## Installation
60+
61+
`npm install minecraft-protocol`
62+
63+
## Documentation
64+
65+
* [API doc](API.md)
66+
* [faq](FAQ.md)
67+
* [protocol doc](https://minecraft-data.prismarine.js.org/?d=protocol) and [wiki.vg/Protocol](https://wiki.vg/Protocol)
5668

5769
## Usage
5870

@@ -135,16 +147,6 @@ server.on('login', function(client) {
135147
});
136148
```
137149

138-
## Installation
139-
140-
`npm install minecraft-protocol`
141-
142-
## Documentation
143-
144-
See [doc](API.md)
145-
See [faq](FAQ.md)
146-
147-
148150
## Testing
149151

150152
* Ensure your system has the `java` executable in `PATH`.

examples/client_electron/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"start": "electron ."
99
},
1010
"dependencies": {
11-
"electron": "^9.1.2",
11+
"electron": "^11.5.0",
1212
"electron-reload": "^1.5.0"
1313
}
1414
}

examples/client_microsoft_auth/client_microsoft_auth.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22

33
const mc = require('minecraft-protocol')
44

5-
if (process.argv.length < 4 || process.argv.length > 6) {
6-
console.log('Usage : node echo.js <host> <port> [<email>] [<password>]')
5+
const [,, host, port, userOrEmail, password] = process.argv
6+
if (!userOrEmail) {
7+
console.log('Usage : node client_microsoft_auth.js <host> <port> <username/email> [<password>]')
78
process.exit(1)
89
}
910

1011
const client = mc.createClient({
11-
host: process.argv[2],
12-
port: parseInt(process.argv[3]),
13-
username: process.argv[4], // your microsoft account email
14-
password: process.argv[5], // your microsoft account password
12+
host,
13+
port: parseInt(port),
14+
username: userOrEmail, // your microsoft account email
15+
password: password, // your microsoft account password
1516
auth: 'microsoft' // This option must be present and set to 'microsoft' to use Microsoft Account Authentication. Failure to do so will result in yggdrasil throwing invalid account information.
1617
})
1718

examples/server/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ server.on('login', function (client) {
2626
entityId: client.id,
2727
isHardcore: false,
2828
gameMode: 0,
29-
previousGameMode: 255,
29+
previousGameMode: 1,
3030
worldNames: loginPacket.worldNames,
3131
dimensionCodec: loginPacket.dimensionCodec,
3232
dimension: loginPacket.dimension,

examples/server_channel/server_channel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ server.on('login', function (client) {
1818
entityId: client.id,
1919
isHardcore: false,
2020
gameMode: 0,
21-
previousGameMode: 255,
21+
previousGameMode: 1,
2222
worldNames: loginPacket.worldNames,
2323
dimensionCodec: loginPacket.dimensionCodec,
2424
dimension: loginPacket.dimension,

examples/server_custom_channel/server_custom_channel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ server.on('login', function (client) {
1515
entityId: client.id,
1616
isHardcore: false,
1717
gameMode: 0,
18-
previousGameMode: 255,
18+
previousGameMode: 1,
1919
worldNames: loginPacket.worldNames,
2020
dimensionCodec: loginPacket.dimensionCodec,
2121
dimension: loginPacket.dimension,

examples/server_helloworld/server_helloworld.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ server.on('login', function (client) {
2626
entityId: client.id,
2727
isHardcore: false,
2828
gameMode: 0,
29-
previousGameMode: 255,
29+
previousGameMode: 1,
3030
worldNames: loginPacket.worldNames,
3131
dimensionCodec: loginPacket.dimensionCodec,
3232
dimension: loginPacket.dimension,

0 commit comments

Comments
 (0)