Initial commit

This commit is contained in:
2026-08-24 22:20:36 +02:00
commit 62f7b1278a
251 changed files with 16670 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
const Game = require("../../../Game/Game");
const MaintenanceScheduledPacket = require("../../../Packets/MaintenanceScheduled");
const isAuthenticated = require("../../../Utility/isAuthenticated");
module.exports = async (res, req) => {
res.onAborted(() => res.isAborted = true);
const maintenanceTimeSeconds = req.getQuery("time");
const timestamp = req.getQuery("timestamp");
const hasPermission = await isAuthenticated(res, req);
if (!hasPermission) return;
if (!Game.listeningServer) return res.cork(() => res.writeStatus("400").end("Server is offline!"));
if (!maintenanceTimeSeconds) return res.cork(() => res.writeStatus("400").end("No approximate time was provided!"));
if (!timestamp) return res.cork(() => res.writeStatus("400").end("No timestamp was provided!"));
const parsedTimestamp = parseInt(timestamp);
if (parsedTimestamp < Date.now()) return res.cork(() => res.writeStatus("400").end("Incorrect timestamp was provided!"));
const event = {
fn: Game.disconnectAll.bind(Game),
arguments: []
};
Game.eventsFixed.add(parsedTimestamp, event);
const packet = MaintenanceScheduledPacket({
timestamp: parsedTimestamp / 1000,
timeSeconds: maintenanceTimeSeconds
});
Game.maps.forEach(map => app.publish(map.id.toString(), packet, true, true));
res.cork(() => res
.writeStatus("200")
.end("Shutdown has been scheduled!"));
};
+20
View File
@@ -0,0 +1,20 @@
const Game = require("../../../Game/Game");
const isAuthenticated = require("../../../Utility/isAuthenticated");
module.exports = async (res, req) => {
res.onAborted(() => res.isAborted = true);
const state = req.getQuery("state");
const hasPermission = await isAuthenticated(res, req);
if (!hasPermission) return;
if (!state) return res.cork(() => res.writeStatus("400").end("Missing new game state!"));
Game.state = parseInt(state);
res.cork(() => res
.writeStatus("200")
.end(`New game state is set to be ${state}`));
};