Compare commits
24 Commits
@@ -11,6 +11,8 @@ jobs:
|
|||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- uses: xmake-io/github-action-setup-xmake@v1
|
- uses: xmake-io/github-action-setup-xmake@v1
|
||||||
|
with:
|
||||||
|
xmake-version: 2.9.9
|
||||||
|
|
||||||
- run: |
|
- run: |
|
||||||
xmake repo -u
|
xmake repo -u
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ jobs:
|
|||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- uses: xmake-io/github-action-setup-xmake@v1
|
- uses: xmake-io/github-action-setup-xmake@v1
|
||||||
|
with:
|
||||||
|
xmake-version: 2.9.9
|
||||||
|
|
||||||
- run: |
|
- run: |
|
||||||
xmake repo -u
|
xmake repo -u
|
||||||
|
|||||||
Vendored
+3
-3
@@ -12,7 +12,7 @@ export class PAPI {
|
|||||||
pluginsName: string,
|
pluginsName: string,
|
||||||
/** PAPI变量 */
|
/** PAPI变量 */
|
||||||
PAPIName: string
|
PAPIName: string
|
||||||
): boolean;
|
): void;
|
||||||
|
|
||||||
/** 注册一个服务器PAPI变量 */
|
/** 注册一个服务器PAPI变量 */
|
||||||
static registerServerPlaceholder(
|
static registerServerPlaceholder(
|
||||||
@@ -25,7 +25,7 @@ export class PAPI {
|
|||||||
pluginsName: string,
|
pluginsName: string,
|
||||||
/** PAPI变量 */
|
/** PAPI变量 */
|
||||||
PAPIName: string
|
PAPIName: string
|
||||||
): boolean;
|
): void;
|
||||||
|
|
||||||
/** 注册一个静态PAPI变量 */
|
/** 注册一个静态PAPI变量 */
|
||||||
static registerStaticPlaceholder(
|
static registerStaticPlaceholder(
|
||||||
@@ -37,7 +37,7 @@ export class PAPI {
|
|||||||
PAPIName: string,
|
PAPIName: string,
|
||||||
/** 更新时间 */
|
/** 更新时间 */
|
||||||
UpdateInterval: number
|
UpdateInterval: number
|
||||||
): boolean;
|
): void;
|
||||||
|
|
||||||
/** 获取一个服务器变量的值 */
|
/** 获取一个服务器变量的值 */
|
||||||
static getValue(
|
static getValue(
|
||||||
|
|||||||
+12
-12
@@ -1,22 +1,22 @@
|
|||||||
const PlaceholderAPI = {
|
const PlaceholderAPI = {
|
||||||
/** 获取一个服务器变量的值 @type {function(string):string} */
|
/** 获取一个服务器变量的值 @type {function(string):string} */
|
||||||
getValueAPI: ll.import("BEPlaceholderAPI", "GetValue"),
|
getValueAPI: ll.imports("BEPlaceholderAPI", "GetValue"),
|
||||||
/** 获取一个玩家变量的值 @type {function(string,Player):string} */
|
/** 获取一个玩家变量的值 @type {function(string,Player):string} */
|
||||||
getValueByPlayerAPI: ll.import("BEPlaceholderAPI", "GetValueWithPlayer"),
|
getValueByPlayerAPI: ll.imports("BEPlaceholderAPI", "GetValueWithPlayer"),
|
||||||
/** 注册一个玩家变量 @type {function(string,string,string):boolean} */
|
/** 注册一个玩家变量 @type {function(string,string,string):boolean} */
|
||||||
registerPlayerPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerPlayerPlaceholder"),
|
registerPlayerPlaceholderAPI: ll.imports("BEPlaceholderAPI", "registerPlayerPlaceholder"),
|
||||||
/** 注册一个服务器变量 @type {function(string,string,string):boolean} */
|
/** 注册一个服务器变量 @type {function(string,string,string):boolean} */
|
||||||
registerServerPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerServerPlaceholder"),
|
registerServerPlaceholderAPI: ll.imports("BEPlaceholderAPI", "registerServerPlaceholder"),
|
||||||
/** 注册一个静态变量 @type {function(string,string,string,number):boolean} */
|
/** 注册一个静态变量 @type {function(string,string,string,number):boolean} */
|
||||||
registerStaticPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerStaticPlaceholder"),
|
registerStaticPlaceholderAPI: ll.imports("BEPlaceholderAPI", "registerStaticPlaceholder"),
|
||||||
/** 翻译包含PAPI服务器变量的字符串 @type {function(string):string} */
|
/** 翻译包含PAPI服务器变量的字符串 @type {function(string):string} */
|
||||||
translateStringAPI: ll.import("BEPlaceholderAPI", "translateString"),
|
translateStringAPI: ll.imports("BEPlaceholderAPI", "translateString"),
|
||||||
/** 翻译包含PAPI玩家变量的字符串 @type {function(string,Player):string} */
|
/** 翻译包含PAPI玩家变量的字符串 @type {function(string,Player):string} */
|
||||||
translateStringWithPlayerAPI: ll.import("BEPlaceholderAPI", "translateStringWithPlayer"),
|
translateStringWithPlayerAPI: ll.imports("BEPlaceholderAPI", "translateStringWithPlayer"),
|
||||||
/** 注销PAPI变量 @type {function(string):boolean} */
|
/** 注销PAPI变量 @type {function(string):boolean} */
|
||||||
unRegisterPlaceholderAPI: ll.import("BEPlaceholderAPI", "unRegisterPlaceholder"),
|
unRegisterPlaceholderAPI: ll.imports("BEPlaceholderAPI", "unRegisterPlaceholder"),
|
||||||
/** 获取所有已注册的PAPI变量 @type {function():Array.<string>} */
|
/** 获取所有已注册的PAPI变量 @type {function():Array.<string>} */
|
||||||
getAllPAPI: ll.import("BEPlaceholderAPI", "getAllPAPI")
|
getAllPAPI: ll.imports("BEPlaceholderAPI", "getAllPAPI")
|
||||||
}
|
}
|
||||||
|
|
||||||
Function.prototype.getName =
|
Function.prototype.getName =
|
||||||
@@ -59,7 +59,7 @@ class PAPI {
|
|||||||
*/
|
*/
|
||||||
static registerPlayerPlaceholder(func, PluginName, PAPIName) {
|
static registerPlayerPlaceholder(func, PluginName, PAPIName) {
|
||||||
ll.export(func, PluginName, func.getName());
|
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) {
|
static registerServerPlaceholder(func, PluginName, PAPIName) {
|
||||||
ll.export(func, PluginName, func.getName());
|
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) {
|
static registerStaticPlaceholder(func, PluginName, PAPIName, UpdateInterval = 50) {
|
||||||
ll.export(func, PluginName, func.getName());
|
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}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
const getPluginName = () => {
|
const getPluginName = () => {
|
||||||
|
// quickjs
|
||||||
try {
|
try {
|
||||||
throw new Error("getPluginName");
|
throw new Error("getPluginName");
|
||||||
} catch (error) {
|
} 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 = {
|
module.exports = {
|
||||||
@@ -77,7 +116,7 @@ module.exports = {
|
|||||||
*/
|
*/
|
||||||
emplaceListener: function (eventName, callback, priority = this.EventPriority.Normal, pluginName = getPluginName()) {
|
emplaceListener: function (eventName, callback, priority = this.EventPriority.Normal, pluginName = getPluginName()) {
|
||||||
if (typeof callback !== "function") throw new Error("callback must be a function!");
|
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!`);
|
if (eventId === -1) throw new Error(`Event ${eventName} creation failed!`);
|
||||||
ll.exports((...data) => {
|
ll.exports((...data) => {
|
||||||
let /** @type {boolean} */ result = typeof (data.slice(-1)[0]) === "boolean" ? data.pop() : false;
|
let /** @type {boolean} */ result = typeof (data.slice(-1)[0]) === "boolean" ? data.pop() : false;
|
||||||
@@ -107,7 +146,7 @@ module.exports = {
|
|||||||
* @param {boolean}
|
* @param {boolean}
|
||||||
*/
|
*/
|
||||||
removeListener: function (eventId) {
|
removeListener: function (eventId) {
|
||||||
const result = ll.imports("GMLIB_Event_API", "removeListener")(eventId);
|
const result = ll.importss("GMLIB_Event_API", "removeListener")(eventId);
|
||||||
if (result) {
|
if (result) {
|
||||||
for (let [eventName, eventIds] of Object.entries(this.mEventData)) {
|
for (let [eventName, eventIds] of Object.entries(this.mEventData)) {
|
||||||
this.mEventData[eventName] = eventIds.filter(id => id !== eventId);
|
this.mEventData[eventName] = eventIds.filter(id => id !== eventId);
|
||||||
@@ -123,7 +162,7 @@ module.exports = {
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
hasListener: function (eventId) {
|
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?}
|
* @returns {number?}
|
||||||
*/
|
*/
|
||||||
getListenerPriority: function (eventId) {
|
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;
|
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 {
|
// class ServerSettingForm {
|
||||||
// constructor() {
|
// constructor() {
|
||||||
@@ -6,35 +6,35 @@
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// static getDefaultPriority() {
|
// static getDefaultPriority() {
|
||||||
// return ll.import("GMLIB_ServerSettingForm", "getDefaultPriority")();
|
// return ll.imports("GMLIB_ServerSettingForm", "getDefaultPriority")();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// static hasTitle() {
|
// static hasTitle() {
|
||||||
// return ll.import("GMLIB_ServerSettingForm", "hasTitle")();
|
// return ll.imports("GMLIB_ServerSettingForm", "hasTitle")();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// static getTitle() {
|
// static getTitle() {
|
||||||
// return ll.import("GMLIB_ServerSettingForm", "getTitle")();
|
// return ll.imports("GMLIB_ServerSettingForm", "getTitle")();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// static setTitle(title, forceModify = false) {
|
// static setTitle(title, forceModify = false) {
|
||||||
// return ll.import("GMLIB_ServerSettingForm", "setTitle")(title, forceModify);
|
// return ll.imports("GMLIB_ServerSettingForm", "setTitle")(title, forceModify);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// static hasIcon() {
|
// static hasIcon() {
|
||||||
// return ll.import("GMLIB_ServerSettingForm", "hasIcon")();
|
// return ll.imports("GMLIB_ServerSettingForm", "hasIcon")();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// static getIconData() {
|
// static getIconData() {
|
||||||
// return hasIcon() ? ll.import("GMLIB_ServerSettingForm", "getIconData")() : null;
|
// return hasIcon() ? ll.imports("GMLIB_ServerSettingForm", "getIconData")() : null;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// static getIconType() {
|
// static getIconType() {
|
||||||
// return ll.import("GMLIB_ServerSettingForm", "getIconType")();
|
// return ll.imports("GMLIB_ServerSettingForm", "getIconType")();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// static setIcon(data, type = 0, forceModify = false) {
|
// 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(
|
// static addLabel(
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
// ) {
|
// ) {
|
||||||
// let detectorId = getNextCallbackId();
|
// let detectorId = getNextCallbackId();
|
||||||
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
// 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);
|
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||||
// let detectorId = getNextCallbackId();
|
// let detectorId = getNextCallbackId();
|
||||||
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
// 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(
|
// static addToggle(
|
||||||
@@ -74,7 +74,7 @@
|
|||||||
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||||
// let detectorId = getNextCallbackId();
|
// let detectorId = getNextCallbackId();
|
||||||
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
// 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(
|
// static addDropdown(
|
||||||
@@ -89,7 +89,7 @@
|
|||||||
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||||
// let detectorId = getNextCallbackId();
|
// let detectorId = getNextCallbackId();
|
||||||
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
// 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(
|
// static addSlider(
|
||||||
@@ -106,7 +106,7 @@
|
|||||||
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||||
// let detectorId = getNextCallbackId();
|
// let detectorId = getNextCallbackId();
|
||||||
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
// 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(
|
// static addStepSlider(
|
||||||
@@ -121,57 +121,57 @@
|
|||||||
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||||
// let detectorId = getNextCallbackId();
|
// let detectorId = getNextCallbackId();
|
||||||
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
// 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) {
|
// static removeElement(id) {
|
||||||
// return ll.import("GMLIB_ServerSettingForm", "removeElement")(id);
|
// return ll.imports("GMLIB_ServerSettingForm", "removeElement")(id);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// class NpcDialogueForm {
|
// class NpcDialogueForm {
|
||||||
// constructor(npcName, sceneName, dialogue) {
|
// 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) {
|
// 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) {
|
// sendTo(pl, callback = (pl, index, type) => { }, free = true) {
|
||||||
// let callbackId = getNextCallbackId();
|
// let callbackId = getNextCallbackId();
|
||||||
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
// 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) {
|
// if (free) {
|
||||||
// this.destroy();
|
// this.destroy();
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// destroy() {
|
// destroy() {
|
||||||
// ll.import("GMLIB_NpcDialogueForm", "destroyForm")(this.mFormId);
|
// ll.imports("GMLIB_NpcDialogueForm", "destroyForm")(this.mFormId);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// class ChestForm {
|
// class ChestForm {
|
||||||
// constructor(npcName, sceneName, dialogue) {
|
// 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) {
|
// addButton(button) {
|
||||||
// return ll.import("GMLIB_NpcDialogueForm", "addButton")(this.mFormId, button);
|
// return ll.imports("GMLIB_NpcDialogueForm", "addButton")(this.mFormId, button);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// sendTo(pl, free = true) {
|
// sendTo(pl, free = true) {
|
||||||
// //let callbackId = getNextCallbackId();
|
// //let callbackId = getNextCallbackId();
|
||||||
// //ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
// //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) {
|
// //if (free) {
|
||||||
// // this.destroy();
|
// // this.destroy();
|
||||||
// //}
|
// //}
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// 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
|
slot: number
|
||||||
): Item;
|
): Item;
|
||||||
|
|
||||||
|
/** (GMLIB & Glacie)获取客户端版本协议*/
|
||||||
|
getNetworkProtocolVersion(): number
|
||||||
|
|
||||||
/** (GMLIB)发送更新更新物品数据包 */
|
/** (GMLIB)发送更新更新物品数据包 */
|
||||||
sendInventorySlotPacket(
|
sendInventorySlotPacket(
|
||||||
/** 容器ID */
|
/** 容器ID */
|
||||||
|
|||||||
+231
-221
@@ -1,437 +1,439 @@
|
|||||||
/** LRCA导出接口 */
|
/** LRCA导出接口 */
|
||||||
const GMLIB_API = {
|
const GMLIB_API = {
|
||||||
/** 创建悬浮字 @type {function(FloatPos,string,boolean):number} */
|
/** 创建悬浮字 @type {function(FloatPos,string,boolean):number} */
|
||||||
createFloatingText: ll.import("GMLIB_API", "createFloatingText"),
|
createFloatingText: ll.imports("GMLIB_API", "createFloatingText"),
|
||||||
/** 删除悬浮字 @type {function(number):boolean} */
|
/** 删除悬浮字 @type {function(number):boolean} */
|
||||||
deleteFloatingText: ll.import("GMLIB_API", "deleteFloatingText"),
|
deleteFloatingText: ll.imports("GMLIB_API", "deleteFloatingText"),
|
||||||
/** 设置悬浮字文本 @type {function(number,string):boolean} */
|
/** 设置悬浮字文本 @type {function(number,string):boolean} */
|
||||||
setFloatingTextData: ll.import("GMLIB_API", "setFloatingTextData"),
|
setFloatingTextData: ll.imports("GMLIB_API", "setFloatingTextData"),
|
||||||
/** 发送悬浮字给玩家 @type {function(number,Player):boolean} */
|
/** 发送悬浮字给玩家 @type {function(number,Player):boolean} */
|
||||||
sendFloatingTextToPlayer: ll.import("GMLIB_API", "sendFloatingTextToPlayer"),
|
sendFloatingTextToPlayer: ll.imports("GMLIB_API", "sendFloatingTextToPlayer"),
|
||||||
/** 发送悬浮字给所有玩家 @type {function(number):boolean} */
|
/** 发送悬浮字给所有玩家 @type {function(number):boolean} */
|
||||||
sendFloatingText: ll.import("GMLIB_API", "sendFloatingText"),
|
sendFloatingText: ll.imports("GMLIB_API", "sendFloatingText"),
|
||||||
/** 删除玩家的悬浮字 @type {function(number,Player):boolean} */
|
/** 删除玩家的悬浮字 @type {function(number,Player):boolean} */
|
||||||
removeFloatingTextFromPlayer: ll.import("GMLIB_API", "removeFloatingTextFromPlayer"),
|
removeFloatingTextFromPlayer: ll.imports("GMLIB_API", "removeFloatingTextFromPlayer"),
|
||||||
/** 删除所有玩家悬浮字 @type {function(number):boolean} */
|
/** 删除所有玩家悬浮字 @type {function(number):boolean} */
|
||||||
removeFloatingText: ll.import("GMLIB_API", "removeFloatingText"),
|
removeFloatingText: ll.imports("GMLIB_API", "removeFloatingText"),
|
||||||
/** 更新玩家的悬浮字 @type {function(number,Player):boolean} */
|
/** 更新玩家的悬浮字 @type {function(number,Player):boolean} */
|
||||||
updateClientFloatingTextData: ll.import("GMLIB_API", "updateClientFloatingTextData"),
|
updateClientFloatingTextData: ll.imports("GMLIB_API", "updateClientFloatingTextData"),
|
||||||
/** 更新所有玩家的悬浮字 @type {function(number):boolean} */
|
/** 更新所有玩家的悬浮字 @type {function(number):boolean} */
|
||||||
updateAllClientsFloatingTextData: ll.import("GMLIB_API", "updateAllClientsFloatingTextData"),
|
updateAllClientsFloatingTextData: ll.imports("GMLIB_API", "updateAllClientsFloatingTextData"),
|
||||||
/** 获取服务器Mspt @type {function():number} */
|
/** 获取服务器Mspt @type {function():number} */
|
||||||
getServerMspt: ll.import("GMLIB_API", "getServerMspt"),
|
getServerMspt: ll.imports("GMLIB_API", "getServerMspt"),
|
||||||
/** 获取服务器当前tps @type {function():number} */
|
/** 获取服务器当前tps @type {function():number} */
|
||||||
getServerCurrentTps: ll.import("GMLIB_API", "getServerCurrentTps"),
|
getServerCurrentTps: ll.imports("GMLIB_API", "getServerCurrentTps"),
|
||||||
/** 获取服务器平均tps @type {function():number} */
|
/** 获取服务器平均tps @type {function():number} */
|
||||||
getServerAverageTps: ll.import("GMLIB_API", "getServerAverageTps"),
|
getServerAverageTps: ll.imports("GMLIB_API", "getServerAverageTps"),
|
||||||
/** 获取存档内所有玩家的uuid @type {function():Array<string>} */
|
/** 获取存档内所有玩家的uuid @type {function():Array<string>} */
|
||||||
getAllPlayerUuids: ll.import("GMLIB_API", "getAllPlayerUuids"),
|
getAllPlayerUuids: ll.imports("GMLIB_API", "getAllPlayerUuids"),
|
||||||
/** 获取玩家NBT @type {function(string):NbtCompound} */
|
/** 获取玩家NBT @type {function(string):NbtCompound} */
|
||||||
getPlayerNbt: ll.import("GMLIB_API", "getPlayerNbt"),
|
getPlayerNbt: ll.imports("GMLIB_API", "getPlayerNbt"),
|
||||||
/** 设置玩家NBT @type {function(string,NbtCompound,boolean):boolean} */
|
/** 设置玩家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} */
|
/** 覆盖玩家的特定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} */
|
/** 删除玩家所有的NBT @type {function(string):boolean} */
|
||||||
deletePlayerNbt: ll.import("GMLIB_API", "deletePlayerNbt"),
|
deletePlayerNbt: ll.imports("GMLIB_API", "deletePlayerNbt"),
|
||||||
/** 使用特定语言翻译资源包文本 @type {function(string,Array.<string>,string):string} */
|
/** 使用特定语言翻译资源包文本 @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} */
|
/** 使用默认语言翻译资源包文本 @type {function(string,Array.<string>):string} */
|
||||||
resourcePackDefaultTranslate: ll.import("GMLIB_API", "resourcePackDefaultTranslate"),
|
resourcePackDefaultTranslate: ll.imports("GMLIB_API", "resourcePackDefaultTranslate"),
|
||||||
/** 获取资源包默认语言 @type {function():string} */
|
/** 获取资源包默认语言 @type {function():string} */
|
||||||
getResourcePackI18nLanguage: ll.import("GMLIB_API", "getResourcePackI18nLanguage"),
|
getResourcePackI18nLanguage: ll.imports("GMLIB_API", "getResourcePackI18nLanguage"),
|
||||||
/** 设置资源包默认语言 @type {function(string):void} */
|
/** 设置资源包默认语言 @type {function(string):void} */
|
||||||
chooseResourcePackI18nLanguage: ll.import("GMLIB_API", "chooseResourcePackI18nLanguage"),
|
chooseResourcePackI18nLanguage: ll.imports("GMLIB_API", "chooseResourcePackI18nLanguage"),
|
||||||
/** 启用教育版内容 @type {function():void} */
|
/** 启用教育版内容 @type {function():void} */
|
||||||
setEducationFeatureEnabled: ll.import("GMLib_ServerAPI", "setEducationFeatureEnabled"),
|
setEducationFeatureEnabled: ll.imports("GMLib_ServerAPI", "setEducationFeatureEnabled"),
|
||||||
/** 注册Ability命令 @type {function():void} */
|
/** 注册Ability命令 @type {function():void} */
|
||||||
registerAbilityCommand: ll.import("GMLib_ServerAPI", "registerAbilityCommand"),
|
registerAbilityCommand: ll.imports("GMLib_ServerAPI", "registerAbilityCommand"),
|
||||||
/** 启用Xbox成就 @type {function():void} */
|
/** 启用Xbox成就 @type {function():void} */
|
||||||
setEnableAchievement: ll.import("GMLib_ServerAPI", "setEnableAchievement"),
|
setEnableAchievement: ll.imports("GMLib_ServerAPI", "setEnableAchievement"),
|
||||||
/** 信任所有玩家皮肤 @type {function():void} */
|
/** 信任所有玩家皮肤 @type {function():void} */
|
||||||
setForceTrustSkins: ll.import("GMLib_ServerAPI", "setForceTrustSkins"),
|
setForceTrustSkins: ll.imports("GMLib_ServerAPI", "setForceTrustSkins"),
|
||||||
/** 资源包双端共存 @type {function():void} */
|
/** 资源包双端共存 @type {function():void} */
|
||||||
enableCoResourcePack: ll.import("GMLib_ServerAPI", "enableCoResourcePack"),
|
enableCoResourcePack: ll.imports("GMLib_ServerAPI", "enableCoResourcePack"),
|
||||||
/** 获取存档名字 @type {function():string} */
|
/** 获取存档名字 @type {function():string} */
|
||||||
getLevelName: ll.import("GMLib_ServerAPI", "getLevelName"),
|
getLevelName: ll.imports("GMLib_ServerAPI", "getLevelName"),
|
||||||
/** 设置存档名字 @type {function(string):boolean} */
|
/** 设置存档名字 @type {function(string):boolean} */
|
||||||
setLevelName: ll.import("GMLib_ServerAPI", "setLevelName"),
|
setLevelName: ll.imports("GMLib_ServerAPI", "setLevelName"),
|
||||||
/** 设置假种子 @type {function(number):void} */
|
/** 设置假种子 @type {function(number):void} */
|
||||||
setFakeSeed: ll.import("GMLib_ServerAPI", "setFakeSeed"),
|
setFakeSeed: ll.imports("GMLib_ServerAPI", "setFakeSeed"),
|
||||||
/** 强制生成实体 @type {function(FloatPos,string):Entity} */
|
/** 强制生成实体 @type {function(FloatPos,string):Entity} */
|
||||||
spawnEntity: ll.import("GMLib_ServerAPI", "spawnEntity"),
|
spawnEntity: ll.imports("GMLib_ServerAPI", "spawnEntity"),
|
||||||
/** 射弹投射物 @type {function(Entity,string,number,number):boolean} */
|
/** 射弹投射物 @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} */
|
/** 投掷实体 @type {function(Entity,Entity,number,number):boolean} */
|
||||||
throwEntity: ll.import("GMLib_ServerAPI", "throwEntity"),
|
throwEntity: ll.imports("GMLib_ServerAPI", "throwEntity"),
|
||||||
/** 根据玩家对象获取实体对象 @type {function(Player):Entity} */
|
/** 根据玩家对象获取实体对象 @type {function(Player):Entity} */
|
||||||
PlayerToEntity: ll.import("GMLib_ServerAPI", "PlayerToEntity"),
|
PlayerToEntity: ll.imports("GMLib_ServerAPI", "PlayerToEntity"),
|
||||||
/** 启用错误方块清理 @type {function():void} */
|
/** 启用错误方块清理 @type {function():void} */
|
||||||
setUnknownBlockCleaner: ll.import("GMLib_ModAPI", "setUnknownBlockCleaner"),
|
setUnknownBlockCleaner: ll.imports("GMLib_ModAPI", "setUnknownBlockCleaner"),
|
||||||
/** 获取实验性功能ID列表 @type {function():Array<number>} */
|
/** 获取实验性功能ID列表 @type {function():Array<number>} */
|
||||||
getAllExperiments: ll.import("GMLIB_API", "getAllExperiments"),
|
getAllExperiments: ll.imports("GMLIB_API", "getAllExperiments"),
|
||||||
/** 获取实验性功能文本的键名 @type {function(number):string} */
|
/** 获取实验性功能文本的键名 @type {function(number):string} */
|
||||||
getExperimentTranslateKey: ll.import("GMLIB_API", "getExperimentTranslateKey"),
|
getExperimentTranslateKey: ll.imports("GMLIB_API", "getExperimentTranslateKey"),
|
||||||
/** 获取实验性功能启用状态 @type {function(number):boolean} */
|
/** 获取实验性功能启用状态 @type {function(number):boolean} */
|
||||||
getExperimentEnabled: ll.import("GMLib_ModAPI", "getExperimentEnabled"),
|
getExperimentEnabled: ll.imports("GMLib_ModAPI", "getExperimentEnabled"),
|
||||||
/** 设置实验性功能启用状态 @type {function(number,boolean):void} */
|
/** 设置实验性功能启用状态 @type {function(number,boolean):void} */
|
||||||
setExperimentEnabled: ll.import("GMLib_ModAPI", "setExperimentEnabled"),
|
setExperimentEnabled: ll.imports("GMLib_ModAPI", "setExperimentEnabled"),
|
||||||
/** 注销合成表 @type {function(string):boolean} */
|
/** 注销合成表 @type {function(string):boolean} */
|
||||||
unregisterRecipe: ll.import("GMLIB_API", "unregisterRecipe"),
|
unregisterRecipe: ll.imports("GMLIB_API", "unregisterRecipe"),
|
||||||
/** 设置实验性依赖 @type {function(number):void} */
|
/** 设置实验性依赖 @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} */
|
/** 注册切石机合成表 @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} */
|
/** 注册锻造纹饰合成表 @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} */
|
/** 注册锻造配方合成表 @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} */
|
/** 注册酿造容器表 @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} */
|
/** 注册酿造混合表 @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} */
|
/** 注册熔炼合成表 @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)} */
|
/** 注册有序合成表 @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)} */
|
/** 注册无序合成表 @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)} */
|
/** 注册有序合成表 @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)} */
|
/** 注册无序合成表 @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} */
|
/** 检测LRCA版本是否大于或等于此版本 @type {function(number,number,number):boolean} */
|
||||||
isVersionMatched: ll.import("GMLIB_API", "isVersionMatched"),
|
isVersionMatched: ll.imports("GMLIB_API", "isVersionMatched"),
|
||||||
/** 获取LRCA版本 @type {function():string} */
|
/** 获取LRCA版本 @type {function():string} */
|
||||||
getVersion_LRCA: ll.import("GMLIB_API", "getVersion_LRCA"),
|
getVersion_LRCA: ll.imports("GMLIB_API", "getVersion_LRCA"),
|
||||||
/** 获取GMLIB版本 @type {function():string} */
|
/** 获取GMLIB版本 @type {function():string} */
|
||||||
getVersion_GMLIB: ll.import("GMLIB_API", "getVersion_GMLIB"),
|
getVersion_GMLIB: ll.imports("GMLIB_API", "getVersion_GMLIB"),
|
||||||
/** 获取玩家坐标 @type {function(string):IntPos} */
|
/** 获取玩家坐标 @type {function(string):IntPos} */
|
||||||
getPlayerPosition: ll.import("GMLIB_API", "getPlayerPosition"),
|
getPlayerPosition: ll.imports("GMLIB_API", "getPlayerPosition"),
|
||||||
/** 设置玩家坐标 @type {function(string,IntPos):boolean} */
|
/** 设置玩家坐标 @type {function(string,IntPos):boolean} */
|
||||||
setPlayerPosition: ll.import("GMLIB_API", "setPlayerPosition"),
|
setPlayerPosition: ll.imports("GMLIB_API", "setPlayerPosition"),
|
||||||
/** 玩家是否存在于计分板 @type {function(string,string):boolean} */
|
/** 玩家是否存在于计分板 @type {function(string,string):boolean} */
|
||||||
playerHasScore: ll.import("GMLIB_API", "playerHasScore"),
|
playerHasScore: ll.imports("GMLIB_API", "playerHasScore"),
|
||||||
/** 获取玩家在计分板中的值 @type {function(string,string):number} */
|
/** 获取玩家在计分板中的值 @type {function(string,string):number} */
|
||||||
getPlayerScore: ll.import("GMLIB_API", "getPlayerScore"),
|
getPlayerScore: ll.imports("GMLIB_API", "getPlayerScore"),
|
||||||
/** 增加玩家在计分板中的值 @type {function(string,string,number):boolean} */
|
/** 增加玩家在计分板中的值 @type {function(string,string,number):boolean} */
|
||||||
addPlayerScore: ll.import("GMLIB_API", "addPlayerScore"),
|
addPlayerScore: ll.imports("GMLIB_API", "addPlayerScore"),
|
||||||
/** 减少玩家在计分板中的值 @type {function(string,string,number):boolean} */
|
/** 减少玩家在计分板中的值 @type {function(string,string,number):boolean} */
|
||||||
reducePlayerScore: ll.import("GMLIB_API", "reducePlayerScore"),
|
reducePlayerScore: ll.imports("GMLIB_API", "reducePlayerScore"),
|
||||||
/** 设置玩家在计分板中的值 @type {function(string,string,number):boolean} */
|
/** 设置玩家在计分板中的值 @type {function(string,string,number):boolean} */
|
||||||
setPlayerScore: ll.import("GMLIB_API", "setPlayerScore"),
|
setPlayerScore: ll.imports("GMLIB_API", "setPlayerScore"),
|
||||||
/** 重置玩家在计分板中的数据 @type {function(string,string):boolean} */
|
/** 重置玩家在计分板中的数据 @type {function(string,string):boolean} */
|
||||||
resetPlayerScore: ll.import("GMLIB_API", "resetPlayerScore"),
|
resetPlayerScore: ll.imports("GMLIB_API", "resetPlayerScore"),
|
||||||
/** 重置玩家所有的计分板数据 @type {function(string):boolean} */
|
/** 重置玩家所有的计分板数据 @type {function(string):boolean} */
|
||||||
resetPlayerScores: ll.import("GMLIB_API", "resetPlayerScores"),
|
resetPlayerScores: ll.imports("GMLIB_API", "resetPlayerScores"),
|
||||||
/** 实体是否存在于计分板中 @type {function(string,string):boolean} */
|
/** 实体是否存在于计分板中 @type {function(string,string):boolean} */
|
||||||
entityHasScore: ll.import("GMLIB_API", "entityHasScore"),
|
entityHasScore: ll.imports("GMLIB_API", "entityHasScore"),
|
||||||
/** 获取实体在计分板中的值 @type {function(string,string):number} */
|
/** 获取实体在计分板中的值 @type {function(string,string):number} */
|
||||||
getEntityScore: ll.import("GMLIB_API", "getEntityScore"),
|
getEntityScore: ll.imports("GMLIB_API", "getEntityScore"),
|
||||||
/** 增加实体在计分板中的值 @type {function(string,string,number):boolean} */
|
/** 增加实体在计分板中的值 @type {function(string,string,number):boolean} */
|
||||||
addEntityScore: ll.import("GMLIB_API", "addEntityScore"),
|
addEntityScore: ll.imports("GMLIB_API", "addEntityScore"),
|
||||||
/** 减少实体在计分板中的值 @type {function(string,string,number):boolean} */
|
/** 减少实体在计分板中的值 @type {function(string,string,number):boolean} */
|
||||||
reduceEntityScore: ll.import("GMLIB_API", "reduceEntityScore"),
|
reduceEntityScore: ll.imports("GMLIB_API", "reduceEntityScore"),
|
||||||
/** 设置实体在计分板中的值 @type {function(string,string,number):boolean} */
|
/** 设置实体在计分板中的值 @type {function(string,string,number):boolean} */
|
||||||
setEntityScore: ll.import("GMLIB_API", "setEntityScore"),
|
setEntityScore: ll.imports("GMLIB_API", "setEntityScore"),
|
||||||
/** 重置实体在计分板中的数据 @type {function(string,string):boolean} */
|
/** 重置实体在计分板中的数据 @type {function(string,string):boolean} */
|
||||||
resetEntityScore: ll.import("GMLIB_API", "resetEntityScore"),
|
resetEntityScore: ll.imports("GMLIB_API", "resetEntityScore"),
|
||||||
/** 重置实体所有的计分板数据 @type {function(string):boolean} */
|
/** 重置实体所有的计分板数据 @type {function(string):boolean} */
|
||||||
resetEntityScores: ll.import("GMLIB_API", "resetEntityScores"),
|
resetEntityScores: ll.imports("GMLIB_API", "resetEntityScores"),
|
||||||
/** 字符串是否存在于计分板 @type {function(string,string):boolean} */
|
/** 字符串是否存在于计分板 @type {function(string,string):boolean} */
|
||||||
fakePlayerHasScore: ll.import("GMLIB_API", "fakePlayerHasScore"),
|
fakePlayerHasScore: ll.imports("GMLIB_API", "fakePlayerHasScore"),
|
||||||
/** 获取字符串在计分板中的值 @type {function(string,string):number} */
|
/** 获取字符串在计分板中的值 @type {function(string,string):number} */
|
||||||
getFakePlayerScore: ll.import("GMLIB_API", "getFakePlayerScore"),
|
getFakePlayerScore: ll.imports("GMLIB_API", "getFakePlayerScore"),
|
||||||
/** 增加字符串在计分板中的值 @type {function(string,string,number):boolean} */
|
/** 增加字符串在计分板中的值 @type {function(string,string,number):boolean} */
|
||||||
addFakePlayerScore: ll.import("GMLIB_API", "addFakePlayerScore"),
|
addFakePlayerScore: ll.imports("GMLIB_API", "addFakePlayerScore"),
|
||||||
/** 减少字符串在计分板中的值 @type {function(string,string,number):boolean} */
|
/** 减少字符串在计分板中的值 @type {function(string,string,number):boolean} */
|
||||||
reduceFakePlayerScore: ll.import("GMLIB_API", "reduceFakePlayerScore"),
|
reduceFakePlayerScore: ll.imports("GMLIB_API", "reduceFakePlayerScore"),
|
||||||
/** 设置字符串在计分板中的值 @type {function(string,string,number):boolean} */
|
/** 设置字符串在计分板中的值 @type {function(string,string,number):boolean} */
|
||||||
setFakePlayerScore: ll.import("GMLIB_API", "setFakePlayerScore"),
|
setFakePlayerScore: ll.imports("GMLIB_API", "setFakePlayerScore"),
|
||||||
/** 重置字符串在计分板中的数据 @type {function(string,string):boolean} */
|
/** 重置字符串在计分板中的数据 @type {function(string,string):boolean} */
|
||||||
resetFakePlayerScore: ll.import("GMLIB_API", "resetFakePlayerScore"),
|
resetFakePlayerScore: ll.imports("GMLIB_API", "resetFakePlayerScore"),
|
||||||
/** 重置字符串所有的计分板数据 @type {function(string):boolean} */
|
/** 重置字符串所有的计分板数据 @type {function(string):boolean} */
|
||||||
resetFakePlayerScores: ll.import("GMLIB_API", "resetFakePlayerScores"),
|
resetFakePlayerScores: ll.imports("GMLIB_API", "resetFakePlayerScores"),
|
||||||
/** 创建计分板 @type {function(string):boolean} */
|
/** 创建计分板 @type {function(string):boolean} */
|
||||||
addObjective: ll.import("GMLIB_API", "addObjective"),
|
addObjective: ll.imports("GMLIB_API", "addObjective"),
|
||||||
/** 创建带有显示名称的计分板 @type {function(string,string):boolean} */
|
/** 创建带有显示名称的计分板 @type {function(string,string):boolean} */
|
||||||
addObjectiveWithDisplayName: ll.import("GMLIB_API", "addObjectiveWithDisplayName"),
|
addObjectiveWithDisplayName: ll.imports("GMLIB_API", "addObjectiveWithDisplayName"),
|
||||||
/** 获取计分板显示名字 @type {function(string):string} */
|
/** 获取计分板显示名字 @type {function(string):string} */
|
||||||
getDisplayName: ll.import("GMLIB_API", "getDisplayName"),
|
getDisplayName: ll.imports("GMLIB_API", "getDisplayName"),
|
||||||
/** 设置计分板显示名字 @type {function(string,string):boolean} */
|
/** 设置计分板显示名字 @type {function(string,string):boolean} */
|
||||||
setDisplayName: ll.import("GMLIB_API", "setDisplayName"),
|
setDisplayName: ll.imports("GMLIB_API", "setDisplayName"),
|
||||||
/** 删除计分板 @type {function(string):boolean} */
|
/** 删除计分板 @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} */
|
/** 设置计分板显示 @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} */
|
/** 清除计分板显示 @type {function("list"|"sidebar"|"belowname"):void} */
|
||||||
clearDisplayObjective: ll.import("GMLIB_API", "clearDisplayObjective"),
|
clearDisplayObjective: ll.imports("GMLIB_API", "clearDisplayObjective"),
|
||||||
/** 获取所有计分板 @type {function():Array.<string>} */
|
/** 获取所有计分板 @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}>} */
|
/** 获取所有跟踪目标 @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>} */
|
/** 获取所有跟踪玩家 @type {function():Array.<string>} */
|
||||||
getAllScoreboardPlayers: ll.import("GMLIB_API", "getAllScoreboardPlayers"),
|
getAllScoreboardPlayers: ll.imports("GMLIB_API", "getAllScoreboardPlayers"),
|
||||||
/** 获取所有跟踪字符串 @type {function():Array.<string>} */
|
/** 获取所有跟踪字符串 @type {function():Array.<string>} */
|
||||||
getAllScoreboardFakePlayers: ll.import("GMLIB_API", "getAllScoreboardFakePlayers"),
|
getAllScoreboardFakePlayers: ll.imports("GMLIB_API", "getAllScoreboardFakePlayers"),
|
||||||
/** 获取所有跟踪实体 @type {function():Array.<string>} */
|
/** 获取所有跟踪实体 @type {function():Array.<string>} */
|
||||||
getAllScoreboardEntities: ll.import("GMLIB_API", "getAllScoreboardEntities"),
|
getAllScoreboardEntities: ll.imports("GMLIB_API", "getAllScoreboardEntities"),
|
||||||
/** 根据uuid获取玩家对象 @type {function(string):Player} */
|
/** 根据uuid获取玩家对象 @type {function(string):Player} */
|
||||||
getPlayerFromUuid: ll.import("GMLIB_API", "getPlayerFromUuid"),
|
getPlayerFromUuid: ll.imports("GMLIB_API", "getPlayerFromUuid"),
|
||||||
/** 根据UniqueId获取玩家对象 @type {function(string):Player} */
|
/** 根据UniqueId获取玩家对象 @type {function(string):Player} */
|
||||||
getPlayerFromUniqueId: ll.import("GMLIB_API", "getPlayerFromUniqueId"),
|
getPlayerFromUniqueId: ll.imports("GMLIB_API", "getPlayerFromUniqueId"),
|
||||||
/** 根据UniqueId获取实体对象 @type {function(string):Entity} */
|
/** 根据UniqueId获取实体对象 @type {function(string):Entity} */
|
||||||
getEntityFromUniqueId: ll.import("GMLIB_API", "getEntityFromUniqueId"),
|
getEntityFromUniqueId: ll.imports("GMLIB_API", "getEntityFromUniqueId"),
|
||||||
/** 获取世界出生点 @type {function():IntPos} */
|
/** 获取世界出生点 @type {function():IntPos} */
|
||||||
getWorldSpawn: ll.import("GMLIB_API", "getWorldSpawn"),
|
getWorldSpawn: ll.imports("GMLIB_API", "getWorldSpawn"),
|
||||||
/** 设置世界出生点 @type {function(IntPos):void} */
|
/** 设置世界出生点 @type {function(IntPos):void} */
|
||||||
setWorldSpawn: ll.import("GMLIB_API", "setWorldSpawn"),
|
setWorldSpawn: ll.imports("GMLIB_API", "setWorldSpawn"),
|
||||||
/** 获取玩家重生点 @type {function(Player):IntPos} */
|
/** 获取玩家重生点 @type {function(Player):IntPos} */
|
||||||
getPlayerSpawnPoint: ll.import("GMLIB_API", "getPlayerSpawnPoint"),
|
getPlayerSpawnPoint: ll.imports("GMLIB_API", "getPlayerSpawnPoint"),
|
||||||
/** 设置玩家重生点 @type {function(Player,IntPos):void} */
|
/** 设置玩家重生点 @type {function(Player,IntPos):void} */
|
||||||
setPlayerSpawnPoint: ll.import("GMLIB_API", "setPlayerSpawnPoint"),
|
setPlayerSpawnPoint: ll.imports("GMLIB_API", "setPlayerSpawnPoint"),
|
||||||
/** 清除玩家重生点 @type {function(Player):void} */
|
/** 清除玩家重生点 @type {function(Player):void} */
|
||||||
clearPlayerSpawnPoint: ll.import("GMLIB_API", "clearPlayerSpawnPoint"),
|
clearPlayerSpawnPoint: ll.imports("GMLIB_API", "clearPlayerSpawnPoint"),
|
||||||
/** 设置资源包路径 @type {function(string):void} */
|
/** 设置资源包路径 @type {function(string):void} */
|
||||||
setCustomPackPath: ll.import("GMLIB_API", "setCustomPackPath"),
|
setCustomPackPath: ll.imports("GMLIB_API", "setCustomPackPath"),
|
||||||
/** 获取支持的语言标识符 @type {function():Array.<string>} */
|
/** 获取支持的语言标识符 @type {function():Array.<string>} */
|
||||||
getSupportedLanguages: ll.import("GMLIB_API", "getSupportedLanguages"),
|
getSupportedLanguages: ll.imports("GMLIB_API", "getSupportedLanguages"),
|
||||||
/** 加载语言翻译 @type {function(string,string):void} */
|
/** 加载语言翻译 @type {function(string,string):void} */
|
||||||
loadLanguage: ll.import("GMLIB_API", "loadLanguage"),
|
loadLanguage: ll.imports("GMLIB_API", "loadLanguage"),
|
||||||
/** 更新或创建语言文件 @type {function(string,string,string):void} */
|
/** 更新或创建语言文件 @type {function(string,string,string):void} */
|
||||||
updateOrCreateLanguageFile: ll.import("GMLIB_API", "updateOrCreateLanguageFile"),
|
updateOrCreateLanguageFile: ll.imports("GMLIB_API", "updateOrCreateLanguageFile"),
|
||||||
/** 加载语言文件目录 @type {function(string):void} */
|
/** 加载语言文件目录 @type {function(string):void} */
|
||||||
loadLanguagePath: ll.import("GMLIB_API", "loadLanguagePath"),
|
loadLanguagePath: ll.imports("GMLIB_API", "loadLanguagePath"),
|
||||||
/** 合并json @type {function(string,string):string} */
|
/** 合并json @type {function(string,string):string} */
|
||||||
mergePatchJson: ll.import("GMLIB_API", "mergePatchJson"),
|
mergePatchJson: ll.imports("GMLIB_API", "mergePatchJson"),
|
||||||
/** 根据uuid获取xuid @type {function(string):string} */
|
/** 根据uuid获取xuid @type {function(string):string} */
|
||||||
getXuidByUuid: ll.import("GMLIB_API", "getXuidByUuid"),
|
getXuidByUuid: ll.imports("GMLIB_API", "getXuidByUuid"),
|
||||||
/** 根据uuid获取名字 @type {function(string):string} */
|
/** 根据uuid获取名字 @type {function(string):string} */
|
||||||
getNameByUuid: ll.import("GMLIB_API", "getNameByUuid"),
|
getNameByUuid: ll.imports("GMLIB_API", "getNameByUuid"),
|
||||||
/** 根据xuid获取uuid @type {function(string):string} */
|
/** 根据xuid获取uuid @type {function(string):string} */
|
||||||
getUuidByXuid: ll.import("GMLIB_API", "getUuidByXuid"),
|
getUuidByXuid: ll.imports("GMLIB_API", "getUuidByXuid"),
|
||||||
/** 根据xuid获取名字 @type {function(string):string} */
|
/** 根据xuid获取名字 @type {function(string):string} */
|
||||||
getNameByXuid: ll.import("GMLIB_API", "getNameByXuid"),
|
getNameByXuid: ll.imports("GMLIB_API", "getNameByXuid"),
|
||||||
/** 根据名字获取xuid @type {function(string):string} */
|
/** 根据名字获取xuid @type {function(string):string} */
|
||||||
getXuidByName: ll.import("GMLIB_API", "getXuidByName"),
|
getXuidByName: ll.imports("GMLIB_API", "getXuidByName"),
|
||||||
/** 根据名字获取uuid @type {function(string):string} */
|
/** 根据名字获取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}>} */
|
/** 获取所有已记录的玩家信息 @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} */
|
/** 获取方块RuntimeId @type {function(string,number):number} */
|
||||||
getBlockRuntimeId: ll.import("GMLIB_API", "getBlockRuntimeId"),
|
getBlockRuntimeId: ll.imports("GMLIB_API", "getBlockRuntimeId"),
|
||||||
/** 添加虚假列表玩家 @type {function(string,string):boolean} */
|
/** 添加虚假列表玩家 @type {function(string,string):boolean} */
|
||||||
addFakeList: ll.import("GMLIB_API", "addFakeList"),
|
addFakeList: ll.imports("GMLIB_API", "addFakeList"),
|
||||||
/** 删除虚假列表玩家 @type {function(string):boolean} */
|
/** 删除虚假列表玩家 @type {function(string):boolean} */
|
||||||
removeFakeList: ll.import("GMLIB_API", "removeFakeList"),
|
removeFakeList: ll.imports("GMLIB_API", "removeFakeList"),
|
||||||
/** 删除所有虚假列表玩家 @type {function():void} */
|
/** 删除所有虚假列表玩家 @type {function():void} */
|
||||||
removeAllFakeLists: ll.import("GMLIB_API", "removeAllFakeList"),
|
removeAllFakeLists: ll.imports("GMLIB_API", "removeAllFakeList"),
|
||||||
/** 启用I18n修复 @type {function():void} */
|
/** 启用I18n修复 @type {function():void} */
|
||||||
setFixI18nEnabled: ll.import("GMLib_ModAPI", "setFixI18nEnabled"),
|
setFixI18nEnabled: ll.imports("GMLib_ModAPI", "setFixI18nEnabled"),
|
||||||
/** 获取方块翻译键名 @type {function(Block):string} */
|
/** 获取方块翻译键名 @type {function(Block):string} */
|
||||||
getBlockTranslateKey: ll.import("GMLIB_API", "getBlockTranslateKey"),
|
getBlockTranslateKey: ll.imports("GMLIB_API", "getBlockTranslateKey"),
|
||||||
/** 获取物品翻译键名 @type {function(Item):string} */
|
/** 获取物品翻译键名 @type {function(Item):string} */
|
||||||
getItemTranslateKey: ll.import("GMLIB_API", "getItemTranslateKey"),
|
getItemTranslateKey: ll.imports("GMLIB_API", "getItemTranslateKey"),
|
||||||
/** 获取实体翻译键名 @type {function(Entity):string} */
|
/** 获取实体翻译键名 @type {function(Entity):string} */
|
||||||
getEntityTranslateKey: ll.import("GMLIB_API", "getEntityTranslateKey"),
|
getEntityTranslateKey: ll.imports("GMLIB_API", "getEntityTranslateKey"),
|
||||||
/** 从文件中读取NBT @type {function(string,boolean):NbtCompound} */
|
/** 从文件中读取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} */
|
/** 保存NBT至文件 @type {function(string,NbtCompound,boolean):void} */
|
||||||
saveNbtToFile: ll.import("GMLIB_API", "saveNbtToFile"),
|
saveNbtToFile: ll.imports("GMLIB_API", "saveNbtToFile"),
|
||||||
/** 获取方块硬度 @type {function(Block):number} */
|
/** 获取方块硬度 @type {function(Block):number} */
|
||||||
getBlockDestroySpeed: ll.import("GMLIB_API", "getBlockDestroySpeed"),
|
getBlockDestroySpeed: ll.imports("GMLIB_API", "getBlockDestroySpeed"),
|
||||||
/** 获取物品挖掘方块速度 @type {function(Item,Block):number} */
|
/** 获取物品挖掘方块速度 @type {function(Item,Block):number} */
|
||||||
getDestroyBlockSpeed: ll.import("GMLIB_API", "getDestroyBlockSpeed"),
|
getDestroyBlockSpeed: ll.imports("GMLIB_API", "getDestroyBlockSpeed"),
|
||||||
/** 使玩家挖掘方块 @type {function(Block,IntPos,Player):void} */
|
/** 使玩家挖掘方块 @type {function(Block,IntPos,Player):void} */
|
||||||
playerDestroyBlock: ll.import("GMLIB_API", "playerDestroyBlock"),
|
playerDestroyBlock: ll.imports("GMLIB_API", "playerDestroyBlock"),
|
||||||
/** 物品冒险模式下是否可以挖掘方块 @type {function(Item,Block):boolean} */
|
/** 物品冒险模式下是否可以挖掘方块 @type {function(Item,Block):boolean} */
|
||||||
itemCanDestroyBlock: ll.import("GMLIB_API", "itemCanDestroyBlock"),
|
itemCanDestroyBlock: ll.imports("GMLIB_API", "itemCanDestroyBlock"),
|
||||||
/** 物品是否能破坏方块 @type {function(Item):boolean} */
|
/** 物品是否能破坏方块 @type {function(Item):boolean} */
|
||||||
itemCanDestroyInCreative: ll.import("GMLIB_API", "itemCanDestroyInCreative"),
|
itemCanDestroyInCreative: ll.imports("GMLIB_API", "itemCanDestroyInCreative"),
|
||||||
/** 物品是否可以采集方块 @type {function(Item,Block):boolean} */
|
/** 物品是否可以采集方块 @type {function(Item,Block):boolean} */
|
||||||
itemCanDestroySpecial: ll.import("GMLIB_API", "itemCanDestroySpecial"),
|
itemCanDestroySpecial: ll.imports("GMLIB_API", "itemCanDestroySpecial"),
|
||||||
/** @type {function(Block):boolean} */
|
/** @type {function(Block):boolean} */
|
||||||
blockCanDropWithAnyTool: ll.import("GMLIB_API", "blockCanDropWithAnyTool"),
|
blockCanDropWithAnyTool: ll.imports("GMLIB_API", "blockCanDropWithAnyTool"),
|
||||||
/** @type {function(Block,Player,IntPos):boolean} */
|
/** @type {function(Block,Player,IntPos):boolean} */
|
||||||
blockPlayerWillDestroy: ll.import("GMLIB_API", "blockPlayerWillDestroy"),
|
blockPlayerWillDestroy: ll.imports("GMLIB_API", "blockPlayerWillDestroy"),
|
||||||
/** 使玩家攻击实体 @type {function(Entity,Player):boolean} */
|
/** 使玩家攻击实体 @type {function(Entity,Player):boolean} */
|
||||||
playerAttack: ll.import("GMLIB_API", "playerAttack"),
|
playerAttack: ll.imports("GMLIB_API", "playerAttack"),
|
||||||
/** @type {function(Player,Entity):boolean} */
|
/** @type {function(Player,Entity):void} */
|
||||||
playerPullInEntity: ll.import("GMLIB_API", "playerPullInEntity"),
|
playerPullInEntity: ll.imports("GMLIB_API", "playerPullInEntity"),
|
||||||
/** 根据命令空间获取翻译键名 @type {function(string):string} */
|
/** 根据命令空间获取翻译键名 @type {function(string):string} */
|
||||||
getBlockTranslateKeyFromName: ll.import("GMLIB_API", "getBlockTranslateKeyFromName"),
|
getBlockTranslateKeyFromName: ll.imports("GMLIB_API", "getBlockTranslateKeyFromName"),
|
||||||
/** 获取存档种子 @type {function():string} */
|
/** 获取存档种子 @type {function():string} */
|
||||||
getLevelSeed: ll.import("GMLib_ServerAPI", "getLevelSeed"),
|
getLevelSeed: ll.imports("GMLib_ServerAPI", "getLevelSeed"),
|
||||||
/** 获取方块亮度 @type {function(string,number):number} */
|
/** 获取方块亮度 @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"}>} */
|
/** 获取游戏规则列表 @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} */
|
/** 给物品添加附魔 @type {function(Item,string,number,boolean):boolean} */
|
||||||
applyEnchant: ll.import("GMLIB_API", "applyEnchant"),
|
applyEnchant: ll.imports("GMLIB_API", "applyEnchant"),
|
||||||
/** 删除物品所有附魔 @type {function(Item):void} */
|
/** 删除物品所有附魔 @type {function(Item):void} */
|
||||||
removeEnchants: ll.import("GMLIB_API", "removeEnchants"),
|
removeEnchants: ll.imports("GMLIB_API", "removeEnchants"),
|
||||||
/** 判断物品是否拥有附魔 @type {function(Item,string):boolean} */
|
/** 判断物品是否拥有附魔 @type {function(Item,string):boolean} */
|
||||||
hasEnchant: ll.import("GMLIB_API", "hasEnchant"),
|
hasEnchant: ll.imports("GMLIB_API", "hasEnchant"),
|
||||||
/** 获取附魔等级 @type {function(Item,string):number} */
|
/** 获取附魔等级 @type {function(Item,string):number} */
|
||||||
getEnchantLevel: ll.import("GMLIB_API", "getEnchantLevel"),
|
getEnchantLevel: ll.imports("GMLIB_API", "getEnchantLevel"),
|
||||||
/** 获取附魔名字 @type {function(string,number):number} */
|
/** 获取附魔名字 @type {function(string,number):number} */
|
||||||
getEnchantNameAndLevel: ll.import("GMLIB_API", "getEnchantNameAndLevel"),
|
getEnchantNameAndLevel: ll.imports("GMLIB_API", "getEnchantNameAndLevel"),
|
||||||
/** 通过ID获取附魔命名空间ID @type {function(number):string} */
|
/** 通过ID获取附魔命名空间ID @type {function(number):string} */
|
||||||
getEnchantTypeNameFromId: ll.import("GMLIB_API", "getEnchantTypeNameFromId"),
|
getEnchantTypeNameFromId: ll.imports("GMLIB_API", "getEnchantTypeNameFromId"),
|
||||||
/** 获取最大玩家数 @type {function():number} */
|
/** 获取最大玩家数 @type {function():number} */
|
||||||
getMaxPlayers: ll.import("GMLib_ServerAPI", "getMaxPlayers"),
|
getMaxPlayers: ll.imports("GMLib_ServerAPI", "getMaxPlayers"),
|
||||||
/** 丢出玩家背包内物品 @type {function(Player,Item,boolean):boolean} */
|
/** 丢出玩家背包内物品 @type {function(Player,Item,boolean):boolean} */
|
||||||
dropPlayerItem: ll.import("GMLIB_API", "dropPlayerItem"),
|
dropPlayerItem: ll.imports("GMLIB_API", "dropPlayerItem"),
|
||||||
/** 获取玩家的RuntimeId @type {function(Player):number} */
|
/** 获取玩家的RuntimeId @type {function(Player):number} */
|
||||||
getPlayerRuntimeId: ll.import("GMLIB_API", "getPlayerRuntimeId"),
|
getPlayerRuntimeId: ll.imports("GMLIB_API", "getPlayerRuntimeId"),
|
||||||
/** 获取实体的RuntimeId @type {function(Entity):number} */
|
/** 获取实体的RuntimeId @type {function(Entity):number} */
|
||||||
getEntityRuntimeId: ll.import("GMLIB_API", "getEntityRuntimeId"),
|
getEntityRuntimeId: ll.imports("GMLIB_API", "getEntityRuntimeId"),
|
||||||
/** 获取实体命名 @type {function(Entity):string} */
|
/** 获取实体命名 @type {function(Entity):string} */
|
||||||
getEntityNameTag: ll.import("GMLIB_API", "getEntityNameTag"),
|
getEntityNameTag: ll.imports("GMLIB_API", "getEntityNameTag"),
|
||||||
/** 物品是否有不可破坏标签 @type {function(Item):boolean} */
|
/** 物品是否有不可破坏标签 @type {function(Item):boolean} */
|
||||||
ItemisUnbreakable: ll.import("GMLIB_API", "ItemisUnbreakable"),
|
ItemisUnbreakable: ll.imports("GMLIB_API", "ItemisUnbreakable"),
|
||||||
/** 设置物品不可破坏标签 @type {function(Item,boolean):void} */
|
/** 设置物品不可破坏标签 @type {function(Item,boolean):void} */
|
||||||
setItemUnbreakable: ll.import("GMLIB_API", "setItemUnbreakable"),
|
setItemUnbreakable: ll.imports("GMLIB_API", "setItemUnbreakable"),
|
||||||
/** 物品是否死亡不会掉落 @type {function(Item):boolean} */
|
/** 物品是否死亡不会掉落 @type {function(Item):boolean} */
|
||||||
getItemShouldKeepOnDeath: ll.import("GMLIB_API", "getItemShouldKeepOnDeath"),
|
getItemShouldKeepOnDeath: ll.imports("GMLIB_API", "getItemShouldKeepOnDeath"),
|
||||||
/** 设置物品死亡不掉落 @type {function(Item,boolean):void} */
|
/** 设置物品死亡不掉落 @type {function(Item,boolean):void} */
|
||||||
setItemShouldKeepOnDeath: ll.import("GMLIB_API", "setItemShouldKeepOnDeath"),
|
setItemShouldKeepOnDeath: ll.imports("GMLIB_API", "setItemShouldKeepOnDeath"),
|
||||||
/** 获取物品锁定模式 @type {function(Item):number} */
|
/** 获取物品锁定模式 @type {function(Item):number} */
|
||||||
getItemLockMode: ll.import("GMLIB_API", "getItemLockMode"),
|
getItemLockMode: ll.imports("GMLIB_API", "getItemLockMode"),
|
||||||
/** 设置物品锁定模式 @type {function(Item,number):void} */
|
/** 设置物品锁定模式 @type {function(Item,number):void} */
|
||||||
setItemLockMode: ll.import("GMLIB_API", "setItemLockMode"),
|
setItemLockMode: ll.imports("GMLIB_API", "setItemLockMode"),
|
||||||
/** 获取物品惩罚等级 @type {function(Item):number} */
|
/** 获取物品惩罚等级 @type {function(Item):number} */
|
||||||
getItemRepairCost: ll.import("GMLIB_API", "getItemRepairCost"),
|
getItemRepairCost: ll.imports("GMLIB_API", "getItemRepairCost"),
|
||||||
/** 设置物品惩罚等级 @type {function(Item,number):void} */
|
/** 设置物品惩罚等级 @type {function(Item,number):void} */
|
||||||
setItemRepairCost: ll.import("GMLIB_API", "setItemRepairCost"),
|
setItemRepairCost: ll.imports("GMLIB_API", "setItemRepairCost"),
|
||||||
/** 获取物品冒险模式下可破坏的方块 @type {function(Item):Array.<string>} */
|
/** 获取物品冒险模式下可破坏的方块 @type {function(Item):Array.<string>} */
|
||||||
getItemCanDestroy: ll.import("GMLIB_API", "getItemCanDestroy"),
|
getItemCanDestroy: ll.imports("GMLIB_API", "getItemCanDestroy"),
|
||||||
/** 设置物品冒险模式下可破坏的方块 @type {function(Item,Array.<string>):void} */
|
/** 设置物品冒险模式下可破坏的方块 @type {function(Item,Array.<string>):void} */
|
||||||
setItemCanDestroy: ll.import("GMLIB_API", "setItemCanDestroy"),
|
setItemCanDestroy: ll.imports("GMLIB_API", "setItemCanDestroy"),
|
||||||
/** 获取物品冒险模式下能放置在什么方块上 @type {function(Item):Array.<string>} */
|
/** 获取物品冒险模式下能放置在什么方块上 @type {function(Item):Array.<string>} */
|
||||||
getItemCanPlaceOn: ll.import("GMLIB_API", "getItemCanPlaceOn"),
|
getItemCanPlaceOn: ll.imports("GMLIB_API", "getItemCanPlaceOn"),
|
||||||
/** 设置物品冒险模式下能放置在什么方块上 @type {function(Item,Array.<string>):void} */
|
/** 设置物品冒险模式下能放置在什么方块上 @type {function(Item,Array.<string>):void} */
|
||||||
setItemCanPlaceOn: ll.import("GMLIB_API", "setItemCanPlaceOn"),
|
setItemCanPlaceOn: ll.imports("GMLIB_API", "setItemCanPlaceOn"),
|
||||||
/** 获取玩家饥饿值 @type {function(Player):number} */
|
/** 获取玩家饥饿值 @type {function(Player):number} */
|
||||||
getPlayerHungry: ll.import("GMLIB_API", "getPlayerHungry"),
|
getPlayerHungry: ll.imports("GMLIB_API", "getPlayerHungry"),
|
||||||
/** 获取玩家盔甲覆盖百分比 @type {function(Player):number} */
|
/** 获取玩家盔甲覆盖百分比 @type {function(Player):number} */
|
||||||
getPlayerArmorCoverPercentage: ll.import("GMLIB_API", "getPlayerArmorCoverPercentage"),
|
getPlayerArmorCoverPercentage: ll.imports("GMLIB_API", "getPlayerArmorCoverPercentage"),
|
||||||
/** 获取玩家盔甲值 @type {function(Player):number} */
|
/** 获取玩家盔甲值 @type {function(Player):number} */
|
||||||
getPlayerArmorValue: ll.import("GMLIB_API", "getPlayerArmorValue"),
|
getPlayerArmorValue: ll.imports("GMLIB_API", "getPlayerArmorValue"),
|
||||||
/** 获取实体主人的UniqueID @type {function(Entity):Entity} */
|
/** 获取实体主人的UniqueID @type {function(Entity):Entity} */
|
||||||
getEntityOwnerUniqueId: ll.import("GMLIB_API", "getEntityOwnerUniqueId"),
|
getEntityOwnerUniqueId: ll.imports("GMLIB_API", "getEntityOwnerUniqueId"),
|
||||||
/** 获取物品分类名称 @type {function(Item):string} */
|
/** 获取物品分类名称 @type {function(Item):string} */
|
||||||
getItemCategoryName: ll.import("GMLIB_API", "getItemCategoryName"),
|
getItemCategoryName: ll.imports("GMLIB_API", "getItemCategoryName"),
|
||||||
/** 获取物品的命名 @type {function(Item):string} */
|
/** 获取物品的命名 @type {function(Item):string} */
|
||||||
getItemCustomName: ll.import("GMLIB_API", "getItemCustomName"),
|
getItemCustomName: ll.imports("GMLIB_API", "getItemCustomName"),
|
||||||
/** 获取物品BUFF效果名称 @type {function(Item):string} */
|
/** 获取物品BUFF效果名称 @type {function(Item):string} */
|
||||||
getItemEffecName: ll.import("GMLIB_API", "getItemEffecName"),
|
getItemEffecName: ll.imports("GMLIB_API", "getItemEffecName"),
|
||||||
/** 物品是否为食物 @type {function(Item):boolean} */
|
/** 物品是否为食物 @type {function(Item):boolean} */
|
||||||
itemIsFood: ll.import("GMLIB_API", "itemIsFood"),
|
itemIsFood: ll.imports("GMLIB_API", "itemIsFood"),
|
||||||
/** 设置玩家UI栏物品 @type {function(Player,number,Item):void} */
|
/** 设置玩家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} */
|
/** 获取玩家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} */
|
/** 更新玩家容器物品 @type {function(Player,number,number,Item):void} */
|
||||||
sendInventorySlotPacket: ll.import("GMLIB_API", "sendInventorySlotPacket"),
|
sendInventorySlotPacket: ll.imports("GMLIB_API", "sendInventorySlotPacket"),
|
||||||
/** 获取容器类型 @type {function(Container):string} */
|
/** 获取容器类型 @type {function(Container):string} */
|
||||||
getContainerType: ll.import("GMLIB_API", "getContainerType"),
|
getContainerType: ll.imports("GMLIB_API", "getContainerType"),
|
||||||
/** 玩家是否拥有NBT @type {function(string):boolean} */
|
/** 玩家是否拥有NBT @type {function(string):boolean} */
|
||||||
hasPlayerNbt: ll.import("GMLIB_API", "hasPlayerNbt"),
|
hasPlayerNbt: ll.imports("GMLIB_API", "hasPlayerNbt"),
|
||||||
/** 获取物品最大堆叠数量 @type {function(Item):number} */
|
/** 获取物品最大堆叠数量 @type {function(Item):number} */
|
||||||
getItemMaxCount: ll.import("GMLIB_API", "getItemMaxCount"),
|
getItemMaxCount: ll.imports("GMLIB_API", "getItemMaxCount"),
|
||||||
/** 实体包含在某族里 @type {function(Entity,string):boolean} */
|
/** 实体包含在某族里 @type {function(Entity,string):boolean} */
|
||||||
entityHasFamily: ll.import("GMLIB_API", "entityHasFamily"),
|
entityHasFamily: ll.imports("GMLIB_API", "entityHasFamily"),
|
||||||
/** 获取玩家破坏方块所需时间 @type {function(Player,Block):number} */
|
/** 获取玩家破坏方块所需时间 @type {function(Player,Block):number} */
|
||||||
getPlayerDestroyBlockProgress: ll.import("GMLIB_API", "getPlayerDestroyBlockProgress"),
|
getPlayerDestroyBlockProgress: ll.imports("GMLIB_API", "getPlayerDestroyBlockProgress"),
|
||||||
/** 获取实体的buff是否显示 @type {function(Player,number):boolean} */
|
/** 获取实体的buff是否显示 @type {function(Player,number):boolean} */
|
||||||
getEntityEffectVisible: ll.import("GMLIB_API", "getEntityEffectVisible"),
|
getEntityEffectVisible: ll.imports("GMLIB_API", "getEntityEffectVisible"),
|
||||||
/** 获取实体的buff持续时间 @type {function(Player,number):number} */
|
/** 获取实体的buff持续时间 @type {function(Player,number):number} */
|
||||||
getEntityEffectDuration: ll.import("GMLIB_API", "getEntityEffectDuration"),
|
getEntityEffectDuration: ll.imports("GMLIB_API", "getEntityEffectDuration"),
|
||||||
/** 获取实体的buff简单模式下的持续时间 @type {function(Player,number):number} */
|
/** 获取实体的buff简单模式下的持续时间 @type {function(Player,number):number} */
|
||||||
getEntityEffectDurationEasy: ll.import("GMLIB_API", "getEntityEffectDuration"),
|
getEntityEffectDurationEasy: ll.imports("GMLIB_API", "getEntityEffectDuration"),
|
||||||
/** 获取实体的buff困难模式下的持续时间 @type {function(Player,number):number} */
|
/** 获取实体的buff困难模式下的持续时间 @type {function(Player,number):number} */
|
||||||
getEntityEffectDurationHard: ll.import("GMLIB_API", "getEntityEffectDurationHard"),
|
getEntityEffectDurationHard: ll.imports("GMLIB_API", "getEntityEffectDurationHard"),
|
||||||
/** 获取实体的buff普通模式下的持续时间 @type {function(Player,number):number} */
|
/** 获取实体的buff普通模式下的持续时间 @type {function(Player,number):number} */
|
||||||
getEntityEffectDurationNormal: ll.import("GMLIB_API", "getEntityEffectDurationNormal"),
|
getEntityEffectDurationNormal: ll.imports("GMLIB_API", "getEntityEffectDurationNormal"),
|
||||||
/** 获取实体的buff效果等级 @type {function(Entity,number):number} */
|
/** 获取实体的buff效果等级 @type {function(Entity,number):number} */
|
||||||
getEntityEffectAmplifier: ll.import("GMLIB_API", "getEntityEffectAmplifier"),
|
getEntityEffectAmplifier: ll.imports("GMLIB_API", "getEntityEffectAmplifier"),
|
||||||
/** 获取实体的buff是否为信标给予 @type {function(Entity,number):boolean} */
|
/** 获取实体的buff是否为信标给予 @type {function(Entity,number):boolean} */
|
||||||
getEntityEffectAmbient: ll.import("GMLIB_API", "getEntityEffectAmbient"),
|
getEntityEffectAmbient: ll.imports("GMLIB_API", "getEntityEffectAmbient"),
|
||||||
/** 实体是否拥有buff效果 @type {function(Entity,number):boolean} */
|
/** 实体是否拥有buff效果 @type {function(Entity,number):boolean} */
|
||||||
entityHasEffect: ll.import("GMLIB_API", "entityHasEffect"),
|
entityHasEffect: ll.imports("GMLIB_API", "entityHasEffect"),
|
||||||
/** 获取实体所有buff效果 @type {function(Entity):Array.<number>} */
|
/** 获取实体所有buff效果 @type {function(Entity):Array.<number>} */
|
||||||
getEntityAllEffects: ll.import("GMLIB_API", "getEntityAllEffects"),
|
getEntityAllEffects: ll.imports("GMLIB_API", "getEntityAllEffects"),
|
||||||
/** 获取游戏难度 @type {function():number} */
|
/** 获取游戏难度 @type {function():number} */
|
||||||
getGameDifficulty: ll.import("GMLIB_API", "getGameDifficulty"),
|
getGameDifficulty: ll.imports("GMLIB_API", "getGameDifficulty"),
|
||||||
/** 设置游戏难度 @type {function(difficulty):void} */
|
/** 设置游戏难度 @type {function(difficulty):void} */
|
||||||
setGameDifficulty: ll.import("GMLIB_API", "setGameDifficulty"),
|
setGameDifficulty: ll.imports("GMLIB_API", "setGameDifficulty"),
|
||||||
/** 获取默认游戏模式 @type {function():number} */
|
/** 获取默认游戏模式 @type {function():number} */
|
||||||
getDefaultGameMode: ll.import("GMLIB_API", "getDefaultGameMode"),
|
getDefaultGameMode: ll.imports("GMLIB_API", "getDefaultGameMode"),
|
||||||
/** 设置默认游戏模式 @type {function(mode):void} */
|
/** 设置默认游戏模式 @type {function(mode):void} */
|
||||||
setDefaultGameMode: ll.import("GMLIB_API", "setDefaultGameMode"),
|
setDefaultGameMode: ll.imports("GMLIB_API", "setDefaultGameMode"),
|
||||||
/** 实体是否为某类型 @type {function(Entity, number):boolean} */
|
/** 实体是否为某类型 @type {function(Entity, number):boolean} */
|
||||||
entityIsType: ll.import("GMLIB_API", "entityIsType"),
|
entityIsType: ll.imports("GMLIB_API", "entityIsType"),
|
||||||
/** 实体是包含某类型 @type {function(Entity, number):boolean} */
|
/** 实体是包含某类型 @type {function(Entity, number):boolean} */
|
||||||
entityHasType: ll.import("GMLIB_API", "entityHasType"),
|
entityHasType: ll.imports("GMLIB_API", "entityHasType"),
|
||||||
/** 获取实体类型ID @type {function(Entity):number} */
|
/** 获取实体类型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的二进制流数据包导出接口 */
|
/** LRCA的二进制流数据包导出接口 */
|
||||||
const GMLIB_BinaryStream_API = {
|
const GMLIB_BinaryStream_API = {
|
||||||
/** 创建二进制流数据包 @type {function():number} */
|
/** 创建二进制流数据包 @type {function():number} */
|
||||||
create: ll.import("GMLIB_BinaryStream_API", "create"),
|
create: ll.imports("GMLIB_BinaryStream_API", "create"),
|
||||||
/** 拷贝二进制流数据包 @type {function(number):number} */
|
/** 拷贝二进制流数据包 @type {function(number):number} */
|
||||||
copy: ll.import("GMLIB_BinaryStream_API", "copy"),
|
copy: ll.imports("GMLIB_BinaryStream_API", "copy"),
|
||||||
/** 发送二进制流数据包 @type {function(number,player):void} */
|
/** 发送二进制流数据包 @type {function(number,player):void} */
|
||||||
sendTo: ll.import("GMLIB_BinaryStream_API", "sendTo"),
|
sendTo: ll.imports("GMLIB_BinaryStream_API", "sendTo"),
|
||||||
/** 销毁二进制流数据包 @type {function(number):void} */
|
/** 销毁二进制流数据包 @type {function(number):void} */
|
||||||
destroy: ll.import("GMLIB_BinaryStream_API", "destroy"),
|
destroy: ll.imports("GMLIB_BinaryStream_API", "destroy"),
|
||||||
/** 重置二进制流数据包 @type {function(number):void} */
|
/** 重置二进制流数据包 @type {function(number):void} */
|
||||||
reset: ll.import("GMLIB_BinaryStream_API", "reset"),
|
reset: ll.imports("GMLIB_BinaryStream_API", "reset"),
|
||||||
/** 写入二进制流数据包头部 @type {function(number, number):void} */
|
/** 写入二进制流数据包头部 @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} */
|
/** 写入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} */
|
/** 写入物品 @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} */
|
/** 写入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} */
|
/** 写入字符串 @type {function(number, string):void} */
|
||||||
writeString: ll.import("GMLIB_BinaryStream_API", "writeString"),
|
writeString: ll.imports("GMLIB_BinaryStream_API", "writeString"),
|
||||||
/** 写入布尔值 @type {function(number, boolean):void} */
|
/** 写入布尔值 @type {function(number, boolean):void} */
|
||||||
writeBool: ll.import("GMLIB_BinaryStream_API", "writeBool"),
|
writeBool: ll.imports("GMLIB_BinaryStream_API", "writeBool"),
|
||||||
/** 写入字节 @type {function(number, number):void} */
|
/** 写入字节 @type {function(number, number):void} */
|
||||||
writeByte: ll.import("GMLIB_BinaryStream_API", "writeByte"),
|
writeByte: ll.imports("GMLIB_BinaryStream_API", "writeByte"),
|
||||||
/** 写入双精度浮点数 @type {function(number, number):void} */
|
/** 写入双精度浮点数 @type {function(number, number):void} */
|
||||||
writeDouble: ll.import("GMLIB_BinaryStream_API", "writeDouble"),
|
writeDouble: ll.imports("GMLIB_BinaryStream_API", "writeDouble"),
|
||||||
/** 写入浮点数 @type {function(number, number):void} */
|
/** 写入浮点数 @type {function(number, number):void} */
|
||||||
writeFloat: ll.import("GMLIB_BinaryStream_API", "writeFloat"),
|
writeFloat: ll.imports("GMLIB_BinaryStream_API", "writeFloat"),
|
||||||
/** @type {function(number, number):void} */
|
/** @type {function(number, number):void} */
|
||||||
writeSignedBigEndianInt: ll.import("GMLIB_BinaryStream_API", "writeSignedBigEndianInt"),
|
writeSignedBigEndianInt: ll.imports("GMLIB_BinaryStream_API", "writeSignedBigEndianInt"),
|
||||||
/** @type {function(number, number):void} */
|
/** @type {function(number, number):void} */
|
||||||
writeSignedInt: ll.import("GMLIB_BinaryStream_API", "writeSignedInt"),
|
writeSignedInt: ll.imports("GMLIB_BinaryStream_API", "writeSignedInt"),
|
||||||
/** @type {function(number, number):void} */
|
/** @type {function(number, number):void} */
|
||||||
writeSignedInt64: ll.import("GMLIB_BinaryStream_API", "writeSignedInt64"),
|
writeSignedInt64: ll.imports("GMLIB_BinaryStream_API", "writeSignedInt64"),
|
||||||
/** @type {function(number, number):void} */
|
/** @type {function(number, number):void} */
|
||||||
writeSignedShort: ll.import("GMLIB_BinaryStream_API", "writeSignedShort"),
|
writeSignedShort: ll.imports("GMLIB_BinaryStream_API", "writeSignedShort"),
|
||||||
/** @type {function(number, number):void} */
|
/** @type {function(number, number):void} */
|
||||||
writeUnsignedChar: ll.import("GMLIB_BinaryStream_API", "writeUnsignedChar"),
|
writeUnsignedChar: ll.imports("GMLIB_BinaryStream_API", "writeUnsignedChar"),
|
||||||
/** @type {function(number, number):void} */
|
/** @type {function(number, number):void} */
|
||||||
writeUnsignedInt: ll.import("GMLIB_BinaryStream_API", "writeUnsignedInt"),
|
writeUnsignedInt: ll.imports("GMLIB_BinaryStream_API", "writeUnsignedInt"),
|
||||||
/** @type {function(number, number):void} */
|
/** @type {function(number, number):void} */
|
||||||
writeUnsignedInt64: ll.import("GMLIB_BinaryStream_API", "writeUnsignedInt64"),
|
writeUnsignedInt64: ll.imports("GMLIB_BinaryStream_API", "writeUnsignedInt64"),
|
||||||
/** @type {function(number, number):void} */
|
/** @type {function(number, number):void} */
|
||||||
writeUnsignedShort: ll.import("GMLIB_BinaryStream_API", "writeUnsignedShort"),
|
writeUnsignedShort: ll.imports("GMLIB_BinaryStream_API", "writeUnsignedShort"),
|
||||||
/** @type {function(number, number):void} */
|
/** @type {function(number, number):void} */
|
||||||
writeUnsignedVarInt: ll.import("GMLIB_BinaryStream_API", "writeUnsignedVarInt"),
|
writeUnsignedVarInt: ll.imports("GMLIB_BinaryStream_API", "writeUnsignedVarInt"),
|
||||||
/** @type {function(number, number):void} */
|
/** @type {function(number, number):void} */
|
||||||
writeUnsignedVarInt64: ll.import("GMLIB_BinaryStream_API", "writeUnsignedVarInt64"),
|
writeUnsignedVarInt64: ll.imports("GMLIB_BinaryStream_API", "writeUnsignedVarInt64"),
|
||||||
/** @type {function(number, number):void} */
|
/** @type {function(number, number):void} */
|
||||||
writeVarInt: ll.import("GMLIB_BinaryStream_API", "writeVarInt"),
|
writeVarInt: ll.imports("GMLIB_BinaryStream_API", "writeVarInt"),
|
||||||
/** @type {function(number, number):void} */
|
/** @type {function(number, number):void} */
|
||||||
writeVarInt64: ll.import("GMLIB_BinaryStream_API", "writeVarInt64"),
|
writeVarInt64: ll.imports("GMLIB_BinaryStream_API", "writeVarInt64"),
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 静态悬浮字类列表 @type {Map<number,StaticFloatingText>} */
|
/** 静态悬浮字类列表 @type {Map<number,StaticFloatingText>} */
|
||||||
@@ -2291,14 +2293,14 @@ class GMLIB_BinaryStream {
|
|||||||
this.writeUnsignedVarInt(data.id);
|
this.writeUnsignedVarInt(data.id);
|
||||||
this.writeUnsignedVarInt(data.type);
|
this.writeUnsignedVarInt(data.type);
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case 0: this.writeByte(data.value); break;
|
case 0: this.writeUnsignedChar(data.value); break;
|
||||||
case 1: this.writeSignedShort(data.value); break;
|
case 1: this.writeUnsignedShort(data.value); break;
|
||||||
case 2: this.writeSignedInt(data.value); break;
|
case 2: this.writeVarInt(data.value); break;
|
||||||
case 3: this.writeFloat(data.value); break;
|
case 3: this.writeFloat(data.value); break;
|
||||||
case 4: this.writeString(data.value); break;
|
case 4: this.writeString(data.value); break;
|
||||||
case 5: this.writeCompoundTag(data.value); break;
|
case 5: this.writeCompoundTag(data.value); break;
|
||||||
case 6: this.writeBlockPos(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;
|
case 8: this.writeVec3(data.value); break;
|
||||||
default: throw new Error("Unknown data type");
|
default: throw new Error("Unknown data type");
|
||||||
}
|
}
|
||||||
@@ -2739,10 +2741,9 @@ LLSE_Player.prototype.pullInEntity =
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {Entity} entity 实体对象
|
* @param {Entity} entity 实体对象
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
*/
|
||||||
function (entity) {
|
function (entity) {
|
||||||
return GMLIB_API.playerPullInEntity(this, entity);
|
GMLIB_API.playerPullInEntity(this, entity);
|
||||||
};
|
};
|
||||||
|
|
||||||
LLSE_Item.prototype.applyEnchant =
|
LLSE_Item.prototype.applyEnchant =
|
||||||
@@ -3035,6 +3036,15 @@ LLSE_Player.prototype.sendInventorySlotPacket =
|
|||||||
GMLIB_API.sendInventorySlotPacket(this, containerId, slot, item);
|
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 =
|
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;
|
||||||
|
}
|
||||||
|
};
|
||||||
+6
-3
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "${pluginName}",
|
"name": "${modName}",
|
||||||
"entry": "${pluginFile}",
|
"entry": "${modFile}",
|
||||||
"version": "0.13.6",
|
"version": "${modVersion}",
|
||||||
"author": "GroupMountain",
|
"author": "GroupMountain",
|
||||||
"type": "native",
|
"type": "native",
|
||||||
"passive": true,
|
"passive": true,
|
||||||
@@ -11,6 +11,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "LegacyRemoteCall"
|
"name": "LegacyRemoteCall"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "iListenAttentively"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
function beautify_json(value, indent)
|
|
||||||
import("core.base.json")
|
|
||||||
local json_text = ""
|
|
||||||
local stack = {}
|
|
||||||
|
|
||||||
local function escape_str(s)
|
|
||||||
return string.gsub(s, '[%c\\"]', function(c)
|
|
||||||
local replacements = {['\b'] = '\\b', ['\f'] = '\\f', ['\n'] = '\\n', ['\r'] = '\\r', ['\t'] = '\\t', ['"'] = '\\"', ['\\'] = '\\\\'}
|
|
||||||
return replacements[c] or string.format('\\u%04x', c:byte())
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function is_null(v)
|
|
||||||
return v == json.null
|
|
||||||
end
|
|
||||||
|
|
||||||
local function is_empty_table(t)
|
|
||||||
if type(t) ~= 'table' then return false end
|
|
||||||
for _ in pairs(t) do
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
local function is_array(t)
|
|
||||||
return type(t) == 'table' and json.is_marked_as_array(t) or #t > 0
|
|
||||||
end
|
|
||||||
|
|
||||||
local function serialize(val, level)
|
|
||||||
local spaces = string.rep(" ", level * indent)
|
|
||||||
|
|
||||||
if type(val) == "table" and not stack[val] then
|
|
||||||
if is_empty_table(val) then
|
|
||||||
json_text = json_text .. (is_array(val) and "[]" or "{}")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
stack[val] = true
|
|
||||||
local isArray = is_array(val)
|
|
||||||
json_text = json_text .. (isArray and "[\n" or "{\n")
|
|
||||||
|
|
||||||
local keys = isArray and {} or {}
|
|
||||||
for k in pairs(val) do
|
|
||||||
table.insert(keys, k)
|
|
||||||
end
|
|
||||||
if not isArray then
|
|
||||||
table.sort(keys)
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, k in ipairs(keys) do
|
|
||||||
local v = val[k]
|
|
||||||
json_text = json_text .. spaces .. (isArray and "" or '"' .. escape_str(tostring(k)) .. '": ')
|
|
||||||
serialize(v, level + 1)
|
|
||||||
json_text = json_text .. ",\n"
|
|
||||||
end
|
|
||||||
|
|
||||||
json_text = string.sub(json_text, 1, -3) .. "\n" .. string.rep(" ", (level - 1) * indent) .. (isArray and "]" or "}")
|
|
||||||
stack[val] = nil
|
|
||||||
elseif type(val) == "string" then
|
|
||||||
json_text = json_text .. '"' .. escape_str(val) .. '"'
|
|
||||||
elseif type(val) == "number" then
|
|
||||||
if val % 1 == 0 then
|
|
||||||
json_text = json_text .. tostring(math.floor(val))
|
|
||||||
else
|
|
||||||
json_text = json_text .. tostring(val)
|
|
||||||
end
|
|
||||||
elseif type(val) == "boolean" then
|
|
||||||
json_text = json_text .. tostring(val)
|
|
||||||
elseif is_null(val) then
|
|
||||||
json_text = json_text .. "null"
|
|
||||||
else
|
|
||||||
error("Invalid value type: " .. type(val))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
serialize(value, 1)
|
|
||||||
return json_text
|
|
||||||
end
|
|
||||||
|
|
||||||
function string_formatter(str, variables)
|
|
||||||
return str:gsub("%${(.-)}", function(var)
|
|
||||||
return variables[var] or "${" .. var .. "}"
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
function pack_plugin(target,plugin_define)
|
|
||||||
import("lib.detect.find_file")
|
|
||||||
|
|
||||||
local manifest_path = find_file("manifest.json", os.projectdir())
|
|
||||||
if manifest_path then
|
|
||||||
local manifest = io.readfile(manifest_path)
|
|
||||||
local bindir = path.join(os.projectdir(), "bin/DLL")
|
|
||||||
local pdbdir = path.join(os.projectdir(), "bin/PDB")
|
|
||||||
local outputdir = path.join(bindir, plugin_define.pluginName)
|
|
||||||
local targetfile = path.join(outputdir, plugin_define.pluginFile)
|
|
||||||
local pdbfile = path.join(pdbdir, path.basename(plugin_define.pluginFile) .. ".pdb")
|
|
||||||
local libfile = path.join(os.projectdir(), "lib")
|
|
||||||
local manifestfile = path.join(outputdir, "manifest.json")
|
|
||||||
local oritargetfile = target:targetfile()
|
|
||||||
local oripdbfile = path.join(path.directory(oritargetfile), path.basename(oritargetfile) .. ".pdb")
|
|
||||||
|
|
||||||
os.mkdir(outputdir)
|
|
||||||
os.cp(oritargetfile, targetfile)
|
|
||||||
if os.isfile(oripdbfile) then
|
|
||||||
os.cp(oripdbfile, pdbfile)
|
|
||||||
end
|
|
||||||
os.cp(libfile, outputdir)
|
|
||||||
|
|
||||||
formattedmanifest = string_formatter(manifest, plugin_define)
|
|
||||||
io.writefile(manifestfile,formattedmanifest)
|
|
||||||
cprint("${bright green}[Plugin Packer]: ${reset}plugin already generated to " .. outputdir)
|
|
||||||
else
|
|
||||||
cprint("${bright yellow}warn: ${reset}not found manifest.json in root dir!")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
|
||||||
pack_plugin = pack_plugin,
|
|
||||||
beautify_json = beautify_json,
|
|
||||||
string_formatter = string_formatter
|
|
||||||
}
|
|
||||||
+14
-9
@@ -1,15 +1,14 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
using namespace ll::hash_utils;
|
|
||||||
|
|
||||||
class LegacyScriptBinaryStreamManager {
|
class LegacyScriptBinaryStreamManager {
|
||||||
private:
|
private:
|
||||||
int64 mNextBinaryStreamId = 0;
|
int64 mNextBinaryStreamId = 0;
|
||||||
std::unordered_map<uint64, std::shared_ptr<GMLIB_BinaryStream>> mBinaryStream;
|
std::unordered_map<uint64, std::shared_ptr<GMBinaryStream>> mBinaryStream;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
uint getNextId() { return mNextBinaryStreamId++; }
|
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) {
|
uint64 copyBinaryStream(uint id) {
|
||||||
auto nextId = getNextId();
|
auto nextId = getNextId();
|
||||||
@@ -22,7 +21,7 @@ public:
|
|||||||
|
|
||||||
void removeBinaryStream(uint64 id) { mBinaryStream.erase(id); }
|
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;
|
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...)> {
|
struct Info<R (T::*)(A, AS...)> {
|
||||||
using ArgT = A;
|
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() {
|
void Export_BinaryStream_API() {
|
||||||
RemoteCall::exportAs("GMLIB_BinaryStream_API", "create", []() -> uint64 {
|
RemoteCall::exportAs("GMLIB_BinaryStream_API", "create", []() -> uint64 {
|
||||||
@@ -60,19 +59,26 @@ void Export_BinaryStream_API() {
|
|||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_BinaryStream_API", "reset", [](uint64 id) -> void {
|
RemoteCall::exportAs("GMLIB_BinaryStream_API", "reset", [](uint64 id) -> void {
|
||||||
if (BinaryStreamManager.getBinaryStream(id) == nullptr) BinaryStreamManager.cretateBinaryStream(id);
|
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 {
|
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 {
|
RemoteCall::exportAs("GMLIB_BinaryStream_API", "destroy", [](uint64 id) -> void {
|
||||||
BinaryStreamManager.removeBinaryStream(id);
|
BinaryStreamManager.removeBinaryStream(id);
|
||||||
});
|
});
|
||||||
EXPORTAPI("writePacketHeader", int, bs->writePacketHeader((MinecraftPacketIds)value));
|
EXPORTAPI("writePacketHeader", int, bs->writePacketHeader((MinecraftPacketIds)value));
|
||||||
EXPORTAPI("writeUuid", std::string const&, bs->writeUuid(mce::UUID::fromString(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("writeString", std::string const&, bs->writeString(value));
|
||||||
EXPORTAPI("writeCompoundTag", CompoundTag*, bs->writeCompoundTag(*value));
|
EXPORTAPI("writeCompoundTag", CompoundTag*, bs->writeCompoundTag(*value));
|
||||||
|
EXPORTAPI("writeUnsignedChar", uchar, bs->writeUnsignedChar(value));
|
||||||
EXPORTAPI2(writeBool);
|
EXPORTAPI2(writeBool);
|
||||||
EXPORTAPI2(writeByte);
|
EXPORTAPI2(writeByte);
|
||||||
EXPORTAPI2(writeDouble);
|
EXPORTAPI2(writeDouble);
|
||||||
@@ -81,7 +87,6 @@ void Export_BinaryStream_API() {
|
|||||||
EXPORTAPI2(writeSignedInt);
|
EXPORTAPI2(writeSignedInt);
|
||||||
EXPORTAPI2(writeSignedInt64);
|
EXPORTAPI2(writeSignedInt64);
|
||||||
EXPORTAPI2(writeSignedShort);
|
EXPORTAPI2(writeSignedShort);
|
||||||
EXPORTAPI2(writeUnsignedChar);
|
|
||||||
EXPORTAPI2(writeUnsignedInt);
|
EXPORTAPI2(writeUnsignedInt);
|
||||||
EXPORTAPI2(writeUnsignedInt64);
|
EXPORTAPI2(writeUnsignedInt64);
|
||||||
EXPORTAPI2(writeUnsignedShort);
|
EXPORTAPI2(writeUnsignedShort);
|
||||||
|
|||||||
+312
-239
File diff suppressed because it is too large
Load Diff
+10
-2
@@ -9,6 +9,7 @@ LegacyRemoteCallApi& LegacyRemoteCallApi::getInstance() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool LegacyRemoteCallApi::load() {
|
bool LegacyRemoteCallApi::load() {
|
||||||
|
(void)CustomRecipeRegistry::getInstance();
|
||||||
Export_Legacy_GMLib_ModAPI();
|
Export_Legacy_GMLib_ModAPI();
|
||||||
Export_Legacy_GMLib_ServerAPI();
|
Export_Legacy_GMLib_ServerAPI();
|
||||||
Export_Compatibility_API();
|
Export_Compatibility_API();
|
||||||
@@ -20,8 +21,8 @@ bool LegacyRemoteCallApi::load() {
|
|||||||
logger->info("GMLIB-LegacyRemoteCallApi Loaded!");
|
logger->info("GMLIB-LegacyRemoteCallApi Loaded!");
|
||||||
logger->info(
|
logger->info(
|
||||||
"Loaded Version: {} with {}",
|
"Loaded Version: {} with {}",
|
||||||
fmt::format(fg(fmt::color::pink), "GMLIB-" + GMLIB::Version::getLibVersionString()),
|
fmt::format(fg(fmt::color::pink), "GMLIB-" GMLIB_FILE_VERSION_STRING),
|
||||||
fmt::format(fg(fmt::color::light_green), "GMLIB-LegacyRemoteCallApi-" + LIB_VERSION.asString())
|
fmt::format(fg(fmt::color::light_green), "GMLIB-LegacyRemoteCallApi-{}", LIB_VERSION.to_string())
|
||||||
);
|
);
|
||||||
logger->info("Author: GroupMountain");
|
logger->info("Author: GroupMountain");
|
||||||
logger->info("Repository: https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi");
|
logger->info("Repository: https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi");
|
||||||
@@ -35,3 +36,10 @@ bool LegacyRemoteCallApi::disable() { return true; }
|
|||||||
} // namespace gmlib
|
} // namespace gmlib
|
||||||
|
|
||||||
LL_REGISTER_MOD(gmlib::LegacyRemoteCallApi, gmlib::LegacyRemoteCallApi::getInstance());
|
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(); }
|
||||||
+5
-1
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <ll/api/mod/NativeMod.h>
|
#include <ll/api/mod/NativeMod.h>
|
||||||
#include <ll/api/mod/RegisterHelper.h>
|
#include <ll/api/mod/RegisterHelper.h>
|
||||||
|
#include <ll/api/thread/ThreadPoolExecutor.h>
|
||||||
|
|
||||||
namespace gmlib {
|
namespace gmlib {
|
||||||
|
|
||||||
@@ -9,7 +10,7 @@ class LegacyRemoteCallApi {
|
|||||||
public:
|
public:
|
||||||
static LegacyRemoteCallApi& getInstance();
|
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; }
|
[[nodiscard]] ll::mod::NativeMod& getSelf() const { return mSelf; }
|
||||||
|
|
||||||
@@ -26,8 +27,11 @@ public:
|
|||||||
// /// @return True if the plugin is unloaded successfully.
|
// /// @return True if the plugin is unloaded successfully.
|
||||||
// bool unload();
|
// bool unload();
|
||||||
|
|
||||||
|
ll::thread::ThreadPoolExecutor& getThreadPoolExecutor() { return mThreadPoolExecutor; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ll::mod::NativeMod& mSelf;
|
ll::mod::NativeMod& mSelf;
|
||||||
|
ll::thread::ThreadPoolExecutor mThreadPoolExecutor;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace gmlib
|
} // namespace gmlib
|
||||||
|
|||||||
+74
-112
@@ -83,208 +83,176 @@ void Export_Event_API() {
|
|||||||
}
|
}
|
||||||
case doHash("gmlib::ClientLoginAfterEvent"): {
|
case doHash("gmlib::ClientLoginAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
GMLIB::Event::PacketEvent::ClientLoginAfterEvent,
|
ila::mc::ClientLoginAfterEvent,
|
||||||
(std::string const& realName,
|
(std::string const& realName,
|
||||||
std::string const& uuid,
|
std::string const& uuid,
|
||||||
std::string const& serverXuid,
|
std::string const& serverXuid,
|
||||||
std::string const& clientXuid),
|
std::string const& clientXuid),
|
||||||
(event.getRealName(),
|
(event.realName(), event.uuid().asString(), event.serverAuthXuid(), event.clientAuthXuid()),
|
||||||
event.getUuid().asString(),
|
|
||||||
event.getServerAuthXuid(),
|
|
||||||
event.getClientAuthXuid()),
|
|
||||||
if (result) event.disConnectClient();
|
if (result) event.disConnectClient();
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("gmlib::WeatherUpdateBeforeEvent"): {
|
case doHash("gmlib::WeatherUpdateBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
GMLIB::Event::LevelEvent::WeatherUpdateBeforeEvent,
|
ila::mc::WeatherUpdateBeforeEvent,
|
||||||
(float rainLevel, int rainTime, float lightningLevel, int lightningTime, bool isCancelled),
|
(float rainLevel, int rainTime, float lightningLevel, int lightningTime, bool isCancelled),
|
||||||
(event.getRainLevel(),
|
(event.rainLevel(),
|
||||||
event.getRainingLastTick(),
|
event.rainTime(),
|
||||||
event.getLightningLevel(),
|
event.lightningLevel(),
|
||||||
event.getLightningLastTick(),
|
event.lightningTime(),
|
||||||
event.isCancelled()),
|
event.isCancelled()),
|
||||||
event.setCancelled(result);
|
event.setCancelled(result);
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("gmlib::WeatherUpdateAfterEvent"): {
|
case doHash("gmlib::WeatherUpdateAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
GMLIB::Event::LevelEvent::WeatherUpdateAfterEvent,
|
ila::mc::WeatherUpdateAfterEvent,
|
||||||
(float rainLevel, int rainTime, float lightningLevel, int lightningTime),
|
(float rainLevel, int rainTime, float lightningLevel, int lightningTime),
|
||||||
(event.getRainLevel(),
|
(event.rainLevel(), event.rainTime(), event.lightningLevel(), event.lightningTime()),
|
||||||
event.getRainingLastTick(),
|
|
||||||
event.getLightningLevel(),
|
|
||||||
event.getLightningLastTick()),
|
|
||||||
,
|
,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("gmlib::MobPickupItemBeforeEvent"): {
|
case doHash("gmlib::MobPickupItemBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(ila::mc::ActorPickupItemBeforeEvent,
|
||||||
GMLIB::Event::EntityEvent::MobPickupItemBeforeEvent,
|
|
||||||
(Actor * mob, Actor * item, bool isCancelled),
|
(Actor * mob, Actor * item, bool isCancelled),
|
||||||
(&event.self(), (Actor*)&event.getItemActor(), event.isCancelled()),
|
(&event.self(), (Actor*)&event.itemActor(), event.isCancelled()),
|
||||||
event.setCancelled(result);
|
event.setCancelled(result););
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case doHash("gmlib::MobPickupItemAfterEvent"): {
|
case doHash("gmlib::MobPickupItemAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
GMLIB::Event::EntityEvent::MobPickupItemAfterEvent,
|
ila::mc::ActorPickupItemAfterEvent,
|
||||||
(Actor * mob, Actor * item),
|
(Actor * mob, Actor * item),
|
||||||
(&event.self(), (Actor*)&event.getItemActor()),
|
(&event.self(), (Actor*)&event.itemActor()),
|
||||||
,
|
,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("gmlib::ItemActorSpawnBeforeEvent"): {
|
case doHash("gmlib::ItemActorSpawnBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
GMLIB::Event::EntityEvent::ItemActorSpawnBeforeEvent,
|
ila::mc::SpawnItemActorBeforeEvent,
|
||||||
(ItemStack * item, std::pair<Vec3, int> position, int64 spawnerUniqueId, bool isCancelled),
|
(ItemStack * item, std::pair<Vec3, int> position, int64 spawnerUniqueId, bool isCancelled),
|
||||||
(&event.getItem(),
|
(&event.item(),
|
||||||
{event.getPosition(), event.getBlockSource().getDimensionId().id},
|
{event.pos(), event.blockSource().getDimensionId().id},
|
||||||
event.getSpawner().has_value() ? event.getSpawner()->getOrCreateUniqueID().rawID : -1,
|
event.spawner() ? event.spawner()->getOrCreateUniqueID().rawID : -1,
|
||||||
event.isCancelled()),
|
event.isCancelled()),
|
||||||
event.setCancelled(result);
|
event.setCancelled(result);
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("gmlib::ItemActorSpawnAfterEvent"): {
|
case doHash("gmlib::ItemActorSpawnAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
GMLIB::Event::EntityEvent::ItemActorSpawnAfterEvent,
|
ila::mc::SpawnItemActorAfterEvent,
|
||||||
(Actor * item, std::pair<Vec3, int> position, int64 spawnerUniqueId),
|
(Actor * item, std::pair<Vec3, int> position, int64 spawnerUniqueId),
|
||||||
(&event.self(),
|
(&event.itemActor(),
|
||||||
{event.getPosition(), event.getBlockSource().getDimensionId().id},
|
{event.pos(), event.blockSource().getDimensionId().id},
|
||||||
event.getSpawner().has_value() ? event.getSpawner()->getOrCreateUniqueID().rawID : -1),
|
event.spawner() ? event.spawner()->getOrCreateUniqueID().rawID : -1),
|
||||||
,
|
,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("gmlib::ActorChangeDimensionBeforeEvent"): {
|
case doHash("gmlib::ActorChangeDimensionBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(ila::mc::ActorChangeDimensionBeforeEvent,
|
||||||
GMLIB::Event::EntityEvent::ActorChangeDimensionBeforeEvent,
|
|
||||||
(Actor * entity, int toDimId, bool isCancelled),
|
(Actor * entity, int toDimId, bool isCancelled),
|
||||||
(&event.self(), event.getToDimensionId(), event.isCancelled()),
|
(&event.self(), event.toDimensionId(), event.isCancelled()),
|
||||||
event.setCancelled(result);
|
event.setCancelled(result););
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case doHash("gmlib::ActorChangeDimensionAfterEvent"): {
|
case doHash("gmlib::ActorChangeDimensionAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
GMLIB::Event::EntityEvent::ActorChangeDimensionAfterEvent,
|
ila::mc::ActorChangeDimensionAfterEvent,
|
||||||
(Actor * entity, int fromDimId, int toDimId),
|
(Actor * entity, int fromDimId, int toDimId),
|
||||||
(&event.self(), event.getFromDimensionId(), event.getToDimensionId()),
|
(&event.self(), event.fromDimensionId(), event.toDimensionId()),
|
||||||
,
|
,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("gmlib::PlayerStartSleepBeforeEvent"): {
|
case doHash("gmlib::PlayerStartSleepBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(ila::mc::PlayerStartSleepBeforeEvent,
|
||||||
GMLIB::Event::PlayerEvent::PlayerStartSleepBeforeEvent,
|
|
||||||
(Player * entity, BlockPos pos, bool isCancelled),
|
(Player * entity, BlockPos pos, bool isCancelled),
|
||||||
(&event.self(), event.getPosition(), event.isCancelled()),
|
(&event.self(), event.pos(), event.isCancelled()),
|
||||||
event.setCancelled(result);
|
event.setCancelled(result););
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case doHash("gmlib::PlayerStartSleepAfterEvent"): {
|
case doHash("gmlib::PlayerStartSleepAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
GMLIB::Event::PlayerEvent::PlayerStartSleepAfterEvent,
|
ila::mc::PlayerStartSleepAfterEvent,
|
||||||
(Player * entity, BlockPos pos, int result),
|
(Player * entity, BlockPos pos, int result),
|
||||||
(&event.self(), event.getPosition(), (int)event.getResult()),
|
(&event.self(), event.pos(), (int)event.result()),
|
||||||
,
|
,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("gmlib::PlayerStopSleepBeforeEvent"): {
|
case doHash("gmlib::PlayerStopSleepBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
GMLIB::Event::PlayerEvent::PlayerStopSleepBeforeEvent,
|
ila::mc::PlayerStopSleepBeforeEvent,
|
||||||
(Player * entity, bool forcefulWakeUp, bool updateLevelList, bool isCancelled),
|
(Player * entity, bool forcefulWakeUp, bool updateLevelList, bool isCancelled),
|
||||||
(&event.self(), event.isForcefulWakeUp(), event.isUpdateLevelList(), event.isCancelled()),
|
(&event.self(), event.forcefulWakeUp(), event.updateLevelList(), false),
|
||||||
event.setCancelled(result);
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("gmlib::PlayerStopSleepAfterEvent"): {
|
case doHash("gmlib::PlayerStopSleepAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
GMLIB::Event::PlayerEvent::PlayerStopSleepAfterEvent,
|
ila::mc::PlayerStopSleepAfterEvent,
|
||||||
(Player * entity, bool forcefulWakeUp, bool updateLevelList, bool),
|
(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"): {
|
case doHash("gmlib::DeathMessageAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
GMLIB::Event::EntityEvent::DeathMessageAfterEvent,
|
ila::mc::DeathMessageAfterEvent,
|
||||||
(std::string const& message, std::vector<std::string>, Actor* dead),
|
(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"): {
|
case doHash("gmlib::MobHurtAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
GMLIB::Event::EntityEvent::MobHurtAfterEvent,
|
ila::mc::MobHealthChangeAfterEvent,
|
||||||
(Actor * mob, Actor * source, float damage, int cause),
|
(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;
|
Actor* source = nullptr;
|
||||||
if (damageSource.isEntitySource()) {
|
if (damageSource->isEntitySource()) {
|
||||||
auto uniqueId = damageSource.getDamagingEntityUniqueID();
|
auto uniqueId = damageSource->getDamagingEntityUniqueID();
|
||||||
source = ll::service::getLevel()->fetchEntity(uniqueId, false);
|
source = ll::service::getLevel()->fetchEntity(uniqueId, false);
|
||||||
if (source->getOwner()) source = source->getOwner();
|
if (source->getOwner()) source = source->getOwner();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("gmlib::EndermanTakeBlockBeforeEvent"): {
|
case doHash("gmlib::EndermanTakeBlockBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(ila::mc::EndermanTakeBlockBeforeEvent,
|
||||||
GMLIB::Event::EntityEvent::EndermanTakeBlockBeforeEvent,
|
|
||||||
(Actor * mob, bool isCancelled),
|
(Actor * mob, bool isCancelled),
|
||||||
(&event.self(), event.isCancelled()),
|
(&event.self(), event.isCancelled()),
|
||||||
event.setCancelled(result);
|
event.setCancelled(result););
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case doHash("gmlib::DragonRespawnBeforeEvent"): {
|
case doHash("gmlib::DragonRespawnBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(ila::mc::DragonRespawnBeforeEvent,
|
||||||
GMLIB::Event::EntityEvent::DragonRespawnBeforeEvent,
|
|
||||||
(bool isCancelled),
|
(bool isCancelled),
|
||||||
(event.isCancelled()),
|
(event.isCancelled()),
|
||||||
event.setCancelled(result);
|
event.setCancelled(result););
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case doHash("gmlib::DragonRespawnAfterEvent"): {
|
case doHash("gmlib::DragonRespawnAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(ila::mc::DragonRespawnAfterEvent, (Actor * mob), (&event.self()), );
|
||||||
GMLIB::Event::EntityEvent::DragonRespawnAfterEvent,
|
|
||||||
(Actor * mob),
|
|
||||||
(event.getEnderDragon()),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case doHash("gmlib::ProjectileCreateBeforeEvent"): {
|
case doHash("gmlib::ProjectileCreateBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(ila::mc::ProjectileCreateBeforeEvent,
|
||||||
GMLIB::Event::EntityEvent::ProjectileCreateBeforeEvent,
|
|
||||||
(Actor * mob, int64 uniqueId, bool isCancelled),
|
(Actor * mob, int64 uniqueId, bool isCancelled),
|
||||||
(&event.self(),
|
(&event.self(), event.self().getOwnerId().rawID, event.isCancelled()),
|
||||||
event.getShooter() ? event.getShooter()->getOrCreateUniqueID().rawID : -1,
|
event.setCancelled(result););
|
||||||
event.isCancelled()),
|
|
||||||
event.setCancelled(result);
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case doHash("gmlib::ProjectileCreateAfterEvent"): {
|
case doHash("gmlib::ProjectileCreateAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
GMLIB::Event::EntityEvent::ProjectileCreateAfterEvent,
|
ila::mc::ProjectileCreateAfterEvent,
|
||||||
(Actor * mob, int64 uniqueId),
|
(Actor * mob, int64 uniqueId),
|
||||||
(&event.self(), event.getShooter() ? event.getShooter()->getOrCreateUniqueID().rawID : -1),
|
(&event.self(), event.self().getOwnerId().rawID),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case doHash("gmlib::SpawnWanderingTraderBeforeEvent"): {
|
case doHash("gmlib::SpawnWanderingTraderBeforeEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(ila::mc::SpawnWanderingTraderBeforeEvent,
|
||||||
GMLIB::Event::EntityEvent::SpawnWanderingTraderBeforeEvent,
|
|
||||||
(std::pair<BlockPos, int> pos, bool isCancelled),
|
(std::pair<BlockPos, int> pos, bool isCancelled),
|
||||||
({event.getPos(), event.getRegion().getDimensionId()}, event.isCancelled()),
|
({event.pos(), event.blockSource().getDimensionId()}, event.isCancelled()),
|
||||||
event.setCancelled(result);
|
event.setCancelled(result););
|
||||||
);
|
|
||||||
}
|
|
||||||
case doHash("gmlib::SpawnWanderingTraderAfterEvent"): {
|
|
||||||
REGISTER_EVENT_LISTEN(
|
|
||||||
GMLIB::Event::EntityEvent::SpawnWanderingTraderAfterEvent,
|
|
||||||
(std::pair<BlockPos, int> pos),
|
|
||||||
({event.getPos(), event.getRegion().getDimensionId()}),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
case doHash("gmlib::HandleRequestActionBeforeEvent"): {
|
case doHash("gmlib::HandleRequestActionBeforeEvent"): {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
GMLIB::Event::PlayerEvent::HandleRequestActionBeforeEvent,
|
ila::mc::PlayerRequestItemActionBeforeEvent,
|
||||||
(
|
(
|
||||||
Player * player,
|
Player * player,
|
||||||
std::string const& actionType,
|
std::string const& actionType,
|
||||||
@@ -297,23 +265,22 @@ void Export_Event_API() {
|
|||||||
),
|
),
|
||||||
(
|
(
|
||||||
(Player*)&event.self(),
|
(Player*)&event.self(),
|
||||||
magic_enum::enum_name(requestAction.mActionType).data(),
|
magic_enum::enum_name(event.actionType()).data(),
|
||||||
(int)requestAction.mAmount,
|
event.amount(),
|
||||||
magic_enum::enum_name(requestAction.mSrc->mFullContainerName.mName).data(),
|
magic_enum::enum_name(event.src().mFullContainerName.mName).data(),
|
||||||
(int)requestAction.mSrc->mSlot,
|
(int)event.src().mSlot,
|
||||||
magic_enum::enum_name(requestAction.mDst->mFullContainerName.mName).data(),
|
magic_enum::enum_name(event.dst().mFullContainerName.mName).data(),
|
||||||
(int)requestAction.mDst->mSlot,
|
(int)event.dst().mSlot,
|
||||||
event.isCancelled()
|
event.isCancelled()
|
||||||
),
|
),
|
||||||
event.setCancelled(result);,
|
event.setCancelled(result);,
|
||||||
auto& requestAction = (ItemStackRequestActionTransferBase&)event.getRequestAction();
|
|
||||||
);
|
);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
}
|
}
|
||||||
case doHash("gmlib::HandleRequestActionAfterEvent"): {
|
case doHash("gmlib::HandleRequestActionAfterEvent"): {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
GMLIB::Event::PlayerEvent::HandleRequestActionAfterEvent,
|
ila::mc::PlayerRequestItemActionAfterEvent,
|
||||||
(
|
(
|
||||||
Player * player,
|
Player * player,
|
||||||
std::string const& actionType,
|
std::string const& actionType,
|
||||||
@@ -325,27 +292,22 @@ void Export_Event_API() {
|
|||||||
),
|
),
|
||||||
(
|
(
|
||||||
(Player*)&event.self(),
|
(Player*)&event.self(),
|
||||||
magic_enum::enum_name(requestAction.mActionType).data(),
|
magic_enum::enum_name(event.actionType()).data(),
|
||||||
(int)requestAction.mAmount,
|
event.amount(),
|
||||||
magic_enum::enum_name(requestAction.mSrc->mFullContainerName.mName).data(),
|
magic_enum::enum_name(event.src().mFullContainerName.mName).data(),
|
||||||
(int)requestAction.mSrc->mSlot,
|
(int)event.src().mSlot,
|
||||||
magic_enum::enum_name(requestAction.mDst->mFullContainerName.mName).data(),
|
magic_enum::enum_name(event.dst().mFullContainerName.mName).data(),
|
||||||
(int)requestAction.mDst->mSlot
|
(int)event.dst().mSlot
|
||||||
),
|
),
|
||||||
,
|
,
|
||||||
auto& requestAction = (ItemStackRequestActionTransferBase&)event.getRequestAction();
|
|
||||||
);
|
);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
}
|
}
|
||||||
case doHash("gmlib::ContainerClosePacketSendAfterEvent"): {
|
case doHash("gmlib::ContainerClosePacketSendAfterEvent"): {
|
||||||
REGISTER_EVENT_LISTEN(
|
REGISTER_EVENT_LISTEN(
|
||||||
GMLIB::Event::PacketEvent::ContainerClosePacketSendAfterEvent,
|
ila::mc::PlayerCloseContainerAfterEvent,
|
||||||
(Player * player, int containerId, bool serverInitiatedClose, bool),
|
(Player * player, int containerId, bool serverInitiatedClose, bool),
|
||||||
(event.getServerNetworkHandler()
|
(&event.self(), (int)event.containerId(), event.serverInitiatedClose(), false),
|
||||||
._getServerPlayer(event.getNetworkIdentifier(), event.getPacket().mClientSubId),
|
|
||||||
(int)event.getPacket().mContainerId,
|
|
||||||
event.getPacket().mServerInitiatedClose,
|
|
||||||
false),
|
|
||||||
,
|
,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-6
@@ -1,15 +1,25 @@
|
|||||||
#pragma once
|
#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>
|
#include <RemoteCallAPI.h>
|
||||||
|
using namespace gmlib::mod;
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
#define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA")
|
#define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA")
|
||||||
|
|
||||||
#define LIB_VERSION_MAJOR 0
|
#define LIB_VERSION_MAJOR 1
|
||||||
#define LIB_VERSION_MINOR 13
|
#define LIB_VERSION_MINOR 0
|
||||||
#define LIB_VERSION_PATCH 6
|
#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_ModAPI();
|
||||||
extern void Export_Legacy_GMLib_ServerAPI();
|
extern void Export_Legacy_GMLib_ServerAPI();
|
||||||
@@ -17,4 +27,6 @@ extern void Export_Compatibility_API();
|
|||||||
extern void ExportPAPI();
|
extern void ExportPAPI();
|
||||||
extern void Export_Event_API();
|
extern void Export_Event_API();
|
||||||
extern void Export_BinaryStream_API();
|
extern void Export_BinaryStream_API();
|
||||||
|
extern ll::thread::ThreadPoolExecutor const& getThreadPoolExecutor();
|
||||||
|
extern ll::io::Logger& getLogger();
|
||||||
// extern void Export_Form_API();
|
// extern void Export_Form_API();
|
||||||
+62
-75
@@ -1,10 +1,10 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
std::unordered_set<std::string> HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"};
|
ICustomRecipe::UnlockingRequirement makeRecipeUnlockingKey(std::string const& key) {
|
||||||
|
if (auto context = magic_enum::enum_cast<RecipeUnlockingContext>(key)) {
|
||||||
std::variant<std::string, std::vector<RecipeIngredient>> makeRecipeUnlockingKey(std::string const& key) {
|
return ICustomRecipe::UnlockingRequirement(*context);
|
||||||
if (HardCodedKeys.count(key)) return key;
|
}
|
||||||
return std::vector<RecipeIngredient>({RecipeIngredient(key, 0, 1)});
|
return ICustomRecipe::UnlockingRequirement({ICustomRecipe::Ingredient(key)});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Export_Legacy_GMLib_ModAPI() {
|
void Export_Legacy_GMLib_ModAPI() {
|
||||||
@@ -17,17 +17,13 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::string const& result,
|
std::string const& result,
|
||||||
int count,
|
int count,
|
||||||
std::string const& unlock) -> void {
|
std::string const& unlock) -> void {
|
||||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
if (!GMLevel::getInstance().has_value()) return;
|
||||||
std::vector<RecipeIngredient> types;
|
std::vector<ICustomRecipe::Ingredient> types;
|
||||||
for (auto ing : ingredients) {
|
for (auto& ing : ingredients) {
|
||||||
types.emplace_back(ing, 0, 1);
|
types.emplace_back(ICustomRecipe::Ingredient{ing, 1});
|
||||||
}
|
}
|
||||||
GMLIB::Mod::JsonRecipe::registerShapelessCraftingTableRecipe(
|
CustomRecipeRegistry::getInstance()
|
||||||
recipe_id,
|
.registerShapelessRecipe(recipe_id, types, ItemInstance(result, count), makeRecipeUnlockingKey(unlock));
|
||||||
types,
|
|
||||||
RecipeIngredient(result, 0, count),
|
|
||||||
makeRecipeUnlockingKey(unlock)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -39,16 +35,17 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::string const& result,
|
std::string const& result,
|
||||||
int count,
|
int count,
|
||||||
std::string const& unlock) -> void {
|
std::string const& unlock) -> void {
|
||||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
if (!GMLevel::getInstance().has_value()) return;
|
||||||
std::vector<RecipeIngredient> types;
|
ICustomShapedRecipe::ShapedIngredients types;
|
||||||
for (auto ing : ingredients) {
|
char index = 'A';
|
||||||
types.push_back(RecipeIngredient(ing, 0, 1));
|
for (auto& ing : ingredients) {
|
||||||
|
types.add(std::string(1, index++), ICustomRecipe::Ingredient{ing});
|
||||||
}
|
}
|
||||||
GMLIB::Mod::JsonRecipe::registerShapedCraftingTableRecipe(
|
CustomRecipeRegistry::getInstance().registerShapedRecipe(
|
||||||
recipe_id,
|
recipe_id,
|
||||||
shape,
|
shape,
|
||||||
types,
|
types,
|
||||||
RecipeIngredient(result, 0, count),
|
ItemInstance(result, count),
|
||||||
makeRecipeUnlockingKey(unlock)
|
makeRecipeUnlockingKey(unlock)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -60,13 +57,9 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::string const& input,
|
std::string const& input,
|
||||||
std::string const& output,
|
std::string const& output,
|
||||||
std::vector<std::string> tags) -> void {
|
std::vector<std::string> tags) -> void {
|
||||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
if (!GMLevel::getInstance().has_value()) return;
|
||||||
GMLIB::Mod::JsonRecipe::registerFurnaceRecipe(
|
CustomRecipeRegistry::getInstance()
|
||||||
recipe_id,
|
.registerFurnaceRecipe(ICustomRecipe::Ingredient{input}, ItemInstance{output}, tags);
|
||||||
RecipeIngredient(input, 0, 1),
|
|
||||||
RecipeIngredient(output, 0, 1),
|
|
||||||
tags
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -74,8 +67,12 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
"registerBrewingMixRecipe",
|
"registerBrewingMixRecipe",
|
||||||
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
||||||
) -> void {
|
) -> void {
|
||||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
if (!GMLevel::getInstance().has_value()) return;
|
||||||
GMLIB::Mod::JsonRecipe::registerBrewingMixRecipe(recipe_id, input, output, RecipeIngredient(reagent, 0, 1));
|
CustomRecipeRegistry::getInstance().registerBrewingRecipe(
|
||||||
|
ICustomRecipe::Ingredient{input},
|
||||||
|
ICustomRecipe::Ingredient{reagent},
|
||||||
|
ICustomRecipe::Ingredient{output}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -83,12 +80,11 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
"registerBrewingContainerRecipe",
|
"registerBrewingContainerRecipe",
|
||||||
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
||||||
) -> void {
|
) -> void {
|
||||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
if (!GMLevel::getInstance().has_value()) return;
|
||||||
GMLIB::Mod::JsonRecipe::registerBrewingContainerRecipe(
|
CustomRecipeRegistry::getInstance().registerBrewingRecipe(
|
||||||
recipe_id,
|
ICustomRecipe::Ingredient{input},
|
||||||
RecipeIngredient(input, 0, 1),
|
ICustomRecipe::Ingredient{reagent},
|
||||||
RecipeIngredient(output, 0, 1),
|
ICustomRecipe::Ingredient{output}
|
||||||
RecipeIngredient(reagent, 0, 1)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -100,13 +96,13 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::string const& base,
|
std::string const& base,
|
||||||
std::string const& addition,
|
std::string const& addition,
|
||||||
std::string const& result) -> void {
|
std::string const& result) -> void {
|
||||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
if (!GMLevel::getInstance().has_value()) return;
|
||||||
GMLIB::Mod::JsonRecipe::registerSmithingTransformRecipe(
|
CustomRecipeRegistry::getInstance().registerSmithingTransformRecipe(
|
||||||
recipe_id,
|
recipe_id,
|
||||||
smithing_template,
|
ICustomRecipe::Ingredient{smithing_template},
|
||||||
base,
|
ICustomRecipe::Ingredient{base},
|
||||||
addition,
|
ICustomRecipe::Ingredient{addition},
|
||||||
result
|
ItemInstance{result}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -117,8 +113,13 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::string const& smithing_template,
|
std::string const& smithing_template,
|
||||||
std::string const& base,
|
std::string const& base,
|
||||||
std::string const& addition) -> void {
|
std::string const& addition) -> void {
|
||||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
if (!GMLevel::getInstance().has_value()) return;
|
||||||
GMLIB::Mod::JsonRecipe::registerSmithingTrimRecipe(recipe_id, smithing_template, base, addition);
|
CustomRecipeRegistry::getInstance().registerSmithingTrimRecipe(
|
||||||
|
recipe_id,
|
||||||
|
ICustomRecipe::Ingredient{smithing_template},
|
||||||
|
ICustomRecipe::Ingredient{base},
|
||||||
|
ICustomRecipe::Ingredient{addition}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -130,49 +131,35 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::string const& output,
|
std::string const& output,
|
||||||
int output_data,
|
int output_data,
|
||||||
int output_count) -> void {
|
int output_count) -> void {
|
||||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
if (!GMLevel::getInstance().has_value()) return;
|
||||||
GMLIB::Mod::JsonRecipe::registerStoneCutterRecipe(
|
CustomRecipeRegistry::getInstance().registerStoneCutterRecipe(
|
||||||
recipe_id,
|
recipe_id,
|
||||||
RecipeIngredient(input, 0, 1),
|
ICustomRecipe::Ingredient{input, 1, input_data},
|
||||||
RecipeIngredient(output, 0, 1)
|
{output, output_count, output_data}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
// 错误方块清理
|
// 错误方块清理
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "setUnknownBlockCleaner", []() -> void {
|
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 {
|
RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void {
|
||||||
auto list = GMLIB_Level::getAllExperiments();
|
GMLevel::getInstance().and_then([&](GMLevel& level) {
|
||||||
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
level.setExperimentEnabled((AllExperiments)experiment_id);
|
||||||
if (set.contains((AllExperiments)experiment_id)) {
|
return true;
|
||||||
GMLIB_Level::addExperimentsRequire((AllExperiments)experiment_id);
|
});
|
||||||
} else {
|
|
||||||
ll::io::LoggerRegistry::getInstance().getOrCreate("Server")->error("Experiment ID '{}' does not exist!", experiment_id);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "setExperimentEnabled", [](int experiment_id, bool value) -> void {
|
RemoteCall::exportAs("GMLib_ModAPI", "setExperimentEnabled", [](int experiment_id, bool value) -> void {
|
||||||
if (GMLIB_Level::getInstance()) {
|
GMLevel::getInstance().and_then([&](GMLevel& level) {
|
||||||
auto list = GMLIB_Level::getAllExperiments();
|
level.setExperimentEnabled((AllExperiments)experiment_id, value);
|
||||||
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
return true;
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "getExperimentEnabled", [](int experiment_id) -> bool {
|
RemoteCall::exportAs("GMLib_ModAPI", "getExperimentEnabled", [](int experiment_id) -> bool {
|
||||||
if (GMLIB_Level::getInstance()) {
|
return GMLevel::getInstance()
|
||||||
auto list = GMLIB_Level::getAllExperiments();
|
.transform([&](GMLevel& level) { return level.getExperimentEnabled((AllExperiments)experiment_id); })
|
||||||
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
.value_or(false);
|
||||||
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();
|
|
||||||
});
|
});
|
||||||
|
RemoteCall::exportAs("GMLib_ModAPI", "setFixI18nEnabled", []() -> void {});
|
||||||
}
|
}
|
||||||
+29
-24
@@ -2,57 +2,62 @@
|
|||||||
|
|
||||||
void Export_Legacy_GMLib_ServerAPI() {
|
void Export_Legacy_GMLib_ServerAPI() {
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void {
|
||||||
GMLIB_Level::tryEnableEducationEdition();
|
getLogger().error("GMLib_ServerAPI::setEducationFeatureEnabled is not implemented");
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void {
|
||||||
GMLIB_Level::tryRegisterAbilityCommand();
|
getLogger().error("GMLib_ServerAPI::registerAbilityCommand is not implemented");
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void {
|
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 {
|
RemoteCall::exportAs("GMLib_ServerAPI", "enableCoResourcePack", []() -> void {
|
||||||
GMLIB_Level::requireServerResourcePackAndAllowClientResourcePack();
|
getLogger().error("GMLib_ServerAPI::enableCoResourcePack is not implemented");
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
||||||
return GMLIB_Level::getInstance()
|
return GMLevel::getInstance().transform(
|
||||||
.transform([](GMLIB_Level& level) -> std::string { return level.getLevelName(); })
|
[](GMLevel& level) -> std::string { return level.getLevelName(); }
|
||||||
.value_or("");
|
).value_or("");
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setLevelName", [](std::string const& name) -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setLevelName", [](std::string const& name) -> void {
|
||||||
if (auto level = GMLIB_Level::getInstance()) {
|
if (auto level = GMLevel::getInstance()) {
|
||||||
level->setLevelName(name);
|
level->setLevelName(name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelSeed", []() -> std::string {
|
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelSeed", []() -> std::string {
|
||||||
return GMLIB_Level::getInstance()
|
return GMLevel::getInstance()
|
||||||
.transform([](GMLIB_Level& level) -> std::string { return std::to_string(level.getSeed()); })
|
.transform([](GMLevel& level) -> std::string { return std::to_string(level.getSeed()); })
|
||||||
.value_or("");
|
.value_or("");
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setFakeSeed", [](int64_t seed) -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setFakeSeed", [](int64_t seed) -> void {
|
||||||
return GMLIB_Level::setFakeSeed(seed);
|
getLogger().error("GMLib_ServerAPI::setFakeSeed is not implemented");
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ServerAPI",
|
"GMLib_ServerAPI",
|
||||||
"spawnEntity",
|
"spawnEntity",
|
||||||
[](std::pair<Vec3, int> pos, std::string const& name) -> Actor* {
|
[](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(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ServerAPI",
|
"GMLib_ServerAPI",
|
||||||
"shootProjectile",
|
"shootProjectile",
|
||||||
[](Actor* owner, std::string const& name, float speed, float offset) -> Actor* {
|
[](Actor* owner, std::string const& name, float speed, float offset) -> Actor* {
|
||||||
auto ac = (GMLIB_Actor*)owner;
|
auto actor = GMSpawner::spawnEntity(owner->getPosition(), owner->getDimensionId(), name);
|
||||||
return ac->shootProjectile(name, speed, offset).as_ptr();
|
if (!actor) return nullptr;
|
||||||
|
((GMActor*)owner)->setProjectile((GMActor&)*actor, speed, offset);
|
||||||
|
return actor.as_ptr();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ServerAPI",
|
"GMLib_ServerAPI",
|
||||||
"throwEntity",
|
"throwEntity",
|
||||||
[](Actor* owner, Actor* actor, float speed, float offset) -> bool {
|
[](Actor* owner, Actor* actor, float speed, float offset) -> bool {
|
||||||
auto ac = (GMLIB_Actor*)owner;
|
auto ac = (GMActor*)owner;
|
||||||
return ac->throwEntity(*actor, speed, offset);
|
ac->setProjectile((GMActor&)*actor, speed, offset);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "PlayerToEntity", [](Player* player) -> Actor* { return (Actor*)player; });
|
RemoteCall::exportAs("GMLib_ServerAPI", "PlayerToEntity", [](Player* player) -> Actor* { return (Actor*)player; });
|
||||||
@@ -60,18 +65,18 @@ void Export_Legacy_GMLib_ServerAPI() {
|
|||||||
"GMLib_ServerAPI",
|
"GMLib_ServerAPI",
|
||||||
"addFakeList",
|
"addFakeList",
|
||||||
[](const std::string& name, const std::string& xuid) -> bool {
|
[](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 {
|
RemoteCall::exportAs("GMLib_ServerAPI", "removeFakeList", [](const std::string& nameOrXuid) -> bool {
|
||||||
return GMLIB::Server::FakeList::removeFakeList(nameOrXuid);
|
PlayerListAPI::erase(nameOrXuid);
|
||||||
});
|
return true;
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "removeAllFakeList", []() -> void {
|
|
||||||
return GMLIB::Server::FakeList::removeAllFakeLists();
|
|
||||||
});
|
});
|
||||||
|
RemoteCall::exportAs("GMLib_ServerAPI", "removeAllFakeList", []() -> void { PlayerListAPI::clear(); });
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "getMaxPlayers", []() -> int {
|
RemoteCall::exportAs("GMLib_ServerAPI", "getMaxPlayers", []() -> int {
|
||||||
return GMLIB_Level::getInstance().transform(
|
return GMLevel::getInstance().transform(
|
||||||
[](GMLIB_Level& level) -> int { return level.getMaxPlayerCount(); }
|
[](GMLevel& level) -> int { return level.getMaxPlayerCount(); }
|
||||||
).value_or(0);
|
).value_or(0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+153
-69
@@ -2,122 +2,198 @@
|
|||||||
#include <regex>
|
#include <regex>
|
||||||
|
|
||||||
namespace PAPIRemoteCall {
|
namespace PAPIRemoteCall {
|
||||||
|
std::string GetValue(std::string const& from) { return PlaceholderAPI::getValue(from, std::nullopt).value_or(""); }
|
||||||
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 GetValueWithPlayer(std::string const& key, Player* player) {
|
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& PluginName,
|
||||||
std::string const& FuncName,
|
std::string const& FuncName,
|
||||||
std::string const& PAPIName
|
std::string const& PAPIName
|
||||||
) {
|
) {
|
||||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
if (!RemoteCall::hasFunc(PluginName, FuncName)) return;
|
||||||
GMLIB::Server::PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
auto func = [=]() -> void {
|
||||||
if (isParameters(PAPIName)) {
|
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||||
auto Call = RemoteCall::importAs<std::string(Player * pl, std::unordered_map<std::string, std::string>)>(
|
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,
|
PluginName,
|
||||||
FuncName
|
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
|
||||||
);
|
);
|
||||||
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
|
};
|
||||||
PAPIName,
|
if (ll::mod::ModManagerRegistry::getInstance().hasMod(PluginName)) {
|
||||||
[Call](Player* sp, std::unordered_map<std::string, std::string> map) { return Call(sp, map); },
|
func();
|
||||||
PluginName
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
auto Call = RemoteCall::importAs<std::string(Player * pl)>(PluginName, FuncName);
|
getThreadPoolExecutor().execute(func);
|
||||||
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
|
|
||||||
PAPIName,
|
|
||||||
[Call](Player* sp) { return Call(sp); },
|
|
||||||
PluginName
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool registerServerPlaceholder(
|
void registerServerPlaceholder(
|
||||||
std::string const& PluginName,
|
std::string const& PluginName,
|
||||||
std::string const& FuncName,
|
std::string const& FuncName,
|
||||||
std::string const& PAPIName
|
std::string const& PAPIName
|
||||||
) {
|
) {
|
||||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
if (!RemoteCall::hasFunc(PluginName, FuncName)) return;
|
||||||
GMLIB::Server::PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
auto func = [=]() -> void {
|
||||||
if (isParameters(PAPIName)) {
|
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||||
auto Call =
|
std::weak_ptr mod = ll::mod::ModManagerRegistry::getInstance().getMod(PluginName);
|
||||||
RemoteCall::importAs<std::string(std::unordered_map<std::string, std::string>)>(PluginName, FuncName);
|
if (mod.expired()) return;
|
||||||
GMLIB::Server::PlaceholderAPI::registerServerPlaceholder(
|
PlaceholderAPI::registerPlaceholder(
|
||||||
PAPIName,
|
PAPIName,
|
||||||
[Call](std::unordered_map<std::string, std::string> map) { return Call(map); },
|
[Call = RemoteCall::importAs<std::string(std::unordered_map<std::string, std::string>)>(
|
||||||
PluginName
|
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 {
|
} else {
|
||||||
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
getThreadPoolExecutor().execute(func);
|
||||||
GMLIB::Server::PlaceholderAPI::registerServerPlaceholder(PAPIName, [Call]() { return Call(); }, PluginName);
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool registerStaticPlaceholder(
|
void registerStaticPlaceholder(
|
||||||
std::string const& PluginName,
|
std::string const& PluginName,
|
||||||
std::string const& FuncName,
|
std::string const& FuncName,
|
||||||
std::string const& PAPIName,
|
std::string const& PAPIName,
|
||||||
int num
|
int num
|
||||||
) {
|
) {
|
||||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
if (!RemoteCall::hasFunc(PluginName, FuncName)) return;
|
||||||
GMLIB::Server::PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
auto func = [=]() -> void {
|
||||||
if (isParameters(PAPIName)) {
|
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||||
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
std::weak_ptr mod = ll::mod::ModManagerRegistry::getInstance().getMod(PluginName);
|
||||||
if (num == -1) {
|
if (mod.expired()) return;
|
||||||
GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder(
|
PlaceholderAPI::registerPlaceholder(
|
||||||
PAPIName,
|
PAPIName,
|
||||||
[Call] { return Call(); },
|
[Call = RemoteCall::importAs<std::string()>(PluginName, FuncName)](auto&&...)
|
||||||
PluginName
|
-> std::optional<std::string> { return Call(); },
|
||||||
|
mod
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
if (ll::mod::ModManagerRegistry::getInstance().hasMod(PluginName)) {
|
||||||
|
func();
|
||||||
} else {
|
} else {
|
||||||
GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder(
|
getThreadPoolExecutor().execute(func);
|
||||||
PAPIName,
|
|
||||||
num,
|
|
||||||
[Call] { return Call(); },
|
|
||||||
PluginName
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string translateStringWithPlayer(std::string const& str, Player* pl) {
|
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 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) \
|
#define EXPORTAPI(T) \
|
||||||
RemoteCall::exportAs("BEPlaceholderAPI", ll::utils::string_utils::replaceAll(#T, "PAPIRemoteCall::", ""), T);
|
RemoteCall::exportAs("BEPlaceholderAPI", ll::utils::string_utils::replaceAll(#T, "PAPIRemoteCall::", ""), T);
|
||||||
|
|
||||||
|
#define EXPORTAPI2(T) RemoteCall::exportAs("PlaceholderAPI", #T, NewPapiRemoteCall::T);
|
||||||
|
|
||||||
void ExportPAPI() {
|
void ExportPAPI() {
|
||||||
EXPORTAPI(PAPIRemoteCall::registerPlayerPlaceholder);
|
EXPORTAPI(PAPIRemoteCall::registerPlayerPlaceholder);
|
||||||
EXPORTAPI(PAPIRemoteCall::registerServerPlaceholder);
|
EXPORTAPI(PAPIRemoteCall::registerServerPlaceholder);
|
||||||
@@ -128,4 +204,12 @@ void ExportPAPI() {
|
|||||||
EXPORTAPI(PAPIRemoteCall::translateStringWithPlayer);
|
EXPORTAPI(PAPIRemoteCall::translateStringWithPlayer);
|
||||||
EXPORTAPI(PAPIRemoteCall::unRegisterPlaceholder);
|
EXPORTAPI(PAPIRemoteCall::unRegisterPlaceholder);
|
||||||
EXPORTAPI(PAPIRemoteCall::getAllPAPI);
|
EXPORTAPI(PAPIRemoteCall::getAllPAPI);
|
||||||
|
|
||||||
|
EXPORTAPI2(translate);
|
||||||
|
EXPORTAPI2(translateFromActor);
|
||||||
|
EXPORTAPI2(registerPlaceholder);
|
||||||
|
EXPORTAPI2(unregisterPlaceholder);
|
||||||
|
EXPORTAPI2(unregisterPlaceholderFromModName);
|
||||||
|
EXPORTAPI2(getValue);
|
||||||
|
EXPORTAPI2(getValueFromActor);
|
||||||
}
|
}
|
||||||
+31
-14
@@ -1,29 +1,46 @@
|
|||||||
{
|
{
|
||||||
"format_version": 2,
|
"format_version": 3,
|
||||||
|
"format_uuid": "289f771f-2c9a-4d73-9f3f-8492495a924d",
|
||||||
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
||||||
"version": "0.13.6",
|
"version": "1.2.0",
|
||||||
"info": {
|
"info": {
|
||||||
"name": "GMLIB-LegacyRemoteCallApi",
|
"name": "GMLIB-LegacyRemoteCallApi",
|
||||||
"description": "Legacy RemoteCall API for GMLIB",
|
"description": "Legacy RemoteCall API for GMLIB",
|
||||||
"source": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
|
||||||
"author": "GroupMountain",
|
|
||||||
"tags": [
|
"tags": [
|
||||||
"levilamina",
|
"platform:levilamina",
|
||||||
|
"type:mod",
|
||||||
"gmlib",
|
"gmlib",
|
||||||
"lse",
|
"lse",
|
||||||
"library"
|
"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",
|
"variants": [
|
||||||
"dependencies": {
|
|
||||||
"github.com/GroupMountain/GMLIB": ">=0.13.9"
|
|
||||||
},
|
|
||||||
"files": {
|
|
||||||
"place": [
|
|
||||||
{
|
{
|
||||||
"src": "GMLIB-LegacyRemoteCallApi/*",
|
"platform": "win-x64",
|
||||||
"dest": "plugins/GMLIB-LegacyRemoteCallApi"
|
"dependencies": {
|
||||||
|
"github.com/LiteLDev/LeviLamina": ">=1.3.0",
|
||||||
|
"github.com/GroupMountain/GMLIB-Release": ">=1.3.0-rc.1",
|
||||||
|
"github.com/MiracleForest/iListenAttentively-Release": ">=0.6.0"
|
||||||
|
},
|
||||||
|
"assets": [
|
||||||
|
{
|
||||||
|
"type": "zip",
|
||||||
|
"urls": [
|
||||||
|
"https://{{tooth}}/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,24 +2,28 @@ add_rules("mode.debug", "mode.release")
|
|||||||
|
|
||||||
add_repositories("liteldev-repo https://github.com/LiteLDev/xmake-repo.git")
|
add_repositories("liteldev-repo https://github.com/LiteLDev/xmake-repo.git")
|
||||||
add_repositories("groupmountain-repo https://github.com/GroupMountain/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
|
if not has_config("vs_runtime") then
|
||||||
set_runtimes("MD")
|
set_runtimes("MD")
|
||||||
end
|
end
|
||||||
|
|
||||||
add_requires("levilamina", {configs = {target_type = "server"}})
|
add_requires("levilamina 1.3.0", {configs = {target_type = "server"}})
|
||||||
add_requires("legacyremotecall")
|
add_requires("legacyremotecall")
|
||||||
add_requires("gmlib")
|
|
||||||
add_requires("levibuildscript")
|
add_requires("levibuildscript")
|
||||||
|
add_requires("ilistenattentively 0.6.0")
|
||||||
|
add_requires("gmlib 1.3.0-rc.1")
|
||||||
|
|
||||||
target("GMLIB-LegacyRemoteCallApi")
|
target("GMLIB-LegacyRemoteCallApi")
|
||||||
add_cxflags(
|
add_cxflags(
|
||||||
"/EHa",
|
"/EHa",
|
||||||
"/utf-8"
|
"/utf-8",
|
||||||
|
"/bigobj"
|
||||||
)
|
)
|
||||||
add_defines(
|
add_defines(
|
||||||
"NOMINMAX",
|
"NOMINMAX",
|
||||||
"UNICODE"
|
"UNICODE",
|
||||||
|
"_HAS_CXX23=1"
|
||||||
)
|
)
|
||||||
add_files(
|
add_files(
|
||||||
"src/**.cpp"
|
"src/**.cpp"
|
||||||
@@ -30,21 +34,19 @@ target("GMLIB-LegacyRemoteCallApi")
|
|||||||
add_packages(
|
add_packages(
|
||||||
"levilamina",
|
"levilamina",
|
||||||
"legacyremotecall",
|
"legacyremotecall",
|
||||||
|
"ilistenattentively",
|
||||||
"gmlib"
|
"gmlib"
|
||||||
)
|
)
|
||||||
add_rules("@levibuildscript/linkrule")
|
add_rules("@levibuildscript/linkrule")
|
||||||
|
add_rules("@levibuildscript/modpacker")
|
||||||
set_exceptions("none")
|
set_exceptions("none")
|
||||||
set_kind("shared")
|
set_kind("shared")
|
||||||
set_languages("c++23")
|
set_languages("cxx20")
|
||||||
set_symbols("debug")
|
set_symbols("debug")
|
||||||
|
|
||||||
after_build(function (target)
|
after_build(function (target)
|
||||||
local plugin_packer = import("scripts.after_build")
|
local target_path = path.join("bin", target:name(), "lib")
|
||||||
|
if os.exists(target_path) then
|
||||||
local plugin_define = {
|
os.rm(target_path)
|
||||||
pluginName = target:name(),
|
end
|
||||||
pluginFile = path.filename(target:targetfile()),
|
os.cp("lib", target_path)
|
||||||
}
|
|
||||||
|
|
||||||
plugin_packer.pack_plugin(target,plugin_define)
|
|
||||||
end)
|
end)
|
||||||
Reference in New Issue
Block a user