use name to identify servers not ip
All checks were successful
Publish Docker Image / docker (push) Successful in 43s

This commit is contained in:
Lee 2024-01-03 08:27:33 +00:00
parent 56a75560e8
commit 8826a2530a
5 changed files with 16 additions and 49 deletions

3
.gitignore vendored
View File

@ -229,5 +229,4 @@ data/db.sqlite-shm
data/db.sqlite-wal
data/database-backups
data/config.json
data/servers.json
data/config.json

View File

@ -2,73 +2,61 @@
{
"name": "WildPrison",
"ip": "wildprison.net",
"type": "PC",
"id": 0
"type": "PC"
},
{
"name": "Hypixel",
"ip": "mc.hypixel.net",
"type": "PC",
"id": 1
"type": "PC"
},
{
"name": "CubeCraft",
"name": "Cubecraft",
"ip": "play.cubecraft.net",
"type": "PC",
"id": 2
"type": "PC"
},
{
"name": "Mineplex",
"ip": "mineplex.com",
"type": "PC",
"id": 3
"type": "PC"
},
{
"name": "2b2t",
"ip": "2b2t.org",
"type": "PC",
"id": 4
"type": "PC"
},
{
"name": "AkumaMC",
"ip": "akumamc.net",
"type": "PC",
"id": 5
"type": "PC"
},
{
"name": "Wynncraft",
"ip": "play.wynncraft.com",
"type": "PC",
"id": 6
"type": "PC"
},
{
"name": "Minehut",
"ip": "minehut.com",
"type": "PC",
"id": 7
"type": "PC"
},
{
"name": "Grand Theft Minecraft",
"ip": "gtm.network",
"type": "PC",
"id": 8
"type": "PC"
},
{
"name": "HiveMC",
"ip": "geo.hivebedrock.network",
"type": "PE",
"id": 9
"type": "PE"
},
{
"name": "Purple Prison",
"ip": "MCSL.PURPLE.WTF",
"type": "PC",
"id": 10
"type": "PC"
},
{
"name": "MinecraftOnline",
"ip": "minecraftonline.com",
"type": "PC",
"id": 11
"type": "PC"
}
]

View File

@ -20,7 +20,6 @@ export enum ServerStatus {
}
type ServerOptions = {
id: number;
name: string;
ip: string;
port?: number;
@ -33,11 +32,6 @@ type DnsInfo = {
};
export default class Server {
/**
* The ID of the server.
*/
private id: number;
/**
* The name of the server.
*/
@ -71,8 +65,7 @@ export default class Server {
hasResolved: false,
};
constructor({ id, name, ip, port, type }: ServerOptions) {
this.id = id;
constructor({ name, ip, port, type }: ServerOptions) {
this.name = name;
this.ip = ip;
this.port = port;
@ -106,7 +99,7 @@ export default class Server {
try {
influx.writePoint(
new Point("playerCount")
.tag("id", this.getID().toString())
.tag("name", this.getName())
.tag("ip", this.getIP().toLowerCase())
.intField("playerCount", response.playerCount)
.timestamp(response.timestamp)
@ -163,7 +156,6 @@ export default class Server {
this.favicon = res.favicon; // Set the favicon
resolve({
id: this.getID(),
timestamp: Date.now(),
ip: ip,
playerCount: res.players.online,
@ -189,7 +181,6 @@ export default class Server {
}
resolve({
id: this.getID(),
timestamp: Date.now(),
ip: this.getIP(),
playerCount: res.currentPlayers,
@ -199,15 +190,6 @@ export default class Server {
});
}
/**
* Returns the ID of the server.
*
* @returns the ID
*/
public getID(): number {
return this.id;
}
/**
* Returns the name of the server.
*

View File

@ -15,7 +15,6 @@ export default class ServerManager {
logger.info("Loading servers");
for (const configServer of Servers) {
const server = new Server({
id: configServer.id,
ip: configServer.ip,
name: configServer.name,
type: configServer.type as ServerType,

View File

@ -1,5 +1,4 @@
export type Ping = {
id: number;
timestamp: number;
ip: string;
playerCount: number;