Changed usage of globals, worked around edge cases

This commit is contained in:
danielv authored and Daniel committed 2021-07-12 22:05:54 +02:00
1 parent f9ef2ebbe1
commit 98f801e244
11 files changed
+124 -62

No files matched your search

+4 -3
View File
@@ -1,5 +1,5 @@
"use strict";
const fs = require("fs").promises;
const fs = require("fs-extra");
const path = require("path");
const libPlugin = require("@clusterio/lib/plugin");
@@ -50,7 +50,8 @@ class MasterPlugin extends libPlugin.BaseMasterPlugin {
this.logger.verbose(`Downloading inventory for ${message.data.player_name}`);
return {
player_name: message.data.player_name,
inventory: this.inventories[message.data.player_name],
inventory: this.inventories[message.data.player_name] || {},
new_player: !this.inventories[message.data.player_name],
};
}
@@ -63,7 +64,7 @@ class MasterPlugin extends libPlugin.BaseMasterPlugin {
let inventories = Object.keys(this.inventories)
.map(name => ({
name,
length: this.inventories[name].length,
length: JSON.stringify(this.inventories[name]).length,
}))
.sort((a, b) => a.stringified.length - b.stringified.length);
return {