Content Migration from websites repo
This commit is contained in:
parent
f6eb9794a9
commit
f58a45df06
24 changed files with 7575 additions and 1 deletions
81
pages/1_18_2.tsx
Normal file
81
pages/1_18_2.tsx
Normal file
|
@ -0,0 +1,81 @@
|
|||
import Head from 'next/head'
|
||||
import styles from '/styles/Server.module.css'
|
||||
import Link from 'next/link'
|
||||
import { Mod, ServerData, Details } from '../interfaces/ServerType';
|
||||
import * as mcutil from 'minecraft-server-util'
|
||||
|
||||
function Server_1_18_2(props: ServerData) {
|
||||
const mods = props.server.mods
|
||||
const address = props.server.url + ":" + String(props.server.port)
|
||||
const info = props.server.status
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>1.18.2 Server</title>
|
||||
<meta name="description" content="Minecraft Server running Version 1.18.2" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<link rel="stylesheet" media="screen" href="https://fontlibrary.org//face/minecraftia" type="text/css" />
|
||||
</Head>
|
||||
<h1 className={styles.title}>1.18.2 Server</h1>
|
||||
<p className={styles.description}>{address}</p>
|
||||
<div className={styles.card}>
|
||||
<h2>Mod & Version info</h2>
|
||||
{mods.map((item: Mod) => (
|
||||
<Link key={item.name} href={item.href}>
|
||||
<a className={styles.link}>{item.name} Version: {item.version}</a>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
<div className={styles.card}>
|
||||
<h2>Status: <a className={props.server.status.online == "Online" ? styles.online : styles.offline}>{props.server.status.online}</a></h2>
|
||||
<>
|
||||
{
|
||||
() => {
|
||||
if (info.error != null) {
|
||||
return
|
||||
}
|
||||
else {
|
||||
let data = info.data
|
||||
return (
|
||||
<>
|
||||
<p>Players: {data.players.online}/{data.players.max}</p>
|
||||
<p>Players currently online:
|
||||
{data.players.sample !== null
|
||||
? data.players.sample.map((player: any, index: any) => <span key={index}>{(index ? ', ' : ' ') + player.name}</span>)
|
||||
: <span> -</span>}</p>
|
||||
</>
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
</>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export const getServerSideProps: any = async () => {
|
||||
const res = await fetch('https://minecraft.neshura-server.net/api/servers')
|
||||
const data = await res.json()
|
||||
const options = {
|
||||
timeout: 1000 * 5, //timeout in multiples of 1000ms
|
||||
enableSRV: true
|
||||
}
|
||||
if (data) {
|
||||
const sdata = await mcutil.status(data.v1182.url, data.v1182.port, options)
|
||||
.then((result) => result)
|
||||
.catch((error) => error)
|
||||
if (sdata.players != null) {
|
||||
const serverData = { "data": sdata, "online": "Online" }
|
||||
const server = { "mods": data.v1182.mods, "status": serverData, "url": data.v1182.url, "port": data.v1182.port }
|
||||
return { props: { server } }
|
||||
}
|
||||
else {
|
||||
const serverData = { "error": JSON.stringify(sdata), "online": "Offline" }
|
||||
const server = { "mods": data.v1182.mods, "status": serverData, "url": data.v1182.url, "port": data.v1182.port }
|
||||
return { props: { server } }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default Server_1_18_2;
|
14
pages/_app.tsx
Executable file
14
pages/_app.tsx
Executable file
|
@ -0,0 +1,14 @@
|
|||
import '/styles/globals.css'
|
||||
import Layout from '../components/layout'
|
||||
import { AppProps } from 'next/app'
|
||||
|
||||
function MyApp({ Component, pageProps }: AppProps) {
|
||||
|
||||
return (
|
||||
<Layout>
|
||||
<Component {...pageProps} />
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
|
||||
export default MyApp
|
15
pages/api/navbar.tsx
Normal file
15
pages/api/navbar.tsx
Normal file
|
@ -0,0 +1,15 @@
|
|||
import fsPromises from 'fs/promises'
|
||||
import path from 'path'
|
||||
|
||||
export default async function Navbar(req: any, res: any) {
|
||||
try {
|
||||
const filePath = path.join(process.cwd(), '/confs/navbar.json')
|
||||
const jsonData = await fsPromises.readFile(filePath)
|
||||
const data = JSON.parse(jsonData.toString())
|
||||
res.status(200).json(data)
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error)
|
||||
res.status(500).json({error: 'Error reading data'})
|
||||
}
|
||||
}
|
15
pages/api/servers.tsx
Normal file
15
pages/api/servers.tsx
Normal file
|
@ -0,0 +1,15 @@
|
|||
import fsPromises from 'fs/promises'
|
||||
import path from 'path'
|
||||
|
||||
export default async function Servers(req: any, res: any) {
|
||||
try {
|
||||
const filePath = path.join(process.cwd(), '/confs/servers.json')
|
||||
const jsonData = await fsPromises.readFile(filePath)
|
||||
const data = JSON.parse(jsonData.toString())
|
||||
res.status(200).json(data)
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error)
|
||||
res.status(500).json({error: 'Error reading data'})
|
||||
}
|
||||
}
|
54
pages/index.tsx
Executable file
54
pages/index.tsx
Executable file
|
@ -0,0 +1,54 @@
|
|||
import Head from 'next/head'
|
||||
import styles from '/styles/Home.module.css'
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>Create Next App</title>
|
||||
<meta name="description" content="Generated by create next app" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<link rel="stylesheet" media="screen" href="https://fontlibrary.org//face/minecraftia" type="text/css"/>
|
||||
</Head>
|
||||
|
||||
<h1 className={styles.title}>
|
||||
Welcome to <a href="https://nextjs.org">Next.js!</a>
|
||||
</h1>
|
||||
|
||||
<p className={styles.description}>
|
||||
Get started by editing{' '}
|
||||
<code className={styles.code}>pages/index.js</code>
|
||||
</p>
|
||||
|
||||
<div className={styles.grid}>
|
||||
<a href="https://nextjs.org/docs" className={styles.card}>
|
||||
<h2>Documentation →</h2>
|
||||
<p>Find in-depth information about Next.js features and API.</p>
|
||||
</a>
|
||||
|
||||
<a href="https://nextjs.org/learn" className={styles.card}>
|
||||
<h2>Learn →</h2>
|
||||
<p>Learn about Next.js in an interactive course with quizzes!</p>
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="https://github.com/vercel/next.js/tree/canary/examples"
|
||||
className={styles.card}
|
||||
>
|
||||
<h2>Examples →</h2>
|
||||
<p>Discover and deploy boilerplate example Next.js projects.</p>
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
|
||||
className={styles.card}
|
||||
>
|
||||
<h2>Deploy →</h2>
|
||||
<p>
|
||||
Instantly deploy your Next.js site to a public URL with Vercel.
|
||||
</p>
|
||||
</a>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue