fix: 捕捉 & 插件

This commit is contained in:
unanmed 2024-03-03 10:01:21 +08:00
parent 284a16757b
commit b1a28b6b3d
3 changed files with 15 additions and 10 deletions

View File

@ -325,10 +325,10 @@ core.prototype._loadPluginAsync = async function () {
plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1
)) { )) {
try { try {
value.call(plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1); value?.call(plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1);
} catch (e) { } catch (e) {
console.error(`Plugin '${key}' init fail. `); console.error(`Plugin '${key}' init failed.`);
throw e; console.error(e);
} }
} }
}; };

View File

@ -1063,9 +1063,9 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = {
if (v.x === x + dx * 2 && v.y === y + dy * 2) { if (v.x === x + dx * 2 && v.y === y + dy * 2) {
const loc = `${x + dx},${y + dy}`; const loc = `${x + dx},${y + dy}`;
this.setMapDamage(damage, loc, 0); this.setMapDamage(damage, loc, 0);
}
damage[loc].ambush = damage[loc].ambush ?? []; damage[loc].ambush = damage[loc].ambush ?? [];
damage[loc].ambush.push(this); damage[loc].ambush.push(this);
}
}); });
} }
} }

View File

@ -385,12 +385,17 @@ class MPlugin {
static init() { static init() {
for (const [key, data] of Object.entries(this.plugins)) { for (const [key, data] of Object.entries(this.plugins)) {
try {
if (data.type === 'content') { if (data.type === 'content') {
data.init?.(key, data.data); data.init?.(key, data.data);
} else { } else {
data.data = data.init!(key); data.data = data.init!(key);
} }
this.pluginData[key] = data.data; this.pluginData[key] = data.data;
} catch (e) {
console.error(`Plugin ${key} init failed.`);
console.error(e);
}
} }
this.inited = true; this.inited = true;
} }