feat: adapt GMLIB 0.8.5

This commit is contained in:
Tsubasa6848
2024-02-23 17:41:37 +08:00
Unverified
parent 0001f80ff2
commit cb9c8a015d
3 changed files with 13 additions and 5 deletions
+8 -1
View File
@@ -5,6 +5,7 @@ const PAPIregisterServerPlaceholderAPI = ll.import("BEPlaceholderAPI", "register
const PAPIregisterStaticPlaceholderAPI = ll.import("BEPlaceholderAPI", "registerStaticPlaceholder") const PAPIregisterStaticPlaceholderAPI = ll.import("BEPlaceholderAPI", "registerStaticPlaceholder")
const PAPItranslateStringAPI = ll.import("BEPlaceholderAPI", "translateString") const PAPItranslateStringAPI = ll.import("BEPlaceholderAPI", "translateString")
const PAPIunRegisterPlaceholderAPI = ll.import("BEPlaceholderAPI", "unRegisterPlaceholder") const PAPIunRegisterPlaceholderAPI = ll.import("BEPlaceholderAPI", "unRegisterPlaceholder")
const PAPIgetAllPAPI = ll.import("BEPlaceholderAPI", "getAllPAPI")
Function.prototype.getName = function () { Function.prototype.getName = function () {
@@ -13,7 +14,9 @@ Function.prototype.getName = function () {
} }
class PAPI { class PAPI {
constructor() { } constructor() {
throw new Error("Static class cannot be instantiated");
}
static registerPlayerPlaceholder(func, PluginName, PAPIName) { static registerPlayerPlaceholder(func, PluginName, PAPIName) {
@@ -47,6 +50,10 @@ class PAPI {
return PAPIunRegisterPlaceholderAPI(str) return PAPIunRegisterPlaceholderAPI(str)
} }
static getAllPAPI() {
return PAPIgetAllPAPI();
}
} }
module.exports = { module.exports = {
+4 -3
View File
@@ -108,13 +108,13 @@ std::string registerStaticPlaceholder(
} }
std::string translateString(std::string const& str, std::string const& xuid) { std::string translateString(std::string const& str, std::string const& xuid) {
std::string _str = str; return GMLIB::Server::PlaceholderAPI::translate(str, ll::service::bedrock::getLevel()->getPlayerByXuid(xuid));
GMLIB::Server::PlaceholderAPI::translateString(_str, ll::service::bedrock::getLevel()->getPlayerByXuid(xuid));
return _str;
} }
bool unRegisterPlaceholder(std::string const& str) { return GMLIB::Server::PlaceholderAPI::unRegisterPlaceholder(str); } bool unRegisterPlaceholder(std::string const& str) { return GMLIB::Server::PlaceholderAPI::unRegisterPlaceholder(str); }
std::vector<std::string> getAllPAPI() { return GMLIB::Server::PlaceholderAPI::getAllPAPI(); }
} // namespace PAPIRemoteCall } // namespace PAPIRemoteCall
#define EXPORTAPI(T) \ #define EXPORTAPI(T) \
@@ -128,4 +128,5 @@ void ExportPAPI() {
EXPORTAPI(PAPIRemoteCall::GetValueWithPlayer); EXPORTAPI(PAPIRemoteCall::GetValueWithPlayer);
EXPORTAPI(PAPIRemoteCall::translateString); EXPORTAPI(PAPIRemoteCall::translateString);
EXPORTAPI(PAPIRemoteCall::unRegisterPlaceholder); EXPORTAPI(PAPIRemoteCall::unRegisterPlaceholder);
EXPORTAPI(PAPIRemoteCall::getAllPAPI);
} }