1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-16 11:41:50 +00:00
tobspr_shapez.io/src/js/mods/mod.js

51 lines
1.2 KiB
JavaScript
Raw Normal View History

2022-01-13 20:20:42 +00:00
/* typehints:start */
import { ModInterface } from "./mod_interface";
/* typehints:end */
export class Mod {
/**
*
* @param {object} metadata
* @param {string} metadata.name
* @param {string} metadata.version
* @param {string} metadata.authorName
* @param {string} metadata.authorContact
* @param {string} metadata.id
*/
constructor(metadata) {
this.metadata = metadata;
/**
* @type {ModInterface}
*/
this.interface = undefined;
}
hook_init() {}
executeGuarded(taskName, task) {
try {
return task();
} catch (ex) {
console.error(ex);
alert(
"Mod " +
this.metadata.name +
" (version " +
this.metadata.version +
")" +
" failed to execute '" +
taskName +
"':\n\n" +
ex +
"\n\nPlease forward this to the mod author:\n\n" +
this.metadata.authorName +
" (" +
this.metadata.authorContact +
")"
);
throw ex;
}
}
}