OTv4 is now pterodactyl panel compatible!

This commit is contained in:
DJj123dj
2024-08-22 15:45:38 +02:00
parent 8e730fdfae
commit 7dd9bf1ac0
15 changed files with 141 additions and 144 deletions
+2 -1
View File
@@ -4,6 +4,7 @@
import { ODId, ODManager, ODManagerData, ODSystemError, ODValidId } from "./base"
import nodepath from "path"
import { ODDebugger } from "./console"
import fs from "fs"
/**## ODConfigManager `class`
* This is an open ticket config manager.
@@ -88,7 +89,7 @@ export class ODJsonConfig extends ODConfig {
try {
const filename = (file.endsWith(".json")) ? file : file+".json"
this.file = customPath ? nodepath.join("./",customPath,filename) : nodepath.join("./config/",filename)
this.data = customPath ? require(nodepath.join("../../../../",customPath,filename)) : require(nodepath.join("../../../../config",filename))
this.data = JSON.parse(fs.readFileSync(this.file).toString())
}catch{
throw new ODSystemError("config \""+nodepath.join("./",customPath ?? "",file)+"\" doesn't exist!")
}
+3 -2
View File
@@ -4,6 +4,7 @@
import { ODId, ODManager, ODManagerData, ODSystemError, ODValidId } from "./base"
import nodepath from "path"
import { ODDebugger } from "./console"
import fs from "fs"
export class ODLanguage extends ODManagerData {
file: string
@@ -17,10 +18,10 @@ export class ODLanguage extends ODManagerData {
constructor(id:ODValidId, file:string, customPath?:string){
super(id)
this.file = file
try{
const filename = (file.endsWith(".json")) ? file : file+".json"
this.data = customPath ? require(nodepath.join("../../../../",customPath,filename)) : require(nodepath.join("../../../../languages",filename))
this.file = customPath ? nodepath.join("./",customPath,filename) : nodepath.join("./languages/",filename)
this.data = JSON.parse(fs.readFileSync(this.file).toString())
}catch{
throw new ODSystemError("[API ERROR] Language \""+file+"\" doesn't exist!")
}
+3 -2
View File
@@ -84,13 +84,14 @@ export class ODPlugin extends ODManagerData {
//Get the startfile location relative to the ./plugins/ directory
getStartFile(){
return nodepath.join(this.dir,this.data.startFile)
const newFile = this.data.startFile.replace(/\.ts$/,".js")
return nodepath.join(this.dir,newFile)
}
/**Execute this plugin. Returns `false` on crash. */
async execute(debug:ODDebugger,force?:boolean): Promise<boolean> {
if ((this.enabled && !this.crashed) || force){
try{
await require(nodepath.join("../../../../plugins/",this.getStartFile()))
await import(nodepath.join("../../../../plugins/",this.getStartFile()))
debug.console.log("Plugin \""+this.id.value+"\" loaded successfully!","plugin")
this.executed = true
return true