mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2025-06-17 00:20:25 -04:00
server: ability to change motd and maxPlayers. closes #36
This commit is contained in:
parent
adc47b0f62
commit
2d5fda6635
1 changed files with 4 additions and 5 deletions
9
index.js
9
index.js
|
@ -25,20 +25,19 @@ function createServer(options) {
|
||||||
options['server-port'] != null ?
|
options['server-port'] != null ?
|
||||||
options['server-port'] :
|
options['server-port'] :
|
||||||
25565 ;
|
25565 ;
|
||||||
var maxPlayers = options['max-players'] || 20;
|
|
||||||
var host = options.host || '0.0.0.0';
|
var host = options.host || '0.0.0.0';
|
||||||
var kickTimeout = options.kickTimeout || 10 * 1000;
|
var kickTimeout = options.kickTimeout || 10 * 1000;
|
||||||
var checkTimeoutInterval = options.checkTimeoutInterval || 4 * 1000;
|
var checkTimeoutInterval = options.checkTimeoutInterval || 4 * 1000;
|
||||||
var motd = options.motd || "A Minecraft server";
|
|
||||||
var onlineMode = options['online-mode'] == null ? true : options['online-mode'];
|
var onlineMode = options['online-mode'] == null ? true : options['online-mode'];
|
||||||
var encryptionEnabled = options.encryption == null ? true : options.encryption;
|
var encryptionEnabled = options.encryption == null ? true : options.encryption;
|
||||||
|
|
||||||
var serverKey = ursa.generatePrivateKey(1024);
|
var serverKey = ursa.generatePrivateKey(1024);
|
||||||
|
|
||||||
var server = new Server(options);
|
var server = new Server(options);
|
||||||
|
server.motd = options.motd || "A Minecraft server";
|
||||||
|
server.maxPlayers = options['max-players'] || 20;
|
||||||
server.playerCount = 0;
|
server.playerCount = 0;
|
||||||
server.onlineModeExceptions = {};
|
server.onlineModeExceptions = {};
|
||||||
server.maxPlayers = maxPlayers;
|
|
||||||
server.on("connection", function(client) {
|
server.on("connection", function(client) {
|
||||||
client.once(0xfe, onPing);
|
client.once(0xfe, onPing);
|
||||||
client.once(0x02, onHandshake);
|
client.once(0x02, onHandshake);
|
||||||
|
@ -95,9 +94,9 @@ function createServer(options) {
|
||||||
'§1',
|
'§1',
|
||||||
protocol.version,
|
protocol.version,
|
||||||
protocol.minecraftVersion,
|
protocol.minecraftVersion,
|
||||||
motd,
|
server.motd,
|
||||||
server.playerCount,
|
server.playerCount,
|
||||||
maxPlayers,
|
server.maxPlayers,
|
||||||
].join('\u0000')
|
].join('\u0000')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue