server state and stdio streaming
This commit is contained in:
@@ -9,7 +9,7 @@ export default function Error404() {
|
||||
<div class="container w-full">
|
||||
<div class="max-w-screen-md mx-auto flex flex-col items-center justify-center">
|
||||
<img
|
||||
class="my-6"
|
||||
class="my-6 rounded-3xl"
|
||||
src="/bearcam.gif"
|
||||
alt="a gif of a bear playing with the camera"
|
||||
/>
|
||||
|
@@ -7,7 +7,7 @@ export default function App({ Component }: AppProps) {
|
||||
<head>
|
||||
<meta charSet="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="shortcut icon" href="cyborggrizzly.svg" type="image/svg" />
|
||||
<link rel="shortcut icon" href="/cyborggrizzly.svg" type="image/svg" />
|
||||
<title>MC GRIZZ</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link
|
||||
@@ -24,9 +24,9 @@ export default function App({ Component }: AppProps) {
|
||||
</head>
|
||||
<body>
|
||||
<div class="flex h-[100vh]">
|
||||
<div class="h-full min-w-[400px] bg-licorice overflow-y-auto border-r-2 p-4 dark:border-sky-950 border-sky text-white flex flex-col">
|
||||
<div class="relative h-full min-w-[400px] bg-licorice overflow-y-auto border-r-2 p-4 dark:border-sky-950 border-sky text-white flex flex-col">
|
||||
<div class="flex items-center justify-center p-4 gap-4 mb-8 rounded-3xl bg-smoke-900 border border-sky-950">
|
||||
<img src="cyborggrizzly.svg" alt="" height={100} width={100} />
|
||||
<img src="/cyborggrizzly.svg" alt="" height={100} width={100} />
|
||||
<div>
|
||||
<h1 class="text-4xl font-pixel">MC Grizz</h1>
|
||||
<hr class="color-sky" />
|
||||
@@ -36,11 +36,11 @@ export default function App({ Component }: AppProps) {
|
||||
|
||||
<Nav />
|
||||
|
||||
<small class="mt-auto text-center">
|
||||
Made with love by Emma@Cyborggrizzly 🏳️⚧️❤️
|
||||
</small>
|
||||
<div class="w-full text-center absolute bottom-4 left-0 whitespace-nowrap">
|
||||
<small>Made with love by Emma@Cyborggrizzly 🏳️⚧️❤️</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="max-h-full flex-1">
|
||||
<div class="max-h-full flex-1 overflow-auto">
|
||||
<Component />
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -1,21 +0,0 @@
|
||||
import { HandlerContext } from "$fresh/server.ts";
|
||||
|
||||
// Jokes courtesy of https://punsandoneliners.com/randomness/programmer-jokes/
|
||||
const JOKES = [
|
||||
"Why do Java developers often wear glasses? They can't C#.",
|
||||
"A SQL query walks into a bar, goes up to two tables and says “can I join you?”",
|
||||
"Wasn't hard to crack Forrest Gump's password. 1forrest1.",
|
||||
"I love pressing the F5 key. It's refreshing.",
|
||||
"Called IT support and a chap from Australia came to fix my network connection. I asked “Do you come from a LAN down under?”",
|
||||
"There are 10 types of people in the world. Those who understand binary and those who don't.",
|
||||
"Why are assembly programmers often wet? They work below C level.",
|
||||
"My favourite computer based band is the Black IPs.",
|
||||
"What programme do you use to predict the music tastes of former US presidential candidates? An Al Gore Rhythm.",
|
||||
"An SEO expert walked into a bar, pub, inn, tavern, hostelry, public house.",
|
||||
];
|
||||
|
||||
export const handler = (_req: Request, _ctx: HandlerContext): Response => {
|
||||
const randomIndex = Math.floor(Math.random() * JOKES.length);
|
||||
const body = JOKES[randomIndex];
|
||||
return new Response(body);
|
||||
};
|
1
routes/api/terminal.ts
Normal file
1
routes/api/terminal.ts
Normal file
@@ -0,0 +1 @@
|
||||
// const
|
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