Compare commits
13 Commits
+1
-1
Submodule SDK-GMLIB updated: ae86cc4327...7206bf0c10
+76
-59
@@ -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"),
|
||||||
@@ -19,6 +16,7 @@ const GMLIB_API = {
|
|||||||
setPlayerNbt: ll.import("GMLIB_API", "setPlayerNbt"),
|
setPlayerNbt: ll.import("GMLIB_API", "setPlayerNbt"),
|
||||||
setPlayerNbtTags: ll.import("GMLIB_API", "setPlayerNbtTags"),
|
setPlayerNbtTags: ll.import("GMLIB_API", "setPlayerNbtTags"),
|
||||||
resourcePackTranslate: ll.import("GMLIB_API", "resourcePackTranslate"),
|
resourcePackTranslate: ll.import("GMLIB_API", "resourcePackTranslate"),
|
||||||
|
resourcePackDefaultTranslate: ll.import("GMLIB_API", "resourcePackDefaultTranslate"),
|
||||||
getResourcePackI18nLanguage: ll.import("GMLIB_API", "getResourcePackI18nLanguage"),
|
getResourcePackI18nLanguage: ll.import("GMLIB_API", "getResourcePackI18nLanguage"),
|
||||||
chooseResourcePackI18nLanguage: ll.import("GMLIB_API", "chooseResourcePackI18nLanguage"),
|
chooseResourcePackI18nLanguage: ll.import("GMLIB_API", "chooseResourcePackI18nLanguage"),
|
||||||
setEducationFeatureEnabled: ll.import("GMLib_ServerAPI", "setEducationFeatureEnabled"),
|
setEducationFeatureEnabled: ll.import("GMLib_ServerAPI", "setEducationFeatureEnabled"),
|
||||||
@@ -35,7 +33,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"),
|
||||||
@@ -93,7 +91,12 @@ const GMLIB_API = {
|
|||||||
getPlayerSpawnPoint: ll.import("GMLIB_API", "getPlayerSpawnPoint"),
|
getPlayerSpawnPoint: ll.import("GMLIB_API", "getPlayerSpawnPoint"),
|
||||||
setPlayerSpawnPoint: ll.import("GMLIB_API", "setPlayerSpawnPoint"),
|
setPlayerSpawnPoint: ll.import("GMLIB_API", "setPlayerSpawnPoint"),
|
||||||
clearPlayerSpawnPoint: ll.import("GMLIB_API", "clearPlayerSpawnPoint"),
|
clearPlayerSpawnPoint: ll.import("GMLIB_API", "clearPlayerSpawnPoint"),
|
||||||
setCustomPackPath: ll.import("GMLIB_API", "setCustomPackPath")
|
setCustomPackPath: ll.import("GMLIB_API", "setCustomPackPath"),
|
||||||
|
getSupportedLanguages: ll.import("GMLIB_API", "getSupportedLanguages"),
|
||||||
|
loadLanguage: ll.import("GMLIB_API", "loadLanguage"),
|
||||||
|
updateOrCreateLanguageFile: ll.import("GMLIB_API", "updateOrCreateLanguageFile"),
|
||||||
|
loadLanguagePath: ll.import("GMLIB_API", "loadLanguagePath"),
|
||||||
|
mergePatchJson: ll.import("GMLIB_API", "mergePatchJson")
|
||||||
}
|
}
|
||||||
|
|
||||||
const FloatingTextList = [];
|
const FloatingTextList = [];
|
||||||
@@ -105,10 +108,6 @@ class StaticFloatingText {
|
|||||||
this.mPlaceholderAPI = papi;
|
this.mPlaceholderAPI = papi;
|
||||||
this.mRuntimeId = GMLIB_API.createFloatingText(this.mPosition, this.mText, this.mPlaceholderAPI);
|
this.mRuntimeId = GMLIB_API.createFloatingText(this.mPosition, this.mText, this.mPlaceholderAPI);
|
||||||
FloatingTextList.push(this);
|
FloatingTextList.push(this);
|
||||||
this.sendToClients();
|
|
||||||
mc.listen("onJoin", (pl) => {
|
|
||||||
this.sendToClient(pl);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sendToClient(player) {
|
sendToClient(player) {
|
||||||
@@ -284,22 +283,15 @@ class Minecraft {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static getPlayerNbt(uuid) {
|
static getPlayerNbt(uuid) {
|
||||||
let snbt = GMLIB_API.getPlayerNbt(uuid);
|
return GMLIB_API.getPlayerNbt(uuid);
|
||||||
if (snbt == "null") {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
let nbt = NBT.parseSNBT(snbt);
|
|
||||||
return nbt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static setPlayerNbt(uuid, nbt, forceCreate = true) {
|
static setPlayerNbt(uuid, nbt, forceCreate = true) {
|
||||||
let snbt = nbt.toSNBT();
|
return GMLIB_API.setPlayerNbt(uuid, nbt, forceCreate);
|
||||||
return GMLIB_API.setPlayerNbt(uuid, snbt, forceCreate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static setPlayerNbtTags(uuid, nbt, tags) {
|
static setPlayerNbtTags(uuid, nbt, tags) {
|
||||||
let snbt = nbt.toSNBT();
|
return GMLIB_API.setPlayerNbtTags(uuid, nbt, tags);
|
||||||
return GMLIB_API.setPlayerNbtTags(uuid, snbt, tags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static getPlayerPosition(uuid) {
|
static getPlayerPosition(uuid) {
|
||||||
@@ -371,11 +363,11 @@ class Minecraft {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static getServerLanguage() {
|
static getServerLanguage() {
|
||||||
return GMLIB_API.getResourcePackI18nLanguage(language);
|
return I18nAPI.getCurrentLanguage();
|
||||||
}
|
}
|
||||||
|
|
||||||
static setServerLanguage(language) {
|
static setServerLanguage(language) {
|
||||||
return GMLIB_API.chooseResourcePackI18nLanguage(language);
|
return I18nAPI.chooseLanguage(language);
|
||||||
}
|
}
|
||||||
|
|
||||||
static setCustomPackPath(path) {
|
static setCustomPackPath(path) {
|
||||||
@@ -383,7 +375,7 @@ class Minecraft {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static resourcePackTranslate(key, params = []) {
|
static resourcePackTranslate(key, params = []) {
|
||||||
return GMLIB_API.resourcePackTranslate(key, params);
|
return I18nAPI.get(key, params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,18 +432,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) {
|
||||||
@@ -507,28 +489,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;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
class GMLIB {
|
static isPluginVersionMatched(version) {
|
||||||
constructor() {
|
return GMLIB_API.isVersionMatched(version.mMajor, version.mMinor, version.mPatch);
|
||||||
throw new Error("Static class cannot be instantiated");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static isVersionMatched(major, minor, patch) {
|
static getLrcaVersion() {
|
||||||
return GMLIB_API.isVersionMatched(major, minor, patch);
|
return Version.fromString(GMLIB_API.getVersion_LRCA());
|
||||||
}
|
}
|
||||||
|
|
||||||
static getVersion_LRCA() {
|
static getGmlibVersion() {
|
||||||
return GMLIB_API.getVersion_LRCA();
|
return Version.fromString(GMLIB_API.getVersion_GMLIB());
|
||||||
}
|
|
||||||
|
|
||||||
static getVersion_GMLIB() {
|
|
||||||
return GMLIB_API.getVersion_GMLIB();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -704,7 +680,14 @@ class JsonConfig {
|
|||||||
init() {
|
init() {
|
||||||
if (File.exists(this.mPath)) {
|
if (File.exists(this.mPath)) {
|
||||||
let existDataStr = File.readFrom(this.mPath);
|
let existDataStr = File.readFrom(this.mPath);
|
||||||
this.mData = Object.assign({}, this.mData, JSON.parse(existDataStr));
|
existDataStr = existDataStr.replace(/\/\/.*|\/\*[^]*?\*\//g, "");
|
||||||
|
try {
|
||||||
|
let result = GMLIB_API.mergePatchJson(JSON.stringify(this.mData), existDataStr);
|
||||||
|
this.mData = JSON.parse(result);
|
||||||
|
} catch {
|
||||||
|
let newPath = this.mPath + "_old";
|
||||||
|
File.rename(this.mPath, newPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.save();
|
this.save();
|
||||||
}
|
}
|
||||||
@@ -718,9 +701,9 @@ class JsonConfig {
|
|||||||
return this.mData;
|
return this.mData;
|
||||||
}
|
}
|
||||||
|
|
||||||
get(key, defultValue = null) {
|
get(key, defultValue = undefined) {
|
||||||
let result = this.getData()[key];
|
let result = this.getData()[key];
|
||||||
if (!result && defultValue != null) {
|
if (!result && defultValue != undefined) {
|
||||||
this.set(key, defultValue);
|
this.set(key, defultValue);
|
||||||
return defultValue;
|
return defultValue;
|
||||||
}
|
}
|
||||||
@@ -806,6 +789,47 @@ class JsonI18n {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class I18nAPI {
|
||||||
|
constructor() {
|
||||||
|
throw new Error("Static class cannot be instantiated");
|
||||||
|
}
|
||||||
|
|
||||||
|
static get(key, params = [], langCode = undefined) {
|
||||||
|
if (langCode) {
|
||||||
|
return GMLIB_API.resourcePackTranslate(key, params, langCode);
|
||||||
|
}
|
||||||
|
return GMLIB_API.resourcePackDefaultTranslate(key, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
static translate(key, params = []) {
|
||||||
|
return I18nAPI.get(key, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
static getSupportedLanguages() {
|
||||||
|
return GMLIB_API.getSupportedLanguages();
|
||||||
|
}
|
||||||
|
|
||||||
|
static getCurrentLanguage() {
|
||||||
|
return GMLIB_API.getResourcePackI18nLanguage(language);
|
||||||
|
}
|
||||||
|
|
||||||
|
static chooseLanguage(language) {
|
||||||
|
GMLIB_API.chooseResourcePackI18nLanguage(language);
|
||||||
|
}
|
||||||
|
|
||||||
|
static loadLanguage(code, language) {
|
||||||
|
GMLIB_API.loadLanguage(code, language);
|
||||||
|
}
|
||||||
|
|
||||||
|
static updateOrCreateLanguageFile(code, lang, path) {
|
||||||
|
GMLIB_API.updateOrCreateLanguageFile(code, lang, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
static loadLanguageDirectory(path) {
|
||||||
|
GMLIB_API.loadLanguagePath(path);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
LLSE_Player.prototype.toEntity = function () {
|
LLSE_Player.prototype.toEntity = function () {
|
||||||
return GMLIB_API.PlayerToEntity(this);
|
return GMLIB_API.PlayerToEntity(this);
|
||||||
}
|
}
|
||||||
@@ -830,23 +854,16 @@ LLSE_Entity.prototype.throwEntity = function (proj, speed = 2, offset = 3) {
|
|||||||
return GMLIB_API.throwEntity(this, proj, speed, offset);
|
return GMLIB_API.throwEntity(this, proj, speed, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
StaticFloatingText,
|
StaticFloatingText,
|
||||||
DynamicFloatingText,
|
DynamicFloatingText,
|
||||||
Minecraft,
|
Minecraft,
|
||||||
Recipes,
|
Recipes,
|
||||||
Experiments,
|
Experiments,
|
||||||
GMLIB,
|
|
||||||
Scoreboard,
|
Scoreboard,
|
||||||
JsonConfig,
|
JsonConfig,
|
||||||
JsonLanguage,
|
JsonLanguage,
|
||||||
JsonI18n,
|
JsonI18n,
|
||||||
Version
|
Version,
|
||||||
|
I18nAPI
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "${pluginName}",
|
"name": "${pluginName}",
|
||||||
"entry": "${pluginFile}",
|
"entry": "${pluginFile}",
|
||||||
"version": "0.10.1",
|
"version": "0.12.5",
|
||||||
"author": "GroupMountain",
|
"author": "GroupMountain",
|
||||||
"type": "native",
|
"type": "native",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
|
|||||||
+57
-25
@@ -53,25 +53,19 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerNbt", [](std::string uuid) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerNbt", [](std::string uuid) -> std::unique_ptr<CompoundTag> {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
auto nbt = GMLIB_Player::getPlayerNbt(uid);
|
return std::move(GMLIB_Player::getPlayerNbt(uid));
|
||||||
if (nbt) {
|
|
||||||
return nbt->toSnbt();
|
|
||||||
}
|
|
||||||
return "null";
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "setPlayerNbt", [](std::string uuid, std::string snbt, bool forceCreate) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "setPlayerNbt", [](std::string uuid, CompoundTag* nbt, bool forceCreate) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
auto nbt = CompoundTag::fromSnbt(snbt);
|
|
||||||
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, std::string snbt, std::vector<std::string> tags) -> bool {
|
[](std::string uuid, CompoundTag* nbt, std::vector<std::string> tags) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
auto nbt = CompoundTag::fromSnbt(snbt);
|
|
||||||
return GMLIB_Player::setPlayerNbtTags(uid, *nbt, tags);
|
return GMLIB_Player::setPlayerNbtTags(uid, *nbt, tags);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -83,18 +77,18 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
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 text, bool papi) -> int {
|
||||||
auto ft = new GMLIB::Server::FloatingText(text, pos.first, pos.second, papi);
|
auto ft = new GMLIB::Server::StaticFloatingText(text, pos.first, pos.second, papi);
|
||||||
return ft->getRuntimeID();
|
return ft->getRuntimeID();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -112,7 +106,7 @@ void Export_Compatibility_API() {
|
|||||||
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);
|
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
||||||
if (ft) {
|
if (ft) {
|
||||||
ft->sendToClient(pl);
|
ft->sendToClient(*pl);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -128,7 +122,7 @@ void Export_Compatibility_API() {
|
|||||||
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);
|
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
||||||
if (ft) {
|
if (ft) {
|
||||||
ft->removeFromClient(pl);
|
ft->removeFromClient(*pl);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -144,7 +138,7 @@ void Export_Compatibility_API() {
|
|||||||
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);
|
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
||||||
if (ft) {
|
if (ft) {
|
||||||
ft->updateClient(pl);
|
ft->updateClient(*pl);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -159,28 +153,60 @@ void Export_Compatibility_API() {
|
|||||||
});
|
});
|
||||||
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 {
|
||||||
return GMLIB::Version::getLibVersionString();
|
return GMLIB::Version::getLibVersionString();
|
||||||
});
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"resourcePackDefaultTranslate",
|
||||||
|
[](std::string 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 { return I18n::get(key, params); }
|
[](std::string key, std::vector<std::string> params, std::string code) -> std::string {
|
||||||
|
return I18nAPI::get(key, params, code);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "chooseResourcePackI18nLanguage", [](std::string code) -> void {
|
RemoteCall::exportAs("GMLIB_API", "chooseResourcePackI18nLanguage", [](std::string code) -> void {
|
||||||
if (GMLIB_Level::getInstance()) {
|
if (GMLIB_Level::getInstance()) {
|
||||||
I18n::chooseLanguage(code);
|
I18nAPI::chooseLanguage(code);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getResourcePackI18nLanguage", []() -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getResourcePackI18nLanguage", []() -> std::string {
|
||||||
if (GMLIB_Level::getInstance()) {
|
if (GMLIB_Level::getInstance()) {
|
||||||
return I18n::getCurrentLanguage()->getFullLanguageCode();
|
return I18nAPI::getCurrentLanguageCode();
|
||||||
}
|
}
|
||||||
return "unknown";
|
return "unknown";
|
||||||
});
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getSupportedLanguages", []() -> std::vector<std::string> {
|
||||||
|
if (GMLIB_Level::getInstance()) {
|
||||||
|
return I18nAPI::getSupportedLanguageCodes();
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "loadLanguage", [](std::string code, std::string lang) -> void {
|
||||||
|
if (GMLIB_Level::getInstance()) {
|
||||||
|
I18nAPI::loadLanguage(code, lang);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"updateOrCreateLanguageFile",
|
||||||
|
[](std::string code, std::string lang, std::string path) -> void {
|
||||||
|
if (GMLIB_Level::getInstance()) {
|
||||||
|
I18nAPI::updateOrCreateLanguageFile(path, code, lang);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "loadLanguagePath", [](std::string path) -> void {
|
||||||
|
if (GMLIB_Level::getInstance()) {
|
||||||
|
I18nAPI::loadLanguagesFromDirectory(path);
|
||||||
|
}
|
||||||
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerPosition", [](std::string uuid) -> std::pair<BlockPos, int> {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerPosition", [](std::string 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);
|
||||||
@@ -394,7 +420,7 @@ void Export_Compatibility_API() {
|
|||||||
auto auids = GMLIB_Scoreboard::getInstance()->getInstance()->getAllEntities();
|
auto auids = GMLIB_Scoreboard::getInstance()->getInstance()->getAllEntities();
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
for (auto auid : auids) {
|
for (auto auid : auids) {
|
||||||
result.push_back(std::to_string(auid.get()));
|
result.push_back(std::to_string(auid.id));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
@@ -433,4 +459,10 @@ 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 {
|
||||||
|
auto oldData = nlohmann::ordered_json::parse(oldJson);
|
||||||
|
auto newData = nlohmann::ordered_json::parse(patchJson);
|
||||||
|
oldData.merge_patch(newData);
|
||||||
|
return oldData.dump();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
+5
-1
@@ -17,7 +17,11 @@ bool LRCA::load() {
|
|||||||
ExportPAPI();
|
ExportPAPI();
|
||||||
Export_Event_API();
|
Export_Event_API();
|
||||||
logger.info("GMLIB-LegacyRemoteCallApi Loaded!");
|
logger.info("GMLIB-LegacyRemoteCallApi Loaded!");
|
||||||
logger.info("Version: {}", LIB_VERSION.asString());
|
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())
|
||||||
|
);
|
||||||
logger.info("Author: GroupMountain");
|
logger.info("Author: GroupMountain");
|
||||||
logger.info("Repository: https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi");
|
logger.info("Repository: https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi");
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -174,6 +174,21 @@ void Export_Event_API() {
|
|||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
case doHash("onEndermanTake"): {
|
||||||
|
auto Call = RemoteCall::importAs<bool(Actor * mob)>(eventName, eventId);
|
||||||
|
eventBus->emplaceListener<GMLIB::Event::EntityEvent::EndermanTakeBlockBeforeEvent>(
|
||||||
|
[Call](GMLIB::Event::EntityEvent::EndermanTakeBlockBeforeEvent& ev) {
|
||||||
|
bool result = true;
|
||||||
|
try {
|
||||||
|
result = Call(&ev.self());
|
||||||
|
} catch (...) {}
|
||||||
|
if (!result) {
|
||||||
|
ev.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -3,8 +3,9 @@
|
|||||||
|
|
||||||
#include <RemoteCallAPI.h>
|
#include <RemoteCallAPI.h>
|
||||||
|
|
||||||
#define PLUGIN_NAME "GMLIB-LRCA"
|
#define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA")
|
||||||
#define LIB_VERSION GMLIB::Version(0, 10, 1)
|
|
||||||
|
#define LIB_VERSION GMLIB::Version(0, 12, 5)
|
||||||
|
|
||||||
extern ll::Logger logger;
|
extern ll::Logger logger;
|
||||||
|
|
||||||
|
|||||||
@@ -2,16 +2,18 @@
|
|||||||
|
|
||||||
void Export_Legacy_GMLib_ServerAPI() {
|
void Export_Legacy_GMLib_ServerAPI() {
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void {
|
||||||
GMLIB_Level::addEducationEditionRequired();
|
GMLIB_Level::tryEnableEducationEdition();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void {
|
||||||
GMLIB_Level::forceEnableAbilityCommand();
|
GMLIB_Level::tryRegisterAbilityCommand();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void {
|
||||||
GMLIB_Level::setForceAchievementsEnabled();
|
GMLIB_Level::setForceAchievementsEnabled();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void { GMLIB_Level::setForceTrustSkin(); });
|
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void { GMLIB_Level::trustAllSkins(); });
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "enableCoResourcePack", []() -> void { GMLIB_Level::setCoResourcePack(); });
|
RemoteCall::exportAs("GMLib_ServerAPI", "enableCoResourcePack", []() -> void {
|
||||||
|
GMLIB_Level::requireServerResourcePackAndAllowClientResourcePack();
|
||||||
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
|
|||||||
@@ -3,6 +3,16 @@
|
|||||||
|
|
||||||
namespace PAPIRemoteCall {
|
namespace PAPIRemoteCall {
|
||||||
|
|
||||||
|
std::string removeBrackets(std::string a1) {
|
||||||
|
a1.erase(a1.find_last_not_of("%") + 1);
|
||||||
|
return a1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isParameters(std::string str) {
|
||||||
|
std::regex reg("[<]([^<>]+)[>]");
|
||||||
|
return std::regex_search(removeBrackets(str), reg);
|
||||||
|
}
|
||||||
|
|
||||||
std::string GetValue(std::string const& from) { return GMLIB::Server::PlaceholderAPI::getValue(from); }
|
std::string GetValue(std::string const& from) { return GMLIB::Server::PlaceholderAPI::getValue(from); }
|
||||||
|
|
||||||
std::string GetValueWithPlayer(std::string const& a1, std::string const& a2) {
|
std::string GetValueWithPlayer(std::string const& a1, std::string const& a2) {
|
||||||
@@ -15,12 +25,24 @@ bool registerPlayerPlaceholder(
|
|||||||
std::string const& PAPIName
|
std::string const& PAPIName
|
||||||
) {
|
) {
|
||||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||||
|
if (isParameters(PAPIName)) {
|
||||||
|
auto Call = RemoteCall::importAs<std::string(Player * pl, std::unordered_map<std::string, std::string>)>(
|
||||||
|
PluginName,
|
||||||
|
FuncName
|
||||||
|
);
|
||||||
|
GMLIB::Server::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);
|
auto Call = RemoteCall::importAs<std::string(Player * pl)>(PluginName, FuncName);
|
||||||
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
|
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
|
||||||
PAPIName,
|
PAPIName,
|
||||||
[Call](Player* sp) { return Call(sp); },
|
[Call](Player* sp) { return Call(sp); },
|
||||||
PluginName
|
PluginName
|
||||||
);
|
);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -32,12 +54,22 @@ bool registerServerPlaceholder(
|
|||||||
std::string const& PAPIName
|
std::string const& PAPIName
|
||||||
) {
|
) {
|
||||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||||
|
if (isParameters(PAPIName)) {
|
||||||
|
auto Call =
|
||||||
|
RemoteCall::importAs<std::string(std::unordered_map<std::string, std::string>)>(PluginName, FuncName);
|
||||||
|
GMLIB::Server::PlaceholderAPI::registerServerPlaceholder(
|
||||||
|
PAPIName,
|
||||||
|
[Call](std::unordered_map<std::string, std::string> map) { return Call(map); },
|
||||||
|
PluginName
|
||||||
|
);
|
||||||
|
} else {
|
||||||
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
||||||
GMLIB::Server::PlaceholderAPI::registerServerPlaceholder(
|
GMLIB::Server::PlaceholderAPI::registerServerPlaceholder(
|
||||||
PAPIName,
|
PAPIName,
|
||||||
[Call]() { return Call(); },
|
[Call]() { return Call(); },
|
||||||
PluginName
|
PluginName
|
||||||
);
|
);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -50,6 +82,7 @@ bool registerStaticPlaceholder(
|
|||||||
int num
|
int num
|
||||||
) {
|
) {
|
||||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||||
|
if (isParameters(PAPIName)) {
|
||||||
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
||||||
if (num == -1) {
|
if (num == -1) {
|
||||||
GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder(
|
GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder(
|
||||||
@@ -65,6 +98,7 @@ bool registerStaticPlaceholder(
|
|||||||
PluginName
|
PluginName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"format_version": 2,
|
"format_version": 2,
|
||||||
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
||||||
"version": "0.10.1",
|
"version": "0.12.5",
|
||||||
"info": {
|
"info": {
|
||||||
"name": "GMLIB-LegacyRemoteCallApi",
|
"name": "GMLIB-LegacyRemoteCallApi",
|
||||||
"description": "Legacy RemoteCall API for GMLIB",
|
"description": "Legacy RemoteCall API for GMLIB",
|
||||||
@@ -14,9 +14,9 @@
|
|||||||
"library"
|
"library"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.10.1/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
|
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.12.5/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"github.com/GroupMountain/GMLIB": ">=0.10.0"
|
"github.com/GroupMountain/GMLIB": ">=0.12.4"
|
||||||
},
|
},
|
||||||
"files": {
|
"files": {
|
||||||
"place": [
|
"place": [
|
||||||
|
|||||||
Reference in New Issue
Block a user