feat: adapted to GMLIB version and remove some shit
This commit is contained in:
@@ -4,16 +4,16 @@ using namespace ll::hash_utils;
|
||||
class LegacyScriptBinaryStreamManager {
|
||||
private:
|
||||
int64 mNextBinaryStreamId = 0;
|
||||
std::unordered_map<uint64, std::shared_ptr<GMLIB_BinaryStream>> mBinaryStream;
|
||||
std::unordered_map<uint64, std::shared_ptr<gmlib::network::BinaryStream>> mBinaryStream;
|
||||
|
||||
public:
|
||||
uint getNextId() { return mNextBinaryStreamId++; }
|
||||
|
||||
void cretateBinaryStream(uint id) { mBinaryStream[id] = std::make_shared<GMLIB_BinaryStream>(); }
|
||||
void cretateBinaryStream(uint id) { mBinaryStream[id] = std::make_shared<gmlib::network::BinaryStream>(); }
|
||||
|
||||
void removeBinaryStream(uint64 id) { mBinaryStream.erase(id); }
|
||||
|
||||
std::shared_ptr<GMLIB_BinaryStream> getBinaryStream(uint64 id) {
|
||||
std::shared_ptr<gmlib::network::BinaryStream> getBinaryStream(uint64 id) {
|
||||
return mBinaryStream.contains(id) ? mBinaryStream.at(id) : nullptr;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ template <typename T, typename R, typename A, typename... AS>
|
||||
struct Info<R (T::*)(A, AS...)> {
|
||||
using ArgT = A;
|
||||
};
|
||||
#define EXPORTAPI2(T) EXPORTAPI(#T, Info<decltype(&GMLIB_BinaryStream::T)>::ArgT, bs->T(value))
|
||||
#define EXPORTAPI2(T) EXPORTAPI(#T, Info<decltype(&gmlib::network::BinaryStream::T)>::ArgT, bs->T(value))
|
||||
|
||||
void Export_BinaryStream_API() {
|
||||
RemoteCall::exportAs("GMLIB_BinaryStream_API", "create", []() -> uint64 {
|
||||
|
||||
+248
-358
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -21,7 +21,7 @@ bool LegacyRemoteCallApi::load() {
|
||||
logger.info("GMLIB-LegacyRemoteCallApi Loaded!");
|
||||
logger.info(
|
||||
"Loaded Version: {} with {}",
|
||||
fmt::format(fg(fmt::color::pink), "GMLIB-" + Version::getLibVersionString()),
|
||||
fmt::format(fg(fmt::color::pink), "GMLIB-" + gmlib::Version::getLibVersionString()),
|
||||
fmt::format(fg(fmt::color::light_green), "GMLIB-LegacyRemoteCallApi-" + LIB_VERSION.asString())
|
||||
);
|
||||
logger.info("Author: GroupMountain");
|
||||
@@ -35,4 +35,4 @@ bool LegacyRemoteCallApi::disable() { return true; }
|
||||
|
||||
} // namespace GMLIB
|
||||
|
||||
LL_REGISTER_MOD(LegacyRemoteCallApi, LegacyRemoteCallApi::getInstance());
|
||||
LL_REGISTER_MOD(GMLIB::LegacyRemoteCallApi, GMLIB::LegacyRemoteCallApi::getInstance());
|
||||
|
||||
+17
-17
@@ -63,7 +63,7 @@ void Export_Event_API() {
|
||||
switch (doHash(eventName)) {
|
||||
case doHash("onClientLogin"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
Event::PacketEvent::ClientLoginAfterEvent,
|
||||
gmlib::event::packet::ClientLoginAfterEvent,
|
||||
(std::string const& realName,
|
||||
std::string const& uuid,
|
||||
std::string const& serverXuid,
|
||||
@@ -74,7 +74,7 @@ void Export_Event_API() {
|
||||
}
|
||||
case doHash("onWeatherChange"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
Event::LevelEvent::WeatherUpdateBeforeEvent,
|
||||
gmlib::event::level::WeatherUpdateBeforeEvent,
|
||||
(int lightningLevel, int rainLevel, int lightningLast, int rainLast),
|
||||
(ev.getLightningLevel(), ev.getRainLevel(), ev.getLightningLastTick(), ev.getRainingLastTick()),
|
||||
ev.cancel(),
|
||||
@@ -82,7 +82,7 @@ void Export_Event_API() {
|
||||
}
|
||||
case doHash("onMobPick"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
Event::EntityEvent::MobPickupItemBeforeEvent,
|
||||
gmlib::event::entity::MobPickupItemBeforeEvent,
|
||||
(Actor * mob, Actor * item),
|
||||
(&ev.self(), (Actor*)&ev.getItemActor()),
|
||||
ev.cancel(),
|
||||
@@ -90,7 +90,7 @@ void Export_Event_API() {
|
||||
}
|
||||
case doHash("onItemTrySpawn"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
Event::EntityEvent::ItemActorSpawnBeforeEvent,
|
||||
gmlib::event::entity::ItemActorSpawnBeforeEvent,
|
||||
(const ItemStack* item, std::pair<Vec3, int> position, int64 spawnerUniqueId),
|
||||
(&ev.getItem(),
|
||||
{ev.getPosition(), ev.getBlockSource().getDimensionId().id},
|
||||
@@ -100,7 +100,7 @@ void Export_Event_API() {
|
||||
}
|
||||
case doHash("onItemSpawned"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
Event::EntityEvent::ItemActorSpawnAfterEvent,
|
||||
gmlib::event::entity::ItemActorSpawnAfterEvent,
|
||||
(const ItemStack* item, Actor* itemActor, std::pair<Vec3, int> position, int64 spawnerUniqueId),
|
||||
(&ev.getItem(),
|
||||
(Actor*)&ev.getItemActor(),
|
||||
@@ -111,7 +111,7 @@ void Export_Event_API() {
|
||||
}
|
||||
case doHash("onEntityTryChangeDim"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
Event::EntityEvent::ActorChangeDimensionBeforeEvent,
|
||||
gmlib::event::entity::ActorChangeDimensionBeforeEvent,
|
||||
(Actor * entity, int toDimId),
|
||||
(&ev.self(), ev.getToDimensionId()),
|
||||
ev.cancel(),
|
||||
@@ -119,7 +119,7 @@ void Export_Event_API() {
|
||||
}
|
||||
case doHash("onLeaveBed"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
Event::PlayerEvent::PlayerStopSleepBeforeEvent,
|
||||
gmlib::event::player::PlayerStopSleepBeforeEvent,
|
||||
(Player * pl),
|
||||
(&ev.self()),
|
||||
ev.cancel(),
|
||||
@@ -127,7 +127,7 @@ void Export_Event_API() {
|
||||
}
|
||||
case doHash("onDeathMessage"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
Event::EntityEvent::DeathMessageAfterEvent,
|
||||
gmlib::event::entity::DeathMessageAfterEvent,
|
||||
(std::string const& message, std::vector<std::string>, Actor* dead),
|
||||
(ev.getDeathMessage().first, ev.getDeathMessage().second, &ev.self()),
|
||||
logger.error("Event \"onDeathMessage\" cannot be intercepted"),
|
||||
@@ -135,7 +135,7 @@ void Export_Event_API() {
|
||||
}
|
||||
case doHash("onMobHurted"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
Event::EntityEvent::MobHurtAfterEvent,
|
||||
gmlib::event::entity::MobHurtAfterEvent,
|
||||
(Actor * mob, Actor * source, float damage, int cause),
|
||||
(&ev.self(), source, ev.getDamage(), (int)damageSource.getCause()),
|
||||
logger.error("Event \"onMobHurted\" cannot be intercepted"),
|
||||
@@ -150,7 +150,7 @@ void Export_Event_API() {
|
||||
}
|
||||
case doHash("onEndermanTake"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
Event::EntityEvent::EndermanTakeBlockBeforeEvent,
|
||||
gmlib::event::entity::EndermanTakeBlockBeforeEvent,
|
||||
(Actor * mob),
|
||||
(&ev.self()),
|
||||
ev.cancel(),
|
||||
@@ -158,7 +158,7 @@ void Export_Event_API() {
|
||||
}
|
||||
case doHash("onEntityChangeDim"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
Event::EntityEvent::ActorChangeDimensionAfterEvent,
|
||||
gmlib::event::entity::ActorChangeDimensionAfterEvent,
|
||||
(Actor * mob, int fromDimId),
|
||||
(&ev.self(), ev.getFromDimensionId()),
|
||||
logger.error("Event \"onEntityChangeDim\" cannot be intercepted"),
|
||||
@@ -166,7 +166,7 @@ void Export_Event_API() {
|
||||
}
|
||||
case doHash("onDragonRespawn"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
Event::EntityEvent::DragonRespawnBeforeEvent,
|
||||
gmlib::event::entity::DragonRespawnBeforeEvent,
|
||||
(int64 enderDragonUniqueID),
|
||||
(ev.getEnderDragon().id),
|
||||
ev.cancel(),
|
||||
@@ -174,7 +174,7 @@ void Export_Event_API() {
|
||||
}
|
||||
case doHash("onProjectileTryCreate"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
Event::EntityEvent::ProjectileCreateBeforeEvent,
|
||||
gmlib::event::entity::ProjectileCreateBeforeEvent,
|
||||
(Actor * mob, int64 uniqueId),
|
||||
(&ev.self(), ev.getShooter() ? ev.getShooter()->getOrCreateUniqueID().id : -1),
|
||||
ev.cancel(),
|
||||
@@ -182,7 +182,7 @@ void Export_Event_API() {
|
||||
}
|
||||
case doHash("onProjectileCreate"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
Event::EntityEvent::ProjectileCreateAfterEvent,
|
||||
gmlib::event::entity::ProjectileCreateAfterEvent,
|
||||
(Actor * mob, int64 uniqueId),
|
||||
(&ev.self(), ev.getShooter() ? ev.getShooter()->getOrCreateUniqueID().id : -1),
|
||||
logger.error("Event \"onProjectileCreate\" cannot be intercepted"),
|
||||
@@ -190,7 +190,7 @@ void Export_Event_API() {
|
||||
}
|
||||
case doHash("onSpawnWanderingTrader"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
Event::EntityEvent::SpawnWanderingTraderBeforeEvent,
|
||||
gmlib::event::entity::SpawnWanderingTraderBeforeEvent,
|
||||
(std::pair<BlockPos, int> pos),
|
||||
({ev.getPos(), ev.getRegion().getDimensionId()}),
|
||||
ev.cancel(),
|
||||
@@ -199,7 +199,7 @@ void Export_Event_API() {
|
||||
case doHash("onHandleRequestAction"): {
|
||||
// clang-format off
|
||||
REGISTER_EVENT_LISTEN(
|
||||
Event::PlayerEvent::HandleRequestActionBeforeEvent,
|
||||
gmlib::event::player::HandleRequestActionBeforeEvent,
|
||||
(
|
||||
Player * player,
|
||||
std::string const& actionType,
|
||||
@@ -225,7 +225,7 @@ void Export_Event_API() {
|
||||
}
|
||||
case doHash("onSendContainerClosePacket"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
Event::PacketEvent::ContainerClosePacketSendAfterEvent,
|
||||
gmlib::event::packet::ContainerClosePacketSendAfterEvent,
|
||||
(Player * player, int ContainerNetId),
|
||||
(ev.getServerNetworkHandler()
|
||||
.getServerPlayer(ev.getNetworkIdentifier(), ev.getPacket().mClientSubId),
|
||||
|
||||
+56
-104
@@ -1,28 +1,23 @@
|
||||
#include "Global.h"
|
||||
|
||||
using namespace GMLIB::Server::Form;
|
||||
using namespace ll::hash_utils;
|
||||
|
||||
class LegacyScriptFormManager {
|
||||
private:
|
||||
int64 mNextFormCallbackId = 0;
|
||||
// std::unordered_map<int64, ll::event::ListenerPtr> mEventListeners;
|
||||
// class LegacyScriptFormManager {
|
||||
// private:
|
||||
// int64 mNextFormCallbackId = 0;
|
||||
|
||||
public:
|
||||
std::string getNextFormCallbackId() {
|
||||
mNextFormCallbackId++;
|
||||
return "GMLIB_EVENT_" + std::to_string(mNextFormCallbackId);
|
||||
}
|
||||
// public:
|
||||
// std::string getNextFormCallbackId() {
|
||||
// return "GMLIB_FormApi_" + std::to_string(mNextFormCallbackId++);
|
||||
// }
|
||||
|
||||
public:
|
||||
static LegacyScriptFormManager& getInstance() {
|
||||
static std::unique_ptr<LegacyScriptFormManager> instance;
|
||||
if (!instance) {
|
||||
instance = std::make_unique<LegacyScriptFormManager>();
|
||||
}
|
||||
return *instance;
|
||||
}
|
||||
};
|
||||
// public:
|
||||
// static LegacyScriptFormManager& getInstance() {
|
||||
// static std::unique_ptr<LegacyScriptFormManager> instance;
|
||||
// if (!instance) instance = std::make_unique<LegacyScriptFormManager>();
|
||||
// return *instance;
|
||||
// }
|
||||
// };
|
||||
|
||||
#define PLAYER_DETECROR \
|
||||
[detectorId, result](Player& pl) -> bool { \
|
||||
@@ -31,107 +26,64 @@ public:
|
||||
auto const& detector = RemoteCall::importAs<bool(Player*)>("GMLIB_FORM_CALLBACK", detectorId); \
|
||||
return detector(&pl); \
|
||||
} else { \
|
||||
ServerSettingForm::removeElement(result); \
|
||||
gmlib::form::ServerSettingForm::removeElement(result); \
|
||||
} \
|
||||
} catch (...) {} \
|
||||
return false; \
|
||||
}
|
||||
|
||||
#define CALLBACK_TYPE_STRING \
|
||||
[callbackId, result](Player& pl, std::string const& data) { \
|
||||
#define CALLBACK_TYPE(type) \
|
||||
[callbackId, result](Player& pl, type data) { \
|
||||
try { \
|
||||
if (RemoteCall::hasFunc("GMLIB_FORM_CALLBACK", callbackId)) { \
|
||||
auto const& callback = \
|
||||
RemoteCall::importAs<void(Player*, std::string const&)>("GMLIB_FORM_CALLBACK", callbackId); \
|
||||
auto const& callback = RemoteCall::importAs<void(Player*, type)>("GMLIB_FORM_CALLBACK", callbackId); \
|
||||
callback(&pl, data); \
|
||||
} else { \
|
||||
ServerSettingForm::removeElement(result); \
|
||||
gmlib::form::ServerSettingForm::removeElement(result); \
|
||||
} \
|
||||
} catch (...) {} \
|
||||
}
|
||||
|
||||
#define CALLBACK_TYPE_BOOL \
|
||||
[callbackId, result](Player& pl, bool data) { \
|
||||
try { \
|
||||
if (RemoteCall::hasFunc("GMLIB_FORM_CALLBACK", callbackId)) { \
|
||||
auto const& callback = RemoteCall::importAs<void(Player*, bool)>("GMLIB_FORM_CALLBACK", callbackId); \
|
||||
callback(&pl, data); \
|
||||
} else { \
|
||||
ServerSettingForm::removeElement(result); \
|
||||
} \
|
||||
} catch (...) {} \
|
||||
}
|
||||
|
||||
#define CALLBACK_TYPE_DOUBLE \
|
||||
[callbackId, result](Player& pl, double data) { \
|
||||
try { \
|
||||
if (RemoteCall::hasFunc("GMLIB_FORM_CALLBACK", callbackId)) { \
|
||||
auto const& callback = RemoteCall::importAs<void(Player*, double)>("GMLIB_FORM_CALLBACK", callbackId); \
|
||||
callback(&pl, data); \
|
||||
} else { \
|
||||
ServerSettingForm::removeElement(result); \
|
||||
} \
|
||||
} catch (...) {} \
|
||||
}
|
||||
|
||||
|
||||
#define CALLBACK_TYPE_LONG \
|
||||
[callbackId, result](Player& pl, int64 data) { \
|
||||
try { \
|
||||
if (RemoteCall::hasFunc("GMLIB_FORM_CALLBACK", callbackId)) { \
|
||||
auto const& callback = RemoteCall::importAs<void(Player*, int64)>("GMLIB_FORM_CALLBACK", callbackId); \
|
||||
callback(&pl, data); \
|
||||
} else { \
|
||||
ServerSettingForm::removeElement(result); \
|
||||
} \
|
||||
} catch (...) {} \
|
||||
}
|
||||
|
||||
|
||||
void Export_Form_API() {
|
||||
RemoteCall::exportAs("GMLIB_ServerSettingForm", "getDefaultPriority", []() -> int {
|
||||
return ServerSettingForm::getDefaultPriority();
|
||||
RemoteCall::exportAs("GMLIB_gmlib::form::ServerSettingForm", "getDefaultPriority", []() -> int {
|
||||
return gmlib::form::ServerSettingForm::getDefaultPriority();
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_FormAPI", "getNextFormCallbackId", []() -> std::string {
|
||||
return LegacyScriptFormManager::getInstance().getNextFormCallbackId();
|
||||
// RemoteCall::exportAs("GMLIB_FormAPI", "getNextFormCallbackId", []() -> std::string {
|
||||
// return LegacyScriptFormManager::getInstance().getNextFormCallbackId();
|
||||
// });
|
||||
RemoteCall::exportAs("GMLIB_gmlib::form::ServerSettingForm", "hasTitle", []() -> bool { return gmlib::form::ServerSettingForm::hasTitle(); });
|
||||
RemoteCall::exportAs("GMLIB_gmlib::form::ServerSettingForm", "getTitle", []() -> std::string {
|
||||
return gmlib::form::ServerSettingForm::getTitle();
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_ServerSettingForm", "hasTitle", []() -> bool { return ServerSettingForm::hasTitle(); });
|
||||
RemoteCall::exportAs("GMLIB_ServerSettingForm", "getTitle", []() -> std::string {
|
||||
return ServerSettingForm::getTitle();
|
||||
RemoteCall::exportAs("GMLIB_gmlib::form::ServerSettingForm", "setTitle", [](std::string const& title, bool forceModify) -> bool {
|
||||
return gmlib::form::ServerSettingForm::setTitle(title, forceModify);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_ServerSettingForm", "setTitle", [](std::string const& title, bool forceModify) -> bool {
|
||||
return ServerSettingForm::setTitle(title, forceModify);
|
||||
RemoteCall::exportAs("GMLIB_gmlib::form::ServerSettingForm", "hasIcon", []() -> bool { return gmlib::form::ServerSettingForm::hasIcon(); });
|
||||
RemoteCall::exportAs("GMLIB_gmlib::form::ServerSettingForm", "getIconData", []() -> std::string {
|
||||
return gmlib::form::ServerSettingForm::getIconData().value_or("");
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_ServerSettingForm", "hasIcon", []() -> bool { return ServerSettingForm::hasIcon(); });
|
||||
RemoteCall::exportAs("GMLIB_ServerSettingForm", "getIconData", []() -> std::string {
|
||||
if (auto data = ServerSettingForm::getIconData()) {
|
||||
return data.value();
|
||||
}
|
||||
return "";
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_ServerSettingForm", "getIconType", []() -> int {
|
||||
if (auto type = ServerSettingForm::getIconType()) {
|
||||
return (int)type.value();
|
||||
}
|
||||
return -1;
|
||||
RemoteCall::exportAs("GMLIB_gmlib::form::ServerSettingForm", "getIconType", []() -> int {
|
||||
return gmlib::form::ServerSettingForm::getIconType()
|
||||
.transform([](gmlib::form::IconType&& type) -> int { return (int)type; })
|
||||
.value_or(-1);
|
||||
});
|
||||
RemoteCall::exportAs(
|
||||
"GMLIB_ServerSettingForm",
|
||||
"GMLIB_gmlib::form::ServerSettingForm",
|
||||
"setIcon",
|
||||
[](std::string const& title, uchar type, bool forceModify) -> bool {
|
||||
return ServerSettingForm::setIcon(title, IconType(type), forceModify);
|
||||
return gmlib::form::ServerSettingForm::setIcon(title, gmlib::form::IconType(type), forceModify);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
"GMLIB_ServerSettingForm",
|
||||
"GMLIB_gmlib::form::ServerSettingForm",
|
||||
"addLabel",
|
||||
[](std::string const& text, std::string const& detectorId, int priority) -> uint {
|
||||
uint result = ServerSettingForm::addLabel(text, PLAYER_DETECROR, priority);
|
||||
uint result = gmlib::form::ServerSettingForm::addLabel(text, PLAYER_DETECROR, priority);
|
||||
return result;
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
"GMLIB_ServerSettingForm",
|
||||
"GMLIB_gmlib::form::ServerSettingForm",
|
||||
"addInput",
|
||||
[](std::string const& text,
|
||||
std::string const& placeholder,
|
||||
@@ -139,11 +91,11 @@ void Export_Form_API() {
|
||||
std::string const& callbackId,
|
||||
std::string const& detectorId,
|
||||
int priority) -> uint {
|
||||
uint result = ServerSettingForm::addInput(
|
||||
uint result = gmlib::form::ServerSettingForm::addInput(
|
||||
text,
|
||||
placeholder,
|
||||
defaultVal,
|
||||
CALLBACK_TYPE_STRING,
|
||||
CALLBACK_TYPE(std::string const&),
|
||||
PLAYER_DETECROR,
|
||||
priority
|
||||
);
|
||||
@@ -151,19 +103,19 @@ void Export_Form_API() {
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
"GMLIB_ServerSettingForm",
|
||||
"GMLIB_gmlib::form::ServerSettingForm",
|
||||
"addToggle",
|
||||
[](std::string const& text,
|
||||
bool defaultVal,
|
||||
std::string const& callbackId,
|
||||
std::string const& detectorId,
|
||||
int priority) -> uint {
|
||||
uint result = ServerSettingForm::addToggle(text, defaultVal, CALLBACK_TYPE_BOOL, PLAYER_DETECROR, priority);
|
||||
uint result = gmlib::form::ServerSettingForm::addToggle(text, defaultVal, CALLBACK_TYPE(bool), PLAYER_DETECROR, priority);
|
||||
return result;
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
"GMLIB_ServerSettingForm",
|
||||
"GMLIB_gmlib::form::ServerSettingForm",
|
||||
"addDropdown",
|
||||
[](std::string const& text,
|
||||
std::vector<std::string> options,
|
||||
@@ -171,11 +123,11 @@ void Export_Form_API() {
|
||||
std::string const& callbackId,
|
||||
std::string const& detectorId,
|
||||
int priority) -> uint {
|
||||
uint result = ServerSettingForm::addDropdown(
|
||||
uint result = gmlib::form::ServerSettingForm::addDropdown(
|
||||
text,
|
||||
options,
|
||||
defaultVal,
|
||||
CALLBACK_TYPE_LONG,
|
||||
CALLBACK_TYPE(int64),
|
||||
PLAYER_DETECROR,
|
||||
priority
|
||||
);
|
||||
@@ -183,7 +135,7 @@ void Export_Form_API() {
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
"GMLIB_ServerSettingForm",
|
||||
"GMLIB_gmlib::form::ServerSettingForm",
|
||||
"addSlider",
|
||||
[](std::string const& text,
|
||||
double min,
|
||||
@@ -193,13 +145,13 @@ void Export_Form_API() {
|
||||
std::string const& callbackId,
|
||||
std::string const& detectorId,
|
||||
int priority) -> uint {
|
||||
uint result = ServerSettingForm::addSlider(
|
||||
uint result = gmlib::form::ServerSettingForm::addSlider(
|
||||
text,
|
||||
min,
|
||||
max,
|
||||
step,
|
||||
defaultVal,
|
||||
CALLBACK_TYPE_DOUBLE,
|
||||
CALLBACK_TYPE(double),
|
||||
PLAYER_DETECROR,
|
||||
priority
|
||||
);
|
||||
@@ -207,7 +159,7 @@ void Export_Form_API() {
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
"GMLIB_ServerSettingForm",
|
||||
"GMLIB_gmlib::form::ServerSettingForm",
|
||||
"addStepSlider",
|
||||
[](std::string const& text,
|
||||
std::vector<std::string> steps,
|
||||
@@ -215,18 +167,18 @@ void Export_Form_API() {
|
||||
std::string const& callbackId,
|
||||
std::string const& detectorId,
|
||||
int priority) -> uint {
|
||||
uint result = ServerSettingForm::addStepSlider(
|
||||
uint result = gmlib::form::ServerSettingForm::addStepSlider(
|
||||
text,
|
||||
steps,
|
||||
defaultVal,
|
||||
CALLBACK_TYPE_LONG,
|
||||
CALLBACK_TYPE(int64),
|
||||
PLAYER_DETECROR,
|
||||
priority
|
||||
);
|
||||
return result;
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs("GMLIB_ServerSettingForm", "removeElement", [](uint id) -> bool {
|
||||
return ServerSettingForm::removeElement(id);
|
||||
RemoteCall::exportAs("GMLIB_gmlib::form::ServerSettingForm", "removeElement", [](uint id) -> bool {
|
||||
return gmlib::form::ServerSettingForm::removeElement(id);
|
||||
});
|
||||
}
|
||||
+2
-6
@@ -1,19 +1,15 @@
|
||||
#pragma once
|
||||
#include <include_all.h>
|
||||
#include <headers/include_all.h>
|
||||
|
||||
#include <RemoteCallAPI.h>
|
||||
|
||||
using namespace GMLIB;
|
||||
using namespace Server;
|
||||
using namespace Mod;
|
||||
|
||||
#define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA")
|
||||
|
||||
#define LIB_VERSION_MAJOR 0
|
||||
#define LIB_VERSION_MINOR 13
|
||||
#define LIB_VERSION_PATCH 3
|
||||
|
||||
#define LIB_VERSION Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH)
|
||||
#define LIB_VERSION gmlib::Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH)
|
||||
|
||||
extern ll::Logger logger;
|
||||
|
||||
|
||||
+74
-76
@@ -3,13 +3,8 @@
|
||||
std::unordered_set<std::string> HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"};
|
||||
|
||||
std::variant<std::string, std::vector<RecipeIngredient>> makeRecipeUnlockingKey(std::string const& key) {
|
||||
if (HardCodedKeys.count(key)) {
|
||||
return key;
|
||||
}
|
||||
std::vector<RecipeIngredient> result;
|
||||
auto item = RecipeIngredient(key, 0, 1);
|
||||
result.emplace_back(item);
|
||||
return result;
|
||||
if (HardCodedKeys.count(key)) return key;
|
||||
return std::vector<RecipeIngredient>({RecipeIngredient(key, 0, 1)});
|
||||
}
|
||||
|
||||
void Export_Legacy_GMLib_ModAPI() {
|
||||
@@ -22,18 +17,17 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& result,
|
||||
int count,
|
||||
std::string const& unlock) -> void {
|
||||
auto level = GMLIB_Level::getInstance();
|
||||
if (!level) {
|
||||
return;
|
||||
}
|
||||
if (!gmlib::world::Level::getInstance().has_value()) return;
|
||||
std::vector<RecipeIngredient> types;
|
||||
for (auto ing : ingredients) {
|
||||
auto key = RecipeIngredient(ing, 0, 1);
|
||||
types.push_back(key);
|
||||
types.emplace_back(ing, 0, 1);
|
||||
}
|
||||
auto res = RecipeIngredient(result, 0, count);
|
||||
auto unl = makeRecipeUnlockingKey(unlock);
|
||||
JsonRecipe::registerShapelessCraftingTableRecipe(recipe_id, types, res, unl);
|
||||
gmlib::mod::recipe::JsonRecipeRegistry::registerShapelessCraftingTableRecipe(
|
||||
recipe_id,
|
||||
types,
|
||||
RecipeIngredient(result, 0, count),
|
||||
makeRecipeUnlockingKey(unlock)
|
||||
);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -45,18 +39,18 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& result,
|
||||
int count,
|
||||
std::string const& unlock) -> void {
|
||||
auto level = GMLIB_Level::getInstance();
|
||||
if (!level) {
|
||||
return;
|
||||
}
|
||||
if (!gmlib::world::Level::getInstance().has_value()) return;
|
||||
std::vector<RecipeIngredient> types;
|
||||
for (auto ing : ingredients) {
|
||||
auto key = RecipeIngredient(ing, 0, 1);
|
||||
types.push_back(key);
|
||||
types.push_back(RecipeIngredient(ing, 0, 1));
|
||||
}
|
||||
auto res = RecipeIngredient(result, 0, count);
|
||||
auto unl = makeRecipeUnlockingKey(unlock);
|
||||
JsonRecipe::registerShapedCraftingTableRecipe(recipe_id, shape, types, res, unl);
|
||||
gmlib::mod::recipe::JsonRecipeRegistry::registerShapedCraftingTableRecipe(
|
||||
recipe_id,
|
||||
shape,
|
||||
types,
|
||||
RecipeIngredient(result, 0, count),
|
||||
makeRecipeUnlockingKey(unlock)
|
||||
);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -66,13 +60,13 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& input,
|
||||
std::string const& output,
|
||||
std::vector<std::string> tags) -> void {
|
||||
auto level = GMLIB_Level::getInstance();
|
||||
if (!level) {
|
||||
return;
|
||||
}
|
||||
auto inp = RecipeIngredient(input, 0, 1);
|
||||
auto outp = RecipeIngredient(output, 0, 1);
|
||||
JsonRecipe::registerFurnaceRecipe(recipe_id, inp, outp, tags);
|
||||
if (!gmlib::world::Level::getInstance().has_value()) return;
|
||||
gmlib::mod::recipe::JsonRecipeRegistry::registerFurnaceRecipe(
|
||||
recipe_id,
|
||||
RecipeIngredient(input, 0, 1),
|
||||
RecipeIngredient(output, 0, 1),
|
||||
tags
|
||||
);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -80,12 +74,13 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
"registerBrewingMixRecipe",
|
||||
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
||||
) -> void {
|
||||
auto level = GMLIB_Level::getInstance();
|
||||
if (!level) {
|
||||
return;
|
||||
}
|
||||
auto rea = RecipeIngredient(reagent, 0, 1);
|
||||
JsonRecipe::registerBrewingMixRecipe(recipe_id, input, output, rea);
|
||||
if (!gmlib::world::Level::getInstance().has_value()) return;
|
||||
gmlib::mod::recipe::JsonRecipeRegistry::registerBrewingMixRecipe(
|
||||
recipe_id,
|
||||
input,
|
||||
output,
|
||||
RecipeIngredient(reagent, 0, 1)
|
||||
);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -93,14 +88,13 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
"registerBrewingContainerRecipe",
|
||||
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
||||
) -> void {
|
||||
auto level = GMLIB_Level::getInstance();
|
||||
if (!level) {
|
||||
return;
|
||||
}
|
||||
auto inp = RecipeIngredient(input, 0, 1);
|
||||
auto outp = RecipeIngredient(output, 0, 1);
|
||||
auto rea = RecipeIngredient(reagent, 0, 1);
|
||||
JsonRecipe::registerBrewingContainerRecipe(recipe_id, inp, outp, rea);
|
||||
if (!gmlib::world::Level::getInstance().has_value()) return;
|
||||
gmlib::mod::recipe::JsonRecipeRegistry::registerBrewingContainerRecipe(
|
||||
recipe_id,
|
||||
RecipeIngredient(input, 0, 1),
|
||||
RecipeIngredient(output, 0, 1),
|
||||
RecipeIngredient(reagent, 0, 1)
|
||||
);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -111,11 +105,14 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& base,
|
||||
std::string const& addition,
|
||||
std::string const& result) -> void {
|
||||
auto level = GMLIB_Level::getInstance();
|
||||
if (!level) {
|
||||
return;
|
||||
}
|
||||
JsonRecipe::registerSmithingTransformRecipe(recipe_id, smithing_template, base, addition, result);
|
||||
if (!gmlib::world::Level::getInstance().has_value()) return;
|
||||
gmlib::mod::recipe::JsonRecipeRegistry::registerSmithingTransformRecipe(
|
||||
recipe_id,
|
||||
smithing_template,
|
||||
base,
|
||||
addition,
|
||||
result
|
||||
);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -125,11 +122,13 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& smithing_template,
|
||||
std::string const& base,
|
||||
std::string const& addition) -> void {
|
||||
auto level = GMLIB_Level::getInstance();
|
||||
if (!level) {
|
||||
return;
|
||||
}
|
||||
JsonRecipe::registerSmithingTrimRecipe(recipe_id, smithing_template, base, addition);
|
||||
if (!gmlib::world::Level::getInstance().has_value()) return;
|
||||
gmlib::mod::recipe::JsonRecipeRegistry::registerSmithingTrimRecipe(
|
||||
recipe_id,
|
||||
smithing_template,
|
||||
base,
|
||||
addition
|
||||
);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -141,50 +140,49 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& output,
|
||||
int output_data,
|
||||
int output_count) -> void {
|
||||
auto level = GMLIB_Level::getInstance();
|
||||
if (!level) {
|
||||
return;
|
||||
}
|
||||
auto inp = RecipeIngredient(input, 0, 1);
|
||||
auto outp = RecipeIngredient(output, 0, 1);
|
||||
JsonRecipe::registerStoneCutterRecipe(recipe_id, inp, outp);
|
||||
if (!gmlib::world::Level::getInstance().has_value()) return;
|
||||
gmlib::mod::recipe::JsonRecipeRegistry::registerStoneCutterRecipe(
|
||||
recipe_id,
|
||||
RecipeIngredient(input, 0, 1),
|
||||
RecipeIngredient(output, 0, 1)
|
||||
);
|
||||
}
|
||||
);
|
||||
// 错误方块清理
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "setUnknownBlockCleaner", []() -> void {
|
||||
VanillaFix::setAutoCleanUnknownBlockEnabled();
|
||||
gmlib::tools::VanillaFix::setAutoCleanUnknownBlockEnabled();
|
||||
});
|
||||
// 实验性
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void {
|
||||
auto list = GMLIB_Level::getAllExperiments();
|
||||
auto list = gmlib::world::Level::getAllExperiments();
|
||||
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||
if (set.contains((AllExperiments)experiment_id)) {
|
||||
GMLIB_Level::addExperimentsRequire((AllExperiments)experiment_id);
|
||||
gmlib::world::Level::addExperimentsRequire((AllExperiments)experiment_id);
|
||||
} else {
|
||||
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
||||
}
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "setExperimentEnabled", [](int experiment_id, bool value) -> void {
|
||||
if (GMLIB_Level::getInstance()) {
|
||||
auto list = GMLIB_Level::getAllExperiments();
|
||||
if (gmlib::world::Level::getInstance()) {
|
||||
auto list = gmlib::world::Level::getAllExperiments();
|
||||
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||
if (set.contains((AllExperiments)experiment_id)) {
|
||||
GMLIB_Level::getInstance()->setExperimentEnabled(((AllExperiments)experiment_id), value);
|
||||
gmlib::world::Level::getInstance()->setExperimentEnabled(((AllExperiments)experiment_id), value);
|
||||
} else ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
||||
}
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "getExperimentEnabled", [](int experiment_id) -> bool {
|
||||
if (GMLIB_Level::getInstance()) {
|
||||
auto list = GMLIB_Level::getAllExperiments();
|
||||
if (gmlib::world::Level::getInstance()) {
|
||||
auto list = gmlib::world::Level::getAllExperiments();
|
||||
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||
if (set.contains((AllExperiments)experiment_id)) {
|
||||
return GMLIB_Level::getInstance()->getExperimentEnabled(((AllExperiments)experiment_id));
|
||||
} else {
|
||||
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
||||
return false;
|
||||
return gmlib::world::Level::getInstance()->getExperimentEnabled(((AllExperiments)experiment_id));
|
||||
}
|
||||
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "setFixI18nEnabled", []() -> void { VanillaFix::setFixI18nEnabled(); });
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "setFixI18nEnabled", []() -> void {
|
||||
gmlib::tools::VanillaFix::setFixI18nEnabled();
|
||||
});
|
||||
}
|
||||
+24
-25
@@ -2,50 +2,50 @@
|
||||
|
||||
void Export_Legacy_GMLib_ServerAPI() {
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void {
|
||||
GMLIB_Level::tryEnableEducationEdition();
|
||||
gmlib::world::Level::tryEnableEducationEdition();
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void {
|
||||
GMLIB_Level::tryRegisterAbilityCommand();
|
||||
gmlib::world::Level::tryRegisterAbilityCommand();
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void {
|
||||
GMLIB_Level::setForceAchievementsEnabled();
|
||||
gmlib::world::Level::setForceAchievementsEnabled();
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void {
|
||||
gmlib::world::Level::trustAllSkins();
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void { GMLIB_Level::trustAllSkins(); });
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "enableCoResourcePack", []() -> void {
|
||||
GMLIB_Level::requireServerResourcePackAndAllowClientResourcePack();
|
||||
gmlib::world::Level::requireServerResourcePackAndAllowClientResourcePack();
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
||||
if (auto level = GMLIB_Level::getInstance()) {
|
||||
return level->getLevelName();
|
||||
}
|
||||
return {};
|
||||
return gmlib::world::Level::getInstance()
|
||||
.transform([](gmlib::world::Level& level) -> std::string { return level.getLevelName(); })
|
||||
.value_or("");
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setLevelName", [](std::string const& name) -> void {
|
||||
if (auto level = GMLIB_Level::getInstance()) {
|
||||
if (auto level = gmlib::world::Level::getInstance()) {
|
||||
level->setLevelName(name);
|
||||
}
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelSeed", []() -> std::string {
|
||||
if (auto level = GMLIB_Level::getInstance()) {
|
||||
return std::to_string(level->getSeed());
|
||||
}
|
||||
return {};
|
||||
return gmlib::world::Level::getInstance()
|
||||
.transform([](gmlib::world::Level& level) -> std::string { return std::to_string(level.getSeed()); })
|
||||
.value_or("");
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setFakeSeed", [](int64_t seed) -> void {
|
||||
return GMLIB_Level::setFakeSeed(seed);
|
||||
return gmlib::world::Level::setFakeSeed(seed);
|
||||
});
|
||||
RemoteCall::exportAs(
|
||||
"GMLib_ServerAPI",
|
||||
"spawnEntity",
|
||||
[](std::pair<Vec3, int> pos, std::string const& name) -> Actor* {
|
||||
return GMLIB_Spawner::spawnEntity(pos.first, pos.second, name).as_ptr();
|
||||
return gmlib::world::Spawner::spawnEntity(pos.first, pos.second, name).as_ptr();
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
"GMLib_ServerAPI",
|
||||
"shootProjectile",
|
||||
[](Actor* owner, std::string const& name, float speed, float offset) -> Actor* {
|
||||
auto ac = (GMLIB_Actor*)owner;
|
||||
auto ac = (gmlib::world::Actor*)owner;
|
||||
return ac->shootProjectile(name, speed, offset).as_ptr();
|
||||
}
|
||||
);
|
||||
@@ -53,7 +53,7 @@ void Export_Legacy_GMLib_ServerAPI() {
|
||||
"GMLib_ServerAPI",
|
||||
"throwEntity",
|
||||
[](Actor* owner, Actor* actor, float speed, float offset) -> bool {
|
||||
auto ac = (GMLIB_Actor*)owner;
|
||||
auto ac = (gmlib::world::Actor*)owner;
|
||||
return ac->throwEntity(*actor, speed, offset);
|
||||
}
|
||||
);
|
||||
@@ -62,19 +62,18 @@ void Export_Legacy_GMLib_ServerAPI() {
|
||||
"GMLib_ServerAPI",
|
||||
"addFakeList",
|
||||
[](const std::string& name, const std::string& xuid) -> bool {
|
||||
return FakeList::addFakeList(name, xuid, ActorUniqueID(-1));
|
||||
return gmlib::tools::FakeList::addFakeList(name, xuid, ActorUniqueID(-1));
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "removeFakeList", [](const std::string& nameOrXuid) -> bool {
|
||||
return FakeList::removeFakeList(nameOrXuid);
|
||||
return gmlib::tools::FakeList::removeFakeList(nameOrXuid);
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "removeAllFakeList", []() -> void {
|
||||
return FakeList::removeAllFakeLists();
|
||||
return gmlib::tools::FakeList::removeAllFakeLists();
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "getMaxPlayers", []() -> int {
|
||||
if (auto level = GMLIB_Level::getInstance()) {
|
||||
return level->getMaxPlayerCount();
|
||||
}
|
||||
return {};
|
||||
return gmlib::world::Level::getInstance()
|
||||
.transform([](gmlib::world::Level& level) -> int { return level.getMaxPlayerCount(); })
|
||||
.value_or(0);
|
||||
});
|
||||
}
|
||||
|
||||
+30
-15
@@ -13,9 +13,11 @@ bool isParameters(std::string const& str) {
|
||||
return std::regex_search(removeBrackets(str), reg);
|
||||
}
|
||||
|
||||
std::string GetValue(std::string const& from) { return PlaceholderAPI::getValue(from); }
|
||||
std::string GetValue(std::string const& from) { return gmlib::tools::PlaceholderAPI::getValue(from); }
|
||||
|
||||
std::string GetValueWithPlayer(std::string const& key, Player* player) { return PlaceholderAPI::getValue(key, player); }
|
||||
std::string GetValueWithPlayer(std::string const& key, Player* player) {
|
||||
return gmlib::tools::PlaceholderAPI::getValue(key, player);
|
||||
}
|
||||
|
||||
bool registerPlayerPlaceholder(
|
||||
std::string const& PluginName,
|
||||
@@ -23,20 +25,24 @@ bool registerPlayerPlaceholder(
|
||||
std::string const& PAPIName
|
||||
) {
|
||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||
gmlib::tools::PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||
if (isParameters(PAPIName)) {
|
||||
auto Call = RemoteCall::importAs<std::string(Player * pl, std::unordered_map<std::string, std::string>)>(
|
||||
PluginName,
|
||||
FuncName
|
||||
);
|
||||
PlaceholderAPI::registerPlayerPlaceholder(
|
||||
gmlib::tools::PlaceholderAPI::registerPlayerPlaceholder(
|
||||
PAPIName,
|
||||
[Call](Player* sp, std::unordered_map<std::string, std::string> map) { return Call(sp, map); },
|
||||
PluginName
|
||||
);
|
||||
} else {
|
||||
auto Call = RemoteCall::importAs<std::string(Player * pl)>(PluginName, FuncName);
|
||||
PlaceholderAPI::registerPlayerPlaceholder(PAPIName, [Call](Player* sp) { return Call(sp); }, PluginName);
|
||||
gmlib::tools::PlaceholderAPI::registerPlayerPlaceholder(
|
||||
PAPIName,
|
||||
[Call](Player* sp) { return Call(sp); },
|
||||
PluginName
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -49,18 +55,18 @@ bool registerServerPlaceholder(
|
||||
std::string const& PAPIName
|
||||
) {
|
||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||
gmlib::tools::PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||
if (isParameters(PAPIName)) {
|
||||
auto Call =
|
||||
RemoteCall::importAs<std::string(std::unordered_map<std::string, std::string>)>(PluginName, FuncName);
|
||||
PlaceholderAPI::registerServerPlaceholder(
|
||||
gmlib::tools::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);
|
||||
PlaceholderAPI::registerServerPlaceholder(PAPIName, [Call]() { return Call(); }, PluginName);
|
||||
gmlib::tools::PlaceholderAPI::registerServerPlaceholder(PAPIName, [Call]() { return Call(); }, PluginName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -74,13 +80,22 @@ bool registerStaticPlaceholder(
|
||||
int num
|
||||
) {
|
||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||
gmlib::tools::PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||
if (isParameters(PAPIName)) {
|
||||
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
||||
if (num == -1) {
|
||||
PlaceholderAPI::registerStaticPlaceholder(PAPIName, [Call] { return Call(); }, PluginName);
|
||||
gmlib::tools::PlaceholderAPI::registerStaticPlaceholder(
|
||||
PAPIName,
|
||||
[Call] { return Call(); },
|
||||
PluginName
|
||||
);
|
||||
} else {
|
||||
PlaceholderAPI::registerStaticPlaceholder(PAPIName, num, [Call] { return Call(); }, PluginName);
|
||||
gmlib::tools::PlaceholderAPI::registerStaticPlaceholder(
|
||||
PAPIName,
|
||||
num,
|
||||
[Call] { return Call(); },
|
||||
PluginName
|
||||
);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -89,14 +104,14 @@ bool registerStaticPlaceholder(
|
||||
}
|
||||
|
||||
std::string translateStringWithPlayer(std::string const& str, Player* pl) {
|
||||
return PlaceholderAPI::translateString(str, pl);
|
||||
return gmlib::tools::PlaceholderAPI::translateString(str, pl);
|
||||
}
|
||||
|
||||
std::string translateString(std::string const& str) { return PlaceholderAPI::translateString(str); }
|
||||
std::string translateString(std::string const& str) { return gmlib::tools::PlaceholderAPI::translateString(str); }
|
||||
|
||||
bool unRegisterPlaceholder(std::string const& str) { return PlaceholderAPI::unregisterPlaceholder(str); }
|
||||
bool unRegisterPlaceholder(std::string const& str) { return gmlib::tools::PlaceholderAPI::unregisterPlaceholder(str); }
|
||||
|
||||
std::vector<std::string> getAllPAPI() { return PlaceholderAPI::getAllPAPI(); }
|
||||
std::vector<std::string> getAllPAPI() { return gmlib::tools::PlaceholderAPI::getAllPAPI(); }
|
||||
|
||||
} // namespace PAPIRemoteCall
|
||||
|
||||
|
||||
Reference in New Issue
Block a user