Pin Minecraft 26.3 and add safe Orion managed deployment support
This commit is contained in:
1 parent
dff2b5a9c4
commit
008120dbad
40 files changed
+1877
-490
No files matched your search
@@ -1,3 +1,5 @@
|
||||
import { assertDeploymentEditable } from "@/server/managed";
|
||||
import { withServerOperation } from "@/server/operation";
|
||||
import { NextRequest } from "next/server";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
@@ -18,7 +20,8 @@ export async function GET() {
|
||||
|
||||
/** Danger zone: archive the current world and generate a fresh one. */
|
||||
export async function POST(req: NextRequest) {
|
||||
return handle(async () => {
|
||||
return handle(() => withServerOperation(async () => {
|
||||
assertDeploymentEditable();
|
||||
const { op, confirm } = await readJson<{ op?: string; confirm?: string }>(req);
|
||||
if (op !== "reset") return fail("Unknown operation");
|
||||
if (confirm !== "reset the world") return fail('Type "reset the world" to confirm');
|
||||
@@ -27,6 +30,8 @@ export async function POST(req: NextRequest) {
|
||||
if (!fs.existsSync(worldDir)) return fail("No world folder found");
|
||||
|
||||
await safetyBackup("world reset");
|
||||
const backup = await inspectContainer(env.backupContainer);
|
||||
if (backup.running) await powerContainer(env.backupContainer, "stop");
|
||||
const state = await inspectContainer(env.mcContainer);
|
||||
if (state.running) await powerContainer(env.mcContainer, "stop");
|
||||
|
||||
@@ -34,8 +39,9 @@ export async function POST(req: NextRequest) {
|
||||
fs.renameSync(worldDir, path.join(env.mcDataDir, archived));
|
||||
|
||||
await powerContainer(env.mcContainer, "start");
|
||||
if (backup.running) await powerContainer(env.backupContainer, "start");
|
||||
logActivity("world_reset", null, `old world kept as ${archived}`);
|
||||
notify("warn", "World reset", `A fresh world is generating. Old world kept as ${archived}.`);
|
||||
return ok({ archived });
|
||||
});
|
||||
}));
|
||||
}
|
||||
Reference in new issue
Block a user