Fixed error related to getting playerCount

This commit is contained in:
Daniel Vestøl committed 2018-11-17 16:09:46 +01:00
1 parent ce13ad50e0
commit 9b6f8cf652
2 files changed
+8 -4

No files matched your search

+7 -3
View File
@@ -591,10 +591,10 @@ async function instanceManagement(instanceconfig) {
// require plugin class and execute it
let pluginClass = require(path.resolve(pluginConfig.pluginPath, "index.js"));
plugins[i] = new pluginClass(combinedConfig, async function(data, callback){
if(data.toString('utf8')[0] != "/") {
if(data && data.toString('utf8')[0] != "/") {
log(data.toString('utf8'));
return true;
} else {
} else if (data && data.toString('utf8')[0] == "/"){
return messageInterface(data.toString('utf8'), callback);
}
}, { // extra functions to pass in object. Should have done it like this from the start, but won't break backwards compat.
@@ -670,7 +670,11 @@ async function instanceManagement(instanceconfig) {
publicIP: config.publicIP, // IP of the server should be global for all instances, so we pull that straight from the config
mods:modHashes,
instanceName: instance,
playerCount:playerCount.replace(/(\r\n\t|\n|\r\t)/gm, ""),
}
if(playerCount){
payload.playerCount = playerCount.replace(/(\r\n\t|\n|\r\t)/gm, "");
} else {
payload.playerCount = 0;
}
function callback(err, mac) {
+1 -1
View File
@@ -50,7 +50,7 @@
"mkdirp-promise": "^5.0.1",
"moment": "^2.22.2",
"ncp": "^2.0.0",
"needle": "^2.2.1",
"needle": "^2.2.4",
"node-factorio-api": "^0.3.1-alpha",
"node-forge": "^0.7.1",
"prom-client": "^10.2.3",