-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.js
More file actions
41 lines (34 loc) · 1.12 KB
/
index.js
File metadata and controls
41 lines (34 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'use strict';
const pmp = require('pocket-minecraft-protocol');
const EventEmitter = require('events').EventEmitter;
const path = require('path');
const requireIndex = require('requireindex');
function createPEServer(options) {
options = options || {};
if(options.name == undefined) {
options.name = 'Minecraft: PE Server';
}
const peServer = new PEServer();
options.name = 'MCPE;' + options.name + ';70 70;0.14.3;0;' + options['max-players'];
peServer.connect(options);
return peServer;
}
class PEServer extends EventEmitter {
constructor() {
super();
this._server = null;
}
connect(options) {
const plugins = requireIndex(path.join(__dirname, 'lib', 'plugins'));
this._server = pmp.createServer(options);
Object.keys(plugins)
.filter(pluginName => plugins[pluginName].server!=undefined)
.forEach(pluginName => plugins[pluginName].server(this, options));
this._server.on('error', error => this.emit('error',error));
//this._server.on('listening', () => this.emit('listening',this._server.port));
this.emit('asap');
}
}
module.exports = {
createPEServer:createPEServer
};