adapt: adapt 1.20.72

This commit is contained in:
Tsubasa6848
2024-03-28 00:06:06 +08:00
Unverified
parent e799b2a0c9
commit c65c72d51e
10 changed files with 133 additions and 9 deletions
+49 -1
View File
@@ -480,6 +480,53 @@ class Experiments {
}
}
class Version {
constructor(major, minor, patch) {
this.mMajor = major;
this.mMinor = minor;
this.mPatch = patch;
}
toString(prefix = true) {
let result = `${this.mMajor}.${this.mMinor}.${this.mPatch}`;
if (prefix) {
result = "v" + result;
}
return result;
}
toArray() {
return [this.mMajor, this.mMinor, this.mPatch];
}
valueOf() {
return 100000000 * this.mMajor + 10000 * this.mMinor + this.mPatch;
}
static fromString(string) {
if (typeof string === 'string' || string instanceof String) {
let pattern = /^v?\d+\.\d+\.\d+$/;
if (pattern.test(string)) {
let regex = /\d+/g;
let numbers = string.match(regex);
let array = numbers.slice(0, 3).map(Number);
return new Version(array[0], array[1], array[2]);
}
}
return null;
}
static fromArray(array) {
if (Array.isArray(array) && array.length == 3) {
let isNumber = array.every(element => typeof element == "number");
if (isNumber) {
return new Version(array[0], array[1], array[2])
}
}
return null;
}
}
class GMLIB {
constructor() {
throw new Error("Static class cannot be instantiated");
@@ -782,5 +829,6 @@ module.exports = {
Scoreboard,
JsonConfig,
JsonLanguage,
JsonI18n
JsonI18n,
Version
};
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "${pluginName}",
"entry": "${pluginFile}",
"version": "0.9.5",
"version": "0.10.0",
"author": "GroupMountain",
"type": "native",
"dependencies": [
+2 -2
View File
@@ -158,8 +158,8 @@ void Export_Compatibility_API() {
return false;
});
RemoteCall::exportAs("GMLIB_API", "isVersionMatched", [](int a, int b, int c) -> bool {
auto version = SemVersion(a, b, c, "", "");
return LIB_VERSION.satisfies(version);
auto version = GMLIB::Version(a, b, c, "", "");
return version >= LIB_VERSION;
});
RemoteCall::exportAs("GMLIB_API", "getVersion_LRCA", []() -> std::string { return LIB_VERSION.asString(); });
RemoteCall::exportAs("GMLIB_API", "getVersion_GMLIB", []() -> std::string {
+1 -1
View File
@@ -4,7 +4,7 @@
#include <RemoteCallAPI.h>
#define PLUGIN_NAME "GMLIB-LRCA"
#define LIB_VERSION SemVersion(0, 9, 4, "", "")
#define LIB_VERSION GMLIB::Version(0, 9, 4)
extern ll::Logger logger;
@@ -0,0 +1,53 @@
/**
*
* @name GMLIB_LRCA-Plugin-Template
* @brief plugin template for GMLIB-LegacyRemoteCallApi
*
* @copyright Copyright (c) 2024 GroupMountain
* GMLIB-LegacyRemoteCallApi <https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/>
*
*/
const PluginInfo = {
Name: "GMLIB_LRCA-Plugin-Template",
Author: "your name",
Version: "0.0.1"
}
// 导入 API
const { JsonConfig, JsonI18n } = require('./GMLIB-LegacyRemoteCallApi/lib/GMLIB_API-JS');
// 默认配置文件
const defaultConfig = {
"language": "zh_CN"
};
// 默认语言文件
const zh_CN = {
"consolelog.loaded": "加载成功!",
"consolelog.info": "插件作者: {1}, 当前版本: v{2}"
};
// 初始化配置文件
const config = new JsonConfig(`./plugins/${PluginInfo.Name}/config/config.json`, defaultConfig);
// 初始化 I18n
const I18n = new JsonI18n(`./plugins/${PluginInfo.Name}/language/`, config.get("language"));
I18n.loadLanguage("zh_CN", zh_CN); // 升级语言文件
I18n.setDefaultLanguage("zh_CN"); // 设置I18n无法翻译时采用的默认语言
// I18n快捷翻译函数
function tr(key, data = []) {
return I18n.translate(key, data);
}
// 监听服务器启动
// 在无特殊说明的情况下,一切 MCAPI 都应该在服务器启动后访问。
mc.listen("onServerStarted", () => {
// 你的代码
// 打印插件信息
logger.info(tr("consolelog.loaded"));
logger.info(tr("consolelog.info", [PluginInfo.Author, PluginInfo.Version]));
});
@@ -0,0 +1,3 @@
{
"language": "zh_CN"
}
@@ -0,0 +1,4 @@
{
"consolelog.loaded": "加载成功!",
"consolelog.info": "插件作者: {1}, 当前版本: v{2}"
}
@@ -0,0 +1,16 @@
{
"entry": "GMLIB_LRCA-Plugin-Template.js",
"name": "GMLIB_LRCA-Plugin-Template",
"type": "lse-quickjs",
"version": "0.0.1",
"author": "Your Name",
"description": "plugin description",
"dependencies": [
{
"name": "legacy-script-engine-quickjs"
},
{
"name": "GMLIB-LegacyRemoteCallApi"
}
]
}
+3 -3
View File
@@ -1,7 +1,7 @@
{
"format_version": 2,
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
"version": "0.9.5",
"version": "0.10.0",
"info": {
"name": "GMLIB-LegacyRemoteCallApi",
"description": "Legacy RemoteCall API for GMLIB",
@@ -14,9 +14,9 @@
"library"
]
},
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.9.5/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.10.0/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
"dependencies": {
"github.com/GroupMountain/GMLIB": ">=0.9.8"
"github.com/GroupMountain/GMLIB": ">=0.10.0"
},
"files": {
"place": [