Compare commits
23 Commits
@@ -15,3 +15,4 @@ build/
|
|||||||
/.xmake
|
/.xmake
|
||||||
/CMakeLists.txt
|
/CMakeLists.txt
|
||||||
/bin
|
/bin
|
||||||
|
.cache/clangd/index
|
||||||
|
|||||||
@@ -5,6 +5,5 @@ Legacy RemoteCall API for GMLIB. Only for legacy LSE plugin compatibility.
|
|||||||
- 本模块是 `GMLIB` 的 `Legacy RemoteCall API` 模块,是为LL2的LLSE插件的兼容性保留。
|
- 本模块是 `GMLIB` 的 `Legacy RemoteCall API` 模块,是为LL2的LLSE插件的兼容性保留。
|
||||||
- 通过本模块,可以使LSE插件调用 `GMLIB` 内部的API。
|
- 通过本模块,可以使LSE插件调用 `GMLIB` 内部的API。
|
||||||
|
|
||||||
# 注意事项
|
# 开发文档
|
||||||
- 本模块仅为兼容性保留模块,仅保留过去的接口以保留兼容性。
|
- https://groupmountain.github.io/Documentation/
|
||||||
- 本模块不会提供 `GMLIB` 在迁移到 `LeviLamina` 后新开发的接口。
|
|
||||||
|
|||||||
+1
-1
Submodule SDK-GMLIB updated: 7206bf0c10...710cc6e4c3
+109
-56
@@ -1,6 +1,3 @@
|
|||||||
// LiteLoader-AIDS automatic generated
|
|
||||||
/// <reference path="D:\LiteLoader\VSCode/dts/HelperLib-master/src/index.d.ts"/>
|
|
||||||
|
|
||||||
const GMLIB_API = {
|
const GMLIB_API = {
|
||||||
createFloatingText: ll.import("GMLIB_API", "createFloatingText"),
|
createFloatingText: ll.import("GMLIB_API", "createFloatingText"),
|
||||||
deleteFloatingText: ll.import("GMLIB_API", "deleteFloatingText"),
|
deleteFloatingText: ll.import("GMLIB_API", "deleteFloatingText"),
|
||||||
@@ -18,6 +15,7 @@ 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"),
|
||||||
|
deletePlayerNbt: ll.import("GMLIB_API", "deletePlayerNbt"),
|
||||||
resourcePackTranslate: ll.import("GMLIB_API", "resourcePackTranslate"),
|
resourcePackTranslate: ll.import("GMLIB_API", "resourcePackTranslate"),
|
||||||
resourcePackDefaultTranslate: ll.import("GMLIB_API", "resourcePackDefaultTranslate"),
|
resourcePackDefaultTranslate: ll.import("GMLIB_API", "resourcePackDefaultTranslate"),
|
||||||
getResourcePackI18nLanguage: ll.import("GMLIB_API", "getResourcePackI18nLanguage"),
|
getResourcePackI18nLanguage: ll.import("GMLIB_API", "getResourcePackI18nLanguage"),
|
||||||
@@ -36,7 +34,7 @@ const GMLIB_API = {
|
|||||||
PlayerToEntity: ll.import("GMLib_ServerAPI", "PlayerToEntity"),
|
PlayerToEntity: ll.import("GMLib_ServerAPI", "PlayerToEntity"),
|
||||||
setUnknownBlockCleaner: ll.import("GMLib_ModAPI", "setUnknownBlockCleaner"),
|
setUnknownBlockCleaner: ll.import("GMLib_ModAPI", "setUnknownBlockCleaner"),
|
||||||
getAllExperiments: ll.import("GMLIB_API", "getAllExperiments"),
|
getAllExperiments: ll.import("GMLIB_API", "getAllExperiments"),
|
||||||
getExperimentTranslatedName: ll.import("GMLIB_API", "getExperimentTranslatedName"),
|
getExperimentTranslateKey: ll.import("GMLIB_API", "getExperimentTranslateKey"),
|
||||||
getExperimentEnabled: ll.import("GMLib_ModAPI", "getExperimentEnabled"),
|
getExperimentEnabled: ll.import("GMLib_ModAPI", "getExperimentEnabled"),
|
||||||
setExperimentEnabled: ll.import("GMLib_ModAPI", "setExperimentEnabled"),
|
setExperimentEnabled: ll.import("GMLib_ModAPI", "setExperimentEnabled"),
|
||||||
unregisterRecipe: ll.import("GMLIB_API", "unregisterRecipe"),
|
unregisterRecipe: ll.import("GMLIB_API", "unregisterRecipe"),
|
||||||
@@ -83,6 +81,7 @@ const GMLIB_API = {
|
|||||||
setDisplayObjective: ll.import("GMLIB_API", "setDisplayObjective"),
|
setDisplayObjective: ll.import("GMLIB_API", "setDisplayObjective"),
|
||||||
clearDisplayObjective: ll.import("GMLIB_API", "clearDisplayObjective"),
|
clearDisplayObjective: ll.import("GMLIB_API", "clearDisplayObjective"),
|
||||||
getAllObjectives: ll.import("GMLIB_API", "getAllObjectives"),
|
getAllObjectives: ll.import("GMLIB_API", "getAllObjectives"),
|
||||||
|
getAllTrackedTargets: ll.import("GMLIB_API", "getAllTrackedTargets"),
|
||||||
getAllScoreboardPlayers: ll.import("GMLIB_API", "getAllScoreboardPlayers"),
|
getAllScoreboardPlayers: ll.import("GMLIB_API", "getAllScoreboardPlayers"),
|
||||||
getAllScoreboardFakePlayers: ll.import("GMLIB_API", "getAllScoreboardFakePlayers"),
|
getAllScoreboardFakePlayers: ll.import("GMLIB_API", "getAllScoreboardFakePlayers"),
|
||||||
getAllScoreboardEntities: ll.import("GMLIB_API", "getAllScoreboardEntities"),
|
getAllScoreboardEntities: ll.import("GMLIB_API", "getAllScoreboardEntities"),
|
||||||
@@ -99,7 +98,19 @@ const GMLIB_API = {
|
|||||||
loadLanguage: ll.import("GMLIB_API", "loadLanguage"),
|
loadLanguage: ll.import("GMLIB_API", "loadLanguage"),
|
||||||
updateOrCreateLanguageFile: ll.import("GMLIB_API", "updateOrCreateLanguageFile"),
|
updateOrCreateLanguageFile: ll.import("GMLIB_API", "updateOrCreateLanguageFile"),
|
||||||
loadLanguagePath: ll.import("GMLIB_API", "loadLanguagePath"),
|
loadLanguagePath: ll.import("GMLIB_API", "loadLanguagePath"),
|
||||||
mergePatchJson: ll.import("GMLIB_API", "mergePatchJson")
|
mergePatchJson: ll.import("GMLIB_API", "mergePatchJson"),
|
||||||
|
getXuidByUuid: ll.import("GMLIB_API", "getXuidByUuid"),
|
||||||
|
getNameByUuid: ll.import("GMLIB_API", "getNameByUuid"),
|
||||||
|
getUuidByXuid: ll.import("GMLIB_API", "getUuidByXuid"),
|
||||||
|
getNameByXuid: ll.import("GMLIB_API", "getNameByXuid"),
|
||||||
|
getXuidByName: ll.import("GMLIB_API", "getXuidByName"),
|
||||||
|
getUuidByName: ll.import("GMLIB_API", "getUuidByName"),
|
||||||
|
getAllPlayerInfo: ll.import("GMLIB_API", "getAllPlayerInfo"),
|
||||||
|
getBlockRuntimeId: ll.import("GMLIB_API", "getBlockRuntimeId"),
|
||||||
|
addFakeList: ll.import("GMLIB_API", "addFakeList"),
|
||||||
|
removeFakeList: ll.import("GMLIB_API", "removeFakeList"),
|
||||||
|
removeAllFakeLists: ll.import("GMLIB_API", "removeAllFakeList"),
|
||||||
|
setFixI18nEnabled: ll.import("GMLib_ModAPI", "setFixI18nEnabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
const FloatingTextList = [];
|
const FloatingTextList = [];
|
||||||
@@ -297,6 +308,10 @@ class Minecraft {
|
|||||||
return GMLIB_API.setPlayerNbtTags(uuid, nbt, tags);
|
return GMLIB_API.setPlayerNbtTags(uuid, nbt, tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static deletePlayerNbt(uuid) {
|
||||||
|
return GMLIB_API.deletePlayerNbt(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
static getPlayerPosition(uuid) {
|
static getPlayerPosition(uuid) {
|
||||||
let pos = GMLIB_API.getPlayerPosition(uuid);
|
let pos = GMLIB_API.getPlayerPosition(uuid);
|
||||||
if (pos.dimid == -1) {
|
if (pos.dimid == -1) {
|
||||||
@@ -380,6 +395,38 @@ class Minecraft {
|
|||||||
static resourcePackTranslate(key, params = []) {
|
static resourcePackTranslate(key, params = []) {
|
||||||
return I18nAPI.get(key, params);
|
return I18nAPI.get(key, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static getPlayerFromUuid(uuid) {
|
||||||
|
return GMLIB_API.getPlayerFromUuid(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
static getPlayerFromUniqueId(uniqueId) {
|
||||||
|
return GMLIB_API.getPlayerFromUniqueId(uniqueId);
|
||||||
|
}
|
||||||
|
|
||||||
|
static getEntityFromUniqueId(uniqueId) {
|
||||||
|
return GMLIB_API.getFromUniqueId(uniqueId);
|
||||||
|
}
|
||||||
|
|
||||||
|
static getBlockRuntimeId(block) {
|
||||||
|
return GMLIB_API.getBlockRuntimeId(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
static addFakeList(name, xuid) {
|
||||||
|
return GMLIB_API.addFakeList(xuid, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
static removeFakeList(nameOrXuid) {
|
||||||
|
return GMLIB_API.removeFakeList(nameOrXuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
static removeAllFakeLists() {
|
||||||
|
return GMLIB_API.removeAllFakeLists();
|
||||||
|
}
|
||||||
|
|
||||||
|
static setFixI18nEnabled() {
|
||||||
|
GMLIB_API.setFixI18nEnabled();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Recipes {
|
class Recipes {
|
||||||
@@ -435,18 +482,8 @@ class Experiments {
|
|||||||
return GMLIB_API.getAllExperiments();
|
return GMLIB_API.getAllExperiments();
|
||||||
}
|
}
|
||||||
|
|
||||||
static getExperimentTranslatedName(id) {
|
static getExperimentTranslateKey(id) {
|
||||||
return GMLIB_API.getExperimentTranslatedName(id);
|
return GMLIB_API.getExperimentTranslateKey(id);
|
||||||
}
|
|
||||||
|
|
||||||
static getExperimentsMap() {
|
|
||||||
let ids = this.getAllExperimentIds();
|
|
||||||
let result = {};
|
|
||||||
for (let id in ids) {
|
|
||||||
let name = this.getExperimentTranslatedName(id);
|
|
||||||
result[id] = name;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static getExperimentEnabled(id) {
|
static getExperimentEnabled(id) {
|
||||||
@@ -502,28 +539,22 @@ class Version {
|
|||||||
if (Array.isArray(array) && array.length == 3) {
|
if (Array.isArray(array) && array.length == 3) {
|
||||||
let isNumber = array.every(element => typeof element == "number");
|
let isNumber = array.every(element => typeof element == "number");
|
||||||
if (isNumber) {
|
if (isNumber) {
|
||||||
return new Version(array[0], array[1], array[2])
|
return new Version(array[0], array[1], array[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static isPluginVersionMatched(version) {
|
||||||
|
return GMLIB_API.isVersionMatched(version.mMajor, version.mMinor, version.mPatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
class GMLIB {
|
static getLrcaVersion() {
|
||||||
constructor() {
|
return Version.fromString(GMLIB_API.getVersion_LRCA());
|
||||||
throw new Error("Static class cannot be instantiated");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static isVersionMatched(major, minor, patch) {
|
static getGmlibVersion() {
|
||||||
return GMLIB_API.isVersionMatched(major, minor, patch);
|
return Version.fromString(GMLIB_API.getVersion_GMLIB());
|
||||||
}
|
|
||||||
|
|
||||||
static getVersion_LRCA() {
|
|
||||||
return GMLIB_API.getVersion_LRCA();
|
|
||||||
}
|
|
||||||
|
|
||||||
static getVersion_GMLIB() {
|
|
||||||
return GMLIB_API.getVersion_GMLIB();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -546,29 +577,7 @@ class Scoreboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static getAllTrackedTargets() {
|
static getAllTrackedTargets() {
|
||||||
let result = [];
|
return GMLIB_API.getAllTrackedTargets();
|
||||||
GMLIB_API.getAllScoreboardPlayers().forEach((uuid) => {
|
|
||||||
let key = {
|
|
||||||
"Type": "Player",
|
|
||||||
"Uuid": uuid
|
|
||||||
};
|
|
||||||
result.push(key);
|
|
||||||
});
|
|
||||||
GMLIB_API.getAllScoreboardEntities().forEach((uniqueId) => {
|
|
||||||
let key = {
|
|
||||||
"Type": "Entity",
|
|
||||||
"UniqueId": uniqueId
|
|
||||||
};
|
|
||||||
result.push(key);
|
|
||||||
});
|
|
||||||
GMLIB_API.getAllScoreboardFakePlayers().forEach((name) => {
|
|
||||||
let key = {
|
|
||||||
"Type": "FakePlayer",
|
|
||||||
"Name": name
|
|
||||||
};
|
|
||||||
result.push(key);
|
|
||||||
});
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Objectives
|
// Objectives
|
||||||
@@ -849,6 +858,50 @@ class I18nAPI {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class UserCache {
|
||||||
|
constructor() {
|
||||||
|
throw new Error("Static class cannot be instantiated");
|
||||||
|
}
|
||||||
|
|
||||||
|
static getXuidByUuid(uuid) {
|
||||||
|
let result = GMLIB_API.getXuidByUuid(uuid);
|
||||||
|
return result == "" ? null : result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getUuidByXuid(xuid) {
|
||||||
|
let result = GMLIB_API.getUuidByXuid(xuid);
|
||||||
|
return result == "" ? null : result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getNameByUuid(uuid) {
|
||||||
|
let result = GMLIB_API.getNameByUuid(uuid);
|
||||||
|
return result == "" ? null : result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getNameByXuid(xuid) {
|
||||||
|
let result = GMLIB_API.getNameByXuid(xuid);
|
||||||
|
return result == "" ? null : result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getXuidByName(name) {
|
||||||
|
let result = GMLIB_API.getXuidByName(name);
|
||||||
|
return result == "" ? null : result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getUuidByName(name) {
|
||||||
|
let result = GMLIB_API.getUuidByName(name);
|
||||||
|
return result == "" ? null : result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getPlayerInfo(playerIdentifier) {
|
||||||
|
return GMLIB_API.getAllPlayerInfo().find(Info => Object.keys(Info).some(InfoKey => Info[InfoKey] === playerIdentifier));
|
||||||
|
}
|
||||||
|
|
||||||
|
static getAllPlayerInfo() {
|
||||||
|
return GMLIB_API.getAllPlayerInfo();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
LLSE_Player.prototype.toEntity = function () {
|
LLSE_Player.prototype.toEntity = function () {
|
||||||
return GMLIB_API.PlayerToEntity(this);
|
return GMLIB_API.PlayerToEntity(this);
|
||||||
}
|
}
|
||||||
@@ -879,11 +932,11 @@ module.exports = {
|
|||||||
Minecraft,
|
Minecraft,
|
||||||
Recipes,
|
Recipes,
|
||||||
Experiments,
|
Experiments,
|
||||||
GMLIB,
|
|
||||||
Scoreboard,
|
Scoreboard,
|
||||||
JsonConfig,
|
JsonConfig,
|
||||||
JsonLanguage,
|
JsonLanguage,
|
||||||
JsonI18n,
|
JsonI18n,
|
||||||
Version,
|
Version,
|
||||||
I18nAPI
|
I18nAPI,
|
||||||
|
UserCache
|
||||||
};
|
};
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "${pluginName}",
|
"name": "${pluginName}",
|
||||||
"entry": "${pluginFile}",
|
"entry": "${pluginFile}",
|
||||||
"version": "0.12.4",
|
"version": "0.12.6",
|
||||||
"author": "GroupMountain",
|
"author": "GroupMountain",
|
||||||
"type": "native",
|
"type": "native",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
|
|||||||
+251
-113
@@ -6,7 +6,7 @@ bool isInteger(const std::string& str) {
|
|||||||
return std::regex_match(str, pattern);
|
return std::regex_match(str, pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActorUniqueID parseScriptUniqueID(std::string uniqueId) {
|
ActorUniqueID parseScriptUniqueID(std::string const& uniqueId) {
|
||||||
if (!isInteger(uniqueId)) {
|
if (!isInteger(uniqueId)) {
|
||||||
return ActorUniqueID::INVALID_ID;
|
return ActorUniqueID::INVALID_ID;
|
||||||
}
|
}
|
||||||
@@ -14,14 +14,14 @@ ActorUniqueID parseScriptUniqueID(std::string uniqueId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Export_Compatibility_API() {
|
void Export_Compatibility_API() {
|
||||||
RemoteCall::exportAs("GMLIB_API", "unregisterRecipe", [](std::string id) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "unregisterRecipe", [](std::string const& id) -> bool {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return GMLIB::Mod::CustomRecipe::unregisterRecipe(id);
|
return GMLIB::Mod::CustomRecipe::unregisterRecipe(id);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "setCustomPackPath", [](std::string path) -> void {
|
RemoteCall::exportAs("GMLIB_API", "setCustomPackPath", [](std::string const& path) -> void {
|
||||||
GMLIB::Mod::CustomPacks::addCustomPackPath(path);
|
GMLIB::Mod::CustomPacks::addCustomPackPath(path);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> float {
|
RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> float {
|
||||||
@@ -53,107 +53,109 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerNbt", [](std::string uuid) -> std::unique_ptr<CompoundTag> {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerNbt", [](std::string const& uuid) -> std::unique_ptr<CompoundTag> {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
return std::move(GMLIB_Player::getPlayerNbt(uid));
|
return std::move(GMLIB_Player::getPlayerNbt(uid));
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "setPlayerNbt", [](std::string uuid, CompoundTag* nbt, bool forceCreate) -> bool {
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setPlayerNbt",
|
||||||
|
[](std::string const& uuid, CompoundTag* nbt, bool forceCreate) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
return GMLIB_Player::setPlayerNbt(uid, *nbt, forceCreate);
|
return GMLIB_Player::setPlayerNbt(uid, *nbt, forceCreate);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"setPlayerNbtTags",
|
"setPlayerNbtTags",
|
||||||
[](std::string uuid, CompoundTag* nbt, std::vector<std::string> tags) -> bool {
|
[](std::string const& uuid, CompoundTag* nbt, std::vector<std::string> tags) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
return GMLIB_Player::setPlayerNbtTags(uid, *nbt, tags);
|
return GMLIB_Player::setPlayerNbtTags(uid, *nbt, tags);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "deletePlayerNbt", [](std::string const& uuid) -> bool {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
return GMLIB_Player::deletePlayerNbt(uid);
|
||||||
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getAllExperiments", []() -> std::vector<int> {
|
RemoteCall::exportAs("GMLIB_API", "getAllExperiments", []() -> std::vector<int> {
|
||||||
auto map = GMLIB_Level::getAllExperiments();
|
auto list = GMLIB_Level::getAllExperiments();
|
||||||
std::vector<int> result;
|
std::vector<int> result;
|
||||||
for (auto& key : map) {
|
for (auto& key : list) {
|
||||||
result.push_back(key.first);
|
result.push_back((int)key);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getExperimentTranslatedName", [](int id) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getExperimentTranslateKey", [](int id) -> std::string {
|
||||||
auto map = GMLIB_Level::getAllExperimentsTranslateKeys();
|
std::string result;
|
||||||
if (map.count(id)) {
|
try {
|
||||||
return std::string(map[id]);
|
result = Experiments::getExperimentTextID(AllExperiments(id));
|
||||||
}
|
} catch (...) {}
|
||||||
return "";
|
return result;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"createFloatingText",
|
"createFloatingText",
|
||||||
[](std::pair<Vec3, int> pos, std::string text, bool papi) -> int {
|
[](std::pair<Vec3, int> pos, std::string const& text, bool papi) -> int {
|
||||||
auto ft = new GMLIB::Server::StaticFloatingText(text, pos.first, pos.second, papi);
|
auto ft = std::make_shared<GMLIB::Server::StaticFloatingText>(text, pos.first, pos.second, papi);
|
||||||
|
GMLIB::Server::FloatingTextManager::getInstance().add(ft);
|
||||||
return ft->getRuntimeID();
|
return ft->getRuntimeID();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "setFloatingTextData", [](int id, std::string text) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "setFloatingTextData", [](int id, std::string const& text) -> bool {
|
||||||
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
if (auto ft = GMLIB::Server::FloatingTextManager::getInstance().getFloatingText(id)) {
|
||||||
if (ft) {
|
|
||||||
ft->setText(text);
|
ft->setText(text);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "deleteFloatingText", [](int id) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "deleteFloatingText", [](int id) -> bool {
|
||||||
return GMLIB::Server::FloatingText::deleteFloatingText(id);
|
return GMLIB::Server::FloatingTextManager::getInstance().remove(id);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "sendFloatingTextToPlayer", [](int id, Player* pl) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "sendFloatingTextToPlayer", [](int id, Player* pl) -> bool {
|
||||||
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
if (auto ft = GMLIB::Server::FloatingTextManager::getInstance().getFloatingText(id)) {
|
||||||
if (ft) {
|
ft->sendTo(*pl);
|
||||||
ft->sendToClient(*pl);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "sendFloatingText", [](int id) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "sendFloatingText", [](int id) -> bool {
|
||||||
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
if (auto ft = GMLIB::Server::FloatingTextManager::getInstance().getFloatingText(id)) {
|
||||||
if (ft) {
|
ft->sendToClients();
|
||||||
ft->sendToAllClients();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "removeFloatingTextFromPlayer", [](int id, Player* pl) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "removeFloatingTextFromPlayer", [](int id, Player* pl) -> bool {
|
||||||
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
if (auto ft = GMLIB::Server::FloatingTextManager::getInstance().getFloatingText(id)) {
|
||||||
if (ft) {
|
ft->removeFrom(*pl);
|
||||||
ft->removeFromClient(*pl);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "removeFloatingText", [](int id) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "removeFloatingText", [](int id) -> bool {
|
||||||
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
if (auto ft = GMLIB::Server::FloatingTextManager::getInstance().getFloatingText(id)) {
|
||||||
if (ft) {
|
ft->removeFromClients();
|
||||||
ft->removeFromAllClients();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "updateClientFloatingTextData", [](int id, Player* pl) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "updateClientFloatingTextData", [](int id, Player* pl) -> bool {
|
||||||
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
if (auto ft = GMLIB::Server::FloatingTextManager::getInstance().getFloatingText(id)) {
|
||||||
if (ft) {
|
ft->update(*pl);
|
||||||
ft->updateClient(*pl);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "updateAllClientsFloatingTextData", [](int id) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "updateAllClientsFloatingTextData", [](int id) -> bool {
|
||||||
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
if (auto ft = GMLIB::Server::FloatingTextManager::getInstance().getFloatingText(id)) {
|
||||||
if (ft) {
|
ft->updateClients();
|
||||||
ft->updateAllClients();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "isVersionMatched", [](int a, int b, int c) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "isVersionMatched", [](int a, int b, int c) -> bool {
|
||||||
auto version = GMLIB::Version(a, b, c, "", "");
|
auto version = GMLIB::Version(a, b, c, "", "");
|
||||||
return version >= LIB_VERSION;
|
return LIB_VERSION >= version;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getVersion_LRCA", []() -> std::string { return LIB_VERSION.asString(); });
|
RemoteCall::exportAs("GMLIB_API", "getVersion_LRCA", []() -> std::string { return LIB_VERSION.asString(); });
|
||||||
RemoteCall::exportAs("GMLIB_API", "getVersion_GMLIB", []() -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getVersion_GMLIB", []() -> std::string {
|
||||||
@@ -162,16 +164,16 @@ void Export_Compatibility_API() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"resourcePackDefaultTranslate",
|
"resourcePackDefaultTranslate",
|
||||||
[](std::string key, std::vector<std::string> params) -> std::string { return I18nAPI::get(key, params); }
|
[](std::string const& key, std::vector<std::string> params) -> std::string { return I18nAPI::get(key, params); }
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"resourcePackTranslate",
|
"resourcePackTranslate",
|
||||||
[](std::string key, std::vector<std::string> params, std::string code) -> std::string {
|
[](std::string const& key, std::vector<std::string> params, std::string const& code) -> std::string {
|
||||||
return I18nAPI::get(key, params, code);
|
return I18nAPI::get(key, params, code);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "chooseResourcePackI18nLanguage", [](std::string code) -> void {
|
RemoteCall::exportAs("GMLIB_API", "chooseResourcePackI18nLanguage", [](std::string const& code) -> void {
|
||||||
if (GMLIB_Level::getInstance()) {
|
if (GMLIB_Level::getInstance()) {
|
||||||
I18nAPI::chooseLanguage(code);
|
I18nAPI::chooseLanguage(code);
|
||||||
}
|
}
|
||||||
@@ -188,7 +190,7 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "loadLanguage", [](std::string code, std::string lang) -> void {
|
RemoteCall::exportAs("GMLIB_API", "loadLanguage", [](std::string const& code, std::string const& lang) -> void {
|
||||||
if (GMLIB_Level::getInstance()) {
|
if (GMLIB_Level::getInstance()) {
|
||||||
I18nAPI::loadLanguage(code, lang);
|
I18nAPI::loadLanguage(code, lang);
|
||||||
}
|
}
|
||||||
@@ -196,18 +198,18 @@ void Export_Compatibility_API() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"updateOrCreateLanguageFile",
|
"updateOrCreateLanguageFile",
|
||||||
[](std::string code, std::string lang, std::string path) -> void {
|
[](std::string const& code, std::string const& lang, std::string const& path) -> void {
|
||||||
if (GMLIB_Level::getInstance()) {
|
if (GMLIB_Level::getInstance()) {
|
||||||
I18nAPI::updateOrCreateLanguageFile(path, code, lang);
|
I18nAPI::updateOrCreateLanguageFile(path, code, lang);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "loadLanguagePath", [](std::string path) -> void {
|
RemoteCall::exportAs("GMLIB_API", "loadLanguagePath", [](std::string const& path) -> void {
|
||||||
if (GMLIB_Level::getInstance()) {
|
if (GMLIB_Level::getInstance()) {
|
||||||
I18nAPI::loadLanguagesFromDirectory(path);
|
I18nAPI::loadLanguagesFromDirectory(path);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerPosition", [](std::string uuid) -> std::pair<BlockPos, int> {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerPosition", [](std::string const& uuid) -> std::pair<BlockPos, int> {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
auto pos = GMLIB_Player::getPlayerPosition(uid);
|
auto pos = GMLIB_Player::getPlayerPosition(uid);
|
||||||
if (pos.has_value()) {
|
if (pos.has_value()) {
|
||||||
@@ -218,78 +220,102 @@ void Export_Compatibility_API() {
|
|||||||
-1
|
-1
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "setPlayerPosition", [](std::string uuid, std::pair<BlockPos, int> pos) -> bool {
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setPlayerPosition",
|
||||||
|
[](std::string const& uuid, std::pair<BlockPos, int> pos) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
return GMLIB_Player::setPlayerPosition(uid, pos.first, pos.second);
|
return GMLIB_Player::setPlayerPosition(uid, pos.first, pos.second);
|
||||||
});
|
}
|
||||||
RemoteCall::exportAs("GMLIB_API", "playerHasScore", [](std::string uuid, std::string obj) -> bool {
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "playerHasScore", [](std::string const& uuid, std::string const& obj) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
if (auto result = GMLIB_Player::getPlayerScore(uid, obj)) {
|
if (auto result = GMLIB_Player::getPlayerScore(uid, obj)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerScore", [](std::string uuid, std::string obj) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerScore", [](std::string const& uuid, std::string const& obj) -> int {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
if (auto result = GMLIB_Player::getPlayerScore(uid, obj)) {
|
if (auto result = GMLIB_Player::getPlayerScore(uid, obj)) {
|
||||||
return result.value();
|
return result.value();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "addPlayerScore", [](std::string uuid, std::string obj, int value) -> bool {
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"addPlayerScore",
|
||||||
|
[](std::string const& uuid, std::string const& obj, int value) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
if (auto res = GMLIB_Player::setPlayerScore(uid, obj, value, PlayerScoreSetFunction::Add)) {
|
if (auto res = GMLIB_Player::setPlayerScore(uid, obj, value, PlayerScoreSetFunction::Add)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
}
|
||||||
RemoteCall::exportAs("GMLIB_API", "reducePlayerScore", [](std::string uuid, std::string obj, int value) -> bool {
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"reducePlayerScore",
|
||||||
|
[](std::string const& uuid, std::string const& obj, int value) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
if (auto res = GMLIB_Player::setPlayerScore(uid, obj, value, PlayerScoreSetFunction::Subtract)) {
|
if (auto res = GMLIB_Player::setPlayerScore(uid, obj, value, PlayerScoreSetFunction::Subtract)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
}
|
||||||
RemoteCall::exportAs("GMLIB_API", "setPlayerScore", [](std::string uuid, std::string obj, int value) -> bool {
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setPlayerScore",
|
||||||
|
[](std::string const& uuid, std::string const& obj, int value) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
if (auto res = GMLIB_Player::setPlayerScore(uid, obj, value)) {
|
if (auto res = GMLIB_Player::setPlayerScore(uid, obj, value)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
}
|
||||||
RemoteCall::exportAs("GMLIB_API", "resetPlayerScore", [](std::string uuid, std::string obj) -> bool {
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "resetPlayerScore", [](std::string const& uuid, std::string const& obj) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
return GMLIB_Player::resetPlayerScore(uid, obj);
|
return GMLIB_Player::resetPlayerScore(uid, obj);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "resetPlayerScores", [](std::string uuid) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "resetPlayerScores", [](std::string const& uuid) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
return GMLIB_Player::resetPlayerScore(uid);
|
return GMLIB_Player::resetPlayerScore(uid);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "entityHasScore", [](std::string uniqueId, std::string obj) -> bool {
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"entityHasScore",
|
||||||
|
[](std::string const& uniqueId, std::string const& obj) -> bool {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
if (auto result = GMLIB_Scoreboard::getInstance()->getScore(obj, auid)) {
|
if (auto result = GMLIB_Scoreboard::getInstance()->getScore(obj, auid)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
}
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityScore", [](std::string uniqueId, std::string obj) -> int {
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getEntityScore", [](std::string const& uniqueId, std::string const& obj) -> int {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
if (auto result = GMLIB_Scoreboard::getInstance()->getScore(obj, auid)) {
|
if (auto result = GMLIB_Scoreboard::getInstance()->getScore(obj, auid)) {
|
||||||
return result.value();
|
return result.value();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "addEntityScore", [](std::string uniqueId, std::string obj, int value) -> bool {
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"addEntityScore",
|
||||||
|
[](std::string const& uniqueId, std::string const& obj, int value) -> bool {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
if (auto res = GMLIB_Scoreboard::getInstance()->setScore(obj, auid, value, PlayerScoreSetFunction::Add)) {
|
if (auto res = GMLIB_Scoreboard::getInstance()->setScore(obj, auid, value, PlayerScoreSetFunction::Add)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
}
|
||||||
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"reduceEntityScore",
|
"reduceEntityScore",
|
||||||
[](std::string uniqueId, std::string obj, int value) -> bool {
|
[](std::string const& uniqueId, std::string const& obj, int value) -> bool {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
if (auto res =
|
if (auto res =
|
||||||
GMLIB_Scoreboard::getInstance()->setScore(obj, auid, value, PlayerScoreSetFunction::Subtract)) {
|
GMLIB_Scoreboard::getInstance()->setScore(obj, auid, value, PlayerScoreSetFunction::Subtract)) {
|
||||||
@@ -298,43 +324,59 @@ void Export_Compatibility_API() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "setEntityScore", [](std::string uniqueId, std::string obj, int value) -> bool {
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setEntityScore",
|
||||||
|
[](std::string const& uniqueId, std::string const& obj, int value) -> bool {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
if (auto res = GMLIB_Scoreboard::getInstance()->setScore(obj, auid, value)) {
|
if (auto res = GMLIB_Scoreboard::getInstance()->setScore(obj, auid, value)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
}
|
||||||
RemoteCall::exportAs("GMLIB_API", "resetEntityScore", [](std::string uniqueId, std::string obj) -> bool {
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"resetEntityScore",
|
||||||
|
[](std::string const& uniqueId, std::string const& obj) -> bool {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
return GMLIB_Scoreboard::getInstance()->resetScore(obj, auid);
|
return GMLIB_Scoreboard::getInstance()->resetScore(obj, auid);
|
||||||
});
|
}
|
||||||
RemoteCall::exportAs("GMLIB_API", "resetEntityScores", [](std::string uniqueId) -> bool {
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "resetEntityScores", [](std::string const& uniqueId) -> bool {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
return GMLIB_Scoreboard::getInstance()->resetScore(auid);
|
return GMLIB_Scoreboard::getInstance()->resetScore(auid);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "fakePlayerHasScore", [](std::string name, std::string obj) -> bool {
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"fakePlayerHasScore",
|
||||||
|
[](std::string const& name, std::string const& obj) -> bool {
|
||||||
if (auto result = GMLIB_Scoreboard::getInstance()->getScore(obj, name)) {
|
if (auto result = GMLIB_Scoreboard::getInstance()->getScore(obj, name)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
}
|
||||||
RemoteCall::exportAs("GMLIB_API", "getFakePlayerScore", [](std::string name, std::string obj) -> int {
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getFakePlayerScore", [](std::string const& name, std::string const& obj) -> int {
|
||||||
if (auto result = GMLIB_Scoreboard::getInstance()->getScore(obj, name)) {
|
if (auto result = GMLIB_Scoreboard::getInstance()->getScore(obj, name)) {
|
||||||
return result.value();
|
return result.value();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "addFakePlayerScore", [](std::string name, std::string obj, int value) -> bool {
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"addFakePlayerScore",
|
||||||
|
[](std::string const& name, std::string const& obj, int value) -> bool {
|
||||||
if (auto res = GMLIB_Scoreboard::getInstance()->setScore(obj, name, value, PlayerScoreSetFunction::Add)) {
|
if (auto res = GMLIB_Scoreboard::getInstance()->setScore(obj, name, value, PlayerScoreSetFunction::Add)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
}
|
||||||
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"reduceFakePlayerScore",
|
"reduceFakePlayerScore",
|
||||||
[](std::string name, std::string obj, int value) -> bool {
|
[](std::string const& name, std::string const& obj, int value) -> bool {
|
||||||
if (auto res =
|
if (auto res =
|
||||||
GMLIB_Scoreboard::getInstance()->setScore(obj, name, value, PlayerScoreSetFunction::Subtract)) {
|
GMLIB_Scoreboard::getInstance()->setScore(obj, name, value, PlayerScoreSetFunction::Subtract)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -342,20 +384,28 @@ void Export_Compatibility_API() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "setFakePlayerScore", [](std::string name, std::string obj, int value) -> bool {
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setFakePlayerScore",
|
||||||
|
[](std::string const& name, std::string const& obj, int value) -> bool {
|
||||||
if (auto res = GMLIB_Scoreboard::getInstance()->setScore(obj, name, value)) {
|
if (auto res = GMLIB_Scoreboard::getInstance()->setScore(obj, name, value)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
}
|
||||||
RemoteCall::exportAs("GMLIB_API", "resetFakePlayerScore", [](std::string name, std::string obj) -> bool {
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"resetFakePlayerScore",
|
||||||
|
[](std::string const& name, std::string const& obj) -> bool {
|
||||||
return GMLIB_Scoreboard::getInstance()->resetScore(obj, name);
|
return GMLIB_Scoreboard::getInstance()->resetScore(obj, name);
|
||||||
});
|
}
|
||||||
RemoteCall::exportAs("GMLIB_API", "resetFakePlayerScores", [](std::string name) -> bool {
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "resetFakePlayerScores", [](std::string const& name) -> bool {
|
||||||
return GMLIB_Scoreboard::getInstance()->resetScore(name);
|
return GMLIB_Scoreboard::getInstance()->resetScore(name);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "addObjective", [](std::string obj) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "addObjective", [](std::string const& obj) -> bool {
|
||||||
if (auto res = GMLIB_Scoreboard::getInstance()->getInstance()->addObjective(obj)) {
|
if (auto res = GMLIB_Scoreboard::getInstance()->addObjective(obj)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -363,45 +413,49 @@ void Export_Compatibility_API() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"addObjectiveWithDisplayName",
|
"addObjectiveWithDisplayName",
|
||||||
[](std::string obj, std::string displayName) -> bool {
|
[](std::string const& obj, std::string const& displayName) -> bool {
|
||||||
if (auto res = GMLIB_Scoreboard::getInstance()->getInstance()->addObjective(obj, displayName)) {
|
if (auto res = GMLIB_Scoreboard::getInstance()->addObjective(obj, displayName)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getDisplayName", [](std::string obj) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getDisplayName", [](std::string const& obj) -> std::string {
|
||||||
if (auto result = GMLIB_Scoreboard::getInstance()->getInstance()->getObjectiveDisplayName(obj)) {
|
if (auto result = GMLIB_Scoreboard::getInstance()->getObjectiveDisplayName(obj)) {
|
||||||
return result.value();
|
return result.value();
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "setDisplayName", [](std::string obj, std::string displayName) -> bool {
|
RemoteCall::exportAs(
|
||||||
return GMLIB_Scoreboard::getInstance()->getInstance()->setObjectiveDisplayName(obj, displayName);
|
"GMLIB_API",
|
||||||
});
|
"setDisplayName",
|
||||||
RemoteCall::exportAs("GMLIB_API", "removeObjective", [](std::string obj) -> bool {
|
[](std::string const& obj, std::string const& displayName) -> bool {
|
||||||
return GMLIB_Scoreboard::getInstance()->getInstance()->removeObjective(obj);
|
return GMLIB_Scoreboard::getInstance()->setObjectiveDisplayName(obj, displayName);
|
||||||
});
|
}
|
||||||
RemoteCall::exportAs("GMLIB_API", "setDisplayObjective", [](std::string obj, std::string slot, int order) -> void {
|
|
||||||
return GMLIB_Scoreboard::getInstance()->getInstance()->setObjectiveDisplay(
|
|
||||||
obj,
|
|
||||||
slot,
|
|
||||||
(ObjectiveSortOrder)order
|
|
||||||
);
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "removeObjective", [](std::string const& obj) -> bool {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->removeObjective(obj);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "clearDisplayObjective", [](std::string slot) -> void {
|
RemoteCall::exportAs(
|
||||||
return GMLIB_Scoreboard::getInstance()->getInstance()->clearObjectiveDisplay(slot);
|
"GMLIB_API",
|
||||||
|
"setDisplayObjective",
|
||||||
|
[](std::string const& obj, std::string const& slot, int order) -> void {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->setObjectiveDisplay(obj, slot, (ObjectiveSortOrder)order);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "clearDisplayObjective", [](std::string const& slot) -> void {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->clearObjectiveDisplay(slot);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getAllObjectives", []() -> std::vector<std::string> {
|
RemoteCall::exportAs("GMLIB_API", "getAllObjectives", []() -> std::vector<std::string> {
|
||||||
auto objs = GMLIB_Scoreboard::getInstance()->getInstance()->getObjectives();
|
auto objs = GMLIB_Scoreboard::getInstance()->getObjectives();
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
for (auto obj : objs) {
|
for (auto& obj : objs) {
|
||||||
result.push_back(obj->getName());
|
result.push_back(obj->getName());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardPlayers", []() -> std::vector<std::string> {
|
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardPlayers", []() -> std::vector<std::string> {
|
||||||
auto uuids = GMLIB_Scoreboard::getInstance()->getInstance()->getAllPlayerUuids();
|
auto uuids = GMLIB_Scoreboard::getInstance()->getAllPlayerUuids();
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
for (auto& uuid : uuids) {
|
for (auto& uuid : uuids) {
|
||||||
result.push_back(uuid.asString());
|
result.push_back(uuid.asString());
|
||||||
@@ -409,30 +463,59 @@ void Export_Compatibility_API() {
|
|||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardFakePlayers", []() -> std::vector<std::string> {
|
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardFakePlayers", []() -> std::vector<std::string> {
|
||||||
auto names = GMLIB_Scoreboard::getInstance()->getInstance()->getAllFakePlayers();
|
auto names = GMLIB_Scoreboard::getInstance()->getAllFakePlayers();
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
for (auto name : names) {
|
for (auto& name : names) {
|
||||||
result.push_back(name);
|
result.push_back(name);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardEntities", []() -> std::vector<std::string> {
|
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardEntities", []() -> std::vector<std::string> {
|
||||||
auto auids = GMLIB_Scoreboard::getInstance()->getInstance()->getAllEntities();
|
auto uniqueIds = GMLIB_Scoreboard::getInstance()->getAllEntities();
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
for (auto auid : auids) {
|
for (auto& uniqueId : uniqueIds) {
|
||||||
result.push_back(std::to_string(auid.id));
|
result.push_back(std::to_string(uniqueId.id));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerFromUuid", [](std::string uuid) -> Player* {
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"getAllTrackedTargets",
|
||||||
|
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
||||||
|
std::vector<std::unordered_map<std::string, std::string>> result;
|
||||||
|
auto uuids = GMLIB_Scoreboard::getInstance()->getAllPlayerUuids();
|
||||||
|
for (auto& uuid : uuids) {
|
||||||
|
std::unordered_map<std::string, std::string> data;
|
||||||
|
data["Type"] = "Player";
|
||||||
|
data["Uuid"] = uuid.asString();
|
||||||
|
result.push_back(data);
|
||||||
|
}
|
||||||
|
auto names = GMLIB_Scoreboard::getInstance()->getAllFakePlayers();
|
||||||
|
for (auto& name : names) {
|
||||||
|
std::unordered_map<std::string, std::string> data;
|
||||||
|
data["Type"] = "FakePlayer";
|
||||||
|
data["Name"] = name;
|
||||||
|
result.push_back(data);
|
||||||
|
}
|
||||||
|
auto uniqueIds = GMLIB_Scoreboard::getInstance()->getAllEntities();
|
||||||
|
for (auto& uniqueId : uniqueIds) {
|
||||||
|
std::unordered_map<std::string, std::string> data;
|
||||||
|
data["Type"] = "Entity";
|
||||||
|
data["UniqueId"] = std::to_string(uniqueId.id);
|
||||||
|
result.push_back(data);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getPlayerFromUuid", [](std::string const& uuid) -> Player* {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
return ll::service::getLevel()->getPlayer(uuid);
|
return ll::service::getLevel()->getPlayer(uuid);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerFromUniqueId", [](std::string uniqueId) -> Actor* {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerFromUniqueId", [](std::string const& uniqueId) -> Actor* {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
return ll::service::getLevel()->getPlayer(auid);
|
return ll::service::getLevel()->getPlayer(auid);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityFromUniqueId", [](std::string uniqueId) -> Actor* {
|
RemoteCall::exportAs("GMLIB_API", "getEntityFromUniqueId", [](std::string const& uniqueId) -> Actor* {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
return ll::service::getLevel()->fetchEntity(auid);
|
return ll::service::getLevel()->fetchEntity(auid);
|
||||||
});
|
});
|
||||||
@@ -459,10 +542,65 @@ void Export_Compatibility_API() {
|
|||||||
auto player = (GMLIB_Player*)pl;
|
auto player = (GMLIB_Player*)pl;
|
||||||
player->clearSpawnPoint();
|
player->clearSpawnPoint();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "mergePatchJson", [](std::string oldJson, std::string patchJson) -> std::string {
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"mergePatchJson",
|
||||||
|
[](std::string const& oldJson, std::string const& patchJson) -> std::string {
|
||||||
auto oldData = nlohmann::ordered_json::parse(oldJson);
|
auto oldData = nlohmann::ordered_json::parse(oldJson);
|
||||||
auto newData = nlohmann::ordered_json::parse(patchJson);
|
auto newData = nlohmann::ordered_json::parse(patchJson);
|
||||||
oldData.merge_patch(newData);
|
oldData.merge_patch(newData);
|
||||||
return oldData.dump();
|
return oldData.dump();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getXuidByUuid", [](std::string const& uuid) -> std::string {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
auto result = GMLIB::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);
|
||||||
|
return result ? result.value() : "";
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getUuidByXuid", [](std::string const& xuid) -> std::string {
|
||||||
|
auto result = GMLIB::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);
|
||||||
|
return result ? result.value() : "";
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getXuidByName", [](std::string const& name) -> std::string {
|
||||||
|
auto result = GMLIB::UserCache::getXuidByName(name);
|
||||||
|
return result ? result.value() : "";
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getUuidByName", [](std::string const& name) -> std::string {
|
||||||
|
auto result = GMLIB::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);
|
||||||
|
return result ? result.value().asString() : "";
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_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) {
|
||||||
|
std::unordered_map<std::string, std::string> info;
|
||||||
|
info["Name"] = entry.mName;
|
||||||
|
info["Xuid"] = entry.mXuid;
|
||||||
|
info["Uuid"] = entry.mUuid.asString();
|
||||||
|
result.push_back(info);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getBlockRuntimeId", [](std::string const& blockName) -> uint {
|
||||||
|
if (auto block = Block::tryGetFromRegistry(blockName)) {
|
||||||
|
return block->getRuntimeId();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
+9
-7
@@ -6,15 +6,16 @@ void Export_Event_API() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"callCustomEvent",
|
"callCustomEvent",
|
||||||
[eventBus](std::string eventName, std::string eventId) -> bool {
|
[eventBus](std::string const& eventName, std::string const& eventId) -> bool {
|
||||||
if (RemoteCall::hasFunc(eventName, eventId)) {
|
if (RemoteCall::hasFunc(eventName, eventId)) {
|
||||||
switch (doHash(eventName)) {
|
switch (doHash(eventName)) {
|
||||||
case doHash("onClientLogin"): {
|
case doHash("onClientLogin"): {
|
||||||
auto Call = RemoteCall::importAs<
|
auto Call = RemoteCall::importAs<bool(
|
||||||
bool(std::string realName, std::string uuid, std::string serverXuid, std::string clientXuid)>(
|
std::string const& realName,
|
||||||
eventName,
|
std::string const& uuid,
|
||||||
eventId
|
std::string const& serverXuid,
|
||||||
);
|
std::string const& clientXuid
|
||||||
|
)>(eventName, eventId);
|
||||||
eventBus->emplaceListener<GMLIB::Event::PacketEvent::ClientLoginAfterEvent>(
|
eventBus->emplaceListener<GMLIB::Event::PacketEvent::ClientLoginAfterEvent>(
|
||||||
[Call](GMLIB::Event::PacketEvent::ClientLoginAfterEvent& ev) {
|
[Call](GMLIB::Event::PacketEvent::ClientLoginAfterEvent& ev) {
|
||||||
try {
|
try {
|
||||||
@@ -136,7 +137,8 @@ void Export_Event_API() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case doHash("onDeathMessage"): {
|
case doHash("onDeathMessage"): {
|
||||||
auto Call = RemoteCall::importAs<bool(std::string message, std::vector<std::string>, Actor * dead)>(
|
auto Call =
|
||||||
|
RemoteCall::importAs<bool(std::string const& message, std::vector<std::string>, Actor* dead)>(
|
||||||
eventName,
|
eventName,
|
||||||
eventId
|
eventId
|
||||||
);
|
);
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA")
|
#define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA")
|
||||||
|
|
||||||
#define LIB_VERSION GMLIB::Version(0, 12, 4)
|
#define LIB_VERSION GMLIB::Version(0, 12, 6)
|
||||||
|
|
||||||
extern ll::Logger logger;
|
extern ll::Logger logger;
|
||||||
|
|
||||||
|
|||||||
+44
-33
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
std::unordered_set<std::string> HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"};
|
std::unordered_set<std::string> HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"};
|
||||||
|
|
||||||
std::variant<std::string, std::vector<RecipeIngredient>> makeRecipeUnlockingKey(std::string& key) {
|
std::variant<std::string, std::vector<RecipeIngredient>> makeRecipeUnlockingKey(std::string const& key) {
|
||||||
if (HardCodedKeys.count(key)) {
|
if (HardCodedKeys.count(key)) {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
@@ -17,11 +17,11 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ModAPI",
|
"GMLib_ModAPI",
|
||||||
"registerShapelessRecipe",
|
"registerShapelessRecipe",
|
||||||
[](std::string recipe_id,
|
[](std::string const& recipe_id,
|
||||||
std::vector<std::string> ingredients,
|
std::vector<std::string> ingredients,
|
||||||
std::string result,
|
std::string const& result,
|
||||||
int count,
|
int count,
|
||||||
std::string unlock) -> void {
|
std::string const& unlock) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
@@ -39,12 +39,12 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ModAPI",
|
"GMLib_ModAPI",
|
||||||
"registerShapedRecipe",
|
"registerShapedRecipe",
|
||||||
[](std::string recipe_id,
|
[](std::string const& recipe_id,
|
||||||
std::vector<std::string> shape,
|
std::vector<std::string> shape,
|
||||||
std::vector<std::string> ingredients,
|
std::vector<std::string> ingredients,
|
||||||
std::string result,
|
std::string const& result,
|
||||||
int count,
|
int count,
|
||||||
std::string unlock) -> void {
|
std::string const& unlock) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
@@ -62,7 +62,10 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ModAPI",
|
"GMLib_ModAPI",
|
||||||
"registerFurnaceRecipe",
|
"registerFurnaceRecipe",
|
||||||
[](std::string recipe_id, std::string input, std::string output, std::vector<std::string> tags) -> void {
|
[](std::string const& recipe_id,
|
||||||
|
std::string const& input,
|
||||||
|
std::string const& output,
|
||||||
|
std::vector<std::string> tags) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
@@ -75,7 +78,8 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ModAPI",
|
"GMLib_ModAPI",
|
||||||
"registerBrewingMixRecipe",
|
"registerBrewingMixRecipe",
|
||||||
[](std::string recipe_id, std::string input, std::string output, std::string reagent) -> void {
|
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
||||||
|
) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
@@ -87,7 +91,8 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ModAPI",
|
"GMLib_ModAPI",
|
||||||
"registerBrewingContainerRecipe",
|
"registerBrewingContainerRecipe",
|
||||||
[](std::string recipe_id, std::string input, std::string output, std::string reagent) -> void {
|
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
||||||
|
) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
@@ -101,11 +106,11 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ModAPI",
|
"GMLib_ModAPI",
|
||||||
"registerSmithingTransformRecipe",
|
"registerSmithingTransformRecipe",
|
||||||
[](std::string recipe_id,
|
[](std::string const& recipe_id,
|
||||||
std::string smithing_template,
|
std::string const& smithing_template,
|
||||||
std::string base,
|
std::string const& base,
|
||||||
std::string addition,
|
std::string const& addition,
|
||||||
std::string result) -> void {
|
std::string const& result) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
@@ -122,7 +127,10 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ModAPI",
|
"GMLib_ModAPI",
|
||||||
"registerSmithingTrimRecipe",
|
"registerSmithingTrimRecipe",
|
||||||
[](std::string recipe_id, std::string smithing_template, std::string base, std::string addition) -> void {
|
[](std::string const& recipe_id,
|
||||||
|
std::string const& smithing_template,
|
||||||
|
std::string const& base,
|
||||||
|
std::string const& addition) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
@@ -133,10 +141,10 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ModAPI",
|
"GMLib_ModAPI",
|
||||||
"registerStoneCutterRecipe",
|
"registerStoneCutterRecipe",
|
||||||
[](std::string recipe_id,
|
[](std::string const& recipe_id,
|
||||||
std::string input,
|
std::string const& input,
|
||||||
int input_data,
|
int input_data,
|
||||||
std::string output,
|
std::string const& output,
|
||||||
int output_data,
|
int output_data,
|
||||||
int output_count) -> void {
|
int output_count) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = GMLIB_Level::getInstance();
|
||||||
@@ -154,34 +162,37 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
});
|
});
|
||||||
// 实验性
|
// 实验性
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void {
|
RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void {
|
||||||
auto map = GMLIB_Level::getAllExperiments();
|
auto list = GMLIB_Level::getAllExperiments();
|
||||||
if (map.count(experiment_id)) {
|
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||||
|
if (set.contains((AllExperiments)experiment_id)) {
|
||||||
GMLIB_Level::addExperimentsRequire((AllExperiments)experiment_id);
|
GMLIB_Level::addExperimentsRequire((AllExperiments)experiment_id);
|
||||||
} else {
|
} else {
|
||||||
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "setExperimentEnabled", [](int experiment_id, bool value) -> void {
|
RemoteCall::exportAs("GMLib_ModAPI", "setExperimentEnabled", [](int experiment_id, bool value) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
if (GMLIB_Level::getInstance()) {
|
||||||
if (!level) {
|
auto list = GMLIB_Level::getAllExperiments();
|
||||||
return;
|
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||||
}
|
if (set.contains((AllExperiments)experiment_id)) {
|
||||||
auto map = GMLIB_Level::getAllExperiments();
|
|
||||||
if (map.count(experiment_id)) {
|
|
||||||
GMLIB_Level::getInstance()->setExperimentEnabled(((AllExperiments)experiment_id), value);
|
GMLIB_Level::getInstance()->setExperimentEnabled(((AllExperiments)experiment_id), value);
|
||||||
} else ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
} else ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "getExperimentEnabled", [](int experiment_id) -> bool {
|
RemoteCall::exportAs("GMLib_ModAPI", "getExperimentEnabled", [](int experiment_id) -> bool {
|
||||||
auto level = GMLIB_Level::getInstance();
|
if (GMLIB_Level::getInstance()) {
|
||||||
if (!level) {
|
auto list = GMLIB_Level::getAllExperiments();
|
||||||
return false;
|
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||||
}
|
if (set.contains((AllExperiments)experiment_id)) {
|
||||||
auto map = GMLIB_Level::getAllExperiments();
|
|
||||||
if (map.count(experiment_id)) {
|
|
||||||
return GMLIB_Level::getInstance()->getExperimentEnabled(((AllExperiments)experiment_id));
|
return GMLIB_Level::getInstance()->getExperimentEnabled(((AllExperiments)experiment_id));
|
||||||
} else {
|
} else {
|
||||||
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLib_ModAPI", "setFixI18nEnabled", []() -> void {
|
||||||
|
GMLIB::Mod::VanillaFix::setFixI18nEnabled();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
+36
-14
@@ -1,4 +1,6 @@
|
|||||||
|
#include "GMLIB/Server/FakeListAPI.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
#include "mc/world/ActorUniqueID.h"
|
||||||
|
|
||||||
void Export_Legacy_GMLib_ServerAPI() {
|
void Export_Legacy_GMLib_ServerAPI() {
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void {
|
||||||
@@ -15,29 +17,36 @@ void Export_Legacy_GMLib_ServerAPI() {
|
|||||||
GMLIB_Level::requireServerResourcePackAndAllowClientResourcePack();
|
GMLIB_Level::requireServerResourcePackAndAllowClientResourcePack();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
||||||
auto level = GMLIB_Level::getInstance();
|
if (auto level = GMLIB_Level::getInstance()) {
|
||||||
if (!level) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return level->getLevelName();
|
return level->getLevelName();
|
||||||
});
|
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setLevelName", [](std::string name) -> void {
|
|
||||||
auto level = GMLIB_Level::getInstance();
|
|
||||||
if (!level) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
return level->setLevelName(name);
|
return {};
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLib_ServerAPI", "setLevelName", [](std::string const& name) -> void {
|
||||||
|
if (auto level = GMLIB_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 {};
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setFakeSeed", [](int64_t seed) -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setFakeSeed", [](int64_t seed) -> void {
|
||||||
return GMLIB_Level::setFakeSeed(seed);
|
return GMLIB_Level::setFakeSeed(seed);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "spawnEntity", [](std::pair<Vec3, int> pos, std::string name) -> Actor* {
|
RemoteCall::exportAs(
|
||||||
|
"GMLib_ServerAPI",
|
||||||
|
"spawnEntity",
|
||||||
|
[](std::pair<Vec3, int> pos, std::string const& name) -> Actor* {
|
||||||
return GMLIB_Spawner::spawnEntity(pos.first, pos.second, name);
|
return GMLIB_Spawner::spawnEntity(pos.first, pos.second, name);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ServerAPI",
|
"GMLib_ServerAPI",
|
||||||
"shootProjectile",
|
"shootProjectile",
|
||||||
[](Actor* owner, std::string name, float speed, float offset) -> Actor* {
|
[](Actor* owner, std::string const& name, float speed, float offset) -> Actor* {
|
||||||
auto ac = (GMLIB_Actor*)owner;
|
auto ac = (GMLIB_Actor*)owner;
|
||||||
return ac->shootProjectile(name, speed, offset);
|
return ac->shootProjectile(name, speed, offset);
|
||||||
}
|
}
|
||||||
@@ -47,8 +56,21 @@ void Export_Legacy_GMLib_ServerAPI() {
|
|||||||
"throwEntity",
|
"throwEntity",
|
||||||
[](Actor* owner, Actor* actor, float speed, float offset) -> bool {
|
[](Actor* owner, Actor* actor, float speed, float offset) -> bool {
|
||||||
auto ac = (GMLIB_Actor*)owner;
|
auto ac = (GMLIB_Actor*)owner;
|
||||||
return ac->throwEntity(actor, speed, offset);
|
return ac->throwEntity(*actor, speed, offset);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "PlayerToEntity", [](Player* player) -> Actor* { return (Actor*)player; });
|
RemoteCall::exportAs("GMLib_ServerAPI", "PlayerToEntity", [](Player* player) -> Actor* { return (Actor*)player; });
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLib_ServerAPI",
|
||||||
|
"addFakeList",
|
||||||
|
[](const std::string& name, const std::string& xuid) -> bool {
|
||||||
|
return GMLIB::Server::FakeList::addFakeList(name, xuid, ActorUniqueID(-1));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLib_ServerAPI", "removeFakeList", [](const std::string& nameOrXuid) -> bool {
|
||||||
|
return GMLIB::Server::FakeList::removeFakeList(nameOrXuid);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLib_ServerAPI", "removeAllFakeList", []() -> void {
|
||||||
|
return GMLIB::Server::FakeList::removeAllFakeLists();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,7 @@ std::string removeBrackets(std::string a1) {
|
|||||||
return a1;
|
return a1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isParameters(std::string str) {
|
bool isParameters(std::string const& str) {
|
||||||
std::regex reg("[<]([^<>]+)[>]");
|
std::regex reg("[<]([^<>]+)[>]");
|
||||||
return std::regex_search(removeBrackets(str), reg);
|
return std::regex_search(removeBrackets(str), reg);
|
||||||
}
|
}
|
||||||
@@ -64,11 +64,7 @@ bool registerServerPlaceholder(
|
|||||||
);
|
);
|
||||||
} else {
|
} 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, [Call]() { return Call(); }, PluginName);
|
||||||
PAPIName,
|
|
||||||
[Call]() { return Call(); },
|
|
||||||
PluginName
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -110,7 +106,7 @@ std::string translateStringWithPlayer(std::string const& str, Player* pl) {
|
|||||||
|
|
||||||
std::string translateString(std::string const& str) { return GMLIB::Server::PlaceholderAPI::translateString(str); }
|
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(); }
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"format_version": 2,
|
"format_version": 2,
|
||||||
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
||||||
"version": "0.12.4",
|
"version": "0.12.6",
|
||||||
"info": {
|
"info": {
|
||||||
"name": "GMLIB-LegacyRemoteCallApi",
|
"name": "GMLIB-LegacyRemoteCallApi",
|
||||||
"description": "Legacy RemoteCall API for GMLIB",
|
"description": "Legacy RemoteCall API for GMLIB",
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
"library"
|
"library"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.12.4/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
|
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.12.6/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"github.com/GroupMountain/GMLIB": ">=0.12.4"
|
"github.com/GroupMountain/GMLIB": ">=0.12.4"
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user