Skip to content
This repository was archived by the owner on Aug 21, 2025. It is now read-only.

Commit 7557b0c

Browse files
committed
added pacifista server status service
1 parent 5ea2534 commit 7557b0c

File tree

5 files changed

+84
-3
lines changed

5 files changed

+84
-3
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": "@funixproductions/angular-core",
3-
"version": "0.2.5",
3+
"version": "0.2.6",
44
"description": "Package used in all FunixProductions Angular projects",
55
"scripts": {
66
"ng": "ng",

projects/funixproductions-requests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@funixproductions/funixproductions-requests",
3-
"version": "0.2.5",
3+
"version": "0.2.6",
44
"description": "Package used in all FunixProductions Angular projects",
55
"peerDependencies": {
66
"@angular/common": "^17.1.0",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
export class PacifistaServerInfoDTO {
2+
onlinePlayers: number;
3+
playerSlots: number;
4+
servers: ServerData[];
5+
6+
constructor(onlinePlayers: number,
7+
playerSlots: number,
8+
servers: ServerData[]) {
9+
this.onlinePlayers = onlinePlayers;
10+
this.playerSlots = playerSlots;
11+
this.servers = servers;
12+
}
13+
}
14+
15+
export class ServerData {
16+
name: string;
17+
isOnline: boolean;
18+
onlinePlayers: number;
19+
playerSlots: number;
20+
players: PacifistaServerPlayer[];
21+
22+
constructor(name: string,
23+
isOnline: boolean,
24+
onlinePlayers: number,
25+
playerSlots: number,
26+
players: PacifistaServerPlayer[]) {
27+
this.name = name;
28+
this.isOnline = isOnline;
29+
this.onlinePlayers = onlinePlayers;
30+
this.playerSlots = playerSlots;
31+
this.players = players;
32+
}
33+
}
34+
35+
export class PacifistaServerPlayer {
36+
name: string;
37+
uuid: string;
38+
39+
constructor(name: string, uuid: string) {
40+
this.name = name;
41+
this.uuid = uuid;
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import {HttpClient, HttpHeaders} from "@angular/common/http";
2+
import {environment} from "../../../../../../../environments/environment";
3+
import {environmentDev} from "../../../../../../../environments/environment-dev";
4+
import {Observable} from "rxjs";
5+
import {PacifistaServerInfoDTO} from "../dtos/PacifistaServerInfoDTO";
6+
7+
export class PacifistaServerInfoService {
8+
9+
private readonly domain: string;
10+
private readonly path: string = 'essentials/status';
11+
private readonly http: HttpClient;
12+
13+
constructor(httpClient: HttpClient, productionEnv: boolean) {
14+
this.http = httpClient;
15+
16+
if (productionEnv) {
17+
this.domain = environment.pacifistaApiUrl;
18+
} else {
19+
this.domain = environmentDev.pacifistaApiUrl;
20+
}
21+
}
22+
23+
public getStatus(): Observable<PacifistaServerInfoDTO> {
24+
return this.http.get<PacifistaServerInfoDTO>(this.domain + this.path, {
25+
headers: this.getHeaders()
26+
});
27+
}
28+
29+
private getHeaders(): HttpHeaders {
30+
return new HttpHeaders({
31+
'Content-Type': 'application/json'
32+
});
33+
}
34+
35+
}

projects/funixproductions-requests/src/public-api.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,7 @@ export * from './lib/services/pacifista-api/web/user/services/PacifistaWebUserLi
8888
export * from './lib/services/pacifista-api/web/vote/dtos/VoteDTO';
8989
export * from './lib/services/pacifista-api/web/vote/dtos/VoteWebsiteDTO';
9090
export * from './lib/services/pacifista-api/web/vote/dtos/VotesCountDTO';
91-
export * from './lib/services/pacifista-api/web/vote/services/VoteService';
91+
export * from './lib/services/pacifista-api/web/vote/services/VoteService';
92+
93+
export * from './lib/services/pacifista-api/server/essentials/status/dtos/PacifistaServerInfoDTO';
94+
export * from './lib/services/pacifista-api/server/essentials/status/services/PacifistaServerInfoService';

0 commit comments

Comments
 (0)