Create proxies for Minecraft
Install the package:
$ npm install @minecraft-js/proxies
And then import it in your JavaScript/TypeScript file
const Proxies = require('@minecraft-js/proxies'); // CommonJS
import * as Proxies from '@minecraft-js/proxies'; // ES6
Read only proxies are proxies where you can only read packets. Create a read only proxy like so
const proxy = new Proxies.ReadOnlyProxy({
serverHostname: 'localhost', // Target server hostname
port: 8080, // Proxy port
});
And then you can use the ReadOnlyProxy#on
method to listen for different events:
raw_listening
- When the TCP server is listeningraw_connect
- When a client opens a connectionraw_disconnect
- When a client closes a connectionraw_close
- When the TCP server is closederror
- When an error occursoutgoing_data
- When data is sent to the target serverincoming_data
- When data is received from the target server
If you are using TypeScript or you want type checking make sure to install the typed-emitter
package!
$ npm install typed-emitter