diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..3b66410 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "git.ignoreLimitWarning": true +} \ No newline at end of file diff --git a/i18n.json b/i18n.json index 9881460..d3d78c3 100644 --- a/i18n.json +++ b/i18n.json @@ -8,6 +8,7 @@ "/status": ["status", "common"], "/house": ["house", "common"], "/tos": ["tos", "common"], - "/hcunews": ["hcunews", "common"] + "/hcunews": ["hcunews", "common"], + "/minecraft": ["minecraft", "common"] } } \ No newline at end of file diff --git a/locales/en/minecraft.json b/locales/en/minecraft.json new file mode 100644 index 0000000..e9545b9 --- /dev/null +++ b/locales/en/minecraft.json @@ -0,0 +1,5 @@ +{ + "title": "Minecraft Multiplayer", + "playing": "{{count}} player(s) online.", + "no_one": "No one is playing." +} \ No newline at end of file diff --git a/locales/ja/minecraft.json b/locales/ja/minecraft.json new file mode 100644 index 0000000..30ac2e4 --- /dev/null +++ b/locales/ja/minecraft.json @@ -0,0 +1,5 @@ +{ + "title": "Minecraft マルチプレイ", + "playing": "{{count}} 人がプレイしています。", + "no_one": "現在、誰もログインしていません。" +} \ No newline at end of file diff --git a/pages/components/Minecraft.js b/pages/components/Minecraft.js new file mode 100644 index 0000000..fff4b84 --- /dev/null +++ b/pages/components/Minecraft.js @@ -0,0 +1,47 @@ +import React, { useState, useEffect } from 'react'; +import useTranslation from 'next-translate/useTranslation' +import { useRouter } from 'next/router' +import axios from 'axios'; + +export default function Minecraft(props) { + const router = useRouter() + const { locale, locales, defaultLocale, pathname } = router + const { t, lang } = useTranslation("minecraft") + + const [dataMinecraft, setDataMinecraft] = useState({ hits: [] }); + const [data, setData] = useState({ hits: [] }); + + useEffect(() => { + const fetchData = async () => { + const result = await axios( + 'https://mcapi.us/server/status?ip=yude.jp', + ); + setData(result.data); + }; + fetchData(); + }, []); + + if (data === undefined){ + console.log("[Minecraft Query] データの取得に失敗しました。 / Failed to retrieve data.") + console.log(data) + return ( +

Failed to retrieve data

+ ) + }else{ + console.log(data) + const player = data.players && data.players.now + const playing = t('minecraft:playing', {count: player}) + const no_one = t('minecraft:no_one') + return ( +

+ {(() => { + if (player == 0) { + return {no_one} + } else { + return {playing} + } + })()} +

+ ) + } +} \ No newline at end of file diff --git a/pages/minecraft.js b/pages/minecraft.js new file mode 100644 index 0000000..5bbc7a4 --- /dev/null +++ b/pages/minecraft.js @@ -0,0 +1,31 @@ +import React, { useState, useEffect } from 'react'; +import Layout from "./components/Layout" +import useTranslation from 'next-translate/useTranslation' +import { useRouter } from 'next/router' +import Minecraft from './components/Minecraft' +import Image from 'next/image' + +export default function About(props) { + const router = useRouter() + const { locale, locales, defaultLocale, pathname } = router + const { t, lang } = useTranslation("minecraft") + const title = t('title') + + return ( + +
+

{title}

+
+ Dynmap Header +
+ +
+
+ ) +} \ No newline at end of file diff --git a/public/static/images/dynmap.png b/public/static/images/dynmap.png new file mode 100644 index 0000000..a2f640b Binary files /dev/null and b/public/static/images/dynmap.png differ