-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1bd1144
commit 04f33e4
Showing
12 changed files
with
147 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
import fs from "node:fs"; | ||
let files = fs.readdirSync("src/packets"); | ||
files = files.filter(f => { | ||
if(fs.statSync("src/packets/" + f).isDirectory()) return false; | ||
return true; | ||
}); | ||
let shareTextData = `// Do not touch this file, it is automatically changed.\nexport default ${JSON.stringify(files.map(f => f.replace(".ts", "")))} as const`; | ||
fs.writeFileSync("../Share/Packets.ts", shareTextData); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { OurClient, Packet, ServerPacketResponse } from "../index.js"; | ||
import { servers } from "../db.js"; | ||
import serverManager, { userHasAccessToServer } from "../serverManager.js"; | ||
import { Permission, hasServerPermission } from "../../../Share/Permission.js"; | ||
import { Request } from "../../../Share/Requests.js"; | ||
|
||
import IntegratorInstall from "./integrator/IntegratorInstall.js" | ||
import serverIntegrator from "../serverIntegrator.js"; | ||
|
||
export default class IntegratorPacket extends Packet { | ||
name: Request = "integrator"; | ||
requiresAuth: boolean = true; | ||
async handle(client: OurClient, data: any): ServerPacketResponse<"integrator"> { | ||
const server = await servers.findById(data.id); | ||
if(!server || !userHasAccessToServer(client.data.auth.user, server.toJSON())) return "Server not found!"; | ||
switch(data.action) { | ||
case "install": | ||
if(!hasServerPermission(client.data.auth.user, server.toJSON(), "integrator.install")) return "You can't do that!"; | ||
return await IntegratorInstall(server.toJSON(), client, data); | ||
case "status": | ||
const status = await serverIntegrator.request(server.toJSON(), "status"); | ||
return { | ||
type: "status", | ||
status | ||
} | ||
} | ||
return; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { OurClient } from "../.."; | ||
import { Server } from "../../../../Share/Server"; | ||
import fs from "node:fs/promises"; | ||
import { buildInfo } from "../../../../Share/BuildInfo.js"; | ||
import { integratorJarPath } from "../../serverIntegrator.js"; | ||
import logger from "../../logger.js"; | ||
|
||
export default async function install(server: Server, client: OurClient, data: any): Promise<{type: "install-success"}> { | ||
logger.log(`${client.data.auth.user?.username} is installing the BurgerPanel integrator on server ${server.name}`, "server.integrator"); | ||
await fs.copyFile(integratorJarPath, server.path + `/plugins/BurgerPanelIntegrator-${buildInfo.version}.jar`); | ||
return { | ||
type: "install-success" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export type IntegratorPlayerInformation = { | ||
name: string, | ||
uuid: string, | ||
location: { | ||
world: string, | ||
x: number, | ||
y: number, | ||
z: number | ||
} | ||
}; | ||
export type IntegratorServerInformation = { | ||
tps: number, | ||
players: IntegratorPlayerInformation[] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// Do not touch this file, it is automatically changed. | ||
export default ["attachToServer","auth","createServer","createUser","deleteServer","deleteUser","detachFromServer","editUser","getAllServers","getAllSettings","getServer","getSetting","getUserData","getUserToken","getUsers","importServer","killServer","listSessions","logging","logout","ping","plugins","serverFiles","serverLogs","setServerOption","setSetting","startServer","stopServer","systemInformation","writeToConsole"] as const | ||
export default ["attachToServer","auth","createServer","createUser","deleteServer","deleteUser","detachFromServer","editUser","getAllServers","getAllSettings","getServer","getSetting","getUserData","getUserToken","getUsers","importServer","integrator","killServer","listSessions","logging","logout","ping","plugins","serverFiles","serverLogs","setServerOption","setSetting","startServer","stopServer","systemInformation","writeToConsole"] as const |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters