sync worldstate opnly if change worldstate config
All checks were successful
Build / build (pull_request) Successful in 1m58s

This commit is contained in:
2025-11-04 17:18:56 +01:00
parent 24c9baf363
commit 2be93f1b54

View File

@@ -21,12 +21,14 @@ export const getConfigController: RequestHandler = async (req, res) => {
export const setConfigController: RequestHandler = async (req, res) => {
const account = await getAccountForRequest(req);
if (isAdministrator(account)) {
let isWorldStateUpdate = false;
for (const [id, value] of Object.entries(req.body as Record<string, boolean | string | number>)) {
if (id.startsWith("worldState")) isWorldStateUpdate = true;
const [obj, idx] = configIdToIndexable(id);
obj[idx] = value;
}
sendWsBroadcastEx({ config_reloaded: true }, undefined, parseInt(String(req.query.wsid)));
sendWsBroadcast({ sync_world_state: true });
if (isWorldStateUpdate) sendWsBroadcast({ sync_world_state: true });
syncConfigWithDatabase();
await saveConfig();
res.end();