import React, { useState, useEffect } from 'react'; import useTranslation from 'next-translate/useTranslation' import { useRouter } from 'next/router' import axios from 'axios'; import Image from 'next/image' import { list } from 'postcss'; export default function Minecraft(props) { const [data, setData] = useState({ hits: [] }); useEffect(() => { const fetchData = async () => { const result = await axios( 'https://api.mcsrvstat.us/2/yude.jp', ); setData(result.data); }; fetchData(); }, []); if (data === undefined){ console.log("[Minecraft Query] データの取得に失敗しました。 / Failed to retrieve data.") return (

{t('minecraft:fail')}

) }else{ const status = data.online const player = data.players && data.players.online return (
{(() => { if (status == true) { if (player == undefined || player == 0) { return {t('minecraft:no_one')} } else { return {t('minecraft:playing', {count: player})} }}else if (status == false) { return {t('minecraft:offline')} }else { return {t('minecraft:loading')} } })()} {(() => { if (data.players && data.players.list){ var list = []; var url = []; for (var i in data.players.list){ url.push('https://mc-heads.net/avatar/' + data.players.list[i]) } for (var i in url){ list.push({i}/) } return
{list}
} })()}
) } }