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
)) {
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);
}
}
};

View File

@ -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);
});
}
}

View File

@ -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;
}