@lazy/rcon
v0.5.0
Published
## Quick start
Downloads
7
Readme
@lazy/rcon
Quick start
npm i @lazy/rconRaw rcon commands
import { createConnection } from 'node:net'
import { createRconClient } from '@lazy/rcon'
const rcon = createRconClient(createConnection, {
host: 'localhost',
port: 25575,
password: 'password',
})
console.log(await rcon.$exec('whitelist add notch')) // Added Notch to the whitelist
rcon.$disconnect()Structured rcon commands
import { createConnection } from 'node:net'
import { createRconClient, minecraft } from '@lazy/rcon'
const rcon = createRconClient(
createConnection,
{
host: 'localhost',
port: 25575,
password: 'password',
},
minecraft,
)
console.log(await rcon.whitelistAdd({ player: 'notch' })) // { status: 'player_added' }
rcon.$disconnect()Custom rcon commands
import { createConnection } from 'node:net'
import { createRconClient } from '@lazy/rcon'
const rcon = createRconClient(
createConnection,
{
host: 'localhost',
port: 25575,
password: 'password',
},
{
whitelistAdd: {
request: {
body: 'whitelist add {player}',
params: {
player: {
type: 'string',
},
},
},
response: [
{
body: 'Added {player} to the whitelist',
params: {
status: {
const: 'player_added',
},
},
},
{
body: 'Player is already whitelisted',
params: {
status: {
const: 'player_already_added',
},
},
},
{
body: 'That player does not exist',
params: {
status: {
const: 'player_not_found',
},
},
},
],
},
},
)
console.log(await rcon.whitelistAdd({ player: 'notch' })) // { status: 'player_added' }
rcon.$disconnect()React native
import { createRconClient } from '@lazy/rcon'
import TcpSocket from 'react-native-tcp-socket'
const rcon = createRconClient((options) => TcpSocket.createConnection(options, () => {}), {
host: 'localhost',
port: 25575,
password: 'password',
})