Skip to content

Commit ae67527

Browse files
committed
Get info
1 parent dfda6c2 commit ae67527

File tree

5 files changed

+26
-17
lines changed

5 files changed

+26
-17
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@carbonhost/typescript",
3-
"version": "0.0.45",
3+
"version": "0.0.46",
44
"main": "dist/index.js",
55
"module": "dist/index.mjs",
66
"types": "dist/index.d.ts",

src/managers/minecraft-manager.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
import type { AxiosInstance } from "axios";
3-
import type {CarbonStarStats} from "../types/stats";
3+
import type {CarbonPluginInfo, CarbonStarStats} from "../types/carbon-plugin";
44
import type {CarbonStar} from "../carbon-star";
55
import type {CarbonPluginCommandResponse} from "../carbon-plugin/types";
66

@@ -26,13 +26,7 @@ export class MinecraftManager {
2626
}).then((res) => res.data);
2727
}
2828

29-
// TODO: Make this ping the `/` endpoint
30-
async isCarbonPluginInstalled() {
31-
try {
32-
await this.axios.get("/commands?query=carbon");
33-
return true;
34-
} catch (e) {
35-
return false;
36-
}
29+
async getInfo() {
30+
return this.axios.get<CarbonPluginInfo>("/carbon-plugin").then((res) => res.data);
3731
}
3832
}

src/managers/stat-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
import type { AxiosInstance } from "axios";
33
import type {CarbonStar} from "../carbon-star";
4-
import type {CarbonStarStats} from "../types/stats";
4+
import type {CarbonStarStats} from "../types/carbon-plugin";
55

66
export class StatManager {
77
// @ts-ignore

src/types/carbon-plugin.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export interface CarbonStarStats {
2+
onlinePlayers: number
3+
ramUsage: number
4+
cpuUsage: number
5+
timestamp: Date
6+
}
7+
8+
export interface CarbonPluginInfo {
9+
tps: number
10+
mspt: number
11+
resources: {
12+
ramUsage: number
13+
ramTotal: number
14+
cpuUsage: number
15+
cpuCores: number
16+
}
17+
playerCountInfo: {
18+
onlinePlayers: number
19+
maxPlayers: number
20+
}
21+
}

src/types/stats.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)