diff --git a/public/libs/core.js b/public/libs/core.js index 236013a..87b5fef 100644 --- a/public/libs/core.js +++ b/public/libs/core.js @@ -325,10 +325,10 @@ core.prototype._loadPluginAsync = async function () { plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 )) { try { - value.call(plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1); + value?.call(plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1); } catch (e) { - console.error(`Plugin '${key}' init fail. `); - throw e; + console.error(`Plugin '${key}' init failed.`); + console.error(e); } } }; diff --git a/public/project/plugins.js b/public/project/plugins.js index bc3eaa1..3c9abd9 100644 --- a/public/project/plugins.js +++ b/public/project/plugins.js @@ -1063,9 +1063,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = { if (v.x === x + dx * 2 && v.y === y + dy * 2) { const loc = `${x + dx},${y + dy}`; this.setMapDamage(damage, loc, 0); + damage[loc].ambush = damage[loc].ambush ?? []; + damage[loc].ambush.push(this); } - damage[loc].ambush = damage[loc].ambush ?? []; - damage[loc].ambush.push(this); }); } } diff --git a/src/game/system.ts b/src/game/system.ts index fbf00bc..5d3ef8f 100644 --- a/src/game/system.ts +++ b/src/game/system.ts @@ -385,12 +385,17 @@ class MPlugin { static init() { for (const [key, data] of Object.entries(this.plugins)) { - if (data.type === 'content') { - data.init?.(key, data.data); - } else { - data.data = data.init!(key); + try { + if (data.type === 'content') { + data.init?.(key, data.data); + } else { + data.data = data.init!(key); + } + this.pluginData[key] = data.data; + } catch (e) { + console.error(`Plugin ${key} init failed.`); + console.error(e); } - this.pluginData[key] = data.data; } this.inited = true; }