From 5657c64aa6085c6fe04fedb1e7c96f304e041691 Mon Sep 17 00:00:00 2001 From: Big Bad Waffle Date: Sun, 10 Mar 2019 19:40:11 +0200 Subject: [PATCH] fixed old io.set invocations to point to async versions --- .../components/extensions/socialCommands.js | 60 ++++++++++--------- src/server/fixes/fixes.js | 11 ++-- src/server/index.js | 15 +++-- src/server/world/customMap.js | 11 ++-- 4 files changed, 51 insertions(+), 46 deletions(-) diff --git a/src/server/components/extensions/socialCommands.js b/src/server/components/extensions/socialCommands.js index 023f764f..af999ba9 100644 --- a/src/server/components/extensions/socialCommands.js +++ b/src/server/components/extensions/socialCommands.js @@ -98,7 +98,7 @@ module.exports = { }, //actions - join: function (value) { + join: async function (value) { if (typeof (value) !== 'string') return; @@ -143,10 +143,11 @@ module.exports = { channels.push(value); let charname = obj.auth.charname; - io.set({ - ent: charname, - field: 'customChannels', - value: JSON.stringify(channels) + await io.setAsync({ + key: charname, + table: 'customChannels', + value: channels, + serialize: true }); obj.socket.emit('events', { @@ -165,7 +166,7 @@ module.exports = { }); }, - leave: function (value) { + leave: async function (value) { if (typeof (value) !== 'string') return; @@ -189,10 +190,11 @@ module.exports = { channels.spliceWhere(c => (c === value)); let charname = obj.auth.charname; - io.set({ - ent: charname, - field: 'customChannels', - value: JSON.stringify(channels) + await io.setAsync({ + key: charname, + table: 'customChannels', + value: channels, + serialize: true }); obj.socket.emit('event', { @@ -270,11 +272,11 @@ module.exports = { }); }, - mute: function (target, reason) { + mute: async function (target, reason = null) { if (typeof (target) === 'object') { let keys = Object.keys(target); target = keys[0]; - reason = keys[1]; + reason = keys[1] || null; } if (target === this.obj.name) @@ -309,23 +311,24 @@ module.exports = { }] }); - io.set({ - ent: new Date(), - field: 'modLog', - value: JSON.stringify({ + await io.setAsync({ + key: new Date(), + table: 'modLog', + value: { source: this.obj.name, command: 'mute', target: target, reason: reason - }) + }, + serialize: true }); }, - unmute: function (target, reason) { + unmute: async function (target, reason = null) { if (typeof (target) === 'object') { let keys = Object.keys(target); target = keys[0]; - reason = keys[1]; + reason = keys[1] || null; } if (target === this.obj.name) @@ -360,15 +363,16 @@ module.exports = { }] }); - io.set({ - ent: new Date(), - field: 'modLog', - value: JSON.stringify({ + await io.setAsync({ + key: new Date(), + table: 'modLog', + value: { source: this.obj.name, command: 'unmute', target: target, reason: reason - }) + }, + serialize: true }); }, @@ -562,14 +566,14 @@ module.exports = { }, 1, this.obj); }, - setPassword: function (config) { + setPassword: async function (config) { let keys = Object.keys(config); let username = keys[0]; let hashedPassword = keys[1]; - io.set({ - ent: username, - field: 'login', + await io.setAsync({ + key: username, + table: 'login', value: hashedPassword }); }, diff --git a/src/server/fixes/fixes.js b/src/server/fixes/fixes.js index 5bbd87fe..4d73dafc 100644 --- a/src/server/fixes/fixes.js +++ b/src/server/fixes/fixes.js @@ -114,15 +114,16 @@ module.exports = { }); }, - fixSkins: function (username, skins) { + fixSkins: async function (username, skins) { let length = skins.length; skins = skins.filter(s => !!configSkins.getBlueprint(s)); if (length !== skins.length) { - io.set({ - ent: username, - field: 'skins', - value: JSON.stringify(skins) + await io.setAsync({ + key: username, + table: 'skins', + value: skins, + serialize: true }); } } diff --git a/src/server/index.js b/src/server/index.js index 242553a5..c84902f8 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -59,21 +59,20 @@ let startup = { sheets.init(); }, - onError: function (e) { + onError: async function (e) { if (e.toString().indexOf('ERR_IPC_CHANNEL_CLOSED') > -1) return; _.log('Error Logged: ' + e.toString()); _.log(e.stack); - io.set({ - ent: new Date(), - field: 'error', - value: e.toString() + ' | ' + e.stack.toString(), - callback: function () { - process.exit(); - } + await io.setAsync({ + key: new Date(), + table: 'error', + value: e.toString() + ' | ' + e.stack.toString() }); + + process.exit(); } }; diff --git a/src/server/world/customMap.js b/src/server/world/customMap.js index 132ad3fb..8362d861 100644 --- a/src/server/world/customMap.js +++ b/src/server/world/customMap.js @@ -21,11 +21,12 @@ module.exports = { this.build(callback); }, - save: function () { - io.set({ - ent: this.ent, - field: 'customMap', - value: JSON.stringify(this.tiles) + save: async function () { + await io.setAsync({ + key: this.ent, + table: 'customMap', + value: this.tiles, + serialize: true }); },