mirror of
https://github.com/danbulant/flying-squid
synced 2026-07-05 11:10:44 +00:00
Added configuration
This commit is contained in:
parent
133b5040d4
commit
5ce8a0ea0a
3 changed files with 19 additions and 7 deletions
|
|
@ -7,6 +7,7 @@ Minecraft Server
|
||||||
A semi-functional minecraft server in Node.js
|
A semi-functional minecraft server in Node.js
|
||||||
|
|
||||||
## Building / Running
|
## Building / Running
|
||||||
|
Before running or building it is recommended that you configure the server in config/settings.json
|
||||||
|
|
||||||
npm install
|
npm install
|
||||||
node app.js
|
node app.js
|
||||||
|
|
|
||||||
18
app.js
18
app.js
|
|
@ -1,14 +1,15 @@
|
||||||
var mc = require('minecraft-protocol');
|
var mc = require('minecraft-protocol');
|
||||||
var states = mc.states;
|
var states = mc.states;
|
||||||
|
var settings = require('./config/settings');
|
||||||
var World = require('./world/world');
|
var World = require('./world/world');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var timeStarted = Math.floor(new Date() / 1000).toString();
|
var timeStarted = Math.floor(new Date() / 1000).toString();
|
||||||
|
|
||||||
var options = {
|
var options = {
|
||||||
motd: 'Minecraft Server',
|
motd: settings.motd,
|
||||||
'max-players': 20,
|
'max-players': settings.maxPlayers,
|
||||||
port: 25565,
|
port: settings.port,
|
||||||
'online-mode': true,
|
'online-mode': settings.onlineMode,
|
||||||
reducedDebugInfo: false
|
reducedDebugInfo: false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -21,7 +22,9 @@ for (var x = 0; x < 16;x++) {
|
||||||
|
|
||||||
var server = mc.createServer(options);
|
var server = mc.createServer(options);
|
||||||
|
|
||||||
createLog();
|
if(settings.logging == true) {
|
||||||
|
createLog();
|
||||||
|
}
|
||||||
|
|
||||||
server.on('login', function(client) {
|
server.on('login', function(client) {
|
||||||
|
|
||||||
|
|
@ -141,8 +144,9 @@ function createLog() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function log(message) {
|
function log(message) {
|
||||||
fs.appendFile("logs/" + timeStarted + ".log", message + "\n", function (err) {
|
if(settings.logging == true) {
|
||||||
});
|
fs.appendFile("logs/" + timeStarted + ".log", message + "\n", function (err) { });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function broadcast(message, exclude, username) {
|
function broadcast(message, exclude, username) {
|
||||||
|
|
|
||||||
7
config/settings.json
Normal file
7
config/settings.json
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"motd": "A Minecraft Server",
|
||||||
|
"port": 25565,
|
||||||
|
"maxPlayers": 10,
|
||||||
|
"onlineMode": true,
|
||||||
|
"logging": true
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue