server state and stdio streaming
This commit is contained in:
48
routes/setup/eula.tsx
Normal file
48
routes/setup/eula.tsx
Normal file
@@ -0,0 +1,48 @@
|
||||
import { Handlers, PageProps } from "$fresh/server.ts";
|
||||
import { Button } from "../../components/Button.tsx";
|
||||
import { Content } from "../../components/Content.tsx";
|
||||
import { SERVER_STATE } from "../../state/serverState.ts";
|
||||
|
||||
export const handler: Handlers = {
|
||||
async POST(req, _ctx) {
|
||||
const url = new URL(req.url);
|
||||
SERVER_STATE.acceptEULA();
|
||||
return Response.redirect(url.origin + '/setup/start');
|
||||
}
|
||||
};
|
||||
|
||||
export default async function EULA({url}: PageProps) {
|
||||
// TODO: this does not respect instances and needs to once they are supported
|
||||
const eulaText = await Deno.readTextFileSync("./server/eula.txt");
|
||||
|
||||
return (
|
||||
<div class="container p-8">
|
||||
<Content>
|
||||
<h2 class="text-2xl font-pixel">Minecraft EULA</h2>
|
||||
<p>
|
||||
This page is provided as a courtesy. The text below is the contents of
|
||||
"eula.txt," a file that is generated by the server the first time it
|
||||
runs. In order to run the server, you must agree to the EULA by
|
||||
changing "false" to "true."
|
||||
</p>
|
||||
<p>
|
||||
To make this easier, there is a button below. The one and only action
|
||||
this button takes is to change the value in the text file to true,
|
||||
this is not an agreement between you and CyborgGrizzly Games.
|
||||
</p>
|
||||
<p>
|
||||
If you are unsure of the contents of the EULA, you are encouraged to
|
||||
read it by following the link in the text file.
|
||||
</p>
|
||||
<pre class="p-2 bg-smoke-500 rounded-lg">{eulaText}</pre>
|
||||
<div class="mt-8 w-full">
|
||||
<form action={url.pathname} method="post">
|
||||
<Button class="ml-auto text-right block" type="submit">
|
||||
Accept EULA
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
</Content>
|
||||
</div>
|
||||
);
|
||||
}
|
22
routes/setup/fabric.tsx
Normal file
22
routes/setup/fabric.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Content } from "../../components/Content.tsx";
|
||||
import { FabricVersions } from "../../islands/fabricVersions.tsx";
|
||||
import { initFabric } from "../../util/initFabric.ts";
|
||||
|
||||
export default function FabricSetup() {
|
||||
try {
|
||||
const vers = Deno.readDirSync("./fabric/versions");
|
||||
if (Array.from(vers).length !== 3) throw "";
|
||||
} catch {
|
||||
initFabric();
|
||||
}
|
||||
|
||||
return (
|
||||
<div class="container p-8">
|
||||
<Content>
|
||||
<h2 class="font-pixel text-2xl">Fabric Setup</h2>
|
||||
<p>Select the game version you wish to create a server for. If you know you need a different loader and installer version, you can change it here.</p>
|
||||
<FabricVersions />
|
||||
</Content>
|
||||
</div>
|
||||
);
|
||||
}
|
@@ -10,13 +10,13 @@ export default function Setup() {
|
||||
|
||||
<div class="m-auto flex gap-4 mt-4">
|
||||
<a href="/setup/vanilla">
|
||||
<Button>Vanilla</Button>
|
||||
<Button href="/setup/vanilla">Vanilla</Button>
|
||||
</a>
|
||||
<a href="/setup/fabric">
|
||||
<Button>Fabric</Button>
|
||||
<Button href="/setup/fabric">Fabric</Button>
|
||||
</a>
|
||||
<a href="/setup/forge">
|
||||
<Button>Forge</Button>
|
||||
<Button href="/setup/forge">Forge</Button>
|
||||
</a>
|
||||
</div>
|
||||
</Content>
|
||||
|
27
routes/setup/start.tsx
Normal file
27
routes/setup/start.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Handlers } from "$fresh/server.ts";
|
||||
import { Content } from "../../components/Content.tsx";
|
||||
import { Terminal } from "../../islands/terminal.tsx";
|
||||
import { SERVER_STATE } from "../../state/serverState.ts";
|
||||
|
||||
export const handler: Handlers = {
|
||||
async GET(req,ctx) {
|
||||
if (!SERVER_STATE.eulaAccepted) {
|
||||
const url = new URL(req.url);
|
||||
return Response.redirect(`${url.origin}/setup/eula`)
|
||||
}
|
||||
|
||||
const res = await ctx.render();
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
export default function StartFabric() {
|
||||
SERVER_STATE.startMCServer();
|
||||
return (
|
||||
<div class="container p-8">
|
||||
<Content>
|
||||
<Terminal channelId={SERVER_STATE.channelId} />
|
||||
</Content>
|
||||
</div>
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user