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 ( <> 1.18.2 Server

1.18.2 Server

{address}

Mod & Version info

{mods.map((item: Mod) => ( {item.name} Version: {item.version} ))}

Status: {props.server.status.online}

<> { () => { if (info.error != null) { return } else { let data = info.data return ( <>

Players: {data.players.online}/{data.players.max}

Players currently online: {data.players.sample !== null ? data.players.sample.map((player: any, index: any) => {(index ? ', ' : ' ') + player.name}) : -}

) } } }
) } 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;