Compare commits
9 Commits
+1
-1
Submodule SDK-GMLIB updated: fa3ec71bdc...2bb91343e1
+27
-21
@@ -1,11 +1,14 @@
|
|||||||
const PAPIgetValueAPI = ll.import("BEPlaceholderAPI", "GetValue")
|
const PlaceholderAPI = {
|
||||||
const PAPIgetValueByPlayerAPI = ll.import("BEPlaceholderAPI", "GetValueWithPlayer")
|
getValueAPI: ll.import("BEPlaceholderAPI", "GetValue"),
|
||||||
const PAPIregisterPlayerPlaceholderAPI = ll.import("BEPlaceholderAPI", "registerPlayerPlaceholder")
|
getValueByPlayerAPI: ll.import("BEPlaceholderAPI", "GetValueWithPlayer"),
|
||||||
const PAPIregisterServerPlaceholderAPI = ll.import("BEPlaceholderAPI", "registerServerPlaceholder")
|
registerPlayerPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerPlayerPlaceholder"),
|
||||||
const PAPIregisterStaticPlaceholderAPI = ll.import("BEPlaceholderAPI", "registerStaticPlaceholder")
|
registerServerPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerServerPlaceholder"),
|
||||||
const PAPItranslateStringAPI = ll.import("BEPlaceholderAPI", "translateString")
|
registerStaticPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerStaticPlaceholder"),
|
||||||
const PAPIunRegisterPlaceholderAPI = ll.import("BEPlaceholderAPI", "unRegisterPlaceholder")
|
translateStringAPI: ll.import("BEPlaceholderAPI", "translateString"),
|
||||||
const PAPIgetAllPAPI = ll.import("BEPlaceholderAPI", "getAllPAPI")
|
translateStringWithPlayerAPI: ll.import("BEPlaceholderAPI", "translateStringWithPlayer"),
|
||||||
|
unRegisterPlaceholderAPI: ll.import("BEPlaceholderAPI", "unRegisterPlaceholder"),
|
||||||
|
getAllPAPI: ll.import("BEPlaceholderAPI", "getAllPAPI")
|
||||||
|
}
|
||||||
|
|
||||||
Function.prototype.getName = function () {
|
Function.prototype.getName = function () {
|
||||||
return this.name || this.toString().match(/function\s*([^(]*)\(/)[1]
|
return this.name || this.toString().match(/function\s*([^(]*)\(/)[1]
|
||||||
@@ -17,38 +20,41 @@ class PAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static registerPlayerPlaceholder(func, PluginName, PAPIName) {
|
static registerPlayerPlaceholder(func, PluginName, PAPIName) {
|
||||||
ll.export(func, PluginName, func.getName())
|
ll.export(func, PluginName, func.getName());
|
||||||
PAPIregisterPlayerPlaceholderAPI(PluginName, func.getName(), PAPIName)
|
return PlaceholderAPI.registerPlayerPlaceholderAPI(PluginName, func.getName(), PAPIName);
|
||||||
}
|
}
|
||||||
|
|
||||||
static registerServerPlaceholder(func, PluginName, PAPIName) {
|
static registerServerPlaceholder(func, PluginName, PAPIName) {
|
||||||
ll.export(func, PluginName, func.getName())
|
ll.export(func, PluginName, func.getName());
|
||||||
PAPIregisterServerPlaceholderAPI(PluginName, func.getName(), PAPIName)
|
return PlaceholderAPI.registerServerPlaceholderAPI(PluginName, func.getName(), PAPIName);
|
||||||
}
|
}
|
||||||
|
|
||||||
static registerStaticPlaceholder(func, PluginName, PAPIName, UpdateInterval = 50) {
|
static registerStaticPlaceholder(func, PluginName, PAPIName, UpdateInterval = 50) {
|
||||||
ll.export(func, PluginName, func.getName())
|
ll.export(func, PluginName, func.getName());
|
||||||
PAPIregisterStaticPlaceholderAPI(PluginName, func.getName(), PAPIName, UpdateInterval)
|
return PlaceholderAPI.registerStaticPlaceholderAPI(PluginName, func.getName(), PAPIName, UpdateInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static getValue(key) {
|
static getValue(key) {
|
||||||
return PAPIgetValueAPI(key)
|
return PlaceholderAPI.getValueAPI(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static getValueByPlayer(key, xuid) {
|
static getValueByPlayer(key, pl) {
|
||||||
return PAPIgetValueByPlayerAPI(key, xuid)
|
return PlaceholderAPI.getValueByPlayerAPI(key, pl);
|
||||||
}
|
}
|
||||||
|
|
||||||
static translateString(str, xuid = "") {
|
static translateString(str, pl = null) {
|
||||||
return PAPItranslateStringAPI(str, xuid)
|
if (pl) {
|
||||||
|
return PlaceholderAPI.translateStringWithPlayerAPI(str, pl);
|
||||||
|
}
|
||||||
|
return PlaceholderAPI.translateStringAPI(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unRegisterPlaceholder(str) {
|
static unRegisterPlaceholder(str) {
|
||||||
return PAPIunRegisterPlaceholderAPI(str)
|
return PlaceholderAPI.unRegisterPlaceholderAPI(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static getAllPAPI() {
|
static getAllPAPI() {
|
||||||
return PAPIgetAllPAPI();
|
return PlaceholderAPI.getAllPAPI();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
const CallEvent = ll.import("GMLIB_API", "callCustomEvent");
|
||||||
|
|
||||||
|
let NextEventId = 0;
|
||||||
|
|
||||||
|
function getNextEventId() {
|
||||||
|
NextEventId++;
|
||||||
|
return "GMLIB_Event_" + NextEventId;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Event {
|
||||||
|
constructor() {
|
||||||
|
throw new Error("Static class cannot be instantiated");
|
||||||
|
}
|
||||||
|
|
||||||
|
static listen(event, callback) {
|
||||||
|
let eventId = getNextEventId();
|
||||||
|
ll.export(callback, event, eventId);
|
||||||
|
let result = CallEvent(event, eventId);
|
||||||
|
if (!result) {
|
||||||
|
logger.error(`Cannot listen event "${event}"!`);
|
||||||
|
logger.error(`Event "${event}" No Found!`);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
Event
|
||||||
|
};
|
||||||
@@ -15,6 +15,8 @@ const GMLIB_API = {
|
|||||||
getPlayerNbt: ll.import("GMLIB_API", "getPlayerNbt"),
|
getPlayerNbt: ll.import("GMLIB_API", "getPlayerNbt"),
|
||||||
setPlayerNbt: ll.import("GMLIB_API", "setPlayerNbt"),
|
setPlayerNbt: ll.import("GMLIB_API", "setPlayerNbt"),
|
||||||
setPlayerNbtTags: ll.import("GMLIB_API", "setPlayerNbtTags"),
|
setPlayerNbtTags: ll.import("GMLIB_API", "setPlayerNbtTags"),
|
||||||
|
resourcePackTranslate: ll.import("GMLIB_API", "resourcePackTranslate"),
|
||||||
|
chooseResourcePackI18nLanguage: ll.import("GMLIB_API", "chooseResourcePackI18nLanguage"),
|
||||||
setEducationFeatureEnabled: ll.import("GMLib_ServerAPI", "setEducationFeatureEnabled"),
|
setEducationFeatureEnabled: ll.import("GMLib_ServerAPI", "setEducationFeatureEnabled"),
|
||||||
registerAbilityCommand: ll.import("GMLib_ServerAPI", "registerAbilityCommand"),
|
registerAbilityCommand: ll.import("GMLib_ServerAPI", "registerAbilityCommand"),
|
||||||
setEnableAchievement: ll.import("GMLib_ServerAPI", "setEnableAchievement"),
|
setEnableAchievement: ll.import("GMLib_ServerAPI", "setEnableAchievement"),
|
||||||
@@ -300,6 +302,14 @@ class Minecraft {
|
|||||||
static throwEntity(entity, proj, speed = 2, offset = 3) {
|
static throwEntity(entity, proj, speed = 2, offset = 3) {
|
||||||
return GMLIB_API.throwEntity(entity, proj, speed = 2, offset = 3);
|
return GMLIB_API.throwEntity(entity, proj, speed = 2, offset = 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static chooseResourcePackI18nLanguage(language) {
|
||||||
|
return GMLIB_API.chooseResourcePackI18nLanguage(language);
|
||||||
|
}
|
||||||
|
|
||||||
|
static resourcePackTranslate(key, params = []) {
|
||||||
|
return GMLIB_API.resourcePackTranslate(key, params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Recipes {
|
class Recipes {
|
||||||
|
|||||||
@@ -133,4 +133,12 @@ void Export_Compatibility_API() {
|
|||||||
RemoteCall::exportAs("GMLIB_API", "getVersion_GMLIB", []() -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getVersion_GMLIB", []() -> std::string {
|
||||||
return GMLIB::Version::getLibVersionString();
|
return GMLIB::Version::getLibVersionString();
|
||||||
});
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"resourcePackTranslate",
|
||||||
|
[](std::string key, std::vector<std::string> params) -> std::string { return I18n::get(key, params); }
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "chooseResourcePackI18nLanguage", [](std::string code) -> void {
|
||||||
|
I18n::chooseLanguage(code);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
@@ -20,6 +20,7 @@ auto load(ll::plugin::NativePlugin& self) -> bool {
|
|||||||
Export_Legacy_GMLib_ServerAPI();
|
Export_Legacy_GMLib_ServerAPI();
|
||||||
Export_Compatibility_API();
|
Export_Compatibility_API();
|
||||||
ExportPAPI();
|
ExportPAPI();
|
||||||
|
Export_Event_API();
|
||||||
logger.info("GMLIB-LegacyRemoteCallApi Loaded!");
|
logger.info("GMLIB-LegacyRemoteCallApi Loaded!");
|
||||||
logger.info("Version: {}", LIB_VERSION.asString());
|
logger.info("Version: {}", LIB_VERSION.asString());
|
||||||
logger.info("Author: GroupMountain");
|
logger.info("Author: GroupMountain");
|
||||||
|
|||||||
@@ -0,0 +1,162 @@
|
|||||||
|
#include "Global.h"
|
||||||
|
using namespace ll::hash_utils;
|
||||||
|
|
||||||
|
void Export_Event_API() {
|
||||||
|
auto eventBus = &ll::event::EventBus::getInstance();
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"callCustomEvent",
|
||||||
|
[eventBus](std::string eventName, std::string eventId) -> bool {
|
||||||
|
if (RemoteCall::hasFunc(eventName, eventId)) {
|
||||||
|
switch (do_hash(eventName)) {
|
||||||
|
case do_hash("onClientLogin"): {
|
||||||
|
auto Call = RemoteCall::importAs<
|
||||||
|
bool(std::string realName, std::string uuid, std::string serverXuid, std::string clientXuid)>(
|
||||||
|
eventName,
|
||||||
|
eventId
|
||||||
|
);
|
||||||
|
eventBus->emplaceListener<GMLIB::Event::PacketEvent::ClientLoginAfterEvent>(
|
||||||
|
[Call](GMLIB::Event::PacketEvent::ClientLoginAfterEvent& ev) {
|
||||||
|
try {
|
||||||
|
Call(
|
||||||
|
ev.getRealName(),
|
||||||
|
ev.getUuid().asString(),
|
||||||
|
ev.getServerAuthXuid(),
|
||||||
|
ev.getClientAuthXuid()
|
||||||
|
);
|
||||||
|
} catch (...) {}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case do_hash("onWeatherChange"): {
|
||||||
|
auto Call =
|
||||||
|
RemoteCall::importAs<bool(int lightningLevel, int rainLevel, int lightningLast, int rainLast)>(
|
||||||
|
eventName,
|
||||||
|
eventId
|
||||||
|
);
|
||||||
|
eventBus->emplaceListener<GMLIB::Event::LevelEvent::WeatherUpdateBeforeEvent>(
|
||||||
|
[Call](GMLIB::Event::LevelEvent::WeatherUpdateBeforeEvent& ev) {
|
||||||
|
bool result = true;
|
||||||
|
try {
|
||||||
|
result = Call(
|
||||||
|
ev.getLightningLevel(),
|
||||||
|
ev.getRainLevel(),
|
||||||
|
ev.getLightningLastTick(),
|
||||||
|
ev.getRainingLastTick()
|
||||||
|
);
|
||||||
|
} catch (...) {}
|
||||||
|
if (!result) {
|
||||||
|
ev.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case do_hash("onMobPick"): {
|
||||||
|
auto Call = RemoteCall::importAs<bool(Actor * mob, Actor * item)>(eventName, eventId);
|
||||||
|
eventBus->emplaceListener<GMLIB::Event::EntityEvent::MobPickupItemBeforeEvent>(
|
||||||
|
[Call](GMLIB::Event::EntityEvent::MobPickupItemBeforeEvent& ev) {
|
||||||
|
bool result = true;
|
||||||
|
try {
|
||||||
|
result = Call(&ev.self(), (Actor*)&ev.getItemActor());
|
||||||
|
} catch (...) {}
|
||||||
|
if (!result) {
|
||||||
|
ev.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case do_hash("onItemTrySpawn"): {
|
||||||
|
auto Call = RemoteCall::importAs<
|
||||||
|
bool(const ItemStack* item, std::pair<Vec3, int> position, Actor* spawner)>(eventName, eventId);
|
||||||
|
eventBus->emplaceListener<GMLIB::Event::EntityEvent::ItemActorSpawnBeforeEvent>(
|
||||||
|
[Call](GMLIB::Event::EntityEvent::ItemActorSpawnBeforeEvent& ev) {
|
||||||
|
auto pos = ev.getPosition();
|
||||||
|
auto dimid = ev.getBlockSource().getDimensionId().id;
|
||||||
|
std::pair<Vec3, int> lsePos = {pos, dimid};
|
||||||
|
bool result = true;
|
||||||
|
try {
|
||||||
|
result = Call(&ev.getItem(), lsePos, ev.getSpawner());
|
||||||
|
} catch (...) {}
|
||||||
|
if (!result) {
|
||||||
|
ev.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case do_hash("onItemSpawned"): {
|
||||||
|
auto Call = RemoteCall::importAs<
|
||||||
|
bool(const ItemStack* item, Actor* itemActor, std::pair<Vec3, int> position, Actor* spawner)>(
|
||||||
|
eventName,
|
||||||
|
eventId
|
||||||
|
);
|
||||||
|
eventBus->emplaceListener<GMLIB::Event::EntityEvent::ItemActorSpawnAfterEvent>(
|
||||||
|
[Call](GMLIB::Event::EntityEvent::ItemActorSpawnAfterEvent& ev) {
|
||||||
|
auto pos = ev.getPosition();
|
||||||
|
auto dimid = ev.getBlockSource().getDimensionId().id;
|
||||||
|
std::pair<Vec3, int> lsePos = {pos, dimid};
|
||||||
|
try {
|
||||||
|
Call(&ev.getItem(), (Actor*)&ev.getItemActor(), lsePos, ev.getSpawner());
|
||||||
|
} catch (...) {}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case do_hash("onTextSend"): {
|
||||||
|
auto Call = RemoteCall::importAs<bool(std::string author, std::string message)>(eventName, eventId);
|
||||||
|
eventBus->emplaceListener<GMLIB::Event::PacketEvent::TextPacketSendBeforeEvent>(
|
||||||
|
[Call](GMLIB::Event::PacketEvent::TextPacketSendBeforeEvent& ev) {
|
||||||
|
auto pkt = ev.getPacket();
|
||||||
|
bool result = true;
|
||||||
|
try {
|
||||||
|
result = Call(pkt.mAuthor, pkt.mMessage);
|
||||||
|
} catch (...) {}
|
||||||
|
if (!result) {
|
||||||
|
ev.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case do_hash("onLeaveBed"): {
|
||||||
|
auto Call = RemoteCall::importAs<bool(Player * pl)>(eventName, eventId);
|
||||||
|
eventBus->emplaceListener<GMLIB::Event::PlayerEvent::PlayerStopSleepBeforeEvent>(
|
||||||
|
[Call](GMLIB::Event::PlayerEvent::PlayerStopSleepBeforeEvent& ev) {
|
||||||
|
bool result = true;
|
||||||
|
try {
|
||||||
|
result = Call(&ev.self());
|
||||||
|
} catch (...) {}
|
||||||
|
if (!result) {
|
||||||
|
ev.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case do_hash("onDeathMessage"): {
|
||||||
|
auto Call = RemoteCall::importAs<bool(std::string message, std::vector<std::string>, Actor * dead)>(
|
||||||
|
eventName,
|
||||||
|
eventId
|
||||||
|
);
|
||||||
|
eventBus->emplaceListener<GMLIB::Event::EntityEvent::DeathMessageAfterEvent>(
|
||||||
|
[Call](GMLIB::Event::EntityEvent::DeathMessageAfterEvent& ev) {
|
||||||
|
auto msg = ev.getDeathMessage();
|
||||||
|
auto source = ev.getDamageSource();
|
||||||
|
try {
|
||||||
|
Call(msg.first, msg.second, &ev.self());
|
||||||
|
} catch (...) {}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
+3
-1
@@ -1,9 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <include_all.h>
|
#include <include_all.h>
|
||||||
|
|
||||||
#include <RemoteCallAPI.h>
|
#include <RemoteCallAPI.h>
|
||||||
|
|
||||||
#define PLUGIN_NAME "GMLIB-LRCA"
|
#define PLUGIN_NAME "GMLIB-LRCA"
|
||||||
#define LIB_VERSION SemVersion(0, 9, 0, "", "")
|
#define LIB_VERSION SemVersion(0, 9, 1, "", "")
|
||||||
|
|
||||||
extern ll::Logger logger;
|
extern ll::Logger logger;
|
||||||
|
|
||||||
@@ -11,3 +12,4 @@ extern void Export_Legacy_GMLib_ModAPI();
|
|||||||
extern void Export_Legacy_GMLib_ServerAPI();
|
extern void Export_Legacy_GMLib_ServerAPI();
|
||||||
extern void Export_Compatibility_API();
|
extern void Export_Compatibility_API();
|
||||||
extern void ExportPAPI();
|
extern void ExportPAPI();
|
||||||
|
extern void Export_Event_API();
|
||||||
+24
-58
@@ -3,87 +3,53 @@
|
|||||||
|
|
||||||
namespace PAPIRemoteCall {
|
namespace PAPIRemoteCall {
|
||||||
|
|
||||||
std::string removeBrackets(std::string a1) {
|
|
||||||
a1.erase(a1.find_last_not_of("%") + 1);
|
|
||||||
return a1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isParameters(std::string str) {
|
|
||||||
std::regex reg("[<]([^<>]+)[>]");
|
|
||||||
return std::regex_search(removeBrackets(str), reg);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string GetValue(std::string const& from) { return GMLIB::Server::PlaceholderAPI::getValue(from); }
|
std::string GetValue(std::string const& from) { return GMLIB::Server::PlaceholderAPI::getValue(from); }
|
||||||
|
|
||||||
std::string GetValueWithPlayer(std::string const& a1, std::string const& a2) {
|
std::string GetValueWithPlayer(std::string const& a1, std::string const& a2) {
|
||||||
return GMLIB::Server::PlaceholderAPI::getValue(a1, ll::service::bedrock::getLevel()->getPlayer(a2));
|
return GMLIB::Server::PlaceholderAPI::getValue(a1, ll::service::bedrock::getLevel()->getPlayer(a2));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
bool registerPlayerPlaceholder(
|
||||||
registerPlayerPlaceholder(std::string const& PluginName, std::string const& FuncName, std::string const& PAPIName) {
|
std::string const& PluginName,
|
||||||
|
std::string const& FuncName,
|
||||||
|
std::string const& PAPIName
|
||||||
|
) {
|
||||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||||
if (isParameters(PAPIName)) {
|
auto Call = RemoteCall::importAs<std::string(Player * pl)>(PluginName, FuncName);
|
||||||
auto Call =
|
|
||||||
RemoteCall::importAs<std::string(std::string const& arg, std::unordered_map<std::string, std::string>)>(
|
|
||||||
PluginName,
|
|
||||||
FuncName
|
|
||||||
);
|
|
||||||
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
|
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
|
||||||
PAPIName,
|
PAPIName,
|
||||||
[Call](Player* sp, std::unordered_map<std::string, std::string> map) {
|
[Call](Player* sp) { return Call(sp); },
|
||||||
return Call(sp->getXuid(), map);
|
|
||||||
},
|
|
||||||
PluginName
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
auto Call = RemoteCall::importAs<std::string(std::string const& arg)>(PluginName, FuncName);
|
|
||||||
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
|
|
||||||
PAPIName,
|
|
||||||
[Call](Player* sp) { return Call(sp->getXuid()); },
|
|
||||||
PluginName
|
PluginName
|
||||||
);
|
);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
return false;
|
||||||
// logger.error("Function no find({}:{})", PluginName, FuncName);
|
|
||||||
return "Function no find";
|
|
||||||
}
|
|
||||||
return "Register Success";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
bool registerServerPlaceholder(
|
||||||
registerServerPlaceholder(std::string const& PluginName, std::string const& FuncName, std::string const& PAPIName) {
|
std::string const& PluginName,
|
||||||
|
std::string const& FuncName,
|
||||||
|
std::string const& PAPIName
|
||||||
|
) {
|
||||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||||
if (isParameters(PAPIName)) {
|
|
||||||
auto Call =
|
|
||||||
RemoteCall::importAs<std::string(std::unordered_map<std::string, std::string>)>(PluginName, FuncName);
|
|
||||||
GMLIB::Server::PlaceholderAPI::registerServerPlaceholder(
|
|
||||||
PAPIName,
|
|
||||||
[Call](std::unordered_map<std::string, std::string> map) { return Call(map); },
|
|
||||||
PluginName
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
||||||
GMLIB::Server::PlaceholderAPI::registerServerPlaceholder(
|
GMLIB::Server::PlaceholderAPI::registerServerPlaceholder(
|
||||||
PAPIName,
|
PAPIName,
|
||||||
[Call]() { return Call(); },
|
[Call]() { return Call(); },
|
||||||
PluginName
|
PluginName
|
||||||
);
|
);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
return false;
|
||||||
// logger.error("Function no find({}:{})", PluginName, FuncName);
|
|
||||||
return "Function no find";
|
|
||||||
}
|
|
||||||
return "Register Success";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string registerStaticPlaceholder(
|
bool registerStaticPlaceholder(
|
||||||
std::string const& PluginName,
|
std::string const& PluginName,
|
||||||
std::string const& FuncName,
|
std::string const& FuncName,
|
||||||
std::string const& PAPIName,
|
std::string const& PAPIName,
|
||||||
int num
|
int num
|
||||||
) {
|
) {
|
||||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||||
if (isParameters(PAPIName)) {
|
|
||||||
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
||||||
if (num == -1) {
|
if (num == -1) {
|
||||||
GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder(
|
GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder(
|
||||||
@@ -99,18 +65,17 @@ std::string registerStaticPlaceholder(
|
|||||||
PluginName
|
PluginName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
return false;
|
||||||
// logger.error("Function no find({}:{})", PluginName, FuncName);
|
|
||||||
return "Function no find";
|
|
||||||
}
|
|
||||||
return "Register Success";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string translateString(std::string const& str, std::string const& xuid) {
|
std::string translateStringWithPlayer(std::string const& str, Player* pl) {
|
||||||
return GMLIB::Server::PlaceholderAPI::translate(str, ll::service::bedrock::getLevel()->getPlayerByXuid(xuid));
|
return GMLIB::Server::PlaceholderAPI::translateString(str, pl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string translateString(std::string const& str) { return GMLIB::Server::PlaceholderAPI::translateString(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(); }
|
std::vector<std::string> getAllPAPI() { return GMLIB::Server::PlaceholderAPI::getAllPAPI(); }
|
||||||
@@ -127,6 +92,7 @@ void ExportPAPI() {
|
|||||||
EXPORTAPI(PAPIRemoteCall::GetValue);
|
EXPORTAPI(PAPIRemoteCall::GetValue);
|
||||||
EXPORTAPI(PAPIRemoteCall::GetValueWithPlayer);
|
EXPORTAPI(PAPIRemoteCall::GetValueWithPlayer);
|
||||||
EXPORTAPI(PAPIRemoteCall::translateString);
|
EXPORTAPI(PAPIRemoteCall::translateString);
|
||||||
|
EXPORTAPI(PAPIRemoteCall::translateStringWithPlayer);
|
||||||
EXPORTAPI(PAPIRemoteCall::unRegisterPlaceholder);
|
EXPORTAPI(PAPIRemoteCall::unRegisterPlaceholder);
|
||||||
EXPORTAPI(PAPIRemoteCall::getAllPAPI);
|
EXPORTAPI(PAPIRemoteCall::getAllPAPI);
|
||||||
}
|
}
|
||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"format_version": 2,
|
"format_version": 2,
|
||||||
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
||||||
"version": "0.9.0",
|
"version": "0.9.1",
|
||||||
"info": {
|
"info": {
|
||||||
"name": "GMLIB-LegacyRemoteCallApi",
|
"name": "GMLIB-LegacyRemoteCallApi",
|
||||||
"description": "Legacy RemoteCall API for GMLIB",
|
"description": "Legacy RemoteCall API for GMLIB",
|
||||||
@@ -14,9 +14,9 @@
|
|||||||
"library"
|
"library"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.9.0/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
|
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.9.1/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"github.com/GroupMountain/GMLIB": ">=0.9.0"
|
"github.com/GroupMountain/GMLIB": ">=0.9.2"
|
||||||
},
|
},
|
||||||
"files": {
|
"files": {
|
||||||
"place": [
|
"place": [
|
||||||
|
|||||||
Reference in New Issue
Block a user