mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-11-27 17:55:45 -05:00
Compare commits
5 commits
93178ba379
...
742fcbf512
Author | SHA1 | Date | |
---|---|---|---|
|
742fcbf512 | ||
|
590dc33fed | ||
|
89de052d44 | ||
|
5bebac3662 | ||
|
6a15f4a0c6 |
10 changed files with 55 additions and 8 deletions
|
@ -151,6 +151,7 @@ Returns a `Client` instance and perform login.
|
|||
* realmId : The id of the Realm to join.
|
||||
* pickRealm(realms) : A function which will have an array of the user Realms (joined/owned) passed to it. The function should return a Realm.
|
||||
* 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.
|
||||
* onLoginPluginRequest(packet, meta) : (optional) callback that is called when a `login_plugin_request` packet is received. When this option is defined and of type function then the callback is called and expected to write a `login_plugin_response` packet on client with at least `messageId: packet.messageId` in the payload. If no login_plugin_response is send the connection will halt. When the `onLoginPluginRequest` option is not defined or not of type function then a login_plugin_response packet with `messageId: packet.messageId` and no data is send.
|
||||
|
||||
|
||||
## mc.Client(isServer,version,[customPackets])
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
# History
|
||||
|
||||
## 1.50.0
|
||||
* [1.21 Support (#1342)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/5bebac36620d8f8ec256d19483e20e643d63de2a) (thanks @GroobleDierne)
|
||||
|
||||
## 1.49.0
|
||||
* [support 1.20.6 (#1338)](https://github.com/PrismarineJS/node-minecraft-protocol/commit/0b0012d60f0f1648be5ff705e7694bb1cd4ec37c) (thanks @rom1504)
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ Parse and serialize minecraft packets, plus authentication and encryption.
|
|||
|
||||
* 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),
|
||||
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)
|
||||
, 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.16.5), 1.17 (21w07a, 1.17, 1.17.1), 1.18 (1.18, 1.18.1 and 1.18.2), 1.19 (1.19, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.20, 1.20.1, 1.20.2, 1.20.3, 1.20.4, 1.20.5, 1.20.6)
|
||||
, 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.16.5), 1.17 (21w07a, 1.17, 1.17.1), 1.18 (1.18, 1.18.1 and 1.18.2), 1.19 (1.19, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.20, 1.20.1, 1.20.2, 1.20.3, 1.20.4, 1.20.5, 1.20.6, 1.21.1)
|
||||
* Parses all packets and emits events with packet fields as JavaScript
|
||||
objects.
|
||||
* Send a packet by supplying fields as a JavaScript object.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "minecraft-protocol",
|
||||
"version": "1.49.0",
|
||||
"version": "1.50.0",
|
||||
"description": "Parse and serialize minecraft packets, plus authentication and encryption.",
|
||||
"main": "src/index.js",
|
||||
"types": "src/index.d.ts",
|
||||
|
@ -33,7 +33,7 @@
|
|||
},
|
||||
"browser": "src/browser.js",
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.2.1",
|
||||
"@types/node": "^22.7.9",
|
||||
"espower-loader": "^1.0.0",
|
||||
"intelli-espower-loader": "^1.0.0",
|
||||
"minecraft-packets": "^1.1.5",
|
||||
|
@ -52,7 +52,7 @@
|
|||
"endian-toggle": "^0.0.0",
|
||||
"lodash.get": "^4.1.2",
|
||||
"lodash.merge": "^4.3.0",
|
||||
"minecraft-data": "^3.75.0",
|
||||
"minecraft-data": "^3.78.0",
|
||||
"minecraft-folder-path": "^1.2.0",
|
||||
"node-fetch": "^2.6.1",
|
||||
"node-rsa": "^0.4.2",
|
||||
|
|
|
@ -18,7 +18,13 @@ module.exports = function (client, options) {
|
|||
|
||||
const above385 = mcdata.version.version >= 385
|
||||
if (above385) { // 1.13-pre3 (385) added Added Login Plugin Message (https://wiki.vg/Protocol_History#1.13-pre3)
|
||||
client.on('login_plugin_request', onLoginPluginRequest)
|
||||
client.on('login_plugin_request', (...args) => {
|
||||
if (options.onLoginPluginRequest != null && typeof options.onLoginPluginRequest === 'function') {
|
||||
options.onLoginPluginRequest(...args)
|
||||
} else {
|
||||
onLoginPluginRequest(...args)
|
||||
}
|
||||
})
|
||||
}
|
||||
const channelNames = above385 ? ['minecraft:register', 'minecraft:unregister'] : ['REGISTER', 'UNREGISTER']
|
||||
|
||||
|
|
1
src/index.d.ts
vendored
1
src/index.d.ts
vendored
|
@ -154,6 +154,7 @@ declare module 'minecraft-protocol' {
|
|||
disableChatSigning?: boolean
|
||||
/** Pass custom client implementation if needed. */
|
||||
Client?: Client
|
||||
onLoginPluginRequest?: (packet: any, meta: any, ...args: any[]) => void
|
||||
}
|
||||
|
||||
export class Server extends EventEmitter {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
defaultVersion: '1.20.6',
|
||||
supportedVersions: ['1.7', '1.8.8', '1.9.4', '1.10.2', '1.11.2', '1.12.2', '1.13.2', '1.14.4', '1.15.2', '1.16.5', '1.17.1', '1.18.2', '1.19', '1.19.2', '1.19.3', '1.19.4', '1.20', '1.20.1', '1.20.2', '1.20.4', '1.20.6']
|
||||
defaultVersion: '1.21.1',
|
||||
supportedVersions: ['1.7', '1.8.8', '1.9.4', '1.10.2', '1.11.2', '1.12.2', '1.13.2', '1.14.4', '1.15.2', '1.16.5', '1.17.1', '1.18.2', '1.19', '1.19.2', '1.19.3', '1.19.4', '1.20', '1.20.1', '1.20.2', '1.20.4', '1.20.6', '1.21.1']
|
||||
}
|
||||
|
|
|
@ -284,6 +284,36 @@ for (const supportedVersion of mc.supportedVersions) {
|
|||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('sends a valid login_plugin_request packet', function (done) {
|
||||
const onLoginPluginRequest = function (packet) {
|
||||
client.write('login_plugin_response', {
|
||||
messageId: packet.messageId,
|
||||
data: Buffer.from('Hallo from nmp')
|
||||
})
|
||||
}
|
||||
const client = mc.createClient({
|
||||
username: 'Player',
|
||||
version: version.minecraftVersion,
|
||||
port: PORT,
|
||||
onLoginPluginRequest: onLoginPluginRequest
|
||||
})
|
||||
client.on('error', err => done(err))
|
||||
client.on('login', function () {
|
||||
client.write('login_plugin_request', {
|
||||
messageId: 0,
|
||||
channel: 'minecraft:brand',
|
||||
data: Buffer.from([0x00])
|
||||
})
|
||||
})
|
||||
client.on('login_plugin_response', function (packet) {
|
||||
assert.strictEqual(packet.messageId, 0)
|
||||
assert.strictEqual(!!packet.data)
|
||||
console.info('Client send in plugin response: ' + packet.data.toString())
|
||||
client.end()
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe.skip('online', function () {
|
||||
|
|
|
@ -135,6 +135,9 @@ const values = {
|
|||
delete results['..']
|
||||
return results
|
||||
},
|
||||
vec2f: {
|
||||
x: 0, y: 0
|
||||
},
|
||||
vec3f: {
|
||||
x: 0, y: 0, z: 0
|
||||
},
|
||||
|
@ -153,6 +156,9 @@ const values = {
|
|||
SlotComponent: {
|
||||
type: 'hide_tooltip'
|
||||
},
|
||||
ChatTypes: {
|
||||
registryIndex: 1
|
||||
},
|
||||
SlotComponentType: 0,
|
||||
nbt: nbtValue,
|
||||
optionalNbt: nbtValue,
|
||||
|
|
|
@ -83,7 +83,7 @@ for (const supportedVersion of mc.supportedVersions) {
|
|||
plainMessage: message,
|
||||
signedChatContent: '',
|
||||
unsignedChatContent: JSON.stringify({ text: message }),
|
||||
type: 0,
|
||||
type: mcData.supportFeature('incrementedChatType') ? { registryIndex: 1 } : 0,
|
||||
senderUuid: 'd3527a0b-bc03-45d5-a878-2aafdd8c8a43', // random
|
||||
senderName: JSON.stringify({ text: sender }),
|
||||
senderTeam: undefined,
|
||||
|
|
Loading…
Reference in a new issue