Compare commits

..

26 Commits

16 changed files with 306 additions and 147 deletions
+2 -4
View File
@@ -9,12 +9,10 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
submodules: recursive
- uses: actions/checkout@v4
- uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: branch@master
- run: |
xmake repo -u
+2 -4
View File
@@ -9,12 +9,10 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
submodules: recursive
- uses: actions/checkout@v4
- uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: branch@master
- run: |
xmake repo -u
-3
View File
@@ -1,3 +0,0 @@
[submodule "SDK-GMLIB"]
path = SDK-GMLIB
url = https://github.com/GroupMountain/SDK-GMLIB.git
Submodule SDK-GMLIB deleted from 710cc6e4c3
+126 -42
View File
@@ -110,10 +110,28 @@ const GMLIB_API = {
addFakeList: ll.import("GMLIB_API", "addFakeList"),
removeFakeList: ll.import("GMLIB_API", "removeFakeList"),
removeAllFakeLists: ll.import("GMLIB_API", "removeAllFakeList"),
setFixI18nEnabled: ll.import("GMLib_ModAPI", "setFixI18nEnabled")
setFixI18nEnabled: ll.import("GMLib_ModAPI", "setFixI18nEnabled"),
getBlockTranslateKey: ll.import("GMLIB_API", "getBlockTranslateKey"),
getItemTranslateKey: ll.import("GMLIB_API", "getItemTranslateKey"),
getEntityTranslateKey: ll.import("GMLIB_API", "getEntityTranslateKey"),
readNbtFromFile: ll.import("GMLIB_API", "readNbtFromFile"),
saveNbtToFile: ll.import("GMLIB_API", "saveNbtToFile"),
getBlockDestroySpeed: ll.import("GMLIB_API", "getBlockDestroySpeed"),
getDestroyBlockSpeed: ll.import("GMLIB_API", "getDestroyBlockSpeed"),
playerDestroyBlock: ll.import("GMLIB_API", "playerDestroyBlock"),
itemCanDestroyBlock: ll.import("GMLIB_API", "itemCanDestroyBlock"),
itemCanDestroyInCreative: ll.import("GMLIB_API", "itemCanDestroyInCreative"),
itemCanDestroySpecial: ll.import("GMLIB_API", "itemCanDestroySpecial"),
blockCanDropWithAnyTool: ll.import("GMLIB_API", "blockCanDropWithAnyTool"),
blockIsAlwaysDestroyable: ll.import("GMLIB_API", "blockIsAlwaysDestroyable"),
blockPlayerWillDestroy: ll.import("GMLIB_API", "blockPlayerWillDestroy"),
playerAttack: ll.import("GMLIB_API", "playerAttack"),
playerPullInEntity: ll.import("GMLIB_API", "playerPullInEntity"),
getBlockTranslateKeyFromName: ll.import("GMLIB_API", "getBlockTranslateKeyFromName")
}
const FloatingTextList = [];
const mStaticFloatingTextMap = new Map();
const mDynamicFloatingTextMap = new Map();
class StaticFloatingText {
constructor(pos, text, papi = true) {
@@ -121,7 +139,7 @@ class StaticFloatingText {
this.mText = text;
this.mPlaceholderAPI = papi;
this.mRuntimeId = GMLIB_API.createFloatingText(this.mPosition, this.mText, this.mPlaceholderAPI);
FloatingTextList.push(this);
mStaticFloatingTextMap.set(this.mRuntimeId, this);
}
sendToClient(player) {
@@ -175,32 +193,21 @@ class StaticFloatingText {
}
destroy() {
let size_t = FloatingTextList.indexOf(this);
FloatingTextList.splice(size_t, 1);
mStaticFloatingTextMap.delete(this.mRuntimeId);
return GMLIB_API.deleteFloatingText(this.mRuntimeId);
}
isDynamic() {
return false;
}
static getFloatingText(runtimeId) {
for (const ft of FloatingTextList) {
if (ft.getRuntimeId() == runtimeId) {
if (!ft.isDynamic()) {
return ft;
}
}
if (mStaticFloatingTextMap.has(runtimeId)) {
return mStaticFloatingTextMap.get(runtimeId);
}
return null;
}
static getAllFloatingTexts() {
let result = [];
FloatingTextList.forEach((ft) => {
if (!ft.isDynamic()) {
result.push(ft);
}
mStaticFloatingTextMap.forEach((ft) => {
result.push(ft);
});
return result;
}
@@ -208,9 +215,13 @@ class StaticFloatingText {
class DynamicFloatingText extends StaticFloatingText {
constructor(pos, text, updateRate = 1, papi = true) {
super(pos, text, papi);
this.mPosition = pos;
this.mText = text;
this.mPlaceholderAPI = papi;
this.mRuntimeId = GMLIB_API.createFloatingText(this.mPosition, this.mText, this.mPlaceholderAPI);
this.mUpdateRate = updateRate;
this.mTaskId = null;
mDynamicFloatingTextMap.set(this.mRuntimeId, this);
this.startUpdate();
}
@@ -235,7 +246,7 @@ class DynamicFloatingText extends StaticFloatingText {
}
stopUpdate() {
if (this.mTaskId != null) {
if (this.mTaskId) {
clearInterval(this.mTaskId);
this.mTaskId = null;
return true;
@@ -244,32 +255,21 @@ class DynamicFloatingText extends StaticFloatingText {
}
destroy() {
let size_t = FloatingTextList.indexOf(this);
FloatingTextList.splice(size_t, 1);
mDynamicFloatingTextMap.delete(this.mRuntimeId);
return GMLIB_API.deleteFloatingText(this.mRuntimeId);
}
isDynamic() {
return true;
}
static getFloatingText(runtimeId) {
for (const ft of FloatingTextList) {
if (ft.getRuntimeId() == runtimeId) {
if (ft.isDynamic()) {
return ft;
}
}
if (mDynamicFloatingTextMap.has(runtimeId)) {
return mDynamicFloatingTextMap.get(runtimeId);
}
return null;
}
static getAllFloatingTexts() {
let result = [];
FloatingTextList.forEach((ft) => {
if (ft.isDynamic()) {
result.push(ft);
}
mDynamicFloatingTextMap.forEach((ft) => {
result.push(ft);
});
return result;
}
@@ -413,7 +413,7 @@ class Minecraft {
}
static addFakeList(name, xuid) {
return GMLIB_API.addFakeList(xuid, name);
return GMLIB_API.addFakeList(name, xuid);
}
static removeFakeList(nameOrXuid) {
@@ -427,6 +427,18 @@ class Minecraft {
static setFixI18nEnabled() {
GMLIB_API.setFixI18nEnabled();
}
static saveNbtToFile(path, nbt, isBinary = true) {
return GMLIB_API.saveNbtToFile(path, nbt, isBinary);
}
static readNbtFromFile(path, isBinary = true) {
return GMLIB_API.readNbtFromFile(path, isBinary);
}
static getBlockTranslateKeyFromName(name) {
return GMLIB_API.getBlockTranslateKeyFromName(name);
}
}
class Recipes {
@@ -823,14 +835,18 @@ class I18nAPI {
}
static get(key, params = [], langCode = undefined) {
let data = [];
params.forEach((param) => {
data.push(param);
});
if (langCode) {
return GMLIB_API.resourcePackTranslate(key, params, langCode);
return GMLIB_API.resourcePackTranslate(key, data, langCode);
}
return GMLIB_API.resourcePackDefaultTranslate(key, params);
return GMLIB_API.resourcePackDefaultTranslate(key, data);
}
static translate(key, params = []) {
return I18nAPI.get(key, params);
static translate(key, params = [], langCode = undefined) {
return I18nAPI.get(key, params, langCode);
}
static getSupportedLanguages() {
@@ -926,6 +942,74 @@ LLSE_Entity.prototype.throwEntity = function (proj, speed = 2, offset = 3) {
return GMLIB_API.throwEntity(this, proj, speed, offset);
}
LLSE_Entity.prototype.getTranslateKey = function () {
return GMLIB_API.getEntityTranslateKey(this);
}
LLSE_Entity.prototype.getTranslateName = function (language) {
return I18nAPI.get(this.getTranslateKey(), [], language);
}
LLSE_Block.prototype.getTranslateKey = function () {
return GMLIB_API.getBlockTranslateKey(this);
}
LLSE_Block.prototype.getTranslateName = function (language) {
return I18nAPI.get(this.getTranslateKey(), [], language);
}
LLSE_Item.prototype.getTranslateKey = function () {
return GMLIB_API.getItemTranslateKey(this);
}
LLSE_Item.prototype.getTranslateName = function (language) {
return I18nAPI.get(this.getTranslateKey(), [], language);
}
LLSE_Block.prototype.getBlockDestroySpeed = function () {
return GMLIB_API.getBlockDestroySpeed(this);
}
LLSE_Item.prototype.getDestroyBlockSpeed = function (block) {
return GMLIB_API.getDestroyBlockSpeed(this, block);
}
LLSE_Block.prototype.playerDestroy = function (player) {
GMLIB_API.playerDestroyBlock(this, this.pos, player);
}
LLSE_Item.prototype.canDestroy = function (block) {
return GMLIB_API.itemCanDestroyBlock(this, block);
}
LLSE_Item.prototype.canDestroyInCreative = function () {
return GMLIB_API.itemCanDestroyInCreative(this);
}
LLSE_Item.prototype.canDestroySpecial = function (block) {
return GMLIB_API.itemCanDestroySpecial(this, block);
}
LLSE_Block.prototype.canDropWithAnyTool = function () {
return GMLIB_API.blockCanDropWithAnyTool(this);
}
LLSE_Block.prototype.isAlwaysDestroyable = function () {
return GMLIB_API.blockIsAlwaysDestroyable(this);
}
LLSE_Block.prototype.playerWillDestroy = function (player) {
return GMLIB_API.blockPlayerWillDestroy(this, player, this.pos);
}
LLSE_Player.prototype.attack = function (entity) {
return GMLIB_API.playerAttack(this, entity);
}
LLSE_Player.prototype.pullInEntity = function (entity) {
return GMLIB_API.playerPullInEntity(this, entity);
}
module.exports = {
StaticFloatingText,
DynamicFloatingText,
+2 -1
View File
@@ -1,9 +1,10 @@
{
"name": "${pluginName}",
"entry": "${pluginFile}",
"version": "0.12.6",
"version": "0.13.0",
"author": "GroupMountain",
"type": "native",
"passive": true,
"dependencies": [
{
"name": "GMLIB"
+98 -23
View File
@@ -19,10 +19,10 @@ void Export_Compatibility_API() {
if (!level) {
return false;
}
return GMLIB::Mod::CustomRecipe::unregisterRecipe(id);
return CustomRecipe::unregisterRecipe(id);
});
RemoteCall::exportAs("GMLIB_API", "setCustomPackPath", [](std::string const& path) -> void {
GMLIB::Mod::CustomPacks::addCustomPackPath(path);
CustomPacks::addCustomPackPath(path);
});
RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> float {
auto level = GMLIB_Level::getInstance();
@@ -96,70 +96,71 @@ void Export_Compatibility_API() {
"GMLIB_API",
"createFloatingText",
[](std::pair<Vec3, int> pos, std::string const& text, bool papi) -> int {
auto ft = std::make_shared<GMLIB::Server::StaticFloatingText>(text, pos.first, pos.second, papi);
GMLIB::Server::FloatingTextManager::getInstance().add(ft);
auto& manager = FloatingTextManager::getInstance();
auto ft = manager.createStatic(text, pos.first, pos.second, papi);
manager.add(ft);
return ft->getRuntimeID();
}
);
RemoteCall::exportAs("GMLIB_API", "setFloatingTextData", [](int id, std::string const& text) -> bool {
if (auto ft = GMLIB::Server::FloatingTextManager::getInstance().getFloatingText(id)) {
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
ft->setText(text);
return true;
}
return false;
});
RemoteCall::exportAs("GMLIB_API", "deleteFloatingText", [](int id) -> bool {
return GMLIB::Server::FloatingTextManager::getInstance().remove(id);
return FloatingTextManager::getInstance().remove(id);
});
RemoteCall::exportAs("GMLIB_API", "sendFloatingTextToPlayer", [](int id, Player* pl) -> bool {
if (auto ft = GMLIB::Server::FloatingTextManager::getInstance().getFloatingText(id)) {
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
ft->sendTo(*pl);
return true;
}
return false;
});
RemoteCall::exportAs("GMLIB_API", "sendFloatingText", [](int id) -> bool {
if (auto ft = GMLIB::Server::FloatingTextManager::getInstance().getFloatingText(id)) {
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
ft->sendToClients();
return true;
}
return false;
});
RemoteCall::exportAs("GMLIB_API", "removeFloatingTextFromPlayer", [](int id, Player* pl) -> bool {
if (auto ft = GMLIB::Server::FloatingTextManager::getInstance().getFloatingText(id)) {
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
ft->removeFrom(*pl);
return true;
}
return false;
});
RemoteCall::exportAs("GMLIB_API", "removeFloatingText", [](int id) -> bool {
if (auto ft = GMLIB::Server::FloatingTextManager::getInstance().getFloatingText(id)) {
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
ft->removeFromClients();
return true;
}
return false;
});
RemoteCall::exportAs("GMLIB_API", "updateClientFloatingTextData", [](int id, Player* pl) -> bool {
if (auto ft = GMLIB::Server::FloatingTextManager::getInstance().getFloatingText(id)) {
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
ft->update(*pl);
return true;
}
return false;
});
RemoteCall::exportAs("GMLIB_API", "updateAllClientsFloatingTextData", [](int id) -> bool {
if (auto ft = GMLIB::Server::FloatingTextManager::getInstance().getFloatingText(id)) {
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
ft->updateClients();
return true;
}
return false;
});
RemoteCall::exportAs("GMLIB_API", "isVersionMatched", [](int a, int b, int c) -> bool {
auto version = GMLIB::Version(a, b, c, "", "");
auto version = Version(a, b, c, "", "");
return LIB_VERSION >= version;
});
RemoteCall::exportAs("GMLIB_API", "getVersion_LRCA", []() -> std::string { return LIB_VERSION.asString(); });
RemoteCall::exportAs("GMLIB_API", "getVersion_GMLIB", []() -> std::string {
return GMLIB::Version::getLibVersionString();
return Version::getLibVersionString();
});
RemoteCall::exportAs(
"GMLIB_API",
@@ -198,7 +199,8 @@ void Export_Compatibility_API() {
RemoteCall::exportAs(
"GMLIB_API",
"updateOrCreateLanguageFile",
[](std::string const& code, std::string const& lang, std::string const& path) -> void {
[](std::string const& code, std::unordered_map<std::string, std::string> lang, std::string const& path
) -> void {
if (GMLIB_Level::getInstance()) {
I18nAPI::updateOrCreateLanguageFile(path, code, lang);
}
@@ -554,32 +556,32 @@ void Export_Compatibility_API() {
);
RemoteCall::exportAs("GMLIB_API", "getXuidByUuid", [](std::string const& uuid) -> std::string {
auto uid = mce::UUID::fromString(uuid);
auto result = GMLIB::UserCache::getXuidByUuid(uid);
auto result = UserCache::getXuidByUuid(uid);
return result ? result.value() : "";
});
RemoteCall::exportAs("GMLIB_API", "getNameByUuid", [](std::string const& uuid) -> std::string {
auto uid = mce::UUID::fromString(uuid);
auto result = GMLIB::UserCache::getNameByUuid(uid);
auto result = UserCache::getNameByUuid(uid);
return result ? result.value() : "";
});
RemoteCall::exportAs("GMLIB_API", "getUuidByXuid", [](std::string const& xuid) -> std::string {
auto result = GMLIB::UserCache::getUuidByXuid(xuid);
auto result = UserCache::getUuidByXuid(xuid);
return result ? result.value().asString() : "";
});
RemoteCall::exportAs("GMLIB_API", "getNameByXuid", [](std::string const& xuid) -> std::string {
auto result = GMLIB::UserCache::getNameByXuid(xuid);
auto result = UserCache::getNameByXuid(xuid);
return result ? result.value() : "";
});
RemoteCall::exportAs("GMLIB_API", "getXuidByName", [](std::string const& name) -> std::string {
auto result = GMLIB::UserCache::getXuidByName(name);
auto result = UserCache::getXuidByName(name);
return result ? result.value() : "";
});
RemoteCall::exportAs("GMLIB_API", "getUuidByName", [](std::string const& name) -> std::string {
auto result = GMLIB::UserCache::getUuidByName(name);
auto result = UserCache::getUuidByName(name);
return result ? result.value().asString() : "";
});
RemoteCall::exportAs("GMLIB_API", "getUuidByName", [](std::string const& name) -> std::string {
auto result = GMLIB::UserCache::getUuidByName(name);
auto result = UserCache::getUuidByName(name);
return result ? result.value().asString() : "";
});
RemoteCall::exportAs(
@@ -587,7 +589,7 @@ void Export_Compatibility_API() {
"getAllPlayerInfo",
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
std::vector<std::unordered_map<std::string, std::string>> result;
GMLIB::UserCache::forEach([&result](const GMLIB::UserCache::UserCacheEntry& entry) {
UserCache::forEach([&result](const UserCache::UserCacheEntry& entry) {
std::unordered_map<std::string, std::string> info;
info["Name"] = entry.mName;
info["Xuid"] = entry.mXuid;
@@ -603,4 +605,77 @@ void Export_Compatibility_API() {
}
return 0;
});
RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKey", [](Block const* block) -> std::string {
return block->buildDescriptionId();
});
RemoteCall::exportAs("GMLIB_API", "getItemTranslateKey", [](ItemStack* item) -> std::string {
return item->getDescriptionId();
});
RemoteCall::exportAs("GMLIB_API", "getEntityTranslateKey", [](Actor* entity) -> std::string {
return entity->getEntityLocNameString();
});
RemoteCall::exportAs(
"GMLIB_API",
"readNbtFromFile",
[](std::string const& path, bool isBinary) -> std::unique_ptr<CompoundTag> {
if (auto nbt = GMLIB_CompoundTag::readFromFile(path, isBinary)) {
return std::make_unique<CompoundTag>(nbt.value());
}
return nullptr;
}
);
RemoteCall::exportAs(
"GMLIB_API",
"saveNbtToFile",
[](std::string const& path, CompoundTag* nbt, bool isBinary) -> bool {
return GMLIB_CompoundTag::saveToFile(path, *nbt, isBinary);
}
);
RemoteCall::exportAs("GMLIB_API", "getBlockDestroySpeed", [](Block const* block) -> float {
return block->getDestroySpeed();
});
RemoteCall::exportAs("GMLIB_API", "getDestroyBlockSpeed", [](ItemStack const* item, Block const* block) -> float {
return item->getDestroySpeed(*block);
});
RemoteCall::exportAs(
"GMLIB_API",
"playerDestroyBlock",
[](Block const* block, std::pair<BlockPos, int> pos, Player* player) -> void {
return block->playerDestroy(*player, pos.first);
}
);
RemoteCall::exportAs("GMLIB_API", "itemCanDestroyBlock", [](ItemStack const* item, Block const* block) -> bool {
return item->canDestroy(block);
});
RemoteCall::exportAs("GMLIB_API", "itemCanDestroyInCreative", [](ItemStack const* item) -> bool {
return item->getItem()->canDestroyInCreative();
});
RemoteCall::exportAs("GMLIB_API", "itemCanDestroySpecial", [](ItemStack const* item, Block const* block) -> bool {
return item->canDestroySpecial(*block);
});
RemoteCall::exportAs("GMLIB_API", "blockCanDropWithAnyTool", [](Block const* block) -> bool {
return block->canDropWithAnyTool();
});
RemoteCall::exportAs("GMLIB_API", "blockIsAlwaysDestroyable", [](Block const* block) -> bool {
return block->getMaterial().isAlwaysDestroyable();
});
RemoteCall::exportAs(
"GMLIB_API",
"blockPlayerWillDestroy",
[](Block const* block, Player* player, std::pair<BlockPos, int> pos) -> bool {
return block->playerWillDestroy(*player, pos.first);
}
);
RemoteCall::exportAs("GMLIB_API", "playerAttack", [](Player* player, Actor* entity) -> bool {
return player->attack(*entity, ActorDamageCause::EntityAttack);
});
RemoteCall::exportAs("GMLIB_API", "playerPullInEntity", [](Player* player, Actor* entity) -> bool {
return player->pullInEntity(*entity);
});
RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKeyFromName", [](std::string const& blockName) -> std::string {
if (auto block = Block::tryGetFromRegistry(blockName)) {
return block->buildDescriptionId();
}
return "tile.unknown.name";
});
}
+10 -10
View File
@@ -3,14 +3,14 @@
ll::Logger logger(PLUGIN_NAME);
namespace GMLIB_LegacyRemoteCallApi {
namespace GMLIB {
std::unique_ptr<LRCA>& LRCA::getInstance() {
static std::unique_ptr<LRCA> instance;
std::unique_ptr<LegacyRemoteCallApi>& LegacyRemoteCallApi::getInstance() {
static std::unique_ptr<LegacyRemoteCallApi> instance;
return instance;
}
bool LRCA::load() {
bool LegacyRemoteCallApi::load() {
Export_Legacy_GMLib_ModAPI();
Export_Legacy_GMLib_ServerAPI();
Export_Compatibility_API();
@@ -19,18 +19,18 @@ bool LRCA::load() {
logger.info("GMLIB-LegacyRemoteCallApi Loaded!");
logger.info(
"Loaded Version: {} with {}",
fmt::format(fg(fmt::color::pink), "GMLIB-" + GMLIB::Version::getLibVersionString()),
fmt::format(fg(fmt::color::light_green), "GMLIB-LegacyRemoteCallApi-"+LIB_VERSION.asString())
fmt::format(fg(fmt::color::pink), "GMLIB-" + Version::getLibVersionString()),
fmt::format(fg(fmt::color::light_green), "GMLIB-LegacyRemoteCallApi-" + LIB_VERSION.asString())
);
logger.info("Author: GroupMountain");
logger.info("Repository: https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi");
return true;
}
bool LRCA::enable() { return true; }
bool LegacyRemoteCallApi::enable() { return true; }
bool LRCA::disable() { return true; }
bool LegacyRemoteCallApi::disable() { return true; }
} // namespace GMLIB_LegacyRemoteCallApi
} // namespace GMLIB
LL_REGISTER_PLUGIN(GMLIB_LegacyRemoteCallApi::LRCA, GMLIB_LegacyRemoteCallApi::LRCA::getInstance());
LL_REGISTER_PLUGIN(LegacyRemoteCallApi, LegacyRemoteCallApi::getInstance());
+5 -5
View File
@@ -2,14 +2,14 @@
#include <ll/api/plugin/NativePlugin.h>
#include <ll/api/plugin/RegisterHelper.h>
namespace GMLIB_LegacyRemoteCallApi {
namespace GMLIB {
class LRCA {
class LegacyRemoteCallApi {
public:
static std::unique_ptr<LRCA>& getInstance();
static std::unique_ptr<LegacyRemoteCallApi>& getInstance();
LRCA(ll::plugin::NativePlugin& self) : mSelf(self) {}
LegacyRemoteCallApi(ll::plugin::NativePlugin& self) : mSelf(self) {}
[[nodiscard]] ll::plugin::NativePlugin& getSelf() const { return mSelf; }
@@ -30,4 +30,4 @@ private:
ll::plugin::NativePlugin& mSelf;
};
} // namespace GMLIB_LegacyRemoteCallApi
} // namespace GMLIB
+20 -20
View File
@@ -16,8 +16,8 @@ void Export_Event_API() {
std::string const& serverXuid,
std::string const& clientXuid
)>(eventName, eventId);
eventBus->emplaceListener<GMLIB::Event::PacketEvent::ClientLoginAfterEvent>(
[Call](GMLIB::Event::PacketEvent::ClientLoginAfterEvent& ev) {
eventBus->emplaceListener<Event::PacketEvent::ClientLoginAfterEvent>(
[Call](Event::PacketEvent::ClientLoginAfterEvent& ev) {
try {
Call(
ev.getRealName(),
@@ -36,8 +36,8 @@ void Export_Event_API() {
eventName,
eventId
);
eventBus->emplaceListener<GMLIB::Event::LevelEvent::WeatherUpdateBeforeEvent>(
[Call](GMLIB::Event::LevelEvent::WeatherUpdateBeforeEvent& ev) {
eventBus->emplaceListener<Event::LevelEvent::WeatherUpdateBeforeEvent>(
[Call](Event::LevelEvent::WeatherUpdateBeforeEvent& ev) {
bool result = true;
try {
result = Call(
@@ -56,8 +56,8 @@ void Export_Event_API() {
}
case doHash("onMobPick"): {
auto Call = RemoteCall::importAs<bool(Actor * mob, Actor * item)>(eventName, eventId);
eventBus->emplaceListener<GMLIB::Event::EntityEvent::MobPickupItemBeforeEvent>(
[Call](GMLIB::Event::EntityEvent::MobPickupItemBeforeEvent& ev) {
eventBus->emplaceListener<Event::EntityEvent::MobPickupItemBeforeEvent>(
[Call](Event::EntityEvent::MobPickupItemBeforeEvent& ev) {
bool result = true;
try {
result = Call(&ev.self(), (Actor*)&ev.getItemActor());
@@ -72,8 +72,8 @@ void Export_Event_API() {
case doHash("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) {
eventBus->emplaceListener<Event::EntityEvent::ItemActorSpawnBeforeEvent>(
[Call](Event::EntityEvent::ItemActorSpawnBeforeEvent& ev) {
auto pos = ev.getPosition();
auto dimid = ev.getBlockSource().getDimensionId().id;
std::pair<Vec3, int> lsePos = {pos, dimid};
@@ -94,8 +94,8 @@ void Export_Event_API() {
eventName,
eventId
);
eventBus->emplaceListener<GMLIB::Event::EntityEvent::ItemActorSpawnAfterEvent>(
[Call](GMLIB::Event::EntityEvent::ItemActorSpawnAfterEvent& ev) {
eventBus->emplaceListener<Event::EntityEvent::ItemActorSpawnAfterEvent>(
[Call](Event::EntityEvent::ItemActorSpawnAfterEvent& ev) {
auto pos = ev.getPosition();
auto dimid = ev.getBlockSource().getDimensionId().id;
std::pair<Vec3, int> lsePos = {pos, dimid};
@@ -108,8 +108,8 @@ void Export_Event_API() {
}
case doHash("onEntityChangeDim"): {
auto Call = RemoteCall::importAs<bool(Actor * entity, int toDimId)>(eventName, eventId);
eventBus->emplaceListener<GMLIB::Event::EntityEvent::ActorChangeDimensionBeforeEvent>(
[Call](GMLIB::Event::EntityEvent::ActorChangeDimensionBeforeEvent& ev) {
eventBus->emplaceListener<Event::EntityEvent::ActorChangeDimensionBeforeEvent>(
[Call](Event::EntityEvent::ActorChangeDimensionBeforeEvent& ev) {
bool result = true;
try {
result = Call(&ev.self(), ev.getToDimensionId());
@@ -123,8 +123,8 @@ void Export_Event_API() {
}
case doHash("onLeaveBed"): {
auto Call = RemoteCall::importAs<bool(Player * pl)>(eventName, eventId);
eventBus->emplaceListener<GMLIB::Event::PlayerEvent::PlayerStopSleepBeforeEvent>(
[Call](GMLIB::Event::PlayerEvent::PlayerStopSleepBeforeEvent& ev) {
eventBus->emplaceListener<Event::PlayerEvent::PlayerStopSleepBeforeEvent>(
[Call](Event::PlayerEvent::PlayerStopSleepBeforeEvent& ev) {
bool result = true;
try {
result = Call(&ev.self());
@@ -142,8 +142,8 @@ void Export_Event_API() {
eventName,
eventId
);
eventBus->emplaceListener<GMLIB::Event::EntityEvent::DeathMessageAfterEvent>(
[Call](GMLIB::Event::EntityEvent::DeathMessageAfterEvent& ev) {
eventBus->emplaceListener<Event::EntityEvent::DeathMessageAfterEvent>(
[Call](Event::EntityEvent::DeathMessageAfterEvent& ev) {
auto msg = ev.getDeathMessage();
auto source = ev.getDamageSource();
try {
@@ -158,8 +158,8 @@ void Export_Event_API() {
eventName,
eventId
);
eventBus->emplaceListener<GMLIB::Event::EntityEvent::MobHurtAfterEvent>(
[Call](GMLIB::Event::EntityEvent::MobHurtAfterEvent& ev) {
eventBus->emplaceListener<Event::EntityEvent::MobHurtAfterEvent>(
[Call](Event::EntityEvent::MobHurtAfterEvent& ev) {
auto& damageSource = ev.getSource();
Actor* source = nullptr;
if (damageSource.isEntitySource()) {
@@ -178,8 +178,8 @@ void Export_Event_API() {
}
case doHash("onEndermanTake"): {
auto Call = RemoteCall::importAs<bool(Actor * mob)>(eventName, eventId);
eventBus->emplaceListener<GMLIB::Event::EntityEvent::EndermanTakeBlockBeforeEvent>(
[Call](GMLIB::Event::EntityEvent::EndermanTakeBlockBeforeEvent& ev) {
eventBus->emplaceListener<Event::EntityEvent::EndermanTakeBlockBeforeEvent>(
[Call](Event::EntityEvent::EndermanTakeBlockBeforeEvent& ev) {
bool result = true;
try {
result = Call(&ev.self());
+9 -1
View File
@@ -3,9 +3,17 @@
#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 GMLIB::Version(0, 12, 6)
#define LIB_VERSION_MAJOR 0
#define LIB_VERSION_MINOR 13
#define LIB_VERSION_PATCH 0
#define LIB_VERSION Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH)
extern ll::Logger logger;
+10 -10
View File
@@ -33,7 +33,7 @@ void Export_Legacy_GMLib_ModAPI() {
}
auto res = RecipeIngredient(result, 0, count);
auto unl = makeRecipeUnlockingKey(unlock);
GMLIB::Mod::JsonRecipe::registerShapelessCraftingTableRecipe(recipe_id, types, res, unl);
JsonRecipe::registerShapelessCraftingTableRecipe(recipe_id, types, res, unl);
}
);
RemoteCall::exportAs(
@@ -56,7 +56,7 @@ void Export_Legacy_GMLib_ModAPI() {
}
auto res = RecipeIngredient(result, 0, count);
auto unl = makeRecipeUnlockingKey(unlock);
GMLIB::Mod::JsonRecipe::registerShapedCraftingTableRecipe(recipe_id, shape, types, res, unl);
JsonRecipe::registerShapedCraftingTableRecipe(recipe_id, shape, types, res, unl);
}
);
RemoteCall::exportAs(
@@ -72,7 +72,7 @@ void Export_Legacy_GMLib_ModAPI() {
}
auto inp = RecipeIngredient(input, 0, 1);
auto outp = RecipeIngredient(output, 0, 1);
GMLIB::Mod::JsonRecipe::registerFurnaceRecipe(recipe_id, inp, outp, tags);
JsonRecipe::registerFurnaceRecipe(recipe_id, inp, outp, tags);
}
);
RemoteCall::exportAs(
@@ -85,7 +85,7 @@ void Export_Legacy_GMLib_ModAPI() {
return;
}
auto rea = RecipeIngredient(reagent, 0, 1);
GMLIB::Mod::JsonRecipe::registerBrewingMixRecipe(recipe_id, input, output, rea);
JsonRecipe::registerBrewingMixRecipe(recipe_id, input, output, rea);
}
);
RemoteCall::exportAs(
@@ -100,7 +100,7 @@ void Export_Legacy_GMLib_ModAPI() {
auto inp = RecipeIngredient(input, 0, 1);
auto outp = RecipeIngredient(output, 0, 1);
auto rea = RecipeIngredient(reagent, 0, 1);
GMLIB::Mod::JsonRecipe::registerBrewingContainerRecipe(recipe_id, inp, outp, rea);
JsonRecipe::registerBrewingContainerRecipe(recipe_id, inp, outp, rea);
}
);
RemoteCall::exportAs(
@@ -115,7 +115,7 @@ void Export_Legacy_GMLib_ModAPI() {
if (!level) {
return;
}
GMLIB::Mod::JsonRecipe::registerSmithingTransformRecipe(
JsonRecipe::registerSmithingTransformRecipe(
recipe_id,
smithing_template,
base,
@@ -135,7 +135,7 @@ void Export_Legacy_GMLib_ModAPI() {
if (!level) {
return;
}
GMLIB::Mod::JsonRecipe::registerSmithingTrimRecipe(recipe_id, smithing_template, base, addition);
JsonRecipe::registerSmithingTrimRecipe(recipe_id, smithing_template, base, addition);
}
);
RemoteCall::exportAs(
@@ -153,12 +153,12 @@ void Export_Legacy_GMLib_ModAPI() {
}
auto inp = RecipeIngredient(input, 0, 1);
auto outp = RecipeIngredient(output, 0, 1);
GMLIB::Mod::JsonRecipe::registerStoneCutterRecipe(recipe_id, inp, outp);
JsonRecipe::registerStoneCutterRecipe(recipe_id, inp, outp);
}
);
// 错误方块清理
RemoteCall::exportAs("GMLib_ModAPI", "setUnknownBlockCleaner", []() -> void {
GMLIB::Mod::VanillaFix::setAutoCleanUnknownBlockEnabled();
VanillaFix::setAutoCleanUnknownBlockEnabled();
});
// 实验性
RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void {
@@ -193,6 +193,6 @@ void Export_Legacy_GMLib_ModAPI() {
return false;
});
RemoteCall::exportAs("GMLib_ModAPI", "setFixI18nEnabled", []() -> void {
GMLIB::Mod::VanillaFix::setFixI18nEnabled();
VanillaFix::setFixI18nEnabled();
});
}
+3 -3
View File
@@ -64,13 +64,13 @@ void Export_Legacy_GMLib_ServerAPI() {
"GMLib_ServerAPI",
"addFakeList",
[](const std::string& name, const std::string& xuid) -> bool {
return GMLIB::Server::FakeList::addFakeList(name, xuid, ActorUniqueID(-1));
return FakeList::addFakeList(name, xuid, ActorUniqueID(-1));
}
);
RemoteCall::exportAs("GMLib_ServerAPI", "removeFakeList", [](const std::string& nameOrXuid) -> bool {
return GMLIB::Server::FakeList::removeFakeList(nameOrXuid);
return FakeList::removeFakeList(nameOrXuid);
});
RemoteCall::exportAs("GMLib_ServerAPI", "removeAllFakeList", []() -> void {
return GMLIB::Server::FakeList::removeAllFakeLists();
return FakeList::removeAllFakeLists();
});
}
+12 -12
View File
@@ -13,10 +13,10 @@ bool isParameters(std::string const& str) {
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 PlaceholderAPI::getValue(from); }
std::string GetValueWithPlayer(std::string const& a1, std::string const& a2) {
return GMLIB::Server::PlaceholderAPI::getValue(a1, ll::service::bedrock::getLevel()->getPlayer(a2));
return PlaceholderAPI::getValue(a1, ll::service::bedrock::getLevel()->getPlayer(a2));
}
bool registerPlayerPlaceholder(
@@ -30,14 +30,14 @@ bool registerPlayerPlaceholder(
PluginName,
FuncName
);
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
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);
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
PlaceholderAPI::registerPlayerPlaceholder(
PAPIName,
[Call](Player* sp) { return Call(sp); },
PluginName
@@ -57,14 +57,14 @@ bool registerServerPlaceholder(
if (isParameters(PAPIName)) {
auto Call =
RemoteCall::importAs<std::string(std::unordered_map<std::string, std::string>)>(PluginName, FuncName);
GMLIB::Server::PlaceholderAPI::registerServerPlaceholder(
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);
GMLIB::Server::PlaceholderAPI::registerServerPlaceholder(PAPIName, [Call]() { return Call(); }, PluginName);
PlaceholderAPI::registerServerPlaceholder(PAPIName, [Call]() { return Call(); }, PluginName);
}
return true;
}
@@ -81,13 +81,13 @@ bool registerStaticPlaceholder(
if (isParameters(PAPIName)) {
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
if (num == -1) {
GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder(
PlaceholderAPI::registerStaticPlaceholder(
PAPIName,
[Call] { return Call(); },
PluginName
);
} else {
GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder(
PlaceholderAPI::registerStaticPlaceholder(
PAPIName,
num,
[Call] { return Call(); },
@@ -101,14 +101,14 @@ bool registerStaticPlaceholder(
}
std::string translateStringWithPlayer(std::string const& str, Player* pl) {
return GMLIB::Server::PlaceholderAPI::translateString(str, pl);
return PlaceholderAPI::translateString(str, pl);
}
std::string translateString(std::string const& str) { return GMLIB::Server::PlaceholderAPI::translateString(str); }
std::string translateString(std::string const& str) { return PlaceholderAPI::translateString(str); }
bool unRegisterPlaceholder(std::string const& str) { return GMLIB::Server::PlaceholderAPI::unregisterPlaceholder(str); }
bool unRegisterPlaceholder(std::string const& str) { return PlaceholderAPI::unregisterPlaceholder(str); }
std::vector<std::string> getAllPAPI() { return GMLIB::Server::PlaceholderAPI::getAllPAPI(); }
std::vector<std::string> getAllPAPI() { return PlaceholderAPI::getAllPAPI(); }
} // namespace PAPIRemoteCall
+3 -3
View File
@@ -1,7 +1,7 @@
{
"format_version": 2,
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
"version": "0.12.6",
"version": "0.13.0",
"info": {
"name": "GMLIB-LegacyRemoteCallApi",
"description": "Legacy RemoteCall API for GMLIB",
@@ -14,9 +14,9 @@
"library"
]
},
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.12.6/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.13.0/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
"dependencies": {
"github.com/GroupMountain/GMLIB": ">=0.12.4"
"github.com/GroupMountain/GMLIB": ">=0.13.0"
},
"files": {
"place": [
+4 -5
View File
@@ -1,6 +1,7 @@
add_rules("mode.debug", "mode.release")
add_repositories("liteldev-repo https://github.com/LiteLDev/xmake-repo.git")
add_repositories("groupmountain-repo https://github.com/GroupMountain/xmake-repo.git")
if not has_config("vs_runtime") then
set_runtimes("MD")
@@ -9,6 +10,7 @@ end
-- Option 1: Use the latest version of LeviLamina released on GitHub.
add_requires("levilamina")
add_requires("legacyremotecall")
add_requires("gmlib")
-- Option 2: Use a specific version of LeviLamina released on GitHub.
-- add_requires("levilamina x.x.x")
@@ -53,16 +55,13 @@ target("GMLIB-LegacyRemoteCallApi") -- Change this to your plugin name.
add_files(
"src/**.cpp"
)
add_links(
"SDK-GMLIB/Lib/GMLIB"
)
add_includedirs(
"SDK-GMLIB",
"src"
)
add_packages(
"levilamina",
"legacyremotecall"
"legacyremotecall",
"gmlib"
)
add_shflags(
"/DELAYLOAD:bedrock_server.dll" -- Magic to import symbols from BDS