Compare commits
21 Commits
@@ -11,6 +11,8 @@ jobs:
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- uses: xmake-io/github-action-setup-xmake@v1
|
||||
with:
|
||||
xmake-version: 2.9.9
|
||||
|
||||
- run: |
|
||||
xmake repo -u
|
||||
|
||||
@@ -11,6 +11,8 @@ jobs:
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- uses: xmake-io/github-action-setup-xmake@v1
|
||||
with:
|
||||
xmake-version: 2.9.9
|
||||
|
||||
- run: |
|
||||
xmake repo -u
|
||||
|
||||
Vendored
+3
-3
@@ -12,7 +12,7 @@ export class PAPI {
|
||||
pluginsName: string,
|
||||
/** PAPI变量 */
|
||||
PAPIName: string
|
||||
): boolean;
|
||||
): void;
|
||||
|
||||
/** 注册一个服务器PAPI变量 */
|
||||
static registerServerPlaceholder(
|
||||
@@ -25,7 +25,7 @@ export class PAPI {
|
||||
pluginsName: string,
|
||||
/** PAPI变量 */
|
||||
PAPIName: string
|
||||
): boolean;
|
||||
): void;
|
||||
|
||||
/** 注册一个静态PAPI变量 */
|
||||
static registerStaticPlaceholder(
|
||||
@@ -37,7 +37,7 @@ export class PAPI {
|
||||
PAPIName: string,
|
||||
/** 更新时间 */
|
||||
UpdateInterval: number
|
||||
): boolean;
|
||||
): void;
|
||||
|
||||
/** 获取一个服务器变量的值 */
|
||||
static getValue(
|
||||
|
||||
+12
-12
@@ -1,22 +1,22 @@
|
||||
const PlaceholderAPI = {
|
||||
/** 获取一个服务器变量的值 @type {function(string):string} */
|
||||
getValueAPI: ll.import("BEPlaceholderAPI", "GetValue"),
|
||||
getValueAPI: ll.imports("BEPlaceholderAPI", "GetValue"),
|
||||
/** 获取一个玩家变量的值 @type {function(string,Player):string} */
|
||||
getValueByPlayerAPI: ll.import("BEPlaceholderAPI", "GetValueWithPlayer"),
|
||||
getValueByPlayerAPI: ll.imports("BEPlaceholderAPI", "GetValueWithPlayer"),
|
||||
/** 注册一个玩家变量 @type {function(string,string,string):boolean} */
|
||||
registerPlayerPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerPlayerPlaceholder"),
|
||||
registerPlayerPlaceholderAPI: ll.imports("BEPlaceholderAPI", "registerPlayerPlaceholder"),
|
||||
/** 注册一个服务器变量 @type {function(string,string,string):boolean} */
|
||||
registerServerPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerServerPlaceholder"),
|
||||
registerServerPlaceholderAPI: ll.imports("BEPlaceholderAPI", "registerServerPlaceholder"),
|
||||
/** 注册一个静态变量 @type {function(string,string,string,number):boolean} */
|
||||
registerStaticPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerStaticPlaceholder"),
|
||||
registerStaticPlaceholderAPI: ll.imports("BEPlaceholderAPI", "registerStaticPlaceholder"),
|
||||
/** 翻译包含PAPI服务器变量的字符串 @type {function(string):string} */
|
||||
translateStringAPI: ll.import("BEPlaceholderAPI", "translateString"),
|
||||
translateStringAPI: ll.imports("BEPlaceholderAPI", "translateString"),
|
||||
/** 翻译包含PAPI玩家变量的字符串 @type {function(string,Player):string} */
|
||||
translateStringWithPlayerAPI: ll.import("BEPlaceholderAPI", "translateStringWithPlayer"),
|
||||
translateStringWithPlayerAPI: ll.imports("BEPlaceholderAPI", "translateStringWithPlayer"),
|
||||
/** 注销PAPI变量 @type {function(string):boolean} */
|
||||
unRegisterPlaceholderAPI: ll.import("BEPlaceholderAPI", "unRegisterPlaceholder"),
|
||||
unRegisterPlaceholderAPI: ll.imports("BEPlaceholderAPI", "unRegisterPlaceholder"),
|
||||
/** 获取所有已注册的PAPI变量 @type {function():Array.<string>} */
|
||||
getAllPAPI: ll.import("BEPlaceholderAPI", "getAllPAPI")
|
||||
getAllPAPI: ll.imports("BEPlaceholderAPI", "getAllPAPI")
|
||||
}
|
||||
|
||||
Function.prototype.getName =
|
||||
@@ -59,7 +59,7 @@ class PAPI {
|
||||
*/
|
||||
static registerPlayerPlaceholder(func, PluginName, PAPIName) {
|
||||
ll.export(func, PluginName, func.getName());
|
||||
return PlaceholderAPI.registerPlayerPlaceholderAPI(PluginName, func.getName(), PAPIName);
|
||||
PlaceholderAPI.registerPlayerPlaceholderAPI(PluginName, func.getName(), PAPIName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +71,7 @@ class PAPI {
|
||||
*/
|
||||
static registerServerPlaceholder(func, PluginName, PAPIName) {
|
||||
ll.export(func, PluginName, func.getName());
|
||||
return PlaceholderAPI.registerServerPlaceholderAPI(PluginName, func.getName(), PAPIName);
|
||||
PlaceholderAPI.registerServerPlaceholderAPI(PluginName, func.getName(), PAPIName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,7 +84,7 @@ class PAPI {
|
||||
*/
|
||||
static registerStaticPlaceholder(func, PluginName, PAPIName, UpdateInterval = 50) {
|
||||
ll.export(func, PluginName, func.getName());
|
||||
return PlaceholderAPI.registerStaticPlaceholderAPI(PluginName, func.getName(), PAPIName, UpdateInterval);
|
||||
PlaceholderAPI.registerStaticPlaceholderAPI(PluginName, func.getName(), PAPIName, UpdateInterval);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+44
-5
@@ -2,11 +2,50 @@
|
||||
* @returns {string}
|
||||
*/
|
||||
const getPluginName = () => {
|
||||
// quickjs
|
||||
try {
|
||||
throw new Error("getPluginName");
|
||||
} catch (error) {
|
||||
return error.stack.trim().match(/plugins\\(.*)\\.*\.js:[0-9]+\)$/i)?.[1] || "Unknown";
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes("<anonymous>")) {
|
||||
return line.slice(
|
||||
line.indexOf("(") + 1,
|
||||
line.indexOf("\\")
|
||||
);
|
||||
}
|
||||
if (line.includes("<eval>")) {
|
||||
return line.slice(
|
||||
line.indexOf("/", line.indexOf("/") + 1) + 1,
|
||||
line.indexOf("\\")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// nodejs
|
||||
try {
|
||||
const path = require('path');
|
||||
const selfFileName = path.basename(__filename);
|
||||
const pluginDirectory = Object.entries(
|
||||
require('module')._pathCache
|
||||
).find(
|
||||
([key, _]) =>
|
||||
key.includes(selfFileName)
|
||||
)[0].split("\u0000")[1];
|
||||
const directories = pluginDirectory.split("\\");
|
||||
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||
if (pluginName) return pluginName;
|
||||
} catch { }
|
||||
try {
|
||||
throw new Error("getPluginName");
|
||||
} catch (error) {
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes(".js") && /:\d+:\d+$/.test(line)) {
|
||||
const directories = line.split("\\");
|
||||
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||
if (pluginName) return pluginName;
|
||||
}
|
||||
}
|
||||
return "Unknown";
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
@@ -77,7 +116,7 @@ module.exports = {
|
||||
*/
|
||||
emplaceListener: function (eventName, callback, priority = this.EventPriority.Normal, pluginName = getPluginName()) {
|
||||
if (typeof callback !== "function") throw new Error("callback must be a function!");
|
||||
const /** @type {number} */ eventId = ll.imports("GMLIB_Event_API", "emplaceListener")(pluginName, eventName, priority);
|
||||
const /** @type {number} */ eventId = ll.importss("GMLIB_Event_API", "emplaceListener")(pluginName, eventName, priority);
|
||||
if (eventId === -1) throw new Error(`Event ${eventName} creation failed!`);
|
||||
ll.exports((...data) => {
|
||||
let /** @type {boolean} */ result = typeof (data.slice(-1)[0]) === "boolean" ? data.pop() : false;
|
||||
@@ -107,7 +146,7 @@ module.exports = {
|
||||
* @param {boolean}
|
||||
*/
|
||||
removeListener: function (eventId) {
|
||||
const result = ll.imports("GMLIB_Event_API", "removeListener")(eventId);
|
||||
const result = ll.importss("GMLIB_Event_API", "removeListener")(eventId);
|
||||
if (result) {
|
||||
for (let [eventName, eventIds] of Object.entries(this.mEventData)) {
|
||||
this.mEventData[eventName] = eventIds.filter(id => id !== eventId);
|
||||
@@ -123,7 +162,7 @@ module.exports = {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
hasListener: function (eventId) {
|
||||
return ll.imports("GMLIB_Event_API", "hasListener")(eventId);
|
||||
return ll.importss("GMLIB_Event_API", "hasListener")(eventId);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -132,7 +171,7 @@ module.exports = {
|
||||
* @returns {number?}
|
||||
*/
|
||||
getListenerPriority: function (eventId) {
|
||||
const priority = ll.imports("GMLIB_Event_API", "getListenerPriority")(eventId);
|
||||
const priority = ll.importss("GMLIB_Event_API", "getListenerPriority")(eventId);
|
||||
return priority === -1 ? undefined : priority;
|
||||
},
|
||||
|
||||
|
||||
+24
-24
@@ -1,4 +1,4 @@
|
||||
// // const getNextCallbackId = ll.import("GMLIB_FormAPI", "getNextFormCallbackId");
|
||||
// // const getNextCallbackId = ll.imports("GMLIB_FormAPI", "getNextFormCallbackId");
|
||||
|
||||
// class ServerSettingForm {
|
||||
// constructor() {
|
||||
@@ -6,35 +6,35 @@
|
||||
// }
|
||||
|
||||
// static getDefaultPriority() {
|
||||
// return ll.import("GMLIB_ServerSettingForm", "getDefaultPriority")();
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "getDefaultPriority")();
|
||||
// }
|
||||
|
||||
// static hasTitle() {
|
||||
// return ll.import("GMLIB_ServerSettingForm", "hasTitle")();
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "hasTitle")();
|
||||
// }
|
||||
|
||||
// static getTitle() {
|
||||
// return ll.import("GMLIB_ServerSettingForm", "getTitle")();
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "getTitle")();
|
||||
// }
|
||||
|
||||
// static setTitle(title, forceModify = false) {
|
||||
// return ll.import("GMLIB_ServerSettingForm", "setTitle")(title, forceModify);
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "setTitle")(title, forceModify);
|
||||
// }
|
||||
|
||||
// static hasIcon() {
|
||||
// return ll.import("GMLIB_ServerSettingForm", "hasIcon")();
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "hasIcon")();
|
||||
// }
|
||||
|
||||
// static getIconData() {
|
||||
// return hasIcon() ? ll.import("GMLIB_ServerSettingForm", "getIconData")() : null;
|
||||
// return hasIcon() ? ll.imports("GMLIB_ServerSettingForm", "getIconData")() : null;
|
||||
// }
|
||||
|
||||
// static getIconType() {
|
||||
// return ll.import("GMLIB_ServerSettingForm", "getIconType")();
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "getIconType")();
|
||||
// }
|
||||
|
||||
// static setIcon(data, type = 0, forceModify = false) {
|
||||
// return ll.import("GMLIB_ServerSettingForm", "setIcon")(data, type, forceModify);
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "setIcon")(data, type, forceModify);
|
||||
// }
|
||||
|
||||
// static addLabel(
|
||||
@@ -44,7 +44,7 @@
|
||||
// ) {
|
||||
// let detectorId = getNextCallbackId();
|
||||
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
||||
// return ll.import("GMLIB_ServerSettingForm", "addLabel")(text, detectorId, priority);
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "addLabel")(text, detectorId, priority);
|
||||
// }
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||
// let detectorId = getNextCallbackId();
|
||||
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
||||
// return ll.import("GMLIB_ServerSettingForm", "addInput")(text, placeholder, defaultVal, callbackId, detectorId, priority);
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "addInput")(text, placeholder, defaultVal, callbackId, detectorId, priority);
|
||||
// }
|
||||
|
||||
// static addToggle(
|
||||
@@ -74,7 +74,7 @@
|
||||
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||
// let detectorId = getNextCallbackId();
|
||||
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
||||
// return ll.import("GMLIB_ServerSettingForm", "addToggle")(text, defaultVal, callbackId, detectorId, priority);
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "addToggle")(text, defaultVal, callbackId, detectorId, priority);
|
||||
// }
|
||||
|
||||
// static addDropdown(
|
||||
@@ -89,7 +89,7 @@
|
||||
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||
// let detectorId = getNextCallbackId();
|
||||
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
||||
// return ll.import("GMLIB_ServerSettingForm", "addDropdown")(text, options, defaultVal, callbackId, detectorId, priority);
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "addDropdown")(text, options, defaultVal, callbackId, detectorId, priority);
|
||||
// }
|
||||
|
||||
// static addSlider(
|
||||
@@ -106,7 +106,7 @@
|
||||
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||
// let detectorId = getNextCallbackId();
|
||||
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
||||
// return ll.import("GMLIB_ServerSettingForm", "addSlider")(text, min, max, step, defaultVal, callbackId, detectorId, priority);
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "addSlider")(text, min, max, step, defaultVal, callbackId, detectorId, priority);
|
||||
// }
|
||||
|
||||
// static addStepSlider(
|
||||
@@ -121,57 +121,57 @@
|
||||
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||
// let detectorId = getNextCallbackId();
|
||||
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
||||
// return ll.import("GMLIB_ServerSettingForm", "addStepSlider")(text, steps, defaultVal, callbackId, detectorId, priority);
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "addStepSlider")(text, steps, defaultVal, callbackId, detectorId, priority);
|
||||
// }
|
||||
|
||||
// static removeElement(id) {
|
||||
// return ll.import("GMLIB_ServerSettingForm", "removeElement")(id);
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "removeElement")(id);
|
||||
// }
|
||||
// }
|
||||
|
||||
// class NpcDialogueForm {
|
||||
// constructor(npcName, sceneName, dialogue) {
|
||||
// this.mFormId = ll.import("GMLIB_NpcDialogueForm", "createForm")(npcName, sceneName, dialogue);
|
||||
// this.mFormId = ll.imports("GMLIB_NpcDialogueForm", "createForm")(npcName, sceneName, dialogue);
|
||||
// }
|
||||
|
||||
// addButton(button) {
|
||||
// return ll.import("GMLIB_NpcDialogueForm", "addButton")(this.mFormId, button);
|
||||
// return ll.imports("GMLIB_NpcDialogueForm", "addButton")(this.mFormId, button);
|
||||
// }
|
||||
|
||||
// sendTo(pl, callback = (pl, index, type) => { }, free = true) {
|
||||
// let callbackId = getNextCallbackId();
|
||||
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||
// ll.import("GMLIB_NpcDialogueForm", "sendTo")(this.mFormId, pl, callbackId);
|
||||
// ll.imports("GMLIB_NpcDialogueForm", "sendTo")(this.mFormId, pl, callbackId);
|
||||
// if (free) {
|
||||
// this.destroy();
|
||||
// }
|
||||
// }
|
||||
|
||||
// destroy() {
|
||||
// ll.import("GMLIB_NpcDialogueForm", "destroyForm")(this.mFormId);
|
||||
// ll.imports("GMLIB_NpcDialogueForm", "destroyForm")(this.mFormId);
|
||||
// }
|
||||
// }
|
||||
|
||||
// class ChestForm {
|
||||
// constructor(npcName, sceneName, dialogue) {
|
||||
// this.mFormId = ll.import("GMLIB_NpcDialogueForm", "createForm")(npcName, sceneName, dialogue);
|
||||
// this.mFormId = ll.imports("GMLIB_NpcDialogueForm", "createForm")(npcName, sceneName, dialogue);
|
||||
// }
|
||||
|
||||
// addButton(button) {
|
||||
// return ll.import("GMLIB_NpcDialogueForm", "addButton")(this.mFormId, button);
|
||||
// return ll.imports("GMLIB_NpcDialogueForm", "addButton")(this.mFormId, button);
|
||||
// }
|
||||
|
||||
// sendTo(pl, free = true) {
|
||||
// //let callbackId = getNextCallbackId();
|
||||
// //ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||
// //ll.import("GMLIB_NpcDialogueForm", "sendTo")(this.mFormId, pl, callbackId);
|
||||
// //ll.imports("GMLIB_NpcDialogueForm", "sendTo")(this.mFormId, pl, callbackId);
|
||||
// //if (free) {
|
||||
// // this.destroy();
|
||||
// //}
|
||||
// }
|
||||
|
||||
// destroy() {
|
||||
// //ll.import("GMLIB_NpcDialogueForm", "destroyForm")(this.mFormId);
|
||||
// //ll.imports("GMLIB_NpcDialogueForm", "destroyForm")(this.mFormId);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
Vendored
+3
@@ -1556,6 +1556,9 @@ interface Player {
|
||||
slot: number
|
||||
): Item;
|
||||
|
||||
/** (GMLIB & Glacie)获取客户端版本协议*/
|
||||
getNetworkProtocolVersion(): number
|
||||
|
||||
/** (GMLIB)发送更新更新物品数据包 */
|
||||
sendInventorySlotPacket(
|
||||
/** 容器ID */
|
||||
|
||||
+231
-221
@@ -1,437 +1,439 @@
|
||||
/** LRCA导出接口 */
|
||||
const GMLIB_API = {
|
||||
/** 创建悬浮字 @type {function(FloatPos,string,boolean):number} */
|
||||
createFloatingText: ll.import("GMLIB_API", "createFloatingText"),
|
||||
createFloatingText: ll.imports("GMLIB_API", "createFloatingText"),
|
||||
/** 删除悬浮字 @type {function(number):boolean} */
|
||||
deleteFloatingText: ll.import("GMLIB_API", "deleteFloatingText"),
|
||||
deleteFloatingText: ll.imports("GMLIB_API", "deleteFloatingText"),
|
||||
/** 设置悬浮字文本 @type {function(number,string):boolean} */
|
||||
setFloatingTextData: ll.import("GMLIB_API", "setFloatingTextData"),
|
||||
setFloatingTextData: ll.imports("GMLIB_API", "setFloatingTextData"),
|
||||
/** 发送悬浮字给玩家 @type {function(number,Player):boolean} */
|
||||
sendFloatingTextToPlayer: ll.import("GMLIB_API", "sendFloatingTextToPlayer"),
|
||||
sendFloatingTextToPlayer: ll.imports("GMLIB_API", "sendFloatingTextToPlayer"),
|
||||
/** 发送悬浮字给所有玩家 @type {function(number):boolean} */
|
||||
sendFloatingText: ll.import("GMLIB_API", "sendFloatingText"),
|
||||
sendFloatingText: ll.imports("GMLIB_API", "sendFloatingText"),
|
||||
/** 删除玩家的悬浮字 @type {function(number,Player):boolean} */
|
||||
removeFloatingTextFromPlayer: ll.import("GMLIB_API", "removeFloatingTextFromPlayer"),
|
||||
removeFloatingTextFromPlayer: ll.imports("GMLIB_API", "removeFloatingTextFromPlayer"),
|
||||
/** 删除所有玩家悬浮字 @type {function(number):boolean} */
|
||||
removeFloatingText: ll.import("GMLIB_API", "removeFloatingText"),
|
||||
removeFloatingText: ll.imports("GMLIB_API", "removeFloatingText"),
|
||||
/** 更新玩家的悬浮字 @type {function(number,Player):boolean} */
|
||||
updateClientFloatingTextData: ll.import("GMLIB_API", "updateClientFloatingTextData"),
|
||||
updateClientFloatingTextData: ll.imports("GMLIB_API", "updateClientFloatingTextData"),
|
||||
/** 更新所有玩家的悬浮字 @type {function(number):boolean} */
|
||||
updateAllClientsFloatingTextData: ll.import("GMLIB_API", "updateAllClientsFloatingTextData"),
|
||||
updateAllClientsFloatingTextData: ll.imports("GMLIB_API", "updateAllClientsFloatingTextData"),
|
||||
/** 获取服务器Mspt @type {function():number} */
|
||||
getServerMspt: ll.import("GMLIB_API", "getServerMspt"),
|
||||
getServerMspt: ll.imports("GMLIB_API", "getServerMspt"),
|
||||
/** 获取服务器当前tps @type {function():number} */
|
||||
getServerCurrentTps: ll.import("GMLIB_API", "getServerCurrentTps"),
|
||||
getServerCurrentTps: ll.imports("GMLIB_API", "getServerCurrentTps"),
|
||||
/** 获取服务器平均tps @type {function():number} */
|
||||
getServerAverageTps: ll.import("GMLIB_API", "getServerAverageTps"),
|
||||
getServerAverageTps: ll.imports("GMLIB_API", "getServerAverageTps"),
|
||||
/** 获取存档内所有玩家的uuid @type {function():Array<string>} */
|
||||
getAllPlayerUuids: ll.import("GMLIB_API", "getAllPlayerUuids"),
|
||||
getAllPlayerUuids: ll.imports("GMLIB_API", "getAllPlayerUuids"),
|
||||
/** 获取玩家NBT @type {function(string):NbtCompound} */
|
||||
getPlayerNbt: ll.import("GMLIB_API", "getPlayerNbt"),
|
||||
getPlayerNbt: ll.imports("GMLIB_API", "getPlayerNbt"),
|
||||
/** 设置玩家NBT @type {function(string,NbtCompound,boolean):boolean} */
|
||||
setPlayerNbt: ll.import("GMLIB_API", "setPlayerNbt"),
|
||||
setPlayerNbt: ll.imports("GMLIB_API", "setPlayerNbt"),
|
||||
/** 覆盖玩家的特定nbtTags @type {function(string,NbtCompound,Array.<string>):boolean} */
|
||||
setPlayerNbtTags: ll.import("GMLIB_API", "setPlayerNbtTags"),
|
||||
setPlayerNbtTags: ll.imports("GMLIB_API", "setPlayerNbtTags"),
|
||||
/** 删除玩家所有的NBT @type {function(string):boolean} */
|
||||
deletePlayerNbt: ll.import("GMLIB_API", "deletePlayerNbt"),
|
||||
deletePlayerNbt: ll.imports("GMLIB_API", "deletePlayerNbt"),
|
||||
/** 使用特定语言翻译资源包文本 @type {function(string,Array.<string>,string):string} */
|
||||
resourcePackTranslate: ll.import("GMLIB_API", "resourcePackTranslate"),
|
||||
resourcePackTranslate: ll.imports("GMLIB_API", "resourcePackTranslate"),
|
||||
/** 使用默认语言翻译资源包文本 @type {function(string,Array.<string>):string} */
|
||||
resourcePackDefaultTranslate: ll.import("GMLIB_API", "resourcePackDefaultTranslate"),
|
||||
resourcePackDefaultTranslate: ll.imports("GMLIB_API", "resourcePackDefaultTranslate"),
|
||||
/** 获取资源包默认语言 @type {function():string} */
|
||||
getResourcePackI18nLanguage: ll.import("GMLIB_API", "getResourcePackI18nLanguage"),
|
||||
getResourcePackI18nLanguage: ll.imports("GMLIB_API", "getResourcePackI18nLanguage"),
|
||||
/** 设置资源包默认语言 @type {function(string):void} */
|
||||
chooseResourcePackI18nLanguage: ll.import("GMLIB_API", "chooseResourcePackI18nLanguage"),
|
||||
chooseResourcePackI18nLanguage: ll.imports("GMLIB_API", "chooseResourcePackI18nLanguage"),
|
||||
/** 启用教育版内容 @type {function():void} */
|
||||
setEducationFeatureEnabled: ll.import("GMLib_ServerAPI", "setEducationFeatureEnabled"),
|
||||
setEducationFeatureEnabled: ll.imports("GMLib_ServerAPI", "setEducationFeatureEnabled"),
|
||||
/** 注册Ability命令 @type {function():void} */
|
||||
registerAbilityCommand: ll.import("GMLib_ServerAPI", "registerAbilityCommand"),
|
||||
registerAbilityCommand: ll.imports("GMLib_ServerAPI", "registerAbilityCommand"),
|
||||
/** 启用Xbox成就 @type {function():void} */
|
||||
setEnableAchievement: ll.import("GMLib_ServerAPI", "setEnableAchievement"),
|
||||
setEnableAchievement: ll.imports("GMLib_ServerAPI", "setEnableAchievement"),
|
||||
/** 信任所有玩家皮肤 @type {function():void} */
|
||||
setForceTrustSkins: ll.import("GMLib_ServerAPI", "setForceTrustSkins"),
|
||||
setForceTrustSkins: ll.imports("GMLib_ServerAPI", "setForceTrustSkins"),
|
||||
/** 资源包双端共存 @type {function():void} */
|
||||
enableCoResourcePack: ll.import("GMLib_ServerAPI", "enableCoResourcePack"),
|
||||
enableCoResourcePack: ll.imports("GMLib_ServerAPI", "enableCoResourcePack"),
|
||||
/** 获取存档名字 @type {function():string} */
|
||||
getLevelName: ll.import("GMLib_ServerAPI", "getLevelName"),
|
||||
getLevelName: ll.imports("GMLib_ServerAPI", "getLevelName"),
|
||||
/** 设置存档名字 @type {function(string):boolean} */
|
||||
setLevelName: ll.import("GMLib_ServerAPI", "setLevelName"),
|
||||
setLevelName: ll.imports("GMLib_ServerAPI", "setLevelName"),
|
||||
/** 设置假种子 @type {function(number):void} */
|
||||
setFakeSeed: ll.import("GMLib_ServerAPI", "setFakeSeed"),
|
||||
setFakeSeed: ll.imports("GMLib_ServerAPI", "setFakeSeed"),
|
||||
/** 强制生成实体 @type {function(FloatPos,string):Entity} */
|
||||
spawnEntity: ll.import("GMLib_ServerAPI", "spawnEntity"),
|
||||
spawnEntity: ll.imports("GMLib_ServerAPI", "spawnEntity"),
|
||||
/** 射弹投射物 @type {function(Entity,string,number,number):boolean} */
|
||||
shootProjectile: ll.import("GMLib_ServerAPI", "shootProjectile"),
|
||||
shootProjectile: ll.imports("GMLib_ServerAPI", "shootProjectile"),
|
||||
/** 投掷实体 @type {function(Entity,Entity,number,number):boolean} */
|
||||
throwEntity: ll.import("GMLib_ServerAPI", "throwEntity"),
|
||||
throwEntity: ll.imports("GMLib_ServerAPI", "throwEntity"),
|
||||
/** 根据玩家对象获取实体对象 @type {function(Player):Entity} */
|
||||
PlayerToEntity: ll.import("GMLib_ServerAPI", "PlayerToEntity"),
|
||||
PlayerToEntity: ll.imports("GMLib_ServerAPI", "PlayerToEntity"),
|
||||
/** 启用错误方块清理 @type {function():void} */
|
||||
setUnknownBlockCleaner: ll.import("GMLib_ModAPI", "setUnknownBlockCleaner"),
|
||||
setUnknownBlockCleaner: ll.imports("GMLib_ModAPI", "setUnknownBlockCleaner"),
|
||||
/** 获取实验性功能ID列表 @type {function():Array<number>} */
|
||||
getAllExperiments: ll.import("GMLIB_API", "getAllExperiments"),
|
||||
getAllExperiments: ll.imports("GMLIB_API", "getAllExperiments"),
|
||||
/** 获取实验性功能文本的键名 @type {function(number):string} */
|
||||
getExperimentTranslateKey: ll.import("GMLIB_API", "getExperimentTranslateKey"),
|
||||
getExperimentTranslateKey: ll.imports("GMLIB_API", "getExperimentTranslateKey"),
|
||||
/** 获取实验性功能启用状态 @type {function(number):boolean} */
|
||||
getExperimentEnabled: ll.import("GMLib_ModAPI", "getExperimentEnabled"),
|
||||
getExperimentEnabled: ll.imports("GMLib_ModAPI", "getExperimentEnabled"),
|
||||
/** 设置实验性功能启用状态 @type {function(number,boolean):void} */
|
||||
setExperimentEnabled: ll.import("GMLib_ModAPI", "setExperimentEnabled"),
|
||||
setExperimentEnabled: ll.imports("GMLib_ModAPI", "setExperimentEnabled"),
|
||||
/** 注销合成表 @type {function(string):boolean} */
|
||||
unregisterRecipe: ll.import("GMLIB_API", "unregisterRecipe"),
|
||||
unregisterRecipe: ll.imports("GMLIB_API", "unregisterRecipe"),
|
||||
/** 设置实验性依赖 @type {function(number):void} */
|
||||
registerExperimentsRequire: ll.import("GMLib_ModAPI", "registerExperimentsRequire"),
|
||||
registerExperimentsRequire: ll.imports("GMLib_ModAPI", "registerExperimentsRequire"),
|
||||
/** 注册切石机合成表 @type {function(string,string,number,string,number,number):boolean} */
|
||||
registerStoneCutterRecipe: ll.import("GMLib_ModAPI", "registerStoneCutterRecipe"),
|
||||
registerStoneCutterRecipe: ll.imports("GMLib_ModAPI", "registerStoneCutterRecipe"),
|
||||
/** 注册锻造纹饰合成表 @type {function(string,string,string,string):boolean} */
|
||||
registerSmithingTrimRecipe: ll.import("GMLib_ModAPI", "registerSmithingTrimRecipe"),
|
||||
registerSmithingTrimRecipe: ll.imports("GMLib_ModAPI", "registerSmithingTrimRecipe"),
|
||||
/** 注册锻造配方合成表 @type {function(string,string,string,string):boolean} */
|
||||
registerSmithingTransformRecipe: ll.import("GMLib_ModAPI", "registerSmithingTransformRecipe"),
|
||||
registerSmithingTransformRecipe: ll.imports("GMLib_ModAPI", "registerSmithingTransformRecipe"),
|
||||
/** 注册酿造容器表 @type {function(string,string,string,string):boolean} */
|
||||
registerBrewingContainerRecipe: ll.import("GMLib_ModAPI", "registerBrewingContainerRecipe"),
|
||||
registerBrewingContainerRecipe: ll.imports("GMLib_ModAPI", "registerBrewingContainerRecipe"),
|
||||
/** 注册酿造混合表 @type {function(string,string,string,string):boolean} */
|
||||
registerBrewingMixRecipe: ll.import("GMLib_ModAPI", "registerBrewingMixRecipe"),
|
||||
registerBrewingMixRecipe: ll.imports("GMLib_ModAPI", "registerBrewingMixRecipe"),
|
||||
/** 注册熔炼合成表 @type {function(string,string,string,Array.<string>):boolean} */
|
||||
registerFurnaceRecipe: ll.import("GMLib_ModAPI", "registerFurnaceRecipe"),
|
||||
registerFurnaceRecipe: ll.imports("GMLib_ModAPI", "registerFurnaceRecipe"),
|
||||
/** 注册有序合成表 @type {function(string,Array.<string>,Array.<string>,string,number,string)} */
|
||||
registerShapedRecipe: ll.import("GMLib_ModAPI", "registerShapedRecipe"),
|
||||
registerShapedRecipe: ll.imports("GMLib_ModAPI", "registerShapedRecipe"),
|
||||
/** 注册无序合成表 @type {function(string,Array.<string>,Array.<string>,string,number,string)} */
|
||||
registerShapelessRecipe: ll.import("GMLib_ModAPI", "registerShapelessRecipe"),
|
||||
registerShapelessRecipe: ll.imports("GMLib_ModAPI", "registerShapelessRecipe"),
|
||||
/** 注册有序合成表 @type {function(string,Array.<string>,Array.<string>,string,number,string)} */
|
||||
registerCustomShapedRecipe: ll.import("GMLIB_API", "registerCustomShapedRecipe"),
|
||||
registerCustomShapedRecipe: ll.imports("GMLIB_API", "registerCustomShapedRecipe"),
|
||||
/** 注册无序合成表 @type {function(string,Array.<string>,Array.<string>,string,number,string)} */
|
||||
registerCustomShapelessRecipe: ll.import("GMLIB_API", "registerCustomShapelessRecipe"),
|
||||
registerCustomShapelessRecipe: ll.imports("GMLIB_API", "registerCustomShapelessRecipe"),
|
||||
/** 检测LRCA版本是否大于或等于此版本 @type {function(number,number,number):boolean} */
|
||||
isVersionMatched: ll.import("GMLIB_API", "isVersionMatched"),
|
||||
isVersionMatched: ll.imports("GMLIB_API", "isVersionMatched"),
|
||||
/** 获取LRCA版本 @type {function():string} */
|
||||
getVersion_LRCA: ll.import("GMLIB_API", "getVersion_LRCA"),
|
||||
getVersion_LRCA: ll.imports("GMLIB_API", "getVersion_LRCA"),
|
||||
/** 获取GMLIB版本 @type {function():string} */
|
||||
getVersion_GMLIB: ll.import("GMLIB_API", "getVersion_GMLIB"),
|
||||
getVersion_GMLIB: ll.imports("GMLIB_API", "getVersion_GMLIB"),
|
||||
/** 获取玩家坐标 @type {function(string):IntPos} */
|
||||
getPlayerPosition: ll.import("GMLIB_API", "getPlayerPosition"),
|
||||
getPlayerPosition: ll.imports("GMLIB_API", "getPlayerPosition"),
|
||||
/** 设置玩家坐标 @type {function(string,IntPos):boolean} */
|
||||
setPlayerPosition: ll.import("GMLIB_API", "setPlayerPosition"),
|
||||
setPlayerPosition: ll.imports("GMLIB_API", "setPlayerPosition"),
|
||||
/** 玩家是否存在于计分板 @type {function(string,string):boolean} */
|
||||
playerHasScore: ll.import("GMLIB_API", "playerHasScore"),
|
||||
playerHasScore: ll.imports("GMLIB_API", "playerHasScore"),
|
||||
/** 获取玩家在计分板中的值 @type {function(string,string):number} */
|
||||
getPlayerScore: ll.import("GMLIB_API", "getPlayerScore"),
|
||||
getPlayerScore: ll.imports("GMLIB_API", "getPlayerScore"),
|
||||
/** 增加玩家在计分板中的值 @type {function(string,string,number):boolean} */
|
||||
addPlayerScore: ll.import("GMLIB_API", "addPlayerScore"),
|
||||
addPlayerScore: ll.imports("GMLIB_API", "addPlayerScore"),
|
||||
/** 减少玩家在计分板中的值 @type {function(string,string,number):boolean} */
|
||||
reducePlayerScore: ll.import("GMLIB_API", "reducePlayerScore"),
|
||||
reducePlayerScore: ll.imports("GMLIB_API", "reducePlayerScore"),
|
||||
/** 设置玩家在计分板中的值 @type {function(string,string,number):boolean} */
|
||||
setPlayerScore: ll.import("GMLIB_API", "setPlayerScore"),
|
||||
setPlayerScore: ll.imports("GMLIB_API", "setPlayerScore"),
|
||||
/** 重置玩家在计分板中的数据 @type {function(string,string):boolean} */
|
||||
resetPlayerScore: ll.import("GMLIB_API", "resetPlayerScore"),
|
||||
resetPlayerScore: ll.imports("GMLIB_API", "resetPlayerScore"),
|
||||
/** 重置玩家所有的计分板数据 @type {function(string):boolean} */
|
||||
resetPlayerScores: ll.import("GMLIB_API", "resetPlayerScores"),
|
||||
resetPlayerScores: ll.imports("GMLIB_API", "resetPlayerScores"),
|
||||
/** 实体是否存在于计分板中 @type {function(string,string):boolean} */
|
||||
entityHasScore: ll.import("GMLIB_API", "entityHasScore"),
|
||||
entityHasScore: ll.imports("GMLIB_API", "entityHasScore"),
|
||||
/** 获取实体在计分板中的值 @type {function(string,string):number} */
|
||||
getEntityScore: ll.import("GMLIB_API", "getEntityScore"),
|
||||
getEntityScore: ll.imports("GMLIB_API", "getEntityScore"),
|
||||
/** 增加实体在计分板中的值 @type {function(string,string,number):boolean} */
|
||||
addEntityScore: ll.import("GMLIB_API", "addEntityScore"),
|
||||
addEntityScore: ll.imports("GMLIB_API", "addEntityScore"),
|
||||
/** 减少实体在计分板中的值 @type {function(string,string,number):boolean} */
|
||||
reduceEntityScore: ll.import("GMLIB_API", "reduceEntityScore"),
|
||||
reduceEntityScore: ll.imports("GMLIB_API", "reduceEntityScore"),
|
||||
/** 设置实体在计分板中的值 @type {function(string,string,number):boolean} */
|
||||
setEntityScore: ll.import("GMLIB_API", "setEntityScore"),
|
||||
setEntityScore: ll.imports("GMLIB_API", "setEntityScore"),
|
||||
/** 重置实体在计分板中的数据 @type {function(string,string):boolean} */
|
||||
resetEntityScore: ll.import("GMLIB_API", "resetEntityScore"),
|
||||
resetEntityScore: ll.imports("GMLIB_API", "resetEntityScore"),
|
||||
/** 重置实体所有的计分板数据 @type {function(string):boolean} */
|
||||
resetEntityScores: ll.import("GMLIB_API", "resetEntityScores"),
|
||||
resetEntityScores: ll.imports("GMLIB_API", "resetEntityScores"),
|
||||
/** 字符串是否存在于计分板 @type {function(string,string):boolean} */
|
||||
fakePlayerHasScore: ll.import("GMLIB_API", "fakePlayerHasScore"),
|
||||
fakePlayerHasScore: ll.imports("GMLIB_API", "fakePlayerHasScore"),
|
||||
/** 获取字符串在计分板中的值 @type {function(string,string):number} */
|
||||
getFakePlayerScore: ll.import("GMLIB_API", "getFakePlayerScore"),
|
||||
getFakePlayerScore: ll.imports("GMLIB_API", "getFakePlayerScore"),
|
||||
/** 增加字符串在计分板中的值 @type {function(string,string,number):boolean} */
|
||||
addFakePlayerScore: ll.import("GMLIB_API", "addFakePlayerScore"),
|
||||
addFakePlayerScore: ll.imports("GMLIB_API", "addFakePlayerScore"),
|
||||
/** 减少字符串在计分板中的值 @type {function(string,string,number):boolean} */
|
||||
reduceFakePlayerScore: ll.import("GMLIB_API", "reduceFakePlayerScore"),
|
||||
reduceFakePlayerScore: ll.imports("GMLIB_API", "reduceFakePlayerScore"),
|
||||
/** 设置字符串在计分板中的值 @type {function(string,string,number):boolean} */
|
||||
setFakePlayerScore: ll.import("GMLIB_API", "setFakePlayerScore"),
|
||||
setFakePlayerScore: ll.imports("GMLIB_API", "setFakePlayerScore"),
|
||||
/** 重置字符串在计分板中的数据 @type {function(string,string):boolean} */
|
||||
resetFakePlayerScore: ll.import("GMLIB_API", "resetFakePlayerScore"),
|
||||
resetFakePlayerScore: ll.imports("GMLIB_API", "resetFakePlayerScore"),
|
||||
/** 重置字符串所有的计分板数据 @type {function(string):boolean} */
|
||||
resetFakePlayerScores: ll.import("GMLIB_API", "resetFakePlayerScores"),
|
||||
resetFakePlayerScores: ll.imports("GMLIB_API", "resetFakePlayerScores"),
|
||||
/** 创建计分板 @type {function(string):boolean} */
|
||||
addObjective: ll.import("GMLIB_API", "addObjective"),
|
||||
addObjective: ll.imports("GMLIB_API", "addObjective"),
|
||||
/** 创建带有显示名称的计分板 @type {function(string,string):boolean} */
|
||||
addObjectiveWithDisplayName: ll.import("GMLIB_API", "addObjectiveWithDisplayName"),
|
||||
addObjectiveWithDisplayName: ll.imports("GMLIB_API", "addObjectiveWithDisplayName"),
|
||||
/** 获取计分板显示名字 @type {function(string):string} */
|
||||
getDisplayName: ll.import("GMLIB_API", "getDisplayName"),
|
||||
getDisplayName: ll.imports("GMLIB_API", "getDisplayName"),
|
||||
/** 设置计分板显示名字 @type {function(string,string):boolean} */
|
||||
setDisplayName: ll.import("GMLIB_API", "setDisplayName"),
|
||||
setDisplayName: ll.imports("GMLIB_API", "setDisplayName"),
|
||||
/** 删除计分板 @type {function(string):boolean} */
|
||||
removeObjective: ll.import("GMLIB_API", "removeObjective"),
|
||||
removeObjective: ll.imports("GMLIB_API", "removeObjective"),
|
||||
/** 设置计分板显示 @type {function(string,"list"|"sidebar"|"belowname",0|1):void} */
|
||||
setDisplayObjective: ll.import("GMLIB_API", "setDisplayObjective"),
|
||||
setDisplayObjective: ll.imports("GMLIB_API", "setDisplayObjective"),
|
||||
/** 清除计分板显示 @type {function("list"|"sidebar"|"belowname"):void} */
|
||||
clearDisplayObjective: ll.import("GMLIB_API", "clearDisplayObjective"),
|
||||
clearDisplayObjective: ll.imports("GMLIB_API", "clearDisplayObjective"),
|
||||
/** 获取所有计分板 @type {function():Array.<string>} */
|
||||
getAllObjectives: ll.import("GMLIB_API", "getAllObjectives"),
|
||||
getAllObjectives: ll.imports("GMLIB_API", "getAllObjectives"),
|
||||
/** 获取所有跟踪目标 @type {function():Array.<{"Type":"Player","Uuid":string}|{"Type":"FakePlayer","Name":string}|{"Type":"Entity","UniqueId":string}>} */
|
||||
getAllTrackedTargets: ll.import("GMLIB_API", "getAllTrackedTargets"),
|
||||
getAllTrackedTargets: ll.imports("GMLIB_API", "getAllTrackedTargets"),
|
||||
/** 获取所有跟踪玩家 @type {function():Array.<string>} */
|
||||
getAllScoreboardPlayers: ll.import("GMLIB_API", "getAllScoreboardPlayers"),
|
||||
getAllScoreboardPlayers: ll.imports("GMLIB_API", "getAllScoreboardPlayers"),
|
||||
/** 获取所有跟踪字符串 @type {function():Array.<string>} */
|
||||
getAllScoreboardFakePlayers: ll.import("GMLIB_API", "getAllScoreboardFakePlayers"),
|
||||
getAllScoreboardFakePlayers: ll.imports("GMLIB_API", "getAllScoreboardFakePlayers"),
|
||||
/** 获取所有跟踪实体 @type {function():Array.<string>} */
|
||||
getAllScoreboardEntities: ll.import("GMLIB_API", "getAllScoreboardEntities"),
|
||||
getAllScoreboardEntities: ll.imports("GMLIB_API", "getAllScoreboardEntities"),
|
||||
/** 根据uuid获取玩家对象 @type {function(string):Player} */
|
||||
getPlayerFromUuid: ll.import("GMLIB_API", "getPlayerFromUuid"),
|
||||
getPlayerFromUuid: ll.imports("GMLIB_API", "getPlayerFromUuid"),
|
||||
/** 根据UniqueId获取玩家对象 @type {function(string):Player} */
|
||||
getPlayerFromUniqueId: ll.import("GMLIB_API", "getPlayerFromUniqueId"),
|
||||
getPlayerFromUniqueId: ll.imports("GMLIB_API", "getPlayerFromUniqueId"),
|
||||
/** 根据UniqueId获取实体对象 @type {function(string):Entity} */
|
||||
getEntityFromUniqueId: ll.import("GMLIB_API", "getEntityFromUniqueId"),
|
||||
getEntityFromUniqueId: ll.imports("GMLIB_API", "getEntityFromUniqueId"),
|
||||
/** 获取世界出生点 @type {function():IntPos} */
|
||||
getWorldSpawn: ll.import("GMLIB_API", "getWorldSpawn"),
|
||||
getWorldSpawn: ll.imports("GMLIB_API", "getWorldSpawn"),
|
||||
/** 设置世界出生点 @type {function(IntPos):void} */
|
||||
setWorldSpawn: ll.import("GMLIB_API", "setWorldSpawn"),
|
||||
setWorldSpawn: ll.imports("GMLIB_API", "setWorldSpawn"),
|
||||
/** 获取玩家重生点 @type {function(Player):IntPos} */
|
||||
getPlayerSpawnPoint: ll.import("GMLIB_API", "getPlayerSpawnPoint"),
|
||||
getPlayerSpawnPoint: ll.imports("GMLIB_API", "getPlayerSpawnPoint"),
|
||||
/** 设置玩家重生点 @type {function(Player,IntPos):void} */
|
||||
setPlayerSpawnPoint: ll.import("GMLIB_API", "setPlayerSpawnPoint"),
|
||||
setPlayerSpawnPoint: ll.imports("GMLIB_API", "setPlayerSpawnPoint"),
|
||||
/** 清除玩家重生点 @type {function(Player):void} */
|
||||
clearPlayerSpawnPoint: ll.import("GMLIB_API", "clearPlayerSpawnPoint"),
|
||||
clearPlayerSpawnPoint: ll.imports("GMLIB_API", "clearPlayerSpawnPoint"),
|
||||
/** 设置资源包路径 @type {function(string):void} */
|
||||
setCustomPackPath: ll.import("GMLIB_API", "setCustomPackPath"),
|
||||
setCustomPackPath: ll.imports("GMLIB_API", "setCustomPackPath"),
|
||||
/** 获取支持的语言标识符 @type {function():Array.<string>} */
|
||||
getSupportedLanguages: ll.import("GMLIB_API", "getSupportedLanguages"),
|
||||
getSupportedLanguages: ll.imports("GMLIB_API", "getSupportedLanguages"),
|
||||
/** 加载语言翻译 @type {function(string,string):void} */
|
||||
loadLanguage: ll.import("GMLIB_API", "loadLanguage"),
|
||||
loadLanguage: ll.imports("GMLIB_API", "loadLanguage"),
|
||||
/** 更新或创建语言文件 @type {function(string,string,string):void} */
|
||||
updateOrCreateLanguageFile: ll.import("GMLIB_API", "updateOrCreateLanguageFile"),
|
||||
updateOrCreateLanguageFile: ll.imports("GMLIB_API", "updateOrCreateLanguageFile"),
|
||||
/** 加载语言文件目录 @type {function(string):void} */
|
||||
loadLanguagePath: ll.import("GMLIB_API", "loadLanguagePath"),
|
||||
loadLanguagePath: ll.imports("GMLIB_API", "loadLanguagePath"),
|
||||
/** 合并json @type {function(string,string):string} */
|
||||
mergePatchJson: ll.import("GMLIB_API", "mergePatchJson"),
|
||||
mergePatchJson: ll.imports("GMLIB_API", "mergePatchJson"),
|
||||
/** 根据uuid获取xuid @type {function(string):string} */
|
||||
getXuidByUuid: ll.import("GMLIB_API", "getXuidByUuid"),
|
||||
getXuidByUuid: ll.imports("GMLIB_API", "getXuidByUuid"),
|
||||
/** 根据uuid获取名字 @type {function(string):string} */
|
||||
getNameByUuid: ll.import("GMLIB_API", "getNameByUuid"),
|
||||
getNameByUuid: ll.imports("GMLIB_API", "getNameByUuid"),
|
||||
/** 根据xuid获取uuid @type {function(string):string} */
|
||||
getUuidByXuid: ll.import("GMLIB_API", "getUuidByXuid"),
|
||||
getUuidByXuid: ll.imports("GMLIB_API", "getUuidByXuid"),
|
||||
/** 根据xuid获取名字 @type {function(string):string} */
|
||||
getNameByXuid: ll.import("GMLIB_API", "getNameByXuid"),
|
||||
getNameByXuid: ll.imports("GMLIB_API", "getNameByXuid"),
|
||||
/** 根据名字获取xuid @type {function(string):string} */
|
||||
getXuidByName: ll.import("GMLIB_API", "getXuidByName"),
|
||||
getXuidByName: ll.imports("GMLIB_API", "getXuidByName"),
|
||||
/** 根据名字获取uuid @type {function(string):string} */
|
||||
getUuidByName: ll.import("GMLIB_API", "getUuidByName"),
|
||||
getUuidByName: ll.imports("GMLIB_API", "getUuidByName"),
|
||||
/** 获取所有已记录的玩家信息 @type {function():Array.<{"Uuid":string,"Xuid":string,"Name":string}>} */
|
||||
getAllPlayerInfo: ll.import("GMLIB_API", "getAllPlayerInfo"),
|
||||
getAllPlayerInfo: ll.imports("GMLIB_API", "getAllPlayerInfo"),
|
||||
/** 获取方块RuntimeId @type {function(string,number):number} */
|
||||
getBlockRuntimeId: ll.import("GMLIB_API", "getBlockRuntimeId"),
|
||||
getBlockRuntimeId: ll.imports("GMLIB_API", "getBlockRuntimeId"),
|
||||
/** 添加虚假列表玩家 @type {function(string,string):boolean} */
|
||||
addFakeList: ll.import("GMLIB_API", "addFakeList"),
|
||||
addFakeList: ll.imports("GMLIB_API", "addFakeList"),
|
||||
/** 删除虚假列表玩家 @type {function(string):boolean} */
|
||||
removeFakeList: ll.import("GMLIB_API", "removeFakeList"),
|
||||
removeFakeList: ll.imports("GMLIB_API", "removeFakeList"),
|
||||
/** 删除所有虚假列表玩家 @type {function():void} */
|
||||
removeAllFakeLists: ll.import("GMLIB_API", "removeAllFakeList"),
|
||||
removeAllFakeLists: ll.imports("GMLIB_API", "removeAllFakeList"),
|
||||
/** 启用I18n修复 @type {function():void} */
|
||||
setFixI18nEnabled: ll.import("GMLib_ModAPI", "setFixI18nEnabled"),
|
||||
setFixI18nEnabled: ll.imports("GMLib_ModAPI", "setFixI18nEnabled"),
|
||||
/** 获取方块翻译键名 @type {function(Block):string} */
|
||||
getBlockTranslateKey: ll.import("GMLIB_API", "getBlockTranslateKey"),
|
||||
getBlockTranslateKey: ll.imports("GMLIB_API", "getBlockTranslateKey"),
|
||||
/** 获取物品翻译键名 @type {function(Item):string} */
|
||||
getItemTranslateKey: ll.import("GMLIB_API", "getItemTranslateKey"),
|
||||
getItemTranslateKey: ll.imports("GMLIB_API", "getItemTranslateKey"),
|
||||
/** 获取实体翻译键名 @type {function(Entity):string} */
|
||||
getEntityTranslateKey: ll.import("GMLIB_API", "getEntityTranslateKey"),
|
||||
getEntityTranslateKey: ll.imports("GMLIB_API", "getEntityTranslateKey"),
|
||||
/** 从文件中读取NBT @type {function(string,boolean):NbtCompound} */
|
||||
readNbtFromFile: ll.import("GMLIB_API", "readNbtFromFile"),
|
||||
readNbtFromFile: ll.imports("GMLIB_API", "readNbtFromFile"),
|
||||
/** 保存NBT至文件 @type {function(string,NbtCompound,boolean):void} */
|
||||
saveNbtToFile: ll.import("GMLIB_API", "saveNbtToFile"),
|
||||
saveNbtToFile: ll.imports("GMLIB_API", "saveNbtToFile"),
|
||||
/** 获取方块硬度 @type {function(Block):number} */
|
||||
getBlockDestroySpeed: ll.import("GMLIB_API", "getBlockDestroySpeed"),
|
||||
getBlockDestroySpeed: ll.imports("GMLIB_API", "getBlockDestroySpeed"),
|
||||
/** 获取物品挖掘方块速度 @type {function(Item,Block):number} */
|
||||
getDestroyBlockSpeed: ll.import("GMLIB_API", "getDestroyBlockSpeed"),
|
||||
getDestroyBlockSpeed: ll.imports("GMLIB_API", "getDestroyBlockSpeed"),
|
||||
/** 使玩家挖掘方块 @type {function(Block,IntPos,Player):void} */
|
||||
playerDestroyBlock: ll.import("GMLIB_API", "playerDestroyBlock"),
|
||||
playerDestroyBlock: ll.imports("GMLIB_API", "playerDestroyBlock"),
|
||||
/** 物品冒险模式下是否可以挖掘方块 @type {function(Item,Block):boolean} */
|
||||
itemCanDestroyBlock: ll.import("GMLIB_API", "itemCanDestroyBlock"),
|
||||
itemCanDestroyBlock: ll.imports("GMLIB_API", "itemCanDestroyBlock"),
|
||||
/** 物品是否能破坏方块 @type {function(Item):boolean} */
|
||||
itemCanDestroyInCreative: ll.import("GMLIB_API", "itemCanDestroyInCreative"),
|
||||
itemCanDestroyInCreative: ll.imports("GMLIB_API", "itemCanDestroyInCreative"),
|
||||
/** 物品是否可以采集方块 @type {function(Item,Block):boolean} */
|
||||
itemCanDestroySpecial: ll.import("GMLIB_API", "itemCanDestroySpecial"),
|
||||
itemCanDestroySpecial: ll.imports("GMLIB_API", "itemCanDestroySpecial"),
|
||||
/** @type {function(Block):boolean} */
|
||||
blockCanDropWithAnyTool: ll.import("GMLIB_API", "blockCanDropWithAnyTool"),
|
||||
blockCanDropWithAnyTool: ll.imports("GMLIB_API", "blockCanDropWithAnyTool"),
|
||||
/** @type {function(Block,Player,IntPos):boolean} */
|
||||
blockPlayerWillDestroy: ll.import("GMLIB_API", "blockPlayerWillDestroy"),
|
||||
blockPlayerWillDestroy: ll.imports("GMLIB_API", "blockPlayerWillDestroy"),
|
||||
/** 使玩家攻击实体 @type {function(Entity,Player):boolean} */
|
||||
playerAttack: ll.import("GMLIB_API", "playerAttack"),
|
||||
/** @type {function(Player,Entity):boolean} */
|
||||
playerPullInEntity: ll.import("GMLIB_API", "playerPullInEntity"),
|
||||
playerAttack: ll.imports("GMLIB_API", "playerAttack"),
|
||||
/** @type {function(Player,Entity):void} */
|
||||
playerPullInEntity: ll.imports("GMLIB_API", "playerPullInEntity"),
|
||||
/** 根据命令空间获取翻译键名 @type {function(string):string} */
|
||||
getBlockTranslateKeyFromName: ll.import("GMLIB_API", "getBlockTranslateKeyFromName"),
|
||||
getBlockTranslateKeyFromName: ll.imports("GMLIB_API", "getBlockTranslateKeyFromName"),
|
||||
/** 获取存档种子 @type {function():string} */
|
||||
getLevelSeed: ll.import("GMLib_ServerAPI", "getLevelSeed"),
|
||||
getLevelSeed: ll.imports("GMLib_ServerAPI", "getLevelSeed"),
|
||||
/** 获取方块亮度 @type {function(string,number):number} */
|
||||
getBlockLightEmission: ll.import("GMLIB_API", "getBlockLightEmission"),
|
||||
getBlockLightEmission: ll.imports("GMLIB_API", "getBlockLightEmission"),
|
||||
/** 获取游戏规则列表 @type {function():Array.<{Name:string,Value:string,Type:"Bool"|"Float"|"Int"}>} */
|
||||
getGameRules: ll.import("GMLIB_API", "getGameRules"),
|
||||
getGameRules: ll.imports("GMLIB_API", "getGameRules"),
|
||||
/** 给物品添加附魔 @type {function(Item,string,number,boolean):boolean} */
|
||||
applyEnchant: ll.import("GMLIB_API", "applyEnchant"),
|
||||
applyEnchant: ll.imports("GMLIB_API", "applyEnchant"),
|
||||
/** 删除物品所有附魔 @type {function(Item):void} */
|
||||
removeEnchants: ll.import("GMLIB_API", "removeEnchants"),
|
||||
removeEnchants: ll.imports("GMLIB_API", "removeEnchants"),
|
||||
/** 判断物品是否拥有附魔 @type {function(Item,string):boolean} */
|
||||
hasEnchant: ll.import("GMLIB_API", "hasEnchant"),
|
||||
hasEnchant: ll.imports("GMLIB_API", "hasEnchant"),
|
||||
/** 获取附魔等级 @type {function(Item,string):number} */
|
||||
getEnchantLevel: ll.import("GMLIB_API", "getEnchantLevel"),
|
||||
getEnchantLevel: ll.imports("GMLIB_API", "getEnchantLevel"),
|
||||
/** 获取附魔名字 @type {function(string,number):number} */
|
||||
getEnchantNameAndLevel: ll.import("GMLIB_API", "getEnchantNameAndLevel"),
|
||||
getEnchantNameAndLevel: ll.imports("GMLIB_API", "getEnchantNameAndLevel"),
|
||||
/** 通过ID获取附魔命名空间ID @type {function(number):string} */
|
||||
getEnchantTypeNameFromId: ll.import("GMLIB_API", "getEnchantTypeNameFromId"),
|
||||
getEnchantTypeNameFromId: ll.imports("GMLIB_API", "getEnchantTypeNameFromId"),
|
||||
/** 获取最大玩家数 @type {function():number} */
|
||||
getMaxPlayers: ll.import("GMLib_ServerAPI", "getMaxPlayers"),
|
||||
getMaxPlayers: ll.imports("GMLib_ServerAPI", "getMaxPlayers"),
|
||||
/** 丢出玩家背包内物品 @type {function(Player,Item,boolean):boolean} */
|
||||
dropPlayerItem: ll.import("GMLIB_API", "dropPlayerItem"),
|
||||
dropPlayerItem: ll.imports("GMLIB_API", "dropPlayerItem"),
|
||||
/** 获取玩家的RuntimeId @type {function(Player):number} */
|
||||
getPlayerRuntimeId: ll.import("GMLIB_API", "getPlayerRuntimeId"),
|
||||
getPlayerRuntimeId: ll.imports("GMLIB_API", "getPlayerRuntimeId"),
|
||||
/** 获取实体的RuntimeId @type {function(Entity):number} */
|
||||
getEntityRuntimeId: ll.import("GMLIB_API", "getEntityRuntimeId"),
|
||||
getEntityRuntimeId: ll.imports("GMLIB_API", "getEntityRuntimeId"),
|
||||
/** 获取实体命名 @type {function(Entity):string} */
|
||||
getEntityNameTag: ll.import("GMLIB_API", "getEntityNameTag"),
|
||||
getEntityNameTag: ll.imports("GMLIB_API", "getEntityNameTag"),
|
||||
/** 物品是否有不可破坏标签 @type {function(Item):boolean} */
|
||||
ItemisUnbreakable: ll.import("GMLIB_API", "ItemisUnbreakable"),
|
||||
ItemisUnbreakable: ll.imports("GMLIB_API", "ItemisUnbreakable"),
|
||||
/** 设置物品不可破坏标签 @type {function(Item,boolean):void} */
|
||||
setItemUnbreakable: ll.import("GMLIB_API", "setItemUnbreakable"),
|
||||
setItemUnbreakable: ll.imports("GMLIB_API", "setItemUnbreakable"),
|
||||
/** 物品是否死亡不会掉落 @type {function(Item):boolean} */
|
||||
getItemShouldKeepOnDeath: ll.import("GMLIB_API", "getItemShouldKeepOnDeath"),
|
||||
getItemShouldKeepOnDeath: ll.imports("GMLIB_API", "getItemShouldKeepOnDeath"),
|
||||
/** 设置物品死亡不掉落 @type {function(Item,boolean):void} */
|
||||
setItemShouldKeepOnDeath: ll.import("GMLIB_API", "setItemShouldKeepOnDeath"),
|
||||
setItemShouldKeepOnDeath: ll.imports("GMLIB_API", "setItemShouldKeepOnDeath"),
|
||||
/** 获取物品锁定模式 @type {function(Item):number} */
|
||||
getItemLockMode: ll.import("GMLIB_API", "getItemLockMode"),
|
||||
getItemLockMode: ll.imports("GMLIB_API", "getItemLockMode"),
|
||||
/** 设置物品锁定模式 @type {function(Item,number):void} */
|
||||
setItemLockMode: ll.import("GMLIB_API", "setItemLockMode"),
|
||||
setItemLockMode: ll.imports("GMLIB_API", "setItemLockMode"),
|
||||
/** 获取物品惩罚等级 @type {function(Item):number} */
|
||||
getItemRepairCost: ll.import("GMLIB_API", "getItemRepairCost"),
|
||||
getItemRepairCost: ll.imports("GMLIB_API", "getItemRepairCost"),
|
||||
/** 设置物品惩罚等级 @type {function(Item,number):void} */
|
||||
setItemRepairCost: ll.import("GMLIB_API", "setItemRepairCost"),
|
||||
setItemRepairCost: ll.imports("GMLIB_API", "setItemRepairCost"),
|
||||
/** 获取物品冒险模式下可破坏的方块 @type {function(Item):Array.<string>} */
|
||||
getItemCanDestroy: ll.import("GMLIB_API", "getItemCanDestroy"),
|
||||
getItemCanDestroy: ll.imports("GMLIB_API", "getItemCanDestroy"),
|
||||
/** 设置物品冒险模式下可破坏的方块 @type {function(Item,Array.<string>):void} */
|
||||
setItemCanDestroy: ll.import("GMLIB_API", "setItemCanDestroy"),
|
||||
setItemCanDestroy: ll.imports("GMLIB_API", "setItemCanDestroy"),
|
||||
/** 获取物品冒险模式下能放置在什么方块上 @type {function(Item):Array.<string>} */
|
||||
getItemCanPlaceOn: ll.import("GMLIB_API", "getItemCanPlaceOn"),
|
||||
getItemCanPlaceOn: ll.imports("GMLIB_API", "getItemCanPlaceOn"),
|
||||
/** 设置物品冒险模式下能放置在什么方块上 @type {function(Item,Array.<string>):void} */
|
||||
setItemCanPlaceOn: ll.import("GMLIB_API", "setItemCanPlaceOn"),
|
||||
setItemCanPlaceOn: ll.imports("GMLIB_API", "setItemCanPlaceOn"),
|
||||
/** 获取玩家饥饿值 @type {function(Player):number} */
|
||||
getPlayerHungry: ll.import("GMLIB_API", "getPlayerHungry"),
|
||||
getPlayerHungry: ll.imports("GMLIB_API", "getPlayerHungry"),
|
||||
/** 获取玩家盔甲覆盖百分比 @type {function(Player):number} */
|
||||
getPlayerArmorCoverPercentage: ll.import("GMLIB_API", "getPlayerArmorCoverPercentage"),
|
||||
getPlayerArmorCoverPercentage: ll.imports("GMLIB_API", "getPlayerArmorCoverPercentage"),
|
||||
/** 获取玩家盔甲值 @type {function(Player):number} */
|
||||
getPlayerArmorValue: ll.import("GMLIB_API", "getPlayerArmorValue"),
|
||||
getPlayerArmorValue: ll.imports("GMLIB_API", "getPlayerArmorValue"),
|
||||
/** 获取实体主人的UniqueID @type {function(Entity):Entity} */
|
||||
getEntityOwnerUniqueId: ll.import("GMLIB_API", "getEntityOwnerUniqueId"),
|
||||
getEntityOwnerUniqueId: ll.imports("GMLIB_API", "getEntityOwnerUniqueId"),
|
||||
/** 获取物品分类名称 @type {function(Item):string} */
|
||||
getItemCategoryName: ll.import("GMLIB_API", "getItemCategoryName"),
|
||||
getItemCategoryName: ll.imports("GMLIB_API", "getItemCategoryName"),
|
||||
/** 获取物品的命名 @type {function(Item):string} */
|
||||
getItemCustomName: ll.import("GMLIB_API", "getItemCustomName"),
|
||||
getItemCustomName: ll.imports("GMLIB_API", "getItemCustomName"),
|
||||
/** 获取物品BUFF效果名称 @type {function(Item):string} */
|
||||
getItemEffecName: ll.import("GMLIB_API", "getItemEffecName"),
|
||||
getItemEffecName: ll.imports("GMLIB_API", "getItemEffecName"),
|
||||
/** 物品是否为食物 @type {function(Item):boolean} */
|
||||
itemIsFood: ll.import("GMLIB_API", "itemIsFood"),
|
||||
itemIsFood: ll.imports("GMLIB_API", "itemIsFood"),
|
||||
/** 设置玩家UI栏物品 @type {function(Player,number,Item):void} */
|
||||
setPlayerUIItem: ll.import("GMLIB_API", "setPlayerUIItem"),
|
||||
setPlayerUIItem: ll.imports("GMLIB_API", "setPlayerUIItem"),
|
||||
/** 获取玩家UI栏物品 @type {function(Player,number):Item} */
|
||||
getPlayerUIItem: ll.import("GMLIB_API", "getPlayerUIItem"),
|
||||
getPlayerUIItem: ll.imports("GMLIB_API", "getPlayerUIItem"),
|
||||
/** 更新玩家容器物品 @type {function(Player,number,number,Item):void} */
|
||||
sendInventorySlotPacket: ll.import("GMLIB_API", "sendInventorySlotPacket"),
|
||||
sendInventorySlotPacket: ll.imports("GMLIB_API", "sendInventorySlotPacket"),
|
||||
/** 获取容器类型 @type {function(Container):string} */
|
||||
getContainerType: ll.import("GMLIB_API", "getContainerType"),
|
||||
getContainerType: ll.imports("GMLIB_API", "getContainerType"),
|
||||
/** 玩家是否拥有NBT @type {function(string):boolean} */
|
||||
hasPlayerNbt: ll.import("GMLIB_API", "hasPlayerNbt"),
|
||||
hasPlayerNbt: ll.imports("GMLIB_API", "hasPlayerNbt"),
|
||||
/** 获取物品最大堆叠数量 @type {function(Item):number} */
|
||||
getItemMaxCount: ll.import("GMLIB_API", "getItemMaxCount"),
|
||||
getItemMaxCount: ll.imports("GMLIB_API", "getItemMaxCount"),
|
||||
/** 实体包含在某族里 @type {function(Entity,string):boolean} */
|
||||
entityHasFamily: ll.import("GMLIB_API", "entityHasFamily"),
|
||||
entityHasFamily: ll.imports("GMLIB_API", "entityHasFamily"),
|
||||
/** 获取玩家破坏方块所需时间 @type {function(Player,Block):number} */
|
||||
getPlayerDestroyBlockProgress: ll.import("GMLIB_API", "getPlayerDestroyBlockProgress"),
|
||||
getPlayerDestroyBlockProgress: ll.imports("GMLIB_API", "getPlayerDestroyBlockProgress"),
|
||||
/** 获取实体的buff是否显示 @type {function(Player,number):boolean} */
|
||||
getEntityEffectVisible: ll.import("GMLIB_API", "getEntityEffectVisible"),
|
||||
getEntityEffectVisible: ll.imports("GMLIB_API", "getEntityEffectVisible"),
|
||||
/** 获取实体的buff持续时间 @type {function(Player,number):number} */
|
||||
getEntityEffectDuration: ll.import("GMLIB_API", "getEntityEffectDuration"),
|
||||
getEntityEffectDuration: ll.imports("GMLIB_API", "getEntityEffectDuration"),
|
||||
/** 获取实体的buff简单模式下的持续时间 @type {function(Player,number):number} */
|
||||
getEntityEffectDurationEasy: ll.import("GMLIB_API", "getEntityEffectDuration"),
|
||||
getEntityEffectDurationEasy: ll.imports("GMLIB_API", "getEntityEffectDuration"),
|
||||
/** 获取实体的buff困难模式下的持续时间 @type {function(Player,number):number} */
|
||||
getEntityEffectDurationHard: ll.import("GMLIB_API", "getEntityEffectDurationHard"),
|
||||
getEntityEffectDurationHard: ll.imports("GMLIB_API", "getEntityEffectDurationHard"),
|
||||
/** 获取实体的buff普通模式下的持续时间 @type {function(Player,number):number} */
|
||||
getEntityEffectDurationNormal: ll.import("GMLIB_API", "getEntityEffectDurationNormal"),
|
||||
getEntityEffectDurationNormal: ll.imports("GMLIB_API", "getEntityEffectDurationNormal"),
|
||||
/** 获取实体的buff效果等级 @type {function(Entity,number):number} */
|
||||
getEntityEffectAmplifier: ll.import("GMLIB_API", "getEntityEffectAmplifier"),
|
||||
getEntityEffectAmplifier: ll.imports("GMLIB_API", "getEntityEffectAmplifier"),
|
||||
/** 获取实体的buff是否为信标给予 @type {function(Entity,number):boolean} */
|
||||
getEntityEffectAmbient: ll.import("GMLIB_API", "getEntityEffectAmbient"),
|
||||
getEntityEffectAmbient: ll.imports("GMLIB_API", "getEntityEffectAmbient"),
|
||||
/** 实体是否拥有buff效果 @type {function(Entity,number):boolean} */
|
||||
entityHasEffect: ll.import("GMLIB_API", "entityHasEffect"),
|
||||
entityHasEffect: ll.imports("GMLIB_API", "entityHasEffect"),
|
||||
/** 获取实体所有buff效果 @type {function(Entity):Array.<number>} */
|
||||
getEntityAllEffects: ll.import("GMLIB_API", "getEntityAllEffects"),
|
||||
getEntityAllEffects: ll.imports("GMLIB_API", "getEntityAllEffects"),
|
||||
/** 获取游戏难度 @type {function():number} */
|
||||
getGameDifficulty: ll.import("GMLIB_API", "getGameDifficulty"),
|
||||
getGameDifficulty: ll.imports("GMLIB_API", "getGameDifficulty"),
|
||||
/** 设置游戏难度 @type {function(difficulty):void} */
|
||||
setGameDifficulty: ll.import("GMLIB_API", "setGameDifficulty"),
|
||||
setGameDifficulty: ll.imports("GMLIB_API", "setGameDifficulty"),
|
||||
/** 获取默认游戏模式 @type {function():number} */
|
||||
getDefaultGameMode: ll.import("GMLIB_API", "getDefaultGameMode"),
|
||||
getDefaultGameMode: ll.imports("GMLIB_API", "getDefaultGameMode"),
|
||||
/** 设置默认游戏模式 @type {function(mode):void} */
|
||||
setDefaultGameMode: ll.import("GMLIB_API", "setDefaultGameMode"),
|
||||
setDefaultGameMode: ll.imports("GMLIB_API", "setDefaultGameMode"),
|
||||
/** 实体是否为某类型 @type {function(Entity, number):boolean} */
|
||||
entityIsType: ll.import("GMLIB_API", "entityIsType"),
|
||||
entityIsType: ll.imports("GMLIB_API", "entityIsType"),
|
||||
/** 实体是包含某类型 @type {function(Entity, number):boolean} */
|
||||
entityHasType: ll.import("GMLIB_API", "entityHasType"),
|
||||
entityHasType: ll.imports("GMLIB_API", "entityHasType"),
|
||||
/** 获取实体类型ID @type {function(Entity):number} */
|
||||
getEntityTypeId: ll.import("GMLIB_API", "getEntityTypeId"),
|
||||
getEntityTypeId: ll.imports("GMLIB_API", "getEntityTypeId"),
|
||||
/** 获取实体类型ID @type {function(Entity):number} */
|
||||
getPlayerProtocolVersion: ll.imports("GMLIB_API", "getPlayerProtocolVersion"),
|
||||
};
|
||||
|
||||
/** LRCA的二进制流数据包导出接口 */
|
||||
const GMLIB_BinaryStream_API = {
|
||||
/** 创建二进制流数据包 @type {function():number} */
|
||||
create: ll.import("GMLIB_BinaryStream_API", "create"),
|
||||
create: ll.imports("GMLIB_BinaryStream_API", "create"),
|
||||
/** 拷贝二进制流数据包 @type {function(number):number} */
|
||||
copy: ll.import("GMLIB_BinaryStream_API", "copy"),
|
||||
copy: ll.imports("GMLIB_BinaryStream_API", "copy"),
|
||||
/** 发送二进制流数据包 @type {function(number,player):void} */
|
||||
sendTo: ll.import("GMLIB_BinaryStream_API", "sendTo"),
|
||||
sendTo: ll.imports("GMLIB_BinaryStream_API", "sendTo"),
|
||||
/** 销毁二进制流数据包 @type {function(number):void} */
|
||||
destroy: ll.import("GMLIB_BinaryStream_API", "destroy"),
|
||||
destroy: ll.imports("GMLIB_BinaryStream_API", "destroy"),
|
||||
/** 重置二进制流数据包 @type {function(number):void} */
|
||||
reset: ll.import("GMLIB_BinaryStream_API", "reset"),
|
||||
reset: ll.imports("GMLIB_BinaryStream_API", "reset"),
|
||||
/** 写入二进制流数据包头部 @type {function(number, number):void} */
|
||||
writePacketHeader: ll.import("GMLIB_BinaryStream_API", "writePacketHeader"),
|
||||
writePacketHeader: ll.imports("GMLIB_BinaryStream_API", "writePacketHeader"),
|
||||
/** 写入UUID @type {function(number, string):void} */
|
||||
writeUuid: ll.import("GMLIB_BinaryStream_API", "writeUuid"),
|
||||
writeUuid: ll.imports("GMLIB_BinaryStream_API", "writeUuid"),
|
||||
/** 写入物品 @type {function(number, Item):void} */
|
||||
writeItem: ll.import("GMLIB_BinaryStream_API", "writeItem"),
|
||||
writeItem: ll.imports("GMLIB_BinaryStream_API", "writeItem"),
|
||||
/** 写入NBT @type {function(NbtCompound, Item):void} */
|
||||
writeCompoundTag: ll.import("GMLIB_BinaryStream_API", "writeCompoundTag"),
|
||||
writeCompoundTag: ll.imports("GMLIB_BinaryStream_API", "writeCompoundTag"),
|
||||
/** 写入字符串 @type {function(number, string):void} */
|
||||
writeString: ll.import("GMLIB_BinaryStream_API", "writeString"),
|
||||
writeString: ll.imports("GMLIB_BinaryStream_API", "writeString"),
|
||||
/** 写入布尔值 @type {function(number, boolean):void} */
|
||||
writeBool: ll.import("GMLIB_BinaryStream_API", "writeBool"),
|
||||
writeBool: ll.imports("GMLIB_BinaryStream_API", "writeBool"),
|
||||
/** 写入字节 @type {function(number, number):void} */
|
||||
writeByte: ll.import("GMLIB_BinaryStream_API", "writeByte"),
|
||||
writeByte: ll.imports("GMLIB_BinaryStream_API", "writeByte"),
|
||||
/** 写入双精度浮点数 @type {function(number, number):void} */
|
||||
writeDouble: ll.import("GMLIB_BinaryStream_API", "writeDouble"),
|
||||
writeDouble: ll.imports("GMLIB_BinaryStream_API", "writeDouble"),
|
||||
/** 写入浮点数 @type {function(number, number):void} */
|
||||
writeFloat: ll.import("GMLIB_BinaryStream_API", "writeFloat"),
|
||||
writeFloat: ll.imports("GMLIB_BinaryStream_API", "writeFloat"),
|
||||
/** @type {function(number, number):void} */
|
||||
writeSignedBigEndianInt: ll.import("GMLIB_BinaryStream_API", "writeSignedBigEndianInt"),
|
||||
writeSignedBigEndianInt: ll.imports("GMLIB_BinaryStream_API", "writeSignedBigEndianInt"),
|
||||
/** @type {function(number, number):void} */
|
||||
writeSignedInt: ll.import("GMLIB_BinaryStream_API", "writeSignedInt"),
|
||||
writeSignedInt: ll.imports("GMLIB_BinaryStream_API", "writeSignedInt"),
|
||||
/** @type {function(number, number):void} */
|
||||
writeSignedInt64: ll.import("GMLIB_BinaryStream_API", "writeSignedInt64"),
|
||||
writeSignedInt64: ll.imports("GMLIB_BinaryStream_API", "writeSignedInt64"),
|
||||
/** @type {function(number, number):void} */
|
||||
writeSignedShort: ll.import("GMLIB_BinaryStream_API", "writeSignedShort"),
|
||||
writeSignedShort: ll.imports("GMLIB_BinaryStream_API", "writeSignedShort"),
|
||||
/** @type {function(number, number):void} */
|
||||
writeUnsignedChar: ll.import("GMLIB_BinaryStream_API", "writeUnsignedChar"),
|
||||
writeUnsignedChar: ll.imports("GMLIB_BinaryStream_API", "writeUnsignedChar"),
|
||||
/** @type {function(number, number):void} */
|
||||
writeUnsignedInt: ll.import("GMLIB_BinaryStream_API", "writeUnsignedInt"),
|
||||
writeUnsignedInt: ll.imports("GMLIB_BinaryStream_API", "writeUnsignedInt"),
|
||||
/** @type {function(number, number):void} */
|
||||
writeUnsignedInt64: ll.import("GMLIB_BinaryStream_API", "writeUnsignedInt64"),
|
||||
writeUnsignedInt64: ll.imports("GMLIB_BinaryStream_API", "writeUnsignedInt64"),
|
||||
/** @type {function(number, number):void} */
|
||||
writeUnsignedShort: ll.import("GMLIB_BinaryStream_API", "writeUnsignedShort"),
|
||||
writeUnsignedShort: ll.imports("GMLIB_BinaryStream_API", "writeUnsignedShort"),
|
||||
/** @type {function(number, number):void} */
|
||||
writeUnsignedVarInt: ll.import("GMLIB_BinaryStream_API", "writeUnsignedVarInt"),
|
||||
writeUnsignedVarInt: ll.imports("GMLIB_BinaryStream_API", "writeUnsignedVarInt"),
|
||||
/** @type {function(number, number):void} */
|
||||
writeUnsignedVarInt64: ll.import("GMLIB_BinaryStream_API", "writeUnsignedVarInt64"),
|
||||
writeUnsignedVarInt64: ll.imports("GMLIB_BinaryStream_API", "writeUnsignedVarInt64"),
|
||||
/** @type {function(number, number):void} */
|
||||
writeVarInt: ll.import("GMLIB_BinaryStream_API", "writeVarInt"),
|
||||
writeVarInt: ll.imports("GMLIB_BinaryStream_API", "writeVarInt"),
|
||||
/** @type {function(number, number):void} */
|
||||
writeVarInt64: ll.import("GMLIB_BinaryStream_API", "writeVarInt64"),
|
||||
writeVarInt64: ll.imports("GMLIB_BinaryStream_API", "writeVarInt64"),
|
||||
};
|
||||
|
||||
/** 静态悬浮字类列表 @type {Map<number,StaticFloatingText>} */
|
||||
@@ -2291,14 +2293,14 @@ class GMLIB_BinaryStream {
|
||||
this.writeUnsignedVarInt(data.id);
|
||||
this.writeUnsignedVarInt(data.type);
|
||||
switch (data.type) {
|
||||
case 0: this.writeByte(data.value); break;
|
||||
case 1: this.writeSignedShort(data.value); break;
|
||||
case 2: this.writeSignedInt(data.value); break;
|
||||
case 0: this.writeUnsignedChar(data.value); break;
|
||||
case 1: this.writeUnsignedShort(data.value); break;
|
||||
case 2: this.writeVarInt(data.value); break;
|
||||
case 3: this.writeFloat(data.value); break;
|
||||
case 4: this.writeString(data.value); break;
|
||||
case 5: this.writeCompoundTag(data.value); break;
|
||||
case 6: this.writeBlockPos(data.value); break;
|
||||
case 7: this.writeSignedInt64(data.value); break;
|
||||
case 7: this.writeVarInt64(data.value); break;
|
||||
case 8: this.writeVec3(data.value); break;
|
||||
default: throw new Error("Unknown data type");
|
||||
}
|
||||
@@ -2739,10 +2741,9 @@ LLSE_Player.prototype.pullInEntity =
|
||||
/**
|
||||
*
|
||||
* @param {Entity} entity 实体对象
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function (entity) {
|
||||
return GMLIB_API.playerPullInEntity(this, entity);
|
||||
GMLIB_API.playerPullInEntity(this, entity);
|
||||
};
|
||||
|
||||
LLSE_Item.prototype.applyEnchant =
|
||||
@@ -3035,6 +3036,15 @@ LLSE_Player.prototype.sendInventorySlotPacket =
|
||||
GMLIB_API.sendInventorySlotPacket(this, containerId, slot, item);
|
||||
};
|
||||
|
||||
LLSE_Player.prototype.getNetworkProtocolVersion =
|
||||
/**
|
||||
* 获取客户端版本协议
|
||||
* @returns {number}
|
||||
*/
|
||||
function (containerId, slot, item) {
|
||||
GMLIB_API.getPlayerProtocolVersion(this);
|
||||
};
|
||||
|
||||
LLSE_Container.prototype.getContainerType =
|
||||
/**
|
||||
* 获取容器类型
|
||||
|
||||
Vendored
+42
@@ -0,0 +1,42 @@
|
||||
/** 翻译带PAPI变量文本 */
|
||||
export function translate(
|
||||
/** 要翻译的文本 */
|
||||
value: String,
|
||||
/** 实体对象 */
|
||||
actor?: Entity,
|
||||
/** 目标翻译语言 */
|
||||
language?: String
|
||||
): String;
|
||||
|
||||
/** 注册PAPI变量 */
|
||||
export function registerPlaceholder(
|
||||
/** papi变量 */
|
||||
placeholder: String,
|
||||
/** 回调 */
|
||||
callback: (
|
||||
/** 实体对象 */ actor: Entity,
|
||||
/** 参数 */ params: String[],
|
||||
/** 目标翻译语言 */language: String
|
||||
) => String | undefined
|
||||
): void;
|
||||
|
||||
/** 注销PAPI变量 */
|
||||
export function unregisterPlaceholder(
|
||||
/** papi变量 */
|
||||
placeholder: String
|
||||
): Boolean;
|
||||
|
||||
/** 根据模组名注销PAPI变量 */
|
||||
export function unregisterPlaceholderFromModName(
|
||||
/** 模组名 */
|
||||
modName: String
|
||||
): Boolean;
|
||||
|
||||
/** 获取一个papi变量的值 */
|
||||
export function getValue(
|
||||
/** papi变量名 */
|
||||
placeholder: String,
|
||||
actor?: Entity,
|
||||
params?: Record<String, String>,
|
||||
language?: string
|
||||
): Boolean;
|
||||
@@ -0,0 +1,102 @@
|
||||
/// <reference path='d:/dts/dts/helperlib/src/index.d.ts'/>
|
||||
|
||||
const getPluginName = () => {
|
||||
// quickjs
|
||||
try {
|
||||
throw new Error("getPluginName");
|
||||
} catch (error) {
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes("<anonymous>")) {
|
||||
return line.slice(
|
||||
line.indexOf("(") + 1,
|
||||
line.indexOf("\\")
|
||||
);
|
||||
}
|
||||
if (line.includes("<eval>")) {
|
||||
return line.slice(
|
||||
line.indexOf("/", line.indexOf("/") + 1) + 1,
|
||||
line.indexOf("\\")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// nodejs
|
||||
try {
|
||||
const path = require('path');
|
||||
const selfFileName = path.basename(__filename);
|
||||
const pluginDirectory = Object.entries(
|
||||
require('module')._pathCache
|
||||
).find(
|
||||
([key, _]) =>
|
||||
key.includes(selfFileName)
|
||||
)[0].split("\u0000")[1];
|
||||
const directories = pluginDirectory.split("\\");
|
||||
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||
if (pluginName) return pluginName;
|
||||
} catch { }
|
||||
try {
|
||||
throw new Error("getPluginName");
|
||||
} catch (error) {
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes(".js") && /:\d+:\d+$/.test(line)) {
|
||||
const directories = line.split("\\");
|
||||
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||
if (pluginName) return pluginName;
|
||||
}
|
||||
}
|
||||
return "Unknown";
|
||||
};
|
||||
|
||||
Function.prototype.getName =
|
||||
/**
|
||||
* 获取函数名字
|
||||
* @returns {string}
|
||||
*/
|
||||
function () {
|
||||
return this.name || this.toString().match(/function\s*([^(]*)\(/)?.[1] || getStringHashCode(this.toString()).toString(16);
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取字符串哈希值
|
||||
* @param {string} str 字符串
|
||||
* @returns {number}
|
||||
*/
|
||||
function getStringHashCode(str) {
|
||||
let hash = 0, chr;
|
||||
if (str.length === 0) return hash;
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
chr = str.charCodeAt(i);
|
||||
hash = ((hash << 5) - hash) + chr;
|
||||
hash |= 0;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
translate(value, actor = undefined, language = "") {
|
||||
return actor instanceof LLSE_Entity
|
||||
? ll.importss("PlaceholderAPI", "translateFromActor")(value, actor, language)
|
||||
: ll.importss("PlaceholderAPI", "translate")(value, language);
|
||||
},
|
||||
registerPlaceholder(placeholder, callback) {
|
||||
const pluginName = getPluginName();
|
||||
ll.exports((...args) => {
|
||||
if(!args[0].uniqueId) args[0] = undefined;
|
||||
return callback(...args) ?? "<std::nullopt>";
|
||||
}, pluginName, callback.getName());
|
||||
ll.importss("PlaceholderAPI", "registerPlaceholder")(placeholder, callback.getName(), pluginName);
|
||||
},
|
||||
unregisterPlaceholder(placeholder) {
|
||||
return ll.importss("PlaceholderAPI", "unregisterPlaceholder")(placeholder);
|
||||
},
|
||||
unregisterPlaceholderFromModName(placeholder) {
|
||||
return ll.importss("PlaceholderAPI", "unregisterPlaceholderFromModName")(placeholder);
|
||||
},
|
||||
getValue(placeholder, actor = undefined, params = {}, language = "") {
|
||||
if (actor instanceof LLSE_Player) actor = ll.imports("GMLib_ServerAPI", "PlayerToEntity")(actor);
|
||||
const result = actor instanceof LLSE_Entity
|
||||
? ll.importss("PlaceholderAPI", "getValueFromActor")(placeholder, actor, params, language)
|
||||
: ll.importss("PlaceholderAPI", "getValue")(placeholder, params, language);
|
||||
return result !== "<std::nullopt>" ? result : undefined;
|
||||
}
|
||||
};
|
||||
+4
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "${pluginName}",
|
||||
"entry": "${pluginFile}",
|
||||
"version": "0.13.6",
|
||||
"version": "1.0.1",
|
||||
"author": "GroupMountain",
|
||||
"type": "native",
|
||||
"passive": true,
|
||||
@@ -11,6 +11,9 @@
|
||||
},
|
||||
{
|
||||
"name": "LegacyRemoteCall"
|
||||
},
|
||||
{
|
||||
"name": "iListenAttentively"
|
||||
}
|
||||
]
|
||||
}
|
||||
+15
-10
@@ -1,20 +1,19 @@
|
||||
#include "Global.h"
|
||||
using namespace ll::hash_utils;
|
||||
|
||||
class LegacyScriptBinaryStreamManager {
|
||||
private:
|
||||
int64 mNextBinaryStreamId = 0;
|
||||
std::unordered_map<uint64, std::shared_ptr<GMLIB_BinaryStream>> mBinaryStream;
|
||||
int64 mNextBinaryStreamId = 0;
|
||||
std::unordered_map<uint64, std::shared_ptr<GMBinaryStream>> mBinaryStream;
|
||||
|
||||
public:
|
||||
uint getNextId() { return mNextBinaryStreamId++; }
|
||||
|
||||
void cretateBinaryStream(uint id) { mBinaryStream[id] = std::make_shared<GMLIB_BinaryStream>(); }
|
||||
void cretateBinaryStream(uint id) { mBinaryStream[id] = std::make_shared<GMBinaryStream>(); }
|
||||
|
||||
uint64 copyBinaryStream(uint id) {
|
||||
auto nextId = getNextId();
|
||||
cretateBinaryStream(nextId);
|
||||
if(auto bs = getBinaryStream(nextId); bs !=nullptr){
|
||||
if (auto bs = getBinaryStream(nextId); bs != nullptr) {
|
||||
getBinaryStream(nextId)->mBuffer = getBinaryStream(id)->mBuffer;
|
||||
}
|
||||
return nextId;
|
||||
@@ -22,7 +21,7 @@ public:
|
||||
|
||||
void removeBinaryStream(uint64 id) { mBinaryStream.erase(id); }
|
||||
|
||||
std::shared_ptr<GMLIB_BinaryStream> getBinaryStream(uint64 id) {
|
||||
std::shared_ptr<GMBinaryStream> getBinaryStream(uint64 id) {
|
||||
return mBinaryStream.contains(id) ? mBinaryStream.at(id) : nullptr;
|
||||
}
|
||||
|
||||
@@ -47,7 +46,7 @@ template <typename T, typename R, typename A, typename... AS>
|
||||
struct Info<R (T::*)(A, AS...)> {
|
||||
using ArgT = A;
|
||||
};
|
||||
#define EXPORTAPI2(T) EXPORTAPI(#T, Info<decltype(&GMLIB_BinaryStream::T)>::ArgT, bs->T(value))
|
||||
#define EXPORTAPI2(T) EXPORTAPI(#T, Info<decltype(&BinaryStream::T)>::ArgT, bs->T(value))
|
||||
|
||||
void Export_BinaryStream_API() {
|
||||
RemoteCall::exportAs("GMLIB_BinaryStream_API", "create", []() -> uint64 {
|
||||
@@ -60,17 +59,23 @@ void Export_BinaryStream_API() {
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_BinaryStream_API", "reset", [](uint64 id) -> void {
|
||||
if (BinaryStreamManager.getBinaryStream(id) == nullptr) BinaryStreamManager.cretateBinaryStream(id);
|
||||
else BinaryStreamManager.getBinaryStream(id)->reset();
|
||||
else {
|
||||
auto bs = BinaryStreamManager.getBinaryStream(id);
|
||||
bs->mBuffer.clear();
|
||||
bs->mReadPointer = 0;
|
||||
bs->mHasOverflowed = false;
|
||||
}
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_BinaryStream_API", "sendTo", [](uint64 id, Player* player) -> void {
|
||||
if (auto bs = BinaryStreamManager.getBinaryStream(id); bs != nullptr) bs->sendTo(*player);
|
||||
if (auto bs = BinaryStreamManager.getBinaryStream(id); bs != nullptr)
|
||||
bs->sendTo(static_cast<GMPlayer&>(*player));
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_BinaryStream_API", "destroy", [](uint64 id) -> void {
|
||||
BinaryStreamManager.removeBinaryStream(id);
|
||||
});
|
||||
EXPORTAPI("writePacketHeader", int, bs->writePacketHeader((MinecraftPacketIds)value));
|
||||
EXPORTAPI("writeUuid", std::string const&, bs->writeUuid(mce::UUID::fromString(value)));
|
||||
EXPORTAPI("writeItem", ItemStack*, bs->writeType(NetworkItemStackDescriptor(*value)));
|
||||
EXPORTAPI("writeItem", ItemStack*, bs->writeNetworkItemStackDescriptor(NetworkItemStackDescriptor(*value)));
|
||||
EXPORTAPI("writeString", std::string const&, bs->writeString(value));
|
||||
EXPORTAPI("writeCompoundTag", CompoundTag*, bs->writeCompoundTag(*value));
|
||||
EXPORTAPI2(writeBool);
|
||||
|
||||
+306
-249
File diff suppressed because it is too large
Load Diff
+10
-2
@@ -9,6 +9,7 @@ LegacyRemoteCallApi& LegacyRemoteCallApi::getInstance() {
|
||||
}
|
||||
|
||||
bool LegacyRemoteCallApi::load() {
|
||||
(void)CustomRecipeRegistry::getInstance();
|
||||
Export_Legacy_GMLib_ModAPI();
|
||||
Export_Legacy_GMLib_ServerAPI();
|
||||
Export_Compatibility_API();
|
||||
@@ -20,8 +21,8 @@ bool LegacyRemoteCallApi::load() {
|
||||
logger->info("GMLIB-LegacyRemoteCallApi Loaded!");
|
||||
logger->info(
|
||||
"Loaded Version: {} with {}",
|
||||
fmt::format(fg(fmt::color::pink), "GMLIB-" + GMLIB::Version::getLibVersionString()),
|
||||
fmt::format(fg(fmt::color::light_green), "GMLIB-LegacyRemoteCallApi-" + LIB_VERSION.asString())
|
||||
fmt::format(fg(fmt::color::pink), "GMLIB-" GMLIB_FILE_VERSION_STRING),
|
||||
fmt::format(fg(fmt::color::light_green), "GMLIB-LegacyRemoteCallApi-" + LIB_VERSION.to_string())
|
||||
);
|
||||
logger->info("Author: GroupMountain");
|
||||
logger->info("Repository: https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi");
|
||||
@@ -35,3 +36,10 @@ bool LegacyRemoteCallApi::disable() { return true; }
|
||||
} // namespace gmlib
|
||||
|
||||
LL_REGISTER_MOD(gmlib::LegacyRemoteCallApi, gmlib::LegacyRemoteCallApi::getInstance());
|
||||
|
||||
|
||||
ll::thread::ThreadPoolExecutor const& getThreadPoolExecutor() {
|
||||
return gmlib::LegacyRemoteCallApi::getInstance().getThreadPoolExecutor();
|
||||
}
|
||||
|
||||
ll::io::Logger& getLogger() { return gmlib::LegacyRemoteCallApi::getInstance().getSelf().getLogger(); }
|
||||
+6
-2
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include <ll/api/mod/NativeMod.h>
|
||||
#include <ll/api/mod/RegisterHelper.h>
|
||||
#include <ll/api/thread/ThreadPoolExecutor.h>
|
||||
|
||||
namespace gmlib {
|
||||
|
||||
@@ -9,7 +10,7 @@ class LegacyRemoteCallApi {
|
||||
public:
|
||||
static LegacyRemoteCallApi& getInstance();
|
||||
|
||||
LegacyRemoteCallApi() : mSelf(*ll::mod::NativeMod::current()) {}
|
||||
LegacyRemoteCallApi() : mSelf(*ll::mod::NativeMod::current()), mThreadPoolExecutor(getSelf().getName()) {}
|
||||
|
||||
[[nodiscard]] ll::mod::NativeMod& getSelf() const { return mSelf; }
|
||||
|
||||
@@ -26,8 +27,11 @@ public:
|
||||
// /// @return True if the plugin is unloaded successfully.
|
||||
// bool unload();
|
||||
|
||||
ll::thread::ThreadPoolExecutor& getThreadPoolExecutor() { return mThreadPoolExecutor; }
|
||||
|
||||
private:
|
||||
ll::mod::NativeMod& mSelf;
|
||||
ll::mod::NativeMod& mSelf;
|
||||
ll::thread::ThreadPoolExecutor mThreadPoolExecutor;
|
||||
};
|
||||
|
||||
} // namespace gmlib
|
||||
|
||||
+128
-160
@@ -1,6 +1,4 @@
|
||||
#include "Global.h"
|
||||
#include "ll/api/service/Bedrock.h"
|
||||
#include "ll/api/utils/ErrorUtils.h"
|
||||
using namespace ll::hash_utils;
|
||||
|
||||
class EventManager {
|
||||
@@ -28,7 +26,6 @@ public:
|
||||
|
||||
bool removeListener(ullong id) {
|
||||
if (ll::event::EventBus::getInstance().removeListener(mEventIds[id])) {
|
||||
ll::mod::NativeMod::current()->getLogger().warn("Removed listener with id {}", id);
|
||||
mEventIds[id] = nullptr;
|
||||
return true;
|
||||
}
|
||||
@@ -86,274 +83,245 @@ void Export_Event_API() {
|
||||
}
|
||||
case doHash("gmlib::ClientLoginAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::PacketEvent::ClientLoginAfterEvent,
|
||||
ila::mc::ClientLoginAfterEvent,
|
||||
(std::string const& realName,
|
||||
std::string const& uuid,
|
||||
std::string const& serverXuid,
|
||||
std::string const& clientXuid),
|
||||
(event.getRealName(),
|
||||
event.getUuid().asString(),
|
||||
event.getServerAuthXuid(),
|
||||
event.getClientAuthXuid()),
|
||||
(event.realName(), event.uuid().asString(), event.serverAuthXuid(), event.clientAuthXuid()),
|
||||
if (result) event.disConnectClient();
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::WeatherUpdateBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::LevelEvent::WeatherUpdateBeforeEvent,
|
||||
ila::mc::WeatherUpdateBeforeEvent,
|
||||
(float rainLevel, int rainTime, float lightningLevel, int lightningTime, bool isCancelled),
|
||||
(event.getRainLevel(),
|
||||
event.getRainingLastTick(),
|
||||
event.getLightningLevel(),
|
||||
event.getLightningLastTick(),
|
||||
(event.rainLevel(),
|
||||
event.rainTime(),
|
||||
event.lightningLevel(),
|
||||
event.lightningTime(),
|
||||
event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::WeatherUpdateAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::LevelEvent::WeatherUpdateAfterEvent,
|
||||
ila::mc::WeatherUpdateAfterEvent,
|
||||
(float rainLevel, int rainTime, float lightningLevel, int lightningTime),
|
||||
(event.getRainLevel(),
|
||||
event.getRainingLastTick(),
|
||||
event.getLightningLevel(),
|
||||
event.getLightningLastTick()),
|
||||
(event.rainLevel(), event.rainTime(), event.lightningLevel(), event.lightningTime()),
|
||||
,
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::MobPickupItemBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::MobPickupItemBeforeEvent,
|
||||
(Actor * mob, Actor * item, bool isCancelled),
|
||||
(&event.self(), (Actor*)&event.getItemActor(), event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
REGISTER_EVENT_LISTEN(ila::mc::ActorPickupItemBeforeEvent,
|
||||
(Actor * mob, Actor * item, bool isCancelled),
|
||||
(&event.self(), (Actor*)&event.itemActor(), event.isCancelled()),
|
||||
event.setCancelled(result););
|
||||
}
|
||||
case doHash("gmlib::MobPickupItemAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::MobPickupItemAfterEvent,
|
||||
ila::mc::ActorPickupItemAfterEvent,
|
||||
(Actor * mob, Actor * item),
|
||||
(&event.self(), (Actor*)&event.getItemActor()),
|
||||
(&event.self(), (Actor*)&event.itemActor()),
|
||||
,
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::ItemActorSpawnBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::ItemActorSpawnBeforeEvent,
|
||||
ila::mc::SpawnItemActorBeforeEvent,
|
||||
(ItemStack * item, std::pair<Vec3, int> position, int64 spawnerUniqueId, bool isCancelled),
|
||||
(&event.getItem(),
|
||||
{event.getPosition(), event.getBlockSource().getDimensionId().id},
|
||||
event.getSpawner().has_value() ? event.getSpawner()->getOrCreateUniqueID().rawID : -1,
|
||||
(&event.item(),
|
||||
{event.pos(), event.blockSource().getDimensionId().id},
|
||||
event.spawner() ? event.spawner()->getOrCreateUniqueID().rawID : -1,
|
||||
event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::ItemActorSpawnAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::ItemActorSpawnAfterEvent,
|
||||
ila::mc::SpawnItemActorAfterEvent,
|
||||
(Actor * item, std::pair<Vec3, int> position, int64 spawnerUniqueId),
|
||||
(&event.self(),
|
||||
{event.getPosition(), event.getBlockSource().getDimensionId().id},
|
||||
event.getSpawner().has_value() ? event.getSpawner()->getOrCreateUniqueID().rawID : -1),
|
||||
(&event.itemActor(),
|
||||
{event.pos(), event.blockSource().getDimensionId().id},
|
||||
event.spawner() ? event.spawner()->getOrCreateUniqueID().rawID : -1),
|
||||
,
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::ActorChangeDimensionBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::ActorChangeDimensionBeforeEvent,
|
||||
(Actor * entity, int toDimId, bool isCancelled),
|
||||
(&event.self(), event.getToDimensionId(), event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
REGISTER_EVENT_LISTEN(ila::mc::ActorChangeDimensionBeforeEvent,
|
||||
(Actor * entity, int toDimId, bool isCancelled),
|
||||
(&event.self(), event.toDimensionId(), event.isCancelled()),
|
||||
event.setCancelled(result););
|
||||
}
|
||||
case doHash("gmlib::ActorChangeDimensionAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::ActorChangeDimensionAfterEvent,
|
||||
ila::mc::ActorChangeDimensionAfterEvent,
|
||||
(Actor * entity, int fromDimId, int toDimId),
|
||||
(&event.self(), event.getFromDimensionId(), event.getToDimensionId()),
|
||||
(&event.self(), event.fromDimensionId(), event.toDimensionId()),
|
||||
,
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::PlayerStartSleepBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::PlayerEvent::PlayerStartSleepBeforeEvent,
|
||||
ila::mc::PlayerStartSleepBeforeEvent,
|
||||
(Player * entity, BlockPos pos, bool isCancelled),
|
||||
(&event.self(), event.getPosition(), event.isCancelled()),
|
||||
(&event.self(), event.pos(), event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::PlayerStartSleepAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::PlayerEvent::PlayerStartSleepAfterEvent,
|
||||
ila::mc::PlayerStartSleepAfterEvent,
|
||||
(Player * entity, BlockPos pos, int result),
|
||||
(&event.self(), event.getPosition(), (int)event.getResult()),
|
||||
(&event.self(), event.pos(), (int)event.result()),
|
||||
,
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::PlayerStopSleepBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::PlayerEvent::PlayerStopSleepBeforeEvent,
|
||||
ila::mc::PlayerStopSleepBeforeEvent,
|
||||
(Player * entity, bool forcefulWakeUp, bool updateLevelList, bool isCancelled),
|
||||
(&event.self(), event.isForcefulWakeUp(), event.isUpdateLevelList(), event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
(&event.self(), event.forcefulWakeUp(), event.updateLevelList(), false),
|
||||
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::PlayerStopSleepAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::PlayerEvent::PlayerStopSleepAfterEvent,
|
||||
ila::mc::PlayerStopSleepAfterEvent,
|
||||
(Player * entity, bool forcefulWakeUp, bool updateLevelList, bool),
|
||||
(&event.self(), event.isForcefulWakeUp(), event.isUpdateLevelList(), false),
|
||||
(&event.self(), event.forcefulWakeUp(), event.updateLevelList(), false),
|
||||
,
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::DeathMessageAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::DeathMessageAfterEvent,
|
||||
ila::mc::DeathMessageAfterEvent,
|
||||
(std::string const& message, std::vector<std::string>, Actor* dead),
|
||||
(event.getDeathMessage().first, event.getDeathMessage().second, &event.self()),
|
||||
(event.result().first, event.result().second, &event.self()),
|
||||
,
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::MobHurtAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::MobHurtAfterEvent,
|
||||
ila::mc::MobHealthChangeAfterEvent,
|
||||
(Actor * mob, Actor * source, float damage, int cause),
|
||||
(&event.self(), source, -event.getDamage(), (int)damageSource.getCause()),
|
||||
(&event.self(), source, event.oldValue() - event.newValue(), (int)damageSource->mCause),
|
||||
,
|
||||
auto& damageSource = event.getSource();
|
||||
if (event.newValue() > event.oldValue()) return;
|
||||
auto& damageSource = event.buff().mSource;
|
||||
Actor* source = nullptr;
|
||||
if (damageSource.isEntitySource()) {
|
||||
auto uniqueId = damageSource.getDamagingEntityUniqueID();
|
||||
if (damageSource->isEntitySource()) {
|
||||
auto uniqueId = damageSource->getDamagingEntityUniqueID();
|
||||
source = ll::service::getLevel()->fetchEntity(uniqueId, false);
|
||||
if (source->getOwner()) source = source->getOwner();
|
||||
}
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::EndermanTakeBlockBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::EndermanTakeBlockBeforeEvent,
|
||||
(Actor * mob, bool isCancelled),
|
||||
(&event.self(), event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
REGISTER_EVENT_LISTEN(ila::mc::EndermanTakeBlockBeforeEvent,
|
||||
(Actor * mob, bool isCancelled),
|
||||
(&event.self(), event.isCancelled()),
|
||||
event.setCancelled(result););
|
||||
}
|
||||
case doHash("gmlib::DragonRespawnBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::DragonRespawnBeforeEvent,
|
||||
(bool isCancelled),
|
||||
(event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
REGISTER_EVENT_LISTEN(ila::mc::DragonRespawnBeforeEvent,
|
||||
(bool isCancelled),
|
||||
(event.isCancelled()),
|
||||
event.setCancelled(result););
|
||||
}
|
||||
case doHash("gmlib::DragonRespawnAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::DragonRespawnAfterEvent,
|
||||
(Actor * mob),
|
||||
(event.getEnderDragon()),
|
||||
);
|
||||
REGISTER_EVENT_LISTEN(ila::mc::DragonRespawnAfterEvent, (Actor * mob), (&event.self()), );
|
||||
}
|
||||
case doHash("gmlib::ProjectileCreateBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::ProjectileCreateBeforeEvent,
|
||||
(Actor * mob, int64 uniqueId, bool isCancelled),
|
||||
(&event.self(),
|
||||
event.getShooter() ? event.getShooter()->getOrCreateUniqueID().rawID : -1,
|
||||
event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
REGISTER_EVENT_LISTEN(ila::mc::ProjectileCreateBeforeEvent,
|
||||
(Actor * mob, int64 uniqueId, bool isCancelled),
|
||||
(&event.self(), event.self().getOwnerId().rawID, event.isCancelled()),
|
||||
event.setCancelled(result););
|
||||
}
|
||||
case doHash("gmlib::ProjectileCreateAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::ProjectileCreateAfterEvent,
|
||||
ila::mc::ProjectileCreateAfterEvent,
|
||||
(Actor * mob, int64 uniqueId),
|
||||
(&event.self(), event.getShooter() ? event.getShooter()->getOrCreateUniqueID().rawID : -1),
|
||||
(&event.self(), event.self().getOwnerId().rawID),
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::SpawnWanderingTraderBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::SpawnWanderingTraderBeforeEvent,
|
||||
(std::pair<BlockPos, int> pos, bool isCancelled),
|
||||
({event.getPos(), event.getRegion().getDimensionId()}, event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
REGISTER_EVENT_LISTEN(ila::mc::SpawnWanderingTraderBeforeEvent,
|
||||
(std::pair<BlockPos, int> pos, bool isCancelled),
|
||||
({event.pos(), event.blockSource().getDimensionId()}, event.isCancelled()),
|
||||
event.setCancelled(result););
|
||||
}
|
||||
case doHash("gmlib::SpawnWanderingTraderAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::SpawnWanderingTraderAfterEvent,
|
||||
ila::mc::SpawnWanderingTraderAfterEvent,
|
||||
(std::pair<BlockPos, int> pos),
|
||||
({event.getPos(), event.getRegion().getDimensionId()}),
|
||||
({event.pos(), event.blockSource().getDimensionId()}),
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::HandleRequestActionBeforeEvent"): {
|
||||
// clang-format off
|
||||
case doHash("gmlib::HandleRequestActionBeforeEvent"): {
|
||||
// clang-format off
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerRequestItemActionBeforeEvent,
|
||||
(
|
||||
Player * player,
|
||||
std::string const& actionType,
|
||||
int count,
|
||||
std::string const& sourceContainerNetId,
|
||||
int sourceSlot,
|
||||
std::string const& destinationContainerNetId,
|
||||
int destinationSlot,
|
||||
bool isCancelled
|
||||
),
|
||||
(
|
||||
(Player*)&event.self(),
|
||||
magic_enum::enum_name(event.actionType()).data(),
|
||||
event.amount(),
|
||||
magic_enum::enum_name(event.src().mFullContainerName.mName).data(),
|
||||
(int)event.src().mSlot,
|
||||
magic_enum::enum_name(event.dst().mFullContainerName.mName).data(),
|
||||
(int)event.dst().mSlot,
|
||||
event.isCancelled()
|
||||
),
|
||||
event.setCancelled(result);,
|
||||
);
|
||||
// clang-format on
|
||||
}
|
||||
case doHash("gmlib::HandleRequestActionAfterEvent"): {
|
||||
// clang-format off
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerRequestItemActionAfterEvent,
|
||||
(
|
||||
Player * player,
|
||||
std::string const& actionType,
|
||||
int count,
|
||||
std::string const& sourceContainerNetId,
|
||||
int sourceSlot,
|
||||
std::string const& destinationContainerNetId,
|
||||
int destinationSlot
|
||||
),
|
||||
(
|
||||
(Player*)&event.self(),
|
||||
magic_enum::enum_name(event.actionType()).data(),
|
||||
event.amount(),
|
||||
magic_enum::enum_name(event.src().mFullContainerName.mName).data(),
|
||||
(int)event.src().mSlot,
|
||||
magic_enum::enum_name(event.dst().mFullContainerName.mName).data(),
|
||||
(int)event.dst().mSlot
|
||||
),
|
||||
,
|
||||
);
|
||||
// clang-format on
|
||||
}
|
||||
case doHash("gmlib::ContainerClosePacketSendAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::PlayerEvent::HandleRequestActionBeforeEvent,
|
||||
(
|
||||
Player * player,
|
||||
std::string const& actionType,
|
||||
int count,
|
||||
std::string const& sourceContainerNetId,
|
||||
int sourceSlot,
|
||||
std::string const& destinationContainerNetId,
|
||||
int destinationSlot,
|
||||
bool isCancelled
|
||||
),
|
||||
(
|
||||
&event.self(),
|
||||
magic_enum::enum_name(requestAction.mActionType).data(),
|
||||
(int)requestAction.mAmount,
|
||||
magic_enum::enum_name(requestAction.mSrc->mFullContainerName.mName).data(),
|
||||
(int)requestAction.mSrc->mSlot,
|
||||
magic_enum::enum_name(requestAction.mDst->mFullContainerName.mName).data(),
|
||||
(int)requestAction.mDst->mSlot,
|
||||
event.isCancelled()
|
||||
),
|
||||
event.setCancelled(result);,
|
||||
auto& requestAction = (ItemStackRequestActionTransferBase&)event.getRequestAction();
|
||||
);
|
||||
// clang-format on
|
||||
}
|
||||
case doHash("gmlib::HandleRequestActionAfterEvent"): {
|
||||
// clang-format off
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::PlayerEvent::HandleRequestActionAfterEvent,
|
||||
(
|
||||
Player * player,
|
||||
std::string const& actionType,
|
||||
int count,
|
||||
std::string const& sourceContainerNetId,
|
||||
int sourceSlot,
|
||||
std::string const& destinationContainerNetId,
|
||||
int destinationSlot
|
||||
),
|
||||
(
|
||||
&event.self(),
|
||||
magic_enum::enum_name(requestAction.mActionType).data(),
|
||||
(int)requestAction.mAmount,
|
||||
magic_enum::enum_name(requestAction.mSrc->mFullContainerName.mName).data(),
|
||||
(int)requestAction.mSrc->mSlot,
|
||||
magic_enum::enum_name(requestAction.mDst->mFullContainerName.mName).data(),
|
||||
(int)requestAction.mDst->mSlot
|
||||
),
|
||||
ila::mc::PlayerCloseContainerAfterEvent,
|
||||
(Player * player, int containerId, bool serverInitiatedClose, bool),
|
||||
(&event.self(), (int)event.containerId(), event.serverInitiatedClose(), false),
|
||||
,
|
||||
auto& requestAction = (ItemStackRequestActionTransferBase&)event.getRequestAction();
|
||||
);
|
||||
// clang-format on
|
||||
}
|
||||
case doHash("gmlib::ContainerClosePacketSendAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::PacketEvent::ContainerClosePacketSendAfterEvent,
|
||||
(Player * player, int containerId, bool serverInitiatedClose, bool),
|
||||
(ll::service::getServerNetworkHandler()
|
||||
->_getServerPlayer(event.getNetworkIdentifier(), event.getPacket().mClientSubId),
|
||||
(int)event.getPacket().mContainerId,
|
||||
event.getPacket().mServerInitiatedClose,
|
||||
false),
|
||||
,
|
||||
);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
);
|
||||
}
|
||||
+24
-12
@@ -1,20 +1,32 @@
|
||||
#pragma once
|
||||
#include <include_all.h>
|
||||
|
||||
// clang-format off
|
||||
#define GMLIB_GLOBAL_USING
|
||||
#include <gmlib/GlobalUsing.h>
|
||||
#include <gmlib/include_all.h>
|
||||
#include <ila/include_all.h>
|
||||
#include <RemoteCallAPI.h>
|
||||
using namespace gmlib::mod;
|
||||
// clang-format on
|
||||
|
||||
#define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA")
|
||||
|
||||
#define LIB_VERSION_MAJOR 0
|
||||
#define LIB_VERSION_MINOR 13
|
||||
#define LIB_VERSION_PATCH 6
|
||||
#define LIB_VERSION_MAJOR 1
|
||||
#define LIB_VERSION_MINOR 0
|
||||
#define LIB_VERSION_PATCH 0
|
||||
#define LIB_VERSION_PRERELEASE std::nullopt
|
||||
|
||||
#define LIB_VERSION GMLIB::Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH)
|
||||
#ifdef LIB_VERSION_PRERELEASE
|
||||
#define LIB_VERSION ll::data::Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH, LIB_VERSION_PRERELEASE)
|
||||
#else
|
||||
#define LIB_VERSION ll::data::Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH)
|
||||
#endif
|
||||
|
||||
extern void Export_Legacy_GMLib_ModAPI();
|
||||
extern void Export_Legacy_GMLib_ServerAPI();
|
||||
extern void Export_Compatibility_API();
|
||||
extern void ExportPAPI();
|
||||
extern void Export_Event_API();
|
||||
extern void Export_BinaryStream_API();
|
||||
extern void Export_Legacy_GMLib_ModAPI();
|
||||
extern void Export_Legacy_GMLib_ServerAPI();
|
||||
extern void Export_Compatibility_API();
|
||||
extern void ExportPAPI();
|
||||
extern void Export_Event_API();
|
||||
extern void Export_BinaryStream_API();
|
||||
extern ll::thread::ThreadPoolExecutor const& getThreadPoolExecutor();
|
||||
extern ll::io::Logger& getLogger();
|
||||
// extern void Export_Form_API();
|
||||
+62
-75
@@ -1,10 +1,10 @@
|
||||
#include "Global.h"
|
||||
|
||||
std::unordered_set<std::string> HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"};
|
||||
|
||||
std::variant<std::string, std::vector<RecipeIngredient>> makeRecipeUnlockingKey(std::string const& key) {
|
||||
if (HardCodedKeys.count(key)) return key;
|
||||
return std::vector<RecipeIngredient>({RecipeIngredient(key, 0, 1)});
|
||||
ICustomRecipe::UnlockingRequirement makeRecipeUnlockingKey(std::string const& key) {
|
||||
if (auto context = magic_enum::enum_cast<RecipeUnlockingContext>(key)) {
|
||||
return ICustomRecipe::UnlockingRequirement(*context);
|
||||
}
|
||||
return ICustomRecipe::UnlockingRequirement({ICustomRecipe::Ingredient(key)});
|
||||
}
|
||||
|
||||
void Export_Legacy_GMLib_ModAPI() {
|
||||
@@ -17,17 +17,13 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& result,
|
||||
int count,
|
||||
std::string const& unlock) -> void {
|
||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
std::vector<RecipeIngredient> types;
|
||||
for (auto ing : ingredients) {
|
||||
types.emplace_back(ing, 0, 1);
|
||||
if (!GMLevel::getInstance().has_value()) return;
|
||||
std::vector<ICustomRecipe::Ingredient> types;
|
||||
for (auto& ing : ingredients) {
|
||||
types.emplace_back(ICustomRecipe::Ingredient{ing, 1});
|
||||
}
|
||||
GMLIB::Mod::JsonRecipe::registerShapelessCraftingTableRecipe(
|
||||
recipe_id,
|
||||
types,
|
||||
RecipeIngredient(result, 0, count),
|
||||
makeRecipeUnlockingKey(unlock)
|
||||
);
|
||||
CustomRecipeRegistry::getInstance()
|
||||
.registerShapelessRecipe(recipe_id, types, ItemInstance(result, count), makeRecipeUnlockingKey(unlock));
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -39,16 +35,17 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& result,
|
||||
int count,
|
||||
std::string const& unlock) -> void {
|
||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
std::vector<RecipeIngredient> types;
|
||||
for (auto ing : ingredients) {
|
||||
types.push_back(RecipeIngredient(ing, 0, 1));
|
||||
if (!GMLevel::getInstance().has_value()) return;
|
||||
ICustomShapedRecipe::ShapedIngredients types;
|
||||
char index = 'A';
|
||||
for (auto& ing : ingredients) {
|
||||
types.add(std::string(1, index++), ICustomRecipe::Ingredient{ing});
|
||||
}
|
||||
GMLIB::Mod::JsonRecipe::registerShapedCraftingTableRecipe(
|
||||
CustomRecipeRegistry::getInstance().registerShapedRecipe(
|
||||
recipe_id,
|
||||
shape,
|
||||
types,
|
||||
RecipeIngredient(result, 0, count),
|
||||
ItemInstance(result, count),
|
||||
makeRecipeUnlockingKey(unlock)
|
||||
);
|
||||
}
|
||||
@@ -60,13 +57,9 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& input,
|
||||
std::string const& output,
|
||||
std::vector<std::string> tags) -> void {
|
||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
GMLIB::Mod::JsonRecipe::registerFurnaceRecipe(
|
||||
recipe_id,
|
||||
RecipeIngredient(input, 0, 1),
|
||||
RecipeIngredient(output, 0, 1),
|
||||
tags
|
||||
);
|
||||
if (!GMLevel::getInstance().has_value()) return;
|
||||
CustomRecipeRegistry::getInstance()
|
||||
.registerFurnaceRecipe(ICustomRecipe::Ingredient{input}, ItemInstance{output}, tags);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -74,8 +67,12 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
"registerBrewingMixRecipe",
|
||||
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
||||
) -> void {
|
||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
GMLIB::Mod::JsonRecipe::registerBrewingMixRecipe(recipe_id, input, output, RecipeIngredient(reagent, 0, 1));
|
||||
if (!GMLevel::getInstance().has_value()) return;
|
||||
CustomRecipeRegistry::getInstance().registerBrewingRecipe(
|
||||
ICustomRecipe::Ingredient{input},
|
||||
ICustomRecipe::Ingredient{reagent},
|
||||
ICustomRecipe::Ingredient{output}
|
||||
);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -83,12 +80,11 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
"registerBrewingContainerRecipe",
|
||||
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
||||
) -> void {
|
||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
GMLIB::Mod::JsonRecipe::registerBrewingContainerRecipe(
|
||||
recipe_id,
|
||||
RecipeIngredient(input, 0, 1),
|
||||
RecipeIngredient(output, 0, 1),
|
||||
RecipeIngredient(reagent, 0, 1)
|
||||
if (!GMLevel::getInstance().has_value()) return;
|
||||
CustomRecipeRegistry::getInstance().registerBrewingRecipe(
|
||||
ICustomRecipe::Ingredient{input},
|
||||
ICustomRecipe::Ingredient{reagent},
|
||||
ICustomRecipe::Ingredient{output}
|
||||
);
|
||||
}
|
||||
);
|
||||
@@ -100,13 +96,13 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& base,
|
||||
std::string const& addition,
|
||||
std::string const& result) -> void {
|
||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
GMLIB::Mod::JsonRecipe::registerSmithingTransformRecipe(
|
||||
if (!GMLevel::getInstance().has_value()) return;
|
||||
CustomRecipeRegistry::getInstance().registerSmithingTransformRecipe(
|
||||
recipe_id,
|
||||
smithing_template,
|
||||
base,
|
||||
addition,
|
||||
result
|
||||
ICustomRecipe::Ingredient{smithing_template},
|
||||
ICustomRecipe::Ingredient{base},
|
||||
ICustomRecipe::Ingredient{addition},
|
||||
ItemInstance{result}
|
||||
);
|
||||
}
|
||||
);
|
||||
@@ -117,8 +113,13 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& smithing_template,
|
||||
std::string const& base,
|
||||
std::string const& addition) -> void {
|
||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
GMLIB::Mod::JsonRecipe::registerSmithingTrimRecipe(recipe_id, smithing_template, base, addition);
|
||||
if (!GMLevel::getInstance().has_value()) return;
|
||||
CustomRecipeRegistry::getInstance().registerSmithingTrimRecipe(
|
||||
recipe_id,
|
||||
ICustomRecipe::Ingredient{smithing_template},
|
||||
ICustomRecipe::Ingredient{base},
|
||||
ICustomRecipe::Ingredient{addition}
|
||||
);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -130,49 +131,35 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& output,
|
||||
int output_data,
|
||||
int output_count) -> void {
|
||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
GMLIB::Mod::JsonRecipe::registerStoneCutterRecipe(
|
||||
if (!GMLevel::getInstance().has_value()) return;
|
||||
CustomRecipeRegistry::getInstance().registerStoneCutterRecipe(
|
||||
recipe_id,
|
||||
RecipeIngredient(input, 0, 1),
|
||||
RecipeIngredient(output, 0, 1)
|
||||
ICustomRecipe::Ingredient{input, 1, input_data},
|
||||
{output, output_count, output_data}
|
||||
);
|
||||
}
|
||||
);
|
||||
// 错误方块清理
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "setUnknownBlockCleaner", []() -> void {
|
||||
GMLIB::Mod::VanillaFix::setAutoCleanUnknownBlockEnabled();
|
||||
getLogger().error("setUnknownBlockCleaner is not implemented");
|
||||
});
|
||||
// 实验性
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void {
|
||||
auto list = GMLIB_Level::getAllExperiments();
|
||||
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||
if (set.contains((AllExperiments)experiment_id)) {
|
||||
GMLIB_Level::addExperimentsRequire((AllExperiments)experiment_id);
|
||||
} else {
|
||||
ll::io::LoggerRegistry::getInstance().getOrCreate("Server")->error("Experiment ID '{}' does not exist!", experiment_id);
|
||||
}
|
||||
GMLevel::getInstance().and_then([&](GMLevel& level) {
|
||||
level.setExperimentEnabled((AllExperiments)experiment_id);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "setExperimentEnabled", [](int experiment_id, bool value) -> void {
|
||||
if (GMLIB_Level::getInstance()) {
|
||||
auto list = GMLIB_Level::getAllExperiments();
|
||||
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||
if (set.contains((AllExperiments)experiment_id)) {
|
||||
GMLIB_Level::getInstance()->setExperimentEnabled(((AllExperiments)experiment_id), value);
|
||||
} else ll::io::LoggerRegistry::getInstance().getOrCreate("Server")->error("Experiment ID '{}' does not exist!", experiment_id);
|
||||
}
|
||||
GMLevel::getInstance().and_then([&](GMLevel& level) {
|
||||
level.setExperimentEnabled((AllExperiments)experiment_id, value);
|
||||
return true;
|
||||
});
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "getExperimentEnabled", [](int experiment_id) -> bool {
|
||||
if (GMLIB_Level::getInstance()) {
|
||||
auto list = GMLIB_Level::getAllExperiments();
|
||||
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||
if (set.contains((AllExperiments)experiment_id)) {
|
||||
return GMLIB_Level::getInstance()->getExperimentEnabled(((AllExperiments)experiment_id));
|
||||
}
|
||||
ll::io::LoggerRegistry::getInstance().getOrCreate("Server")->error("Experiment ID '{}' does not exist!", experiment_id);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "setFixI18nEnabled", []() -> void {
|
||||
GMLIB::Mod::VanillaFix::setFixI18nEnabled();
|
||||
return GMLevel::getInstance()
|
||||
.transform([&](GMLevel& level) { return level.getExperimentEnabled((AllExperiments)experiment_id); })
|
||||
.value_or(false);
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "setFixI18nEnabled", []() -> void {});
|
||||
}
|
||||
+29
-24
@@ -2,57 +2,62 @@
|
||||
|
||||
void Export_Legacy_GMLib_ServerAPI() {
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void {
|
||||
GMLIB_Level::tryEnableEducationEdition();
|
||||
getLogger().error("GMLib_ServerAPI::setEducationFeatureEnabled is not implemented");
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void {
|
||||
GMLIB_Level::tryRegisterAbilityCommand();
|
||||
getLogger().error("GMLib_ServerAPI::registerAbilityCommand is not implemented");
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void {
|
||||
GMLIB_Level::setForceAchievementsEnabled();
|
||||
getLogger().error("GMLib_ServerAPI::setEnableAchievement is not implemented");
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void {
|
||||
getLogger().error("GMLib_ServerAPI::setForceTrustSkins is not implemented");
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void { GMLIB_Level::trustAllSkins(); });
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "enableCoResourcePack", []() -> void {
|
||||
GMLIB_Level::requireServerResourcePackAndAllowClientResourcePack();
|
||||
getLogger().error("GMLib_ServerAPI::enableCoResourcePack is not implemented");
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
||||
return GMLIB_Level::getInstance()
|
||||
.transform([](GMLIB_Level& level) -> std::string { return level.getLevelName(); })
|
||||
.value_or("");
|
||||
return GMLevel::getInstance().transform(
|
||||
[](GMLevel& level) -> std::string { return level.getLevelName(); }
|
||||
).value_or("");
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setLevelName", [](std::string const& name) -> void {
|
||||
if (auto level = GMLIB_Level::getInstance()) {
|
||||
if (auto level = GMLevel::getInstance()) {
|
||||
level->setLevelName(name);
|
||||
}
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelSeed", []() -> std::string {
|
||||
return GMLIB_Level::getInstance()
|
||||
.transform([](GMLIB_Level& level) -> std::string { return std::to_string(level.getSeed()); })
|
||||
return GMLevel::getInstance()
|
||||
.transform([](GMLevel& level) -> std::string { return std::to_string(level.getSeed()); })
|
||||
.value_or("");
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setFakeSeed", [](int64_t seed) -> void {
|
||||
return GMLIB_Level::setFakeSeed(seed);
|
||||
getLogger().error("GMLib_ServerAPI::setFakeSeed is not implemented");
|
||||
});
|
||||
RemoteCall::exportAs(
|
||||
"GMLib_ServerAPI",
|
||||
"spawnEntity",
|
||||
[](std::pair<Vec3, int> pos, std::string const& name) -> Actor* {
|
||||
return GMLIB_Spawner::spawnEntity(pos.first, pos.second, name).as_ptr();
|
||||
return GMSpawner::spawnEntity(pos.first, pos.second, name).as_ptr();
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
"GMLib_ServerAPI",
|
||||
"shootProjectile",
|
||||
[](Actor* owner, std::string const& name, float speed, float offset) -> Actor* {
|
||||
auto ac = (GMLIB_Actor*)owner;
|
||||
return ac->shootProjectile(name, speed, offset).as_ptr();
|
||||
auto actor = GMSpawner::spawnEntity(owner->getPosition(), owner->getDimensionId(), name);
|
||||
if (!actor) return nullptr;
|
||||
((GMActor*)owner)->setProjectile((GMActor&)*actor, speed, offset);
|
||||
return actor.as_ptr();
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
"GMLib_ServerAPI",
|
||||
"throwEntity",
|
||||
[](Actor* owner, Actor* actor, float speed, float offset) -> bool {
|
||||
auto ac = (GMLIB_Actor*)owner;
|
||||
return ac->throwEntity(*actor, speed, offset);
|
||||
auto ac = (GMActor*)owner;
|
||||
ac->setProjectile((GMActor&)*actor, speed, offset);
|
||||
return true;
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "PlayerToEntity", [](Player* player) -> Actor* { return (Actor*)player; });
|
||||
@@ -60,18 +65,18 @@ void Export_Legacy_GMLib_ServerAPI() {
|
||||
"GMLib_ServerAPI",
|
||||
"addFakeList",
|
||||
[](const std::string& name, const std::string& xuid) -> bool {
|
||||
return GMLIB::Server::FakeList::addFakeList(name, xuid, ActorUniqueID(-1));
|
||||
PlayerListAPI::push_back(name, xuid);
|
||||
return true;
|
||||
}
|
||||
);
|
||||
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();
|
||||
PlayerListAPI::erase(nameOrXuid);
|
||||
return true;
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "removeAllFakeList", []() -> void { PlayerListAPI::clear(); });
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "getMaxPlayers", []() -> int {
|
||||
return GMLIB_Level::getInstance().transform(
|
||||
[](GMLIB_Level& level) -> int { return level.getMaxPlayerCount(); }
|
||||
return GMLevel::getInstance().transform(
|
||||
[](GMLevel& level) -> int { return level.getMaxPlayerCount(); }
|
||||
).value_or(0);
|
||||
});
|
||||
}
|
||||
|
||||
+163
-79
@@ -2,122 +2,198 @@
|
||||
#include <regex>
|
||||
|
||||
namespace PAPIRemoteCall {
|
||||
|
||||
std::string removeBrackets(std::string a1) {
|
||||
a1.erase(a1.find_last_not_of("%") + 1);
|
||||
return a1;
|
||||
}
|
||||
|
||||
bool isParameters(std::string const& 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 PlaceholderAPI::getValue(from, std::nullopt).value_or(""); }
|
||||
|
||||
std::string GetValueWithPlayer(std::string const& key, Player* player) {
|
||||
return GMLIB::Server::PlaceholderAPI::getValue(key, player);
|
||||
return PlaceholderAPI::getValue(key, (GMActor*)player).value_or("");
|
||||
}
|
||||
|
||||
bool registerPlayerPlaceholder(
|
||||
void registerPlayerPlaceholder(
|
||||
std::string const& PluginName,
|
||||
std::string const& FuncName,
|
||||
std::string const& PAPIName
|
||||
) {
|
||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||
GMLIB::Server::PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||
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);
|
||||
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
|
||||
PAPIName,
|
||||
[Call](Player* sp) { return Call(sp); },
|
||||
PluginName
|
||||
);
|
||||
}
|
||||
return true;
|
||||
if (!RemoteCall::hasFunc(PluginName, FuncName)) return;
|
||||
auto func = [=]() -> void {
|
||||
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||
std::weak_ptr mod = ll::mod::ModManagerRegistry::getInstance().getMod(PluginName);
|
||||
if (mod.expired()) return;
|
||||
PlaceholderAPI::registerPlaceholder(
|
||||
PAPIName,
|
||||
[Call = RemoteCall::importAs<std::string(Player * pl, std::unordered_map<std::string, std::string>)>(
|
||||
PluginName,
|
||||
FuncName
|
||||
)](optional_ref<Actor> actor, ll::StringMap<std::string> const& params, auto&&...
|
||||
) -> std::optional<std::string> {
|
||||
if (actor.has_value() && ((Actor*)actor.as_ptr())->isPlayer()) {
|
||||
std::unordered_map<std::string, std::string> paramMap;
|
||||
for (auto& [key, val] : params) {
|
||||
paramMap[key] = val;
|
||||
}
|
||||
return Call((Player*)actor.as_ptr(), paramMap);
|
||||
}
|
||||
return std::nullopt;
|
||||
},
|
||||
mod
|
||||
);
|
||||
};
|
||||
if (ll::mod::ModManagerRegistry::getInstance().hasMod(PluginName)) {
|
||||
func();
|
||||
} else {
|
||||
getThreadPoolExecutor().execute(func);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool registerServerPlaceholder(
|
||||
void registerServerPlaceholder(
|
||||
std::string const& PluginName,
|
||||
std::string const& FuncName,
|
||||
std::string const& PAPIName
|
||||
) {
|
||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||
GMLIB::Server::PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||
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);
|
||||
GMLIB::Server::PlaceholderAPI::registerServerPlaceholder(PAPIName, [Call]() { return Call(); }, PluginName);
|
||||
}
|
||||
return true;
|
||||
if (!RemoteCall::hasFunc(PluginName, FuncName)) return;
|
||||
auto func = [=]() -> void {
|
||||
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||
std::weak_ptr mod = ll::mod::ModManagerRegistry::getInstance().getMod(PluginName);
|
||||
if (mod.expired()) return;
|
||||
PlaceholderAPI::registerPlaceholder(
|
||||
PAPIName,
|
||||
[Call = RemoteCall::importAs<std::string(std::unordered_map<std::string, std::string>)>(
|
||||
PluginName,
|
||||
FuncName
|
||||
)](auto, ll::StringMap<std::string> const& params, auto&&...) -> std::optional<std::string> {
|
||||
std::unordered_map<std::string, std::string> paramMap;
|
||||
for (auto& [key, val] : params) {
|
||||
paramMap[key] = val;
|
||||
}
|
||||
return Call(paramMap);
|
||||
},
|
||||
mod
|
||||
);
|
||||
};
|
||||
if (ll::mod::ModManagerRegistry::getInstance().hasMod(PluginName)) {
|
||||
func();
|
||||
} else {
|
||||
getThreadPoolExecutor().execute(func);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool registerStaticPlaceholder(
|
||||
void registerStaticPlaceholder(
|
||||
std::string const& PluginName,
|
||||
std::string const& FuncName,
|
||||
std::string const& PAPIName,
|
||||
int num
|
||||
) {
|
||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||
GMLIB::Server::PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||
if (isParameters(PAPIName)) {
|
||||
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
||||
if (num == -1) {
|
||||
GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder(
|
||||
PAPIName,
|
||||
[Call] { return Call(); },
|
||||
PluginName
|
||||
);
|
||||
} else {
|
||||
GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder(
|
||||
PAPIName,
|
||||
num,
|
||||
[Call] { return Call(); },
|
||||
PluginName
|
||||
);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
if (!RemoteCall::hasFunc(PluginName, FuncName)) return;
|
||||
auto func = [=]() -> void {
|
||||
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||
std::weak_ptr mod = ll::mod::ModManagerRegistry::getInstance().getMod(PluginName);
|
||||
if (mod.expired()) return;
|
||||
PlaceholderAPI::registerPlaceholder(
|
||||
PAPIName,
|
||||
[Call = RemoteCall::importAs<std::string()>(PluginName, FuncName)](auto&&...)
|
||||
-> std::optional<std::string> { return Call(); },
|
||||
mod
|
||||
);
|
||||
};
|
||||
if (ll::mod::ModManagerRegistry::getInstance().hasMod(PluginName)) {
|
||||
func();
|
||||
} else {
|
||||
getThreadPoolExecutor().execute(func);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string translateStringWithPlayer(std::string const& str, Player* pl) {
|
||||
return GMLIB::Server::PlaceholderAPI::translateString(str, pl);
|
||||
return PlaceholderAPI::translate(str, (GMActor*)pl);
|
||||
}
|
||||
|
||||
std::string translateString(std::string const& str) { return GMLIB::Server::PlaceholderAPI::translateString(str); }
|
||||
std::string translateString(std::string const& str) { return PlaceholderAPI::translate(str, std::nullopt); }
|
||||
|
||||
bool unRegisterPlaceholder(std::string const& str) { return GMLIB::Server::PlaceholderAPI::unregisterPlaceholder(str); }
|
||||
bool unRegisterPlaceholder(std::string const& str) { return PlaceholderAPI::unregisterPlaceholder(str); }
|
||||
|
||||
std::vector<std::string> getAllPAPI() { return GMLIB::Server::PlaceholderAPI::getAllPAPI(); }
|
||||
std::vector<std::string> getAllPAPI() {
|
||||
std::vector<std::string> result;
|
||||
for (auto& papi : PlaceholderAPI::getAllPlaceholderData()) {
|
||||
result.push_back(papi.first);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace PAPIRemoteCall
|
||||
|
||||
namespace NewPapiRemoteCall {
|
||||
std::string translate(std::string const& value, std::string const& language) {
|
||||
return PlaceholderAPI::translate(value, std::nullopt, language);
|
||||
}
|
||||
std::string translateFromActor(std::string const& value, Actor* actor, std::string const& language) {
|
||||
return PlaceholderAPI::translate(value, (GMActor*)actor, language);
|
||||
}
|
||||
void registerPlaceholder(std::string const& placeholder, std::string const& funcName, std::string const& pluginName) {
|
||||
if (!RemoteCall::hasFunc(pluginName, funcName)) return;
|
||||
auto func = [=]() -> void {
|
||||
if (std::weak_ptr mod = ll::mod::ModManagerRegistry::getInstance().getMod(pluginName); !mod.expired()) {
|
||||
PlaceholderAPI::unregisterPlaceholder(placeholder);
|
||||
PlaceholderAPI::registerPlaceholder(
|
||||
placeholder,
|
||||
[Call = RemoteCall::importAs<
|
||||
std::string(Actor*, std::unordered_map<std::string, std::string>, std::string)>(
|
||||
pluginName,
|
||||
funcName
|
||||
)](optional_ref<Actor> actor, ll::StringMap<std::string> const& params, std::string const& language
|
||||
) -> std::optional<std::string> {
|
||||
std::unordered_map<std::string, std::string> paramMap;
|
||||
for (auto& [key, val] : params) {
|
||||
paramMap[key] = val;
|
||||
}
|
||||
auto result = Call((Actor*)actor.as_ptr(), paramMap, language);
|
||||
return result == "<std::nullopt>" ? std::nullopt : std::optional(result);
|
||||
},
|
||||
mod
|
||||
);
|
||||
}
|
||||
};
|
||||
if (ll::mod::ModManagerRegistry::getInstance().hasMod(pluginName)) {
|
||||
func();
|
||||
} else {
|
||||
getThreadPoolExecutor().execute(func);
|
||||
}
|
||||
}
|
||||
bool unregisterPlaceholder(std::string const& placeholder) {
|
||||
return PlaceholderAPI::unregisterPlaceholder(placeholder);
|
||||
}
|
||||
bool unregisterPlaceholderFromModName(std::string const& pluginName) {
|
||||
std::weak_ptr plugin = ll::mod::ModManagerRegistry::getInstance().getMod(pluginName);
|
||||
if (plugin.expired()) return false;
|
||||
return PlaceholderAPI::unregisterPlaceholder(plugin);
|
||||
}
|
||||
std::string getValue(
|
||||
std::string const& placeholder,
|
||||
std::unordered_map<std::string, std::string> params,
|
||||
std::string const& language
|
||||
) {
|
||||
ll::StringMap<std::string> paramMap;
|
||||
for (auto& [key, val] : params) {
|
||||
paramMap[key] = val;
|
||||
}
|
||||
return PlaceholderAPI::getValue(placeholder, std::nullopt, paramMap, language).value_or("<std::nullopt>");
|
||||
}
|
||||
std::string getValueFromActor(
|
||||
std::string const& placeholder,
|
||||
Actor* actor,
|
||||
std::unordered_map<std::string, std::string> params,
|
||||
std::string const& language
|
||||
) {
|
||||
ll::StringMap<std::string> paramMap;
|
||||
for (auto& [key, val] : params) {
|
||||
paramMap[key] = val;
|
||||
}
|
||||
return PlaceholderAPI::getValue(placeholder, (GMActor*)actor, paramMap, language).value_or("<std::nullopt>");
|
||||
}
|
||||
} // namespace NewPapiRemoteCall
|
||||
|
||||
#define EXPORTAPI(T) \
|
||||
RemoteCall::exportAs("BEPlaceholderAPI", ll::utils::string_utils::replaceAll(#T, "PAPIRemoteCall::", ""), T);
|
||||
|
||||
#define EXPORTAPI2(T) RemoteCall::exportAs("PlaceholderAPI", #T, NewPapiRemoteCall::T);
|
||||
|
||||
void ExportPAPI() {
|
||||
EXPORTAPI(PAPIRemoteCall::registerPlayerPlaceholder);
|
||||
EXPORTAPI(PAPIRemoteCall::registerServerPlaceholder);
|
||||
@@ -128,4 +204,12 @@ void ExportPAPI() {
|
||||
EXPORTAPI(PAPIRemoteCall::translateStringWithPlayer);
|
||||
EXPORTAPI(PAPIRemoteCall::unRegisterPlaceholder);
|
||||
EXPORTAPI(PAPIRemoteCall::getAllPAPI);
|
||||
|
||||
EXPORTAPI2(translate);
|
||||
EXPORTAPI2(translateFromActor);
|
||||
EXPORTAPI2(registerPlaceholder);
|
||||
EXPORTAPI2(unregisterPlaceholder);
|
||||
EXPORTAPI2(unregisterPlaceholderFromModName);
|
||||
EXPORTAPI2(getValue);
|
||||
EXPORTAPI2(getValueFromActor);
|
||||
}
|
||||
+35
-18
@@ -1,29 +1,46 @@
|
||||
{
|
||||
"format_version": 2,
|
||||
"format_version": 3,
|
||||
"format_uuid": "289f771f-2c9a-4d73-9f3f-8492495a924d",
|
||||
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
||||
"version": "0.13.6",
|
||||
"version": "1.0.1",
|
||||
"info": {
|
||||
"name": "GMLIB-LegacyRemoteCallApi",
|
||||
"description": "Legacy RemoteCall API for GMLIB",
|
||||
"source": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
||||
"author": "GroupMountain",
|
||||
"tags": [
|
||||
"levilamina",
|
||||
"platform:levilamina",
|
||||
"type:mod",
|
||||
"gmlib",
|
||||
"lse",
|
||||
"library"
|
||||
]
|
||||
],
|
||||
"avatar_url": "https://raw.githubusercontent.com/GroupMountain/GMLIB-LegacyRemoteCallApi/refs/heads/main/icon.jpg"
|
||||
},
|
||||
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.13.6/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
|
||||
"dependencies": {
|
||||
"github.com/GroupMountain/GMLIB": ">=0.13.9"
|
||||
},
|
||||
"files": {
|
||||
"place": [
|
||||
{
|
||||
"src": "GMLIB-LegacyRemoteCallApi/*",
|
||||
"dest": "plugins/GMLIB-LegacyRemoteCallApi"
|
||||
}
|
||||
]
|
||||
}
|
||||
"variants": [
|
||||
{
|
||||
"platform": "win-x64",
|
||||
"dependencies": {
|
||||
"github.com/LiteLDev/LeviLamina": ">=1.1.1",
|
||||
"github.com/GroupMountain/GMLIB-Release": ">=1.0.0",
|
||||
"github.com/MiracleForest/iListenAttentively-Release": ">=0.4.1"
|
||||
},
|
||||
"assets": [
|
||||
{
|
||||
"type": "zip",
|
||||
"urls": [
|
||||
"https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v$(version)/GMLIB-LegacyRemoteCallApi-windows-x64.zip"
|
||||
],
|
||||
"placements": [
|
||||
{
|
||||
"type": "dir",
|
||||
"src": "GMLIB-LegacyRemoteCallApi",
|
||||
"dest": "plugins/GMLIB-LegacyRemoteCallApi/"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"remove_files": [
|
||||
"plugins/GMLIB-LegacyRemoteCallApi"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2,27 +2,28 @@ add_rules("mode.debug", "mode.release")
|
||||
|
||||
add_repositories("liteldev-repo https://github.com/LiteLDev/xmake-repo.git")
|
||||
add_repositories("groupmountain-repo https://github.com/GroupMountain/xmake-repo.git")
|
||||
add_repositories("miracleforest-repo https://github.com/MiracleForest/xmake-repo.git")
|
||||
|
||||
if not has_config("vs_runtime") then
|
||||
set_runtimes("MD")
|
||||
end
|
||||
|
||||
add_requires("levilamina 1.0.0-rc.3", {configs = {target_type = "server"}})
|
||||
add_requires("legacyremotecall 0.9.0-rc.1")
|
||||
add_requires("gmlib 0.13.10")
|
||||
add_requires("levibuildscript 0.3.0")
|
||||
add_requires("levilamina 1.1.1", {configs = {target_type = "server"}})
|
||||
add_requires("legacyremotecall")
|
||||
add_requires("levibuildscript")
|
||||
add_requires("ilistenattentively")
|
||||
add_requires("gmlib")
|
||||
|
||||
target("GMLIB-LegacyRemoteCallApi")
|
||||
add_cxflags(
|
||||
"/EHa",
|
||||
"/utf-8"
|
||||
"/utf-8",
|
||||
"/bigobj"
|
||||
)
|
||||
add_defines(
|
||||
"NOMINMAX",
|
||||
"UNICODE",
|
||||
"_HAS_CXX17",
|
||||
"_HAS_CXX20",
|
||||
"_HAS_CXX23"
|
||||
"_HAS_CXX23=1"
|
||||
)
|
||||
add_files(
|
||||
"src/**.cpp"
|
||||
@@ -33,6 +34,7 @@ target("GMLIB-LegacyRemoteCallApi")
|
||||
add_packages(
|
||||
"levilamina",
|
||||
"legacyremotecall",
|
||||
"ilistenattentively",
|
||||
"gmlib"
|
||||
)
|
||||
add_rules("@levibuildscript/linkrule")
|
||||
|
||||
Reference in New Issue
Block a user