Files
GMLIB-LegacyRemoteCallApi/lib/BEPlaceholderAPI-JS.js
T
2024-02-24 11:14:27 +08:00

58 lines
2.0 KiB
JavaScript

const PAPIgetValueAPI = ll.import("BEPlaceholderAPI", "GetValue")
const PAPIgetValueByPlayerAPI = ll.import("BEPlaceholderAPI", "GetValueWithPlayer")
const PAPIregisterPlayerPlaceholderAPI = ll.import("BEPlaceholderAPI", "registerPlayerPlaceholder")
const PAPIregisterServerPlaceholderAPI = ll.import("BEPlaceholderAPI", "registerServerPlaceholder")
const PAPIregisterStaticPlaceholderAPI = ll.import("BEPlaceholderAPI", "registerStaticPlaceholder")
const PAPItranslateStringAPI = ll.import("BEPlaceholderAPI", "translateString")
const PAPIunRegisterPlaceholderAPI = ll.import("BEPlaceholderAPI", "unRegisterPlaceholder")
const PAPIgetAllPAPI = ll.import("BEPlaceholderAPI", "getAllPAPI")
Function.prototype.getName = function () {
return this.name || this.toString().match(/function\s*([^(]*)\(/)[1]
}
class PAPI {
constructor() {
throw new Error("Static class cannot be instantiated");
}
static registerPlayerPlaceholder(func, PluginName, PAPIName) {
ll.export(func, PluginName, func.getName())
PAPIregisterPlayerPlaceholderAPI(PluginName, func.getName(), PAPIName)
}
static registerServerPlaceholder(func, PluginName, PAPIName) {
ll.export(func, PluginName, func.getName())
PAPIregisterServerPlaceholderAPI(PluginName, func.getName(), PAPIName)
}
static registerStaticPlaceholder(func, PluginName, PAPIName, UpdateInterval = 50) {
ll.export(func, PluginName, func.getName())
PAPIregisterStaticPlaceholderAPI(PluginName, func.getName(), PAPIName, UpdateInterval)
}
static getValue(key) {
return PAPIgetValueAPI(key)
}
static getValueByPlayer(key, xuid) {
return PAPIgetValueByPlayerAPI(key, xuid)
}
static translateString(str, xuid = "") {
return PAPItranslateStringAPI(str, xuid)
}
static unRegisterPlaceholder(str) {
return PAPIunRegisterPlaceholderAPI(str)
}
static getAllPAPI() {
return PAPIgetAllPAPI();
}
}
module.exports = {
PAPI
};