mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-13 18:21:51 +00:00
Minor adjustments
This commit is contained in:
parent
0dac336670
commit
ce0c2c4977
@ -391,11 +391,11 @@ export class ModInterface {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {typeof Object} classHandle
|
||||
* @param {Object} obj
|
||||
* @param {({ $super, $old }) => any} extender
|
||||
*/
|
||||
extendClass(classHandle, extender) {
|
||||
const prototype = classHandle.prototype;
|
||||
extendObject(obj, extender) {
|
||||
const prototype = obj.prototype;
|
||||
|
||||
const $super = Object.getPrototypeOf(prototype);
|
||||
const $old = {};
|
||||
@ -409,4 +409,13 @@ export class ModInterface {
|
||||
prototype[propertyName] = extensionMethods[propertyName];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {typeof Object} classHandle
|
||||
* @param {({ $super, $old }) => any} extender
|
||||
*/
|
||||
extendClass(classHandle, extender) {
|
||||
this.extendObject(classHandle.prototype, extender);
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,6 +121,9 @@ export class ModLoader {
|
||||
}
|
||||
|
||||
window.$shapez_registerMod = (modClass, meta) => {
|
||||
if (this.initialized) {
|
||||
throw new Error("Can't register mod after modloader is initialized");
|
||||
}
|
||||
if (this.modLoadQueue.some(entry => entry.meta.id === meta.id)) {
|
||||
console.warn("Not registering mod", meta, "since a mod with the same id is already loaded");
|
||||
return;
|
||||
@ -151,8 +154,6 @@ export class ModLoader {
|
||||
|
||||
delete window.$shapez_registerMod;
|
||||
|
||||
this.initialized = true;
|
||||
|
||||
for (let i = 0; i < this.modLoadQueue.length; i++) {
|
||||
const { modClass, meta } = this.modLoadQueue[i];
|
||||
const modDataFile = "modsettings_" + meta.id + "__" + meta.version + ".json";
|
||||
@ -190,6 +191,7 @@ export class ModLoader {
|
||||
}
|
||||
|
||||
this.modLoadQueue = [];
|
||||
this.initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user