Compare commits
3 Commits
+1
-1
Submodule SDK-GMLIB updated: fd8463224f...7206bf0c10
+60
-16
@@ -93,7 +93,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 = [];
|
||||||
@@ -360,11 +365,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) {
|
||||||
@@ -372,7 +377,7 @@ class Minecraft {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static resourcePackTranslate(key, params = []) {
|
static resourcePackTranslate(key, params = []) {
|
||||||
return GMLIB_API.resourcePackTranslate(key, params);
|
return I18nAPI.get(key, params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -693,7 +698,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();
|
||||||
}
|
}
|
||||||
@@ -707,9 +719,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;
|
||||||
}
|
}
|
||||||
@@ -795,6 +807,44 @@ class JsonI18n {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class I18nAPI {
|
||||||
|
constructor() {
|
||||||
|
throw new Error("Static class cannot be instantiated");
|
||||||
|
}
|
||||||
|
|
||||||
|
static get(key, params = []) {
|
||||||
|
GMLIB_API.resourcePackTranslate(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 loadLanguagePath(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);
|
||||||
}
|
}
|
||||||
@@ -819,7 +869,6 @@ 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,
|
||||||
@@ -831,11 +880,6 @@ module.exports = {
|
|||||||
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.12.4",
|
"version": "0.12.3",
|
||||||
"author": "GroupMountain",
|
"author": "GroupMountain",
|
||||||
"type": "native",
|
"type": "native",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ void Export_Compatibility_API() {
|
|||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "setPlayerNbt", [](std::string uuid, CompoundTag* nbt, 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);
|
||||||
logger.warn(nbt->toSnbt());
|
|
||||||
return GMLIB_Player::setPlayerNbt(uid, *nbt, forceCreate);
|
return GMLIB_Player::setPlayerNbt(uid, *nbt, forceCreate);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -67,7 +66,6 @@ void Export_Compatibility_API() {
|
|||||||
"setPlayerNbtTags",
|
"setPlayerNbtTags",
|
||||||
[](std::string uuid, CompoundTag* nbt, 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);
|
||||||
logger.warn(nbt->toSnbt());
|
|
||||||
return GMLIB_Player::setPlayerNbtTags(uid, *nbt, tags);
|
return GMLIB_Player::setPlayerNbtTags(uid, *nbt, tags);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -177,6 +175,31 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
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);
|
||||||
@@ -429,4 +452,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();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
+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, 2)
|
#define LIB_VERSION GMLIB::Version(0, 12, 3)
|
||||||
|
|
||||||
extern ll::Logger logger;
|
extern ll::Logger logger;
|
||||||
|
|
||||||
|
|||||||
+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.2",
|
"version": "0.12.3",
|
||||||
"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.2/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
|
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.12.3/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