mirror of
https://github.com/yude-jp/yude.jp
synced 2024-12-22 20:20:09 +09:00
Change API source, Add server address
This commit is contained in:
parent
3400be0357
commit
b532bb04d3
@ -1,5 +1,7 @@
|
||||
{
|
||||
"title": "Minecraft Multiplayer",
|
||||
"playing": "{{count}} player(s) online.",
|
||||
"no_one": "No one is playing."
|
||||
"no_one": "No one is playing.",
|
||||
"offline": "Server is down.",
|
||||
"address": "Server address"
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
{
|
||||
"title": "Minecraft マルチプレイ",
|
||||
"playing": "{{count}} 人がプレイしています。",
|
||||
"no_one": "現在、誰もログインしていません。"
|
||||
"no_one": "現在、誰もログインしていません。",
|
||||
"offline": "サーバーがオフラインのようです。",
|
||||
"address": "サーバー アドレス"
|
||||
}
|
@ -14,7 +14,7 @@ export default function Minecraft(props) {
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
const result = await axios(
|
||||
'https://mcapi.us/server/status?ip=yude.jp',
|
||||
'https://eu.mc-api.net/v3/server/ping/yude.jp',
|
||||
);
|
||||
setData(result.data);
|
||||
};
|
||||
@ -29,16 +29,21 @@ export default function Minecraft(props) {
|
||||
)
|
||||
}else{
|
||||
console.log(data)
|
||||
const status = data.online
|
||||
const player = data.players && data.players.now
|
||||
const playing = t('minecraft:playing', {count: player})
|
||||
const no_one = t('minecraft:no_one')
|
||||
const offline = t('minecraft:offline')
|
||||
return (
|
||||
<p className="text-center">
|
||||
{(() => {
|
||||
if (player == 0) {
|
||||
if (status) {
|
||||
if (player == undefined) {
|
||||
return <span>{no_one}</span>
|
||||
} else {
|
||||
return <span>{playing}</span>
|
||||
}}else{
|
||||
return <span>{offline}</span>
|
||||
}
|
||||
})()}
|
||||
</p>
|
||||
|
@ -10,7 +10,7 @@ export default function About(props) {
|
||||
const { locale, locales, defaultLocale, pathname } = router
|
||||
const { t, lang } = useTranslation("minecraft")
|
||||
const title = t('title')
|
||||
|
||||
const address = t('address')
|
||||
return (
|
||||
<Layout title={title}>
|
||||
<div>
|
||||
@ -25,6 +25,7 @@ export default function About(props) {
|
||||
/>
|
||||
</div>
|
||||
<Minecraft />
|
||||
<p className="text-center">{address}: <code>yude.jp</code></p>
|
||||
</div>
|
||||
</Layout>
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user