Display some basic stats on web

This commit is contained in:
2021-04-26 02:37:43 +00:00
parent 963b3d9736
commit 33145cb3f2
5 changed files with 63 additions and 3 deletions

View File

@@ -1,7 +1,51 @@
import React, { useState, useEffect } from 'react';
import axios from 'axios';
axios.defaults.baseURL = 'http://minecraft-bot.dns.t0.vc';
function App() {
const [global, setGlobal] = useState(false);
useEffect(() => {
const get = async() => {
try {
const res = await axios.get('/api/global');
setGlobal(res.data);
} catch (error) {
setGlobal(false);
}
};
const interval = setInterval(get, 500);
return () => clearInterval(interval);
}, []);
return (
<div className="app">
<p>Hello world</p>
{global &&
<>
<p>Name: {global.name}</p>
<p>Pos: {global.pos}</p>
<p>Yaw: {global.yaw}</p>
<p>Pitch: {global.pitch}</p>
<p>Dimention: {global.dimension}</p>
<p>Players:
{Object.values(global.players).map(x =>
<div>
{global.player_names[x.player_uuid]}
</div>
)}
</p>
<p>Holding: {global.holding}</p>
<p>AFK: {`${global.afk}`}</p>
<p>Health: {global.health}</p>
<p>Food: {global.food}</p>
<p>Time: {global.time}</p>
</>
}
</div>
);
}