ModAPI.isServer

This commit is contained in:
ZXMushroom63 2025-05-30 17:06:15 +08:00
parent 658107fe14
commit 734db357cf
2 changed files with 4 additions and 1 deletions

View File

@ -27,6 +27,7 @@ const modapi_postinit = "(" + (() => {
ModAPI.meta._developerMap = {};
ModAPI.meta._iconMap = {};
ModAPI.meta._versionMap = {};
ModAPI.isServer = false;
const credits = {};
ModAPI.addCredit = function (category, name, contents) {
if (!credits[category]) {
@ -980,7 +981,7 @@ const modapi_postinit = "(" + (() => {
inlineIntegratedServerStartup = ModAPI.hooks._rippedMethodKeys.filter(key => { return key.startsWith(inlineIntegratedServerStartup); })[0];
const inlineIntegratedServerStartupMethod = ModAPI.hooks.methods[inlineIntegratedServerStartup];
ModAPI.hooks.methods[inlineIntegratedServerStartup] = function (worker, bootstrap) {
var x = inlineIntegratedServerStartupMethod.apply(this, [worker, bootstrap + ";" + globalThis.modapi_postinit + ";" + ModAPI.dedicatedServer._data.join(";")]);
var x = inlineIntegratedServerStartupMethod.apply(this, [worker, bootstrap + ";" + globalThis.modapi_postinit + ";ModAPI.isServer=true;" + ModAPI.dedicatedServer._data.join(";")]);
ModAPI.dedicatedServer._data = [];
ModAPI.dedicatedServer._wasUsed = true;
console.log("[ModAPI] Hooked into inline integrated server.");

View File

@ -83,6 +83,8 @@ The global object has the following properties:
- The version of ModAPI.
- `ModAPI.is_1_12: Boolean`
- Property defining wether or not ModAPI thinks the current version is 1.12-based.
- `ModAPI.isServer: Boolean`
- Property defining wether or not ModAPI thinks it is running on the dedicated server.
- `ModAPI.flavour: String`
- The flavour of ModAPI. Hardcoded to be `"injector"`.