Compare commits
100 Commits
@@ -9,12 +9,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- uses: xmake-io/github-action-setup-xmake@v1
|
- uses: xmake-io/github-action-setup-xmake@v1
|
||||||
|
with:
|
||||||
|
xmake-version: "2.9.3"
|
||||||
|
|
||||||
- run: |
|
- run: |
|
||||||
xmake repo -u
|
xmake repo -u
|
||||||
|
|||||||
@@ -9,12 +9,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- uses: xmake-io/github-action-setup-xmake@v1
|
- uses: xmake-io/github-action-setup-xmake@v1
|
||||||
|
with:
|
||||||
|
xmake-version: "2.9.3"
|
||||||
|
|
||||||
- run: |
|
- run: |
|
||||||
xmake repo -u
|
xmake repo -u
|
||||||
|
|||||||
@@ -15,3 +15,4 @@ build/
|
|||||||
/.xmake
|
/.xmake
|
||||||
/CMakeLists.txt
|
/CMakeLists.txt
|
||||||
/bin
|
/bin
|
||||||
|
.cache/clangd/index
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
[submodule "SDK-GMLIB"]
|
|
||||||
path = SDK-GMLIB
|
|
||||||
url = https://github.com/GroupMountain/SDK-GMLIB.git
|
|
||||||
@@ -5,6 +5,5 @@ Legacy RemoteCall API for GMLIB. Only for legacy LSE plugin compatibility.
|
|||||||
- 本模块是 `GMLIB` 的 `Legacy RemoteCall API` 模块,是为LL2的LLSE插件的兼容性保留。
|
- 本模块是 `GMLIB` 的 `Legacy RemoteCall API` 模块,是为LL2的LLSE插件的兼容性保留。
|
||||||
- 通过本模块,可以使LSE插件调用 `GMLIB` 内部的API。
|
- 通过本模块,可以使LSE插件调用 `GMLIB` 内部的API。
|
||||||
|
|
||||||
# 注意事项
|
# 开发文档
|
||||||
- 本模块仅为兼容性保留模块,仅保留过去的接口以保留兼容性。
|
- https://groupmountain.github.io/Documentation/
|
||||||
- 本模块不会提供 `GMLIB` 在迁移到 `LeviLamina` 后新开发的接口。
|
|
||||||
|
|||||||
-1
Submodule SDK-GMLIB deleted from e4f3e2a188
Vendored
+72
@@ -0,0 +1,72 @@
|
|||||||
|
declare class PAPI {
|
||||||
|
/** 注册一个玩家PAPI变量 */
|
||||||
|
static registerPlayerPlaceholder(
|
||||||
|
/** PAPI调用函数 */
|
||||||
|
func: (
|
||||||
|
/** 玩家对象 */
|
||||||
|
player: Player,
|
||||||
|
/** 变量参数 */
|
||||||
|
param: null | object.<string, string>
|
||||||
|
) => string,
|
||||||
|
/** 插件名字 */
|
||||||
|
pluginsName: string,
|
||||||
|
/** PAPI变量 */
|
||||||
|
PAPIName: string
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 注册一个服务器PAPI变量 */
|
||||||
|
static registerServerPlaceholder(
|
||||||
|
/** PAPI调用函数 */
|
||||||
|
func: (
|
||||||
|
/** 变量参数 */
|
||||||
|
param: null | object.<string, string>
|
||||||
|
) => string,
|
||||||
|
/** 插件名字 */
|
||||||
|
pluginsName: string,
|
||||||
|
/** PAPI变量 */
|
||||||
|
PAPIName: string
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 注册一个静态PAPI变量 */
|
||||||
|
static registerStaticPlaceholder(
|
||||||
|
/** PAPI调用函数 */
|
||||||
|
func: () => string,
|
||||||
|
/** 插件名字 */
|
||||||
|
pluginsName: string,
|
||||||
|
/** PAPI变量 */
|
||||||
|
PAPIName: string,
|
||||||
|
/** 更新时间 */
|
||||||
|
UpdateInterval: number
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 获取一个服务器变量的值 */
|
||||||
|
static getValue(
|
||||||
|
/** PAPI名 */
|
||||||
|
key: string
|
||||||
|
): string;
|
||||||
|
|
||||||
|
/** 获取一个玩家变量的值 */
|
||||||
|
static getValueByPlayer(
|
||||||
|
/** PAPI名 */
|
||||||
|
key: string,
|
||||||
|
/** 玩家对象 */
|
||||||
|
pl: Player
|
||||||
|
): string;
|
||||||
|
|
||||||
|
/** 翻译带PAPI变量的字符串 */
|
||||||
|
static translateString(
|
||||||
|
/** 要翻译的字符串 */
|
||||||
|
str: string,
|
||||||
|
/** 玩家对象 */
|
||||||
|
pl: Player | undefined
|
||||||
|
): string;
|
||||||
|
|
||||||
|
/** 注销一个PAPI变量 */
|
||||||
|
static unRegisterPlaceholder(
|
||||||
|
/** PAPI名 */
|
||||||
|
str: string
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 获取所有已注册的PAPI变量 */
|
||||||
|
static getAllPAPI(): string[];
|
||||||
|
}
|
||||||
@@ -1,47 +1,117 @@
|
|||||||
const PlaceholderAPI = {
|
const PlaceholderAPI = {
|
||||||
|
/** 获取一个服务器变量的值 @type {function(string):string} */
|
||||||
getValueAPI: ll.import("BEPlaceholderAPI", "GetValue"),
|
getValueAPI: ll.import("BEPlaceholderAPI", "GetValue"),
|
||||||
|
/** 获取一个玩家变量的值 @type {function(string,Player):string} */
|
||||||
getValueByPlayerAPI: ll.import("BEPlaceholderAPI", "GetValueWithPlayer"),
|
getValueByPlayerAPI: ll.import("BEPlaceholderAPI", "GetValueWithPlayer"),
|
||||||
|
/** 注册一个玩家变量 @type {function(string,string,string):boolean} */
|
||||||
registerPlayerPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerPlayerPlaceholder"),
|
registerPlayerPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerPlayerPlaceholder"),
|
||||||
|
/** 注册一个服务器变量 @type {function(string,string,string):boolean} */
|
||||||
registerServerPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerServerPlaceholder"),
|
registerServerPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerServerPlaceholder"),
|
||||||
|
/** 注册一个静态变量 @type {function(string,string,string,number):boolean} */
|
||||||
registerStaticPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerStaticPlaceholder"),
|
registerStaticPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerStaticPlaceholder"),
|
||||||
|
/** 翻译包含PAPI服务器变量的字符串 @type {function(string):string} */
|
||||||
translateStringAPI: ll.import("BEPlaceholderAPI", "translateString"),
|
translateStringAPI: ll.import("BEPlaceholderAPI", "translateString"),
|
||||||
|
/** 翻译包含PAPI玩家变量的字符串 @type {function(string,Player):string} */
|
||||||
translateStringWithPlayerAPI: ll.import("BEPlaceholderAPI", "translateStringWithPlayer"),
|
translateStringWithPlayerAPI: ll.import("BEPlaceholderAPI", "translateStringWithPlayer"),
|
||||||
|
/** 注销PAPI变量 @type {function(string):boolean} */
|
||||||
unRegisterPlaceholderAPI: ll.import("BEPlaceholderAPI", "unRegisterPlaceholder"),
|
unRegisterPlaceholderAPI: ll.import("BEPlaceholderAPI", "unRegisterPlaceholder"),
|
||||||
|
/** 获取所有已注册的PAPI变量 @type {function():Array.<string>} */
|
||||||
getAllPAPI: ll.import("BEPlaceholderAPI", "getAllPAPI")
|
getAllPAPI: ll.import("BEPlaceholderAPI", "getAllPAPI")
|
||||||
}
|
}
|
||||||
|
|
||||||
Function.prototype.getName = function () {
|
Function.prototype.getName =
|
||||||
return this.name || this.toString().match(/function\s*([^(]*)\(/)[1]
|
/**
|
||||||
|
* 获取函数名字
|
||||||
|
* @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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** PAPI变量类 */
|
||||||
class PAPI {
|
class PAPI {
|
||||||
constructor() {
|
constructor() {
|
||||||
throw new Error("Static class cannot be instantiated");
|
throw new Error("Static class cannot be instantiated");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册一个玩家PAPI变量
|
||||||
|
* @param {function} func 变量调用的函数
|
||||||
|
* @param {string} PluginName 插件名字
|
||||||
|
* @param {string} PAPIName PAPI变量名
|
||||||
|
* @returns {boolean} 是否注册成功
|
||||||
|
*/
|
||||||
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);
|
return PlaceholderAPI.registerPlayerPlaceholderAPI(PluginName, func.getName(), PAPIName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册一个服务器PAPI变量
|
||||||
|
* @param {function} func 变量调用的函数
|
||||||
|
* @param {string} PluginName 插件名字
|
||||||
|
* @param {string} PAPIName PAPI变量名
|
||||||
|
* @returns {boolean} 是否注册成功
|
||||||
|
*/
|
||||||
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);
|
return PlaceholderAPI.registerServerPlaceholderAPI(PluginName, func.getName(), PAPIName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册一个静态PAPI变量
|
||||||
|
* @param {function} func 变量调用的函数
|
||||||
|
* @param {string} PluginName 插件名字
|
||||||
|
* @param {string} PAPIName PAPI变量名
|
||||||
|
* @param {number} [UpdateInterval=50] 更新间隔
|
||||||
|
* @returns {boolean} 是否注册成功
|
||||||
|
*/
|
||||||
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);
|
return PlaceholderAPI.registerStaticPlaceholderAPI(PluginName, func.getName(), PAPIName, UpdateInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取一个服务器变量的值
|
||||||
|
* @param {string} key PAPI变量名
|
||||||
|
* @returns {string} 值
|
||||||
|
*/
|
||||||
static getValue(key) {
|
static getValue(key) {
|
||||||
return PlaceholderAPI.getValueAPI(key);
|
return PlaceholderAPI.getValueAPI(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取一个玩家变量的值
|
||||||
|
* @param {string} key PAPI变量名
|
||||||
|
* @param {Player} pl 玩家对象
|
||||||
|
* @returns {string} 值
|
||||||
|
*/
|
||||||
static getValueByPlayer(key, pl) {
|
static getValueByPlayer(key, pl) {
|
||||||
return PlaceholderAPI.getValueByPlayerAPI(key, pl);
|
return PlaceholderAPI.getValueByPlayerAPI(key, pl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 翻译带PAPI变量的字符串
|
||||||
|
* @param {string} str 字符串
|
||||||
|
* @param {Player} pl 玩家对象
|
||||||
|
* @returns {string} 翻译结果
|
||||||
|
*/
|
||||||
static translateString(str, pl = null) {
|
static translateString(str, pl = null) {
|
||||||
if (pl) {
|
if (pl) {
|
||||||
return PlaceholderAPI.translateStringWithPlayerAPI(str, pl);
|
return PlaceholderAPI.translateStringWithPlayerAPI(str, pl);
|
||||||
@@ -49,10 +119,19 @@ class PAPI {
|
|||||||
return PlaceholderAPI.translateStringAPI(str);
|
return PlaceholderAPI.translateStringAPI(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注销一个PAPI变量
|
||||||
|
* @param {string} str PAPI变量名
|
||||||
|
* @returns {boolean} 是否注销成功
|
||||||
|
*/
|
||||||
static unRegisterPlaceholder(str) {
|
static unRegisterPlaceholder(str) {
|
||||||
return PlaceholderAPI.unRegisterPlaceholderAPI(str);
|
return PlaceholderAPI.unRegisterPlaceholderAPI(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有已注册的PAPI变量
|
||||||
|
* @returns {Array.<string>} 已注册的PAPI变量数组
|
||||||
|
*/
|
||||||
static getAllPAPI() {
|
static getAllPAPI() {
|
||||||
return PlaceholderAPI.getAllPAPI();
|
return PlaceholderAPI.getAllPAPI();
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+251
@@ -0,0 +1,251 @@
|
|||||||
|
/** 事件监听接口 */
|
||||||
|
declare class Event {
|
||||||
|
/** 生物捡起物品 */
|
||||||
|
static listen(
|
||||||
|
/** 事件名 */
|
||||||
|
event: "onMobDie",
|
||||||
|
/** 监听函数 */
|
||||||
|
listener: (
|
||||||
|
/** 尝试捡起物品的实体对象 */
|
||||||
|
entity: Entity,
|
||||||
|
/** 掉落物实体对象 */
|
||||||
|
itemEntity: Entity
|
||||||
|
) => boolean | void
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 客户端登录后事件(不可以拦截) */
|
||||||
|
static listen(
|
||||||
|
/** 事件名 */
|
||||||
|
event: "onClientLogin",
|
||||||
|
/** 监听函数 */
|
||||||
|
listener: (
|
||||||
|
/** 玩家的游戏名字 */
|
||||||
|
realName: string,
|
||||||
|
/** 玩家的uuid */
|
||||||
|
uuid: string,
|
||||||
|
/** 玩家在服务端的xuid */
|
||||||
|
serverXuid: string,
|
||||||
|
/** 玩家在客户端的xuid */
|
||||||
|
clientXuid: string
|
||||||
|
) => void
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 天气改变事件事件 */
|
||||||
|
static listen(
|
||||||
|
/** 事件名 */
|
||||||
|
event: "onWeatherChange",
|
||||||
|
/** 监听函数 */
|
||||||
|
listener: (
|
||||||
|
/** 雷暴天气等级 */
|
||||||
|
lightningLevel: number,
|
||||||
|
/** 雨天天气等级 */
|
||||||
|
rainLevel: number,
|
||||||
|
/** 雷暴持续时间(刻) */
|
||||||
|
lightningLastTick: number,
|
||||||
|
/** 雨天持续时间(刻) */
|
||||||
|
rainingLastTick: number
|
||||||
|
) => boolean | void
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 掉落物尝试生成 */
|
||||||
|
static listen(
|
||||||
|
event: "onItemTrySpawn",
|
||||||
|
listener: (
|
||||||
|
/** 物品对象 */
|
||||||
|
item: Item,
|
||||||
|
/** 尝试生成的坐标对象 */
|
||||||
|
pos: FloatPos,
|
||||||
|
/** 创建掉落物的实体对象 */
|
||||||
|
spawnerEntity: Entity
|
||||||
|
) => boolean | void
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 掉落物生成完毕(不可以拦截) */
|
||||||
|
static listen(
|
||||||
|
/** 事件名 */
|
||||||
|
event: "onItemSpawned",
|
||||||
|
/** 回调函数 */
|
||||||
|
listener: (
|
||||||
|
/** 物品对象 */
|
||||||
|
item: Item,
|
||||||
|
/** 掉落物实体对象 */
|
||||||
|
entity: Entity,
|
||||||
|
/** 实体生成的坐标 */
|
||||||
|
pos: FloatPos,
|
||||||
|
/** 创建掉落物的实体对象 */
|
||||||
|
spawnerEntity: Entity
|
||||||
|
) => void
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 实体切换维度 */
|
||||||
|
static listen(
|
||||||
|
/** 事件名 */
|
||||||
|
event: "onEntityChangeDim",
|
||||||
|
/** 回调函数 */
|
||||||
|
listener: (
|
||||||
|
/** 切换维度的实体对象 */
|
||||||
|
entity: Entity,
|
||||||
|
/** 前往到的维度ID */
|
||||||
|
dimid: number
|
||||||
|
) => boolean | void
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 实体切换维度后(不可拦截) */
|
||||||
|
static listen(
|
||||||
|
/** 事件名 */
|
||||||
|
event: "onEntityChangeDimAfter",
|
||||||
|
/** 回调函数 */
|
||||||
|
listener: (
|
||||||
|
/** 切换维度的实体对象 */
|
||||||
|
entity: Entity,
|
||||||
|
/** 前往到的维度ID */
|
||||||
|
fromDimid: number
|
||||||
|
) => void
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 玩家下床 */
|
||||||
|
static listen(
|
||||||
|
/** 事件名 */
|
||||||
|
event: "onLeaveBed",
|
||||||
|
/** 回调函数 */
|
||||||
|
listener: (
|
||||||
|
/** 下床的玩家对象 */
|
||||||
|
player: Player
|
||||||
|
) => boolean | void
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 触发死亡信息(不可以拦截) */
|
||||||
|
static listen(
|
||||||
|
/** 事件名 */
|
||||||
|
event: "onDeathMessage",
|
||||||
|
/** 回调函数 */
|
||||||
|
listener: (
|
||||||
|
/** 死亡信息键名 */
|
||||||
|
deathMsgKey: string,
|
||||||
|
/** 死亡信息翻译参数 */
|
||||||
|
deathMsgParams: string[],
|
||||||
|
/** 死亡实体的实体对象 */
|
||||||
|
entity: Entity
|
||||||
|
) => void
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 实体受伤后事件 */
|
||||||
|
static listen(
|
||||||
|
/** 事件名 */
|
||||||
|
event: "onMobHurted",
|
||||||
|
/** 回调函数 */
|
||||||
|
listener: (
|
||||||
|
/** 受伤的实体对象 */
|
||||||
|
entity: Entity,
|
||||||
|
/** 造成伤害的实体对象 */
|
||||||
|
source: Entity,
|
||||||
|
/** 伤害值 */
|
||||||
|
damage: number,
|
||||||
|
/** 伤害类型 */
|
||||||
|
cause: number
|
||||||
|
) => void
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 末影人搬起方块 */
|
||||||
|
static listen(
|
||||||
|
/** 事件名 */
|
||||||
|
event: "onEndermanTake",
|
||||||
|
/** 回调函数 */
|
||||||
|
listener: (
|
||||||
|
/** 末影人实体对象 */
|
||||||
|
entity: Entity
|
||||||
|
) => boolean | void
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 末影龙重生事件 */
|
||||||
|
static listen(
|
||||||
|
/** 事件名 */
|
||||||
|
event: "onDragonRespawn",
|
||||||
|
/** 回调函数 */
|
||||||
|
listener: (
|
||||||
|
/** 末影龙重生后的UniqueID */
|
||||||
|
uniqueID: number
|
||||||
|
) => boolean | void
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 弹射物实体尝试创建 */
|
||||||
|
static listen(
|
||||||
|
/** 事件名 */
|
||||||
|
event: "onProjectileTryCreate",
|
||||||
|
/** 回调函数 */
|
||||||
|
listener: (
|
||||||
|
/** 弹射物实体对象 */
|
||||||
|
entity: Entity,
|
||||||
|
/** 创建弹射的实体的uniqueID */
|
||||||
|
uniqueId: number
|
||||||
|
) => boolean | void
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 弹射物实体成功后(不可拦截) */
|
||||||
|
static listen(
|
||||||
|
/** 事件名 */
|
||||||
|
event: "onProjectileCreate",
|
||||||
|
/** 回调函数 */
|
||||||
|
listener: (
|
||||||
|
/** 弹射物实体对象 */
|
||||||
|
entity: Entity,
|
||||||
|
/** 创建弹射的实体的uniqueID */
|
||||||
|
uniqueId: number
|
||||||
|
) => void
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 生成流浪商人 */
|
||||||
|
static listen(
|
||||||
|
/** 事件名 */
|
||||||
|
event: "onSpawnWanderingTrader",
|
||||||
|
/** 回调函数 */
|
||||||
|
listener: (
|
||||||
|
/** 生成的坐标 */
|
||||||
|
pos: IntPos
|
||||||
|
) => boolean | void
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 处理物品请求 */
|
||||||
|
static listen(
|
||||||
|
/** 事件名 */
|
||||||
|
event: "onHandleRequestAction",
|
||||||
|
/** 回调函数 */
|
||||||
|
listener: (
|
||||||
|
/** 请求玩家 */
|
||||||
|
player: Player,
|
||||||
|
/** 请求类型 */
|
||||||
|
actionType: string,
|
||||||
|
/** 请求数量 */
|
||||||
|
count: number,
|
||||||
|
/** 第一个格子的容器类型 */
|
||||||
|
sourceContainerNetId: string,
|
||||||
|
/** 第一个格子的槽位 */
|
||||||
|
sourceSlot: number,
|
||||||
|
/** 第二个格子的容器类型 */
|
||||||
|
destinationContainerNetId: string,
|
||||||
|
/** 第二个格子的槽位 */
|
||||||
|
destinationSlot: number
|
||||||
|
) => boolean | void
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 发送容器关闭数据包后(不可拦截) */
|
||||||
|
static listen(
|
||||||
|
/** 事件名 */
|
||||||
|
event: "onSendContainerClosePacket",
|
||||||
|
/** 回调函数 */
|
||||||
|
listener: (
|
||||||
|
/** 要被关闭的玩家 */
|
||||||
|
player: Player,
|
||||||
|
/** 容器ID */
|
||||||
|
containerId: number
|
||||||
|
) => void
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 关闭服务器(不可拦截) */
|
||||||
|
static listen(
|
||||||
|
/** 事件名 */
|
||||||
|
event: "onServerStopping",
|
||||||
|
/** 回调函数 */
|
||||||
|
listener: () => void
|
||||||
|
): boolean;
|
||||||
|
}
|
||||||
@@ -1,17 +1,30 @@
|
|||||||
|
/** 事件创建函数 @type {function(string,string):boolean} */
|
||||||
const CallEvent = ll.import("GMLIB_API", "callCustomEvent");
|
const CallEvent = ll.import("GMLIB_API", "callCustomEvent");
|
||||||
|
|
||||||
|
/** 事件ID @type {number} */
|
||||||
let NextEventId = 0;
|
let NextEventId = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取事件ID标识名
|
||||||
|
* @returns {string} 事件ID标识名
|
||||||
|
*/
|
||||||
function getNextEventId() {
|
function getNextEventId() {
|
||||||
NextEventId++;
|
NextEventId++;
|
||||||
return "GMLIB_Event_" + NextEventId;
|
return "GMLIB_Event_" + NextEventId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 事件类 */
|
||||||
class Event {
|
class Event {
|
||||||
constructor() {
|
constructor() {
|
||||||
throw new Error("Static class cannot be instantiated");
|
throw new Error("Static class cannot be instantiated");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监听事件
|
||||||
|
* @param {string} event 事件名称
|
||||||
|
* @param {function} callback 回调
|
||||||
|
* @returns {boolean} 是否创建成功
|
||||||
|
*/
|
||||||
static listen(event, callback) {
|
static listen(event, callback) {
|
||||||
let eventId = getNextEventId();
|
let eventId = getNextEventId();
|
||||||
ll.export(callback, event, eventId);
|
ll.export(callback, event, eventId);
|
||||||
|
|||||||
Vendored
+1373
File diff suppressed because it is too large
Load Diff
+1944
-152
File diff suppressed because it is too large
Load Diff
+2
-1
@@ -1,9 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "${pluginName}",
|
"name": "${pluginName}",
|
||||||
"entry": "${pluginFile}",
|
"entry": "${pluginFile}",
|
||||||
"version": "0.12.1",
|
"version": "0.13.2",
|
||||||
"author": "GroupMountain",
|
"author": "GroupMountain",
|
||||||
"type": "native",
|
"type": "native",
|
||||||
|
"passive": true,
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
{
|
{
|
||||||
"name": "GMLIB"
|
"name": "GMLIB"
|
||||||
|
|||||||
+708
-183
File diff suppressed because it is too large
Load Diff
+10
-10
@@ -3,14 +3,14 @@
|
|||||||
|
|
||||||
ll::Logger logger(PLUGIN_NAME);
|
ll::Logger logger(PLUGIN_NAME);
|
||||||
|
|
||||||
namespace GMLIB_LegacyRemoteCallApi {
|
namespace GMLIB {
|
||||||
|
|
||||||
std::unique_ptr<LRCA>& LRCA::getInstance() {
|
std::unique_ptr<LegacyRemoteCallApi>& LegacyRemoteCallApi::getInstance() {
|
||||||
static std::unique_ptr<LRCA> instance;
|
static std::unique_ptr<LegacyRemoteCallApi> instance;
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LRCA::load() {
|
bool LegacyRemoteCallApi::load() {
|
||||||
Export_Legacy_GMLib_ModAPI();
|
Export_Legacy_GMLib_ModAPI();
|
||||||
Export_Legacy_GMLib_ServerAPI();
|
Export_Legacy_GMLib_ServerAPI();
|
||||||
Export_Compatibility_API();
|
Export_Compatibility_API();
|
||||||
@@ -19,18 +19,18 @@ bool LRCA::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-" + Version::getLibVersionString()),
|
||||||
fmt::format(fg(fmt::color::light_green), "GMLIB-LegacyRemoteCallApi-"+LIB_VERSION.asString())
|
fmt::format(fg(fmt::color::light_green), "GMLIB-LegacyRemoteCallApi-" + LIB_VERSION.asString())
|
||||||
);
|
);
|
||||||
logger.info("Author: GroupMountain");
|
logger.info("Author: GroupMountain");
|
||||||
logger.info("Repository: https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi");
|
logger.info("Repository: https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LRCA::enable() { return true; }
|
bool LegacyRemoteCallApi::enable() { return true; }
|
||||||
|
|
||||||
bool LRCA::disable() { return true; }
|
bool LegacyRemoteCallApi::disable() { return true; }
|
||||||
|
|
||||||
} // namespace GMLIB_LegacyRemoteCallApi
|
} // namespace GMLIB
|
||||||
|
|
||||||
LL_REGISTER_PLUGIN(GMLIB_LegacyRemoteCallApi::LRCA, GMLIB_LegacyRemoteCallApi::LRCA::getInstance());
|
LL_REGISTER_MOD(LegacyRemoteCallApi, LegacyRemoteCallApi::getInstance());
|
||||||
|
|||||||
+9
-9
@@ -1,17 +1,17 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <ll/api/plugin/NativePlugin.h>
|
#include <ll/api/mod/NativeMod.h>
|
||||||
#include <ll/api/plugin/RegisterHelper.h>
|
#include <ll/api/mod/RegisterHelper.h>
|
||||||
|
|
||||||
namespace GMLIB_LegacyRemoteCallApi {
|
namespace GMLIB {
|
||||||
|
|
||||||
class LRCA {
|
class LegacyRemoteCallApi {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static std::unique_ptr<LRCA>& getInstance();
|
static std::unique_ptr<LegacyRemoteCallApi>& getInstance();
|
||||||
|
|
||||||
LRCA(ll::plugin::NativePlugin& self) : mSelf(self) {}
|
LegacyRemoteCallApi(ll::mod::NativeMod& self) : mSelf(self) {}
|
||||||
|
|
||||||
[[nodiscard]] ll::plugin::NativePlugin& getSelf() const { return mSelf; }
|
[[nodiscard]] ll::mod::NativeMod& getSelf() const { return mSelf; }
|
||||||
|
|
||||||
/// @return True if the plugin is loaded successfully.
|
/// @return True if the plugin is loaded successfully.
|
||||||
bool load();
|
bool load();
|
||||||
@@ -27,7 +27,7 @@ public:
|
|||||||
// bool unload();
|
// bool unload();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ll::plugin::NativePlugin& mSelf;
|
ll::mod::NativeMod& mSelf;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace GMLIB_LegacyRemoteCallApi
|
} // namespace GMLIB
|
||||||
|
|||||||
+321
-187
@@ -6,194 +6,328 @@ void Export_Event_API() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"callCustomEvent",
|
"callCustomEvent",
|
||||||
[eventBus](std::string eventName, std::string eventId) -> bool {
|
[eventBus](std::string const& eventName, std::string const& eventId) -> bool {
|
||||||
if (RemoteCall::hasFunc(eventName, eventId)) {
|
if (!RemoteCall::hasFunc(eventName, eventId)) return false;
|
||||||
switch (doHash(eventName)) {
|
switch (doHash(eventName)) {
|
||||||
case doHash("onClientLogin"): {
|
case doHash("onClientLogin"): {
|
||||||
auto Call = RemoteCall::importAs<
|
auto Call = RemoteCall::importAs<bool(
|
||||||
bool(std::string realName, std::string uuid, std::string serverXuid, std::string clientXuid)>(
|
std::string const& realName,
|
||||||
eventName,
|
std::string const& uuid,
|
||||||
eventId
|
std::string const& serverXuid,
|
||||||
);
|
std::string const& clientXuid
|
||||||
eventBus->emplaceListener<GMLIB::Event::PacketEvent::ClientLoginAfterEvent>(
|
)>(eventName, eventId);
|
||||||
[Call](GMLIB::Event::PacketEvent::ClientLoginAfterEvent& ev) {
|
eventBus->emplaceListener<Event::PacketEvent::ClientLoginAfterEvent>(
|
||||||
try {
|
[Call](Event::PacketEvent::ClientLoginAfterEvent& ev) {
|
||||||
Call(
|
try {
|
||||||
ev.getRealName(),
|
Call(
|
||||||
ev.getUuid().asString(),
|
ev.getRealName(),
|
||||||
ev.getServerAuthXuid(),
|
ev.getUuid().asString(),
|
||||||
ev.getClientAuthXuid()
|
ev.getServerAuthXuid(),
|
||||||
);
|
ev.getClientAuthXuid()
|
||||||
} catch (...) {}
|
);
|
||||||
}
|
} catch (...) {}
|
||||||
);
|
}
|
||||||
return true;
|
);
|
||||||
}
|
return true;
|
||||||
case doHash("onWeatherChange"): {
|
}
|
||||||
auto Call =
|
case doHash("onWeatherChange"): {
|
||||||
RemoteCall::importAs<bool(int lightningLevel, int rainLevel, int lightningLast, int rainLast)>(
|
auto Call =
|
||||||
eventName,
|
RemoteCall::importAs<bool(int lightningLevel, int rainLevel, int lightningLast, int rainLast)>(
|
||||||
eventId
|
eventName,
|
||||||
);
|
eventId
|
||||||
eventBus->emplaceListener<GMLIB::Event::LevelEvent::WeatherUpdateBeforeEvent>(
|
);
|
||||||
[Call](GMLIB::Event::LevelEvent::WeatherUpdateBeforeEvent& ev) {
|
eventBus->emplaceListener<Event::LevelEvent::WeatherUpdateBeforeEvent>(
|
||||||
bool result = true;
|
[Call](Event::LevelEvent::WeatherUpdateBeforeEvent& ev) {
|
||||||
try {
|
bool result = true;
|
||||||
result = Call(
|
try {
|
||||||
ev.getLightningLevel(),
|
result = Call(
|
||||||
ev.getRainLevel(),
|
ev.getLightningLevel(),
|
||||||
ev.getLightningLastTick(),
|
ev.getRainLevel(),
|
||||||
ev.getRainingLastTick()
|
ev.getLightningLastTick(),
|
||||||
);
|
ev.getRainingLastTick()
|
||||||
} catch (...) {}
|
);
|
||||||
if (!result) {
|
} catch (...) {}
|
||||||
ev.cancel();
|
if (!result) {
|
||||||
}
|
ev.cancel();
|
||||||
}
|
}
|
||||||
);
|
}
|
||||||
return true;
|
);
|
||||||
}
|
return true;
|
||||||
case doHash("onMobPick"): {
|
}
|
||||||
auto Call = RemoteCall::importAs<bool(Actor * mob, Actor * item)>(eventName, eventId);
|
case doHash("onMobPick"): {
|
||||||
eventBus->emplaceListener<GMLIB::Event::EntityEvent::MobPickupItemBeforeEvent>(
|
auto Call = RemoteCall::importAs<bool(Actor * mob, Actor * item)>(eventName, eventId);
|
||||||
[Call](GMLIB::Event::EntityEvent::MobPickupItemBeforeEvent& ev) {
|
eventBus->emplaceListener<Event::EntityEvent::MobPickupItemBeforeEvent>(
|
||||||
bool result = true;
|
[Call](Event::EntityEvent::MobPickupItemBeforeEvent& ev) {
|
||||||
try {
|
bool result = true;
|
||||||
result = Call(&ev.self(), (Actor*)&ev.getItemActor());
|
try {
|
||||||
} catch (...) {}
|
result = Call(&ev.self(), (Actor*)&ev.getItemActor());
|
||||||
if (!result) {
|
} catch (...) {}
|
||||||
ev.cancel();
|
if (!result) {
|
||||||
}
|
ev.cancel();
|
||||||
}
|
}
|
||||||
);
|
}
|
||||||
return true;
|
);
|
||||||
}
|
return true;
|
||||||
case doHash("onItemTrySpawn"): {
|
}
|
||||||
auto Call = RemoteCall::importAs<
|
case doHash("onItemTrySpawn"): {
|
||||||
bool(const ItemStack* item, std::pair<Vec3, int> position, Actor* spawner)>(eventName, eventId);
|
auto Call =
|
||||||
eventBus->emplaceListener<GMLIB::Event::EntityEvent::ItemActorSpawnBeforeEvent>(
|
RemoteCall::importAs<bool(const ItemStack* item, std::pair<Vec3, int> position, Actor* spawner)>(
|
||||||
[Call](GMLIB::Event::EntityEvent::ItemActorSpawnBeforeEvent& ev) {
|
eventName,
|
||||||
auto pos = ev.getPosition();
|
eventId
|
||||||
auto dimid = ev.getBlockSource().getDimensionId().id;
|
);
|
||||||
std::pair<Vec3, int> lsePos = {pos, dimid};
|
eventBus->emplaceListener<Event::EntityEvent::ItemActorSpawnBeforeEvent>(
|
||||||
bool result = true;
|
[Call](Event::EntityEvent::ItemActorSpawnBeforeEvent& ev) {
|
||||||
try {
|
auto pos = ev.getPosition();
|
||||||
result = Call(&ev.getItem(), lsePos, ev.getSpawner());
|
auto dimid = ev.getBlockSource().getDimensionId().id;
|
||||||
} catch (...) {}
|
std::pair<Vec3, int> lsePos = {pos, dimid};
|
||||||
if (!result) {
|
bool result = true;
|
||||||
ev.cancel();
|
try {
|
||||||
}
|
result = Call(&ev.getItem(), lsePos, ev.getSpawner());
|
||||||
}
|
} catch (...) {}
|
||||||
);
|
if (!result) {
|
||||||
return true;
|
ev.cancel();
|
||||||
}
|
}
|
||||||
case doHash("onItemSpawned"): {
|
}
|
||||||
auto Call = RemoteCall::importAs<
|
);
|
||||||
bool(const ItemStack* item, Actor* itemActor, std::pair<Vec3, int> position, Actor* spawner)>(
|
return true;
|
||||||
eventName,
|
}
|
||||||
eventId
|
case doHash("onItemSpawned"): {
|
||||||
);
|
auto Call = RemoteCall::importAs<
|
||||||
eventBus->emplaceListener<GMLIB::Event::EntityEvent::ItemActorSpawnAfterEvent>(
|
bool(const ItemStack* item, Actor* itemActor, std::pair<Vec3, int> position, Actor* spawner)>(
|
||||||
[Call](GMLIB::Event::EntityEvent::ItemActorSpawnAfterEvent& ev) {
|
eventName,
|
||||||
auto pos = ev.getPosition();
|
eventId
|
||||||
auto dimid = ev.getBlockSource().getDimensionId().id;
|
);
|
||||||
std::pair<Vec3, int> lsePos = {pos, dimid};
|
eventBus->emplaceListener<Event::EntityEvent::ItemActorSpawnAfterEvent>(
|
||||||
try {
|
[Call](Event::EntityEvent::ItemActorSpawnAfterEvent& ev) {
|
||||||
Call(&ev.getItem(), (Actor*)&ev.getItemActor(), lsePos, ev.getSpawner());
|
auto pos = ev.getPosition();
|
||||||
} catch (...) {}
|
auto dimid = ev.getBlockSource().getDimensionId().id;
|
||||||
}
|
std::pair<Vec3, int> lsePos = {pos, dimid};
|
||||||
);
|
try {
|
||||||
return true;
|
Call(&ev.getItem(), (Actor*)&ev.getItemActor(), lsePos, ev.getSpawner());
|
||||||
}
|
} catch (...) {}
|
||||||
case doHash("onEntityChangeDim"): {
|
}
|
||||||
auto Call = RemoteCall::importAs<bool(Actor * entity, int toDimId)>(eventName, eventId);
|
);
|
||||||
eventBus->emplaceListener<GMLIB::Event::EntityEvent::ActorChangeDimensionBeforeEvent>(
|
return true;
|
||||||
[Call](GMLIB::Event::EntityEvent::ActorChangeDimensionBeforeEvent& ev) {
|
}
|
||||||
bool result = true;
|
case doHash("onEntityChangeDim"): {
|
||||||
try {
|
auto Call = RemoteCall::importAs<bool(Actor * entity, int toDimId)>(eventName, eventId);
|
||||||
result = Call(&ev.self(), ev.getToDimensionId());
|
eventBus->emplaceListener<Event::EntityEvent::ActorChangeDimensionBeforeEvent>(
|
||||||
} catch (...) {}
|
[Call](Event::EntityEvent::ActorChangeDimensionBeforeEvent& ev) {
|
||||||
if (!result) {
|
bool result = true;
|
||||||
ev.cancel();
|
try {
|
||||||
}
|
result = Call(&ev.self(), ev.getToDimensionId());
|
||||||
}
|
} catch (...) {}
|
||||||
);
|
if (!result) {
|
||||||
return true;
|
ev.cancel();
|
||||||
}
|
}
|
||||||
case doHash("onLeaveBed"): {
|
}
|
||||||
auto Call = RemoteCall::importAs<bool(Player * pl)>(eventName, eventId);
|
);
|
||||||
eventBus->emplaceListener<GMLIB::Event::PlayerEvent::PlayerStopSleepBeforeEvent>(
|
return true;
|
||||||
[Call](GMLIB::Event::PlayerEvent::PlayerStopSleepBeforeEvent& ev) {
|
}
|
||||||
bool result = true;
|
case doHash("onLeaveBed"): {
|
||||||
try {
|
auto Call = RemoteCall::importAs<bool(Player * pl)>(eventName, eventId);
|
||||||
result = Call(&ev.self());
|
eventBus->emplaceListener<Event::PlayerEvent::PlayerStopSleepBeforeEvent>(
|
||||||
} catch (...) {}
|
[Call](Event::PlayerEvent::PlayerStopSleepBeforeEvent& ev) {
|
||||||
if (!result) {
|
bool result = true;
|
||||||
ev.cancel();
|
try {
|
||||||
}
|
result = Call(&ev.self());
|
||||||
}
|
} catch (...) {}
|
||||||
);
|
if (!result) {
|
||||||
return true;
|
ev.cancel();
|
||||||
}
|
}
|
||||||
case doHash("onDeathMessage"): {
|
}
|
||||||
auto Call = RemoteCall::importAs<bool(std::string message, std::vector<std::string>, Actor * dead)>(
|
);
|
||||||
eventName,
|
return true;
|
||||||
eventId
|
}
|
||||||
);
|
case doHash("onDeathMessage"): {
|
||||||
eventBus->emplaceListener<GMLIB::Event::EntityEvent::DeathMessageAfterEvent>(
|
auto Call =
|
||||||
[Call](GMLIB::Event::EntityEvent::DeathMessageAfterEvent& ev) {
|
RemoteCall::importAs<bool(std::string const& message, std::vector<std::string>, Actor* dead)>(
|
||||||
auto msg = ev.getDeathMessage();
|
eventName,
|
||||||
auto source = ev.getDamageSource();
|
eventId
|
||||||
try {
|
);
|
||||||
Call(msg.first, msg.second, &ev.self());
|
eventBus->emplaceListener<Event::EntityEvent::DeathMessageAfterEvent>(
|
||||||
} catch (...) {}
|
[Call](Event::EntityEvent::DeathMessageAfterEvent& ev) {
|
||||||
}
|
auto msg = ev.getDeathMessage();
|
||||||
);
|
auto source = ev.getDamageSource();
|
||||||
return true;
|
try {
|
||||||
}
|
Call(msg.first, msg.second, &ev.self());
|
||||||
case doHash("onMobHurted"): {
|
} catch (...) {}
|
||||||
auto Call = RemoteCall::importAs<bool(Actor * mob, Actor * source, float damage, int cause)>(
|
}
|
||||||
eventName,
|
);
|
||||||
eventId
|
return true;
|
||||||
);
|
}
|
||||||
eventBus->emplaceListener<GMLIB::Event::EntityEvent::MobHurtAfterEvent>(
|
case doHash("onMobHurted"): {
|
||||||
[Call](GMLIB::Event::EntityEvent::MobHurtAfterEvent& ev) {
|
auto Call = RemoteCall::importAs<bool(Actor * mob, Actor * source, float damage, int cause)>(
|
||||||
auto& damageSource = ev.getSource();
|
eventName,
|
||||||
Actor* source = nullptr;
|
eventId
|
||||||
if (damageSource.isEntitySource()) {
|
);
|
||||||
auto uniqueId = damageSource.getDamagingEntityUniqueID();
|
eventBus->emplaceListener<Event::EntityEvent::MobHurtAfterEvent>(
|
||||||
source = ll::service::getLevel()->fetchEntity(uniqueId);
|
[Call](Event::EntityEvent::MobHurtAfterEvent& ev) {
|
||||||
if (source->getOwner()) {
|
auto& damageSource = ev.getSource();
|
||||||
source = source->getOwner();
|
Actor* source = nullptr;
|
||||||
}
|
if (damageSource.isEntitySource()) {
|
||||||
}
|
auto uniqueId = damageSource.getDamagingEntityUniqueID();
|
||||||
try {
|
source = ll::service::getLevel()->fetchEntity(uniqueId);
|
||||||
Call(&ev.self(), source, ev.getDamage(), (int)damageSource.getCause());
|
if (source->getOwner()) {
|
||||||
} catch (...) {}
|
source = source->getOwner();
|
||||||
}
|
}
|
||||||
);
|
}
|
||||||
return true;
|
try {
|
||||||
}
|
Call(&ev.self(), source, ev.getDamage(), (int)damageSource.getCause());
|
||||||
case doHash("onEndermanTake"): {
|
} catch (...) {}
|
||||||
auto Call = RemoteCall::importAs<bool(Actor * mob)>(eventName, eventId);
|
}
|
||||||
eventBus->emplaceListener<GMLIB::Event::EntityEvent::EndermanTakeBlockBeforeEvent>(
|
);
|
||||||
[Call](GMLIB::Event::EntityEvent::EndermanTakeBlockBeforeEvent& ev) {
|
return true;
|
||||||
bool result = true;
|
}
|
||||||
try {
|
case doHash("onEndermanTake"): {
|
||||||
result = Call(&ev.self());
|
auto Call = RemoteCall::importAs<bool(Actor * mob)>(eventName, eventId);
|
||||||
} catch (...) {}
|
eventBus->emplaceListener<Event::EntityEvent::EndermanTakeBlockBeforeEvent>(
|
||||||
if (!result) {
|
[Call](Event::EntityEvent::EndermanTakeBlockBeforeEvent& ev) {
|
||||||
ev.cancel();
|
bool result = true;
|
||||||
}
|
try {
|
||||||
}
|
result = Call(&ev.self());
|
||||||
);
|
} catch (...) {}
|
||||||
return true;
|
if (!result) {
|
||||||
}
|
ev.cancel();
|
||||||
default:
|
}
|
||||||
return false;
|
}
|
||||||
}
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case doHash("onEntityChangeDimAfter"): {
|
||||||
|
auto Call = RemoteCall::importAs<bool(Actor * mob, int fromDimId)>(eventName, eventId);
|
||||||
|
eventBus->emplaceListener<Event::EntityEvent::ActorChangeDimensionAfterEvent>(
|
||||||
|
[Call](Event::EntityEvent::ActorChangeDimensionAfterEvent& ev) {
|
||||||
|
bool result = true;
|
||||||
|
try {
|
||||||
|
result = Call(&ev.self(), ev.getFromDimensionId());
|
||||||
|
} catch (...) {}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case doHash("onDragonRespawn"): {
|
||||||
|
auto Call = RemoteCall::importAs<bool(int64 enderDragonUniqueID)>(eventName, eventId);
|
||||||
|
eventBus->emplaceListener<Event::EntityEvent::DragonRespawnBeforeEvent>(
|
||||||
|
[Call](Event::EntityEvent::DragonRespawnBeforeEvent& ev) {
|
||||||
|
bool result = true;
|
||||||
|
try {
|
||||||
|
result = Call(ev.getEnderDragon().id);
|
||||||
|
} catch (...) {}
|
||||||
|
if (!result) {
|
||||||
|
ev.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case doHash("onProjectileTryCreate"): {
|
||||||
|
auto Call = RemoteCall::importAs<bool(Actor * mob, int64 uniqueId)>(eventName, eventId);
|
||||||
|
eventBus->emplaceListener<Event::EntityEvent::ProjectileCreateBeforeEvent>(
|
||||||
|
[Call](Event::EntityEvent::ProjectileCreateBeforeEvent& ev) {
|
||||||
|
bool result = true;
|
||||||
|
try {
|
||||||
|
auto uid = ev.getShooter() ? ev.getShooter()->getOrCreateUniqueID().id : -1;
|
||||||
|
result = Call(&ev.self(), uid);
|
||||||
|
} catch (...) {}
|
||||||
|
if (!result) {
|
||||||
|
ev.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case doHash("onProjectileCreate"): {
|
||||||
|
auto Call = RemoteCall::importAs<bool(Actor * mob, int64 uniqueId)>(eventName, eventId);
|
||||||
|
eventBus->emplaceListener<Event::EntityEvent::ProjectileCreateAfterEvent>(
|
||||||
|
[Call](Event::EntityEvent::ProjectileCreateAfterEvent& ev) {
|
||||||
|
try {
|
||||||
|
auto uid = ev.getShooter() ? ev.getShooter()->getOrCreateUniqueID().id : -1;
|
||||||
|
Call(&ev.self(), uid);
|
||||||
|
} catch (...) {}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case doHash("onSpawnWanderingTrader"): {
|
||||||
|
auto Call = RemoteCall::importAs<bool(std::pair<BlockPos, int> pos)>(eventName, eventId);
|
||||||
|
eventBus->emplaceListener<Event::EntityEvent::SpawnWanderingTraderBeforeEvent>(
|
||||||
|
[Call](Event::EntityEvent::SpawnWanderingTraderBeforeEvent& ev) {
|
||||||
|
bool result = true;
|
||||||
|
try {
|
||||||
|
result = Call({ev.getPos(), ev.getRegion().getDimensionId()});
|
||||||
|
} catch (...) {}
|
||||||
|
if (!result) {
|
||||||
|
ev.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case doHash("onHandleRequestAction"): {
|
||||||
|
auto Call = RemoteCall::importAs<bool(
|
||||||
|
Player * player,
|
||||||
|
std::string const& actionType,
|
||||||
|
int count,
|
||||||
|
std::string const& sourceContainerNetId,
|
||||||
|
int sourceSlot,
|
||||||
|
std::string const& destinationContainerNetId,
|
||||||
|
int destinationSlot
|
||||||
|
)>(eventName, eventId);
|
||||||
|
eventBus->emplaceListener<Event::PlayerEvent::HandleRequestActionBeforeEvent>(
|
||||||
|
[Call](Event::PlayerEvent::HandleRequestActionBeforeEvent& ev) {
|
||||||
|
bool result = true;
|
||||||
|
try {
|
||||||
|
auto requestAction = (ItemStackRequestActionTransferBase*)&ev.getRequestAction();
|
||||||
|
auto source = requestAction->getSrc();
|
||||||
|
// TODO: The next version of LeviLamina changes to a member function
|
||||||
|
auto destination = ll::memory::dAccess<ItemStackRequestSlotInfo>(requestAction, 56);
|
||||||
|
result = Call(
|
||||||
|
&ev.self(),
|
||||||
|
magic_enum::enum_name(requestAction->mActionType).data(),
|
||||||
|
ll::memory::dAccess<uchar>(requestAction, 18),
|
||||||
|
magic_enum::enum_name(source.mOpenContainerNetId).data(),
|
||||||
|
source.mSlot,
|
||||||
|
magic_enum::enum_name(destination.mOpenContainerNetId).data(),
|
||||||
|
destination.mSlot
|
||||||
|
);
|
||||||
|
} catch (...) {}
|
||||||
|
if (!result) {
|
||||||
|
ev.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case doHash("onSendContainerClosePacket"): {
|
||||||
|
auto Call = RemoteCall::importAs<bool(Player * player, int ContainerNetId)>(eventName, eventId);
|
||||||
|
eventBus->emplaceListener<Event::PacketEvent::ContainerClosePacketSendAfterEvent>(
|
||||||
|
[Call](Event::PacketEvent::ContainerClosePacketSendAfterEvent& ev) {
|
||||||
|
try {
|
||||||
|
Call(
|
||||||
|
ev.getServerNetworkHandler()
|
||||||
|
.getServerPlayer(ev.getNetworkIdentifier(), ev.getPacket().mClientSubId),
|
||||||
|
(int)ev.getPacket().mContainerId
|
||||||
|
);
|
||||||
|
} catch (...) {}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case doHash("onServerStopping"): {
|
||||||
|
auto Call = RemoteCall::importAs<bool()>(eventName, eventId);
|
||||||
|
eventBus->emplaceListener<ll::event::server::ServerStoppingEvent>(
|
||||||
|
[Call](ll::event::server::ServerStoppingEvent& ev) {
|
||||||
|
try {
|
||||||
|
Call();
|
||||||
|
} catch (...) {}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
+9
-1
@@ -3,9 +3,17 @@
|
|||||||
|
|
||||||
#include <RemoteCallAPI.h>
|
#include <RemoteCallAPI.h>
|
||||||
|
|
||||||
|
using namespace GMLIB;
|
||||||
|
using namespace Server;
|
||||||
|
using namespace Mod;
|
||||||
|
|
||||||
#define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA")
|
#define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA")
|
||||||
|
|
||||||
#define LIB_VERSION GMLIB::Version(0, 12, 1)
|
#define LIB_VERSION_MAJOR 0
|
||||||
|
#define LIB_VERSION_MINOR 13
|
||||||
|
#define LIB_VERSION_PATCH 2
|
||||||
|
|
||||||
|
#define LIB_VERSION Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH)
|
||||||
|
|
||||||
extern ll::Logger logger;
|
extern ll::Logger logger;
|
||||||
|
|
||||||
|
|||||||
+61
-50
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
std::unordered_set<std::string> HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"};
|
std::unordered_set<std::string> HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"};
|
||||||
|
|
||||||
std::variant<std::string, std::vector<RecipeIngredient>> makeRecipeUnlockingKey(std::string& key) {
|
std::variant<std::string, std::vector<RecipeIngredient>> makeRecipeUnlockingKey(std::string const& key) {
|
||||||
if (HardCodedKeys.count(key)) {
|
if (HardCodedKeys.count(key)) {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
@@ -17,11 +17,11 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ModAPI",
|
"GMLib_ModAPI",
|
||||||
"registerShapelessRecipe",
|
"registerShapelessRecipe",
|
||||||
[](std::string recipe_id,
|
[](std::string const& recipe_id,
|
||||||
std::vector<std::string> ingredients,
|
std::vector<std::string> ingredients,
|
||||||
std::string result,
|
std::string const& result,
|
||||||
int count,
|
int count,
|
||||||
std::string unlock) -> void {
|
std::string const& unlock) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
@@ -33,18 +33,18 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
}
|
}
|
||||||
auto res = RecipeIngredient(result, 0, count);
|
auto res = RecipeIngredient(result, 0, count);
|
||||||
auto unl = makeRecipeUnlockingKey(unlock);
|
auto unl = makeRecipeUnlockingKey(unlock);
|
||||||
GMLIB::Mod::JsonRecipe::registerShapelessCraftingTableRecipe(recipe_id, types, res, unl);
|
JsonRecipe::registerShapelessCraftingTableRecipe(recipe_id, types, res, unl);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ModAPI",
|
"GMLib_ModAPI",
|
||||||
"registerShapedRecipe",
|
"registerShapedRecipe",
|
||||||
[](std::string recipe_id,
|
[](std::string const& recipe_id,
|
||||||
std::vector<std::string> shape,
|
std::vector<std::string> shape,
|
||||||
std::vector<std::string> ingredients,
|
std::vector<std::string> ingredients,
|
||||||
std::string result,
|
std::string const& result,
|
||||||
int count,
|
int count,
|
||||||
std::string unlock) -> void {
|
std::string const& unlock) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
@@ -56,38 +56,43 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
}
|
}
|
||||||
auto res = RecipeIngredient(result, 0, count);
|
auto res = RecipeIngredient(result, 0, count);
|
||||||
auto unl = makeRecipeUnlockingKey(unlock);
|
auto unl = makeRecipeUnlockingKey(unlock);
|
||||||
GMLIB::Mod::JsonRecipe::registerShapedCraftingTableRecipe(recipe_id, shape, types, res, unl);
|
JsonRecipe::registerShapedCraftingTableRecipe(recipe_id, shape, types, res, unl);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ModAPI",
|
"GMLib_ModAPI",
|
||||||
"registerFurnaceRecipe",
|
"registerFurnaceRecipe",
|
||||||
[](std::string recipe_id, std::string input, std::string output, std::vector<std::string> tags) -> void {
|
[](std::string const& recipe_id,
|
||||||
|
std::string const& input,
|
||||||
|
std::string const& output,
|
||||||
|
std::vector<std::string> tags) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto inp = RecipeIngredient(input, 0, 1);
|
auto inp = RecipeIngredient(input, 0, 1);
|
||||||
auto outp = RecipeIngredient(output, 0, 1);
|
auto outp = RecipeIngredient(output, 0, 1);
|
||||||
GMLIB::Mod::JsonRecipe::registerFurnaceRecipe(recipe_id, inp, outp, tags);
|
JsonRecipe::registerFurnaceRecipe(recipe_id, inp, outp, tags);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ModAPI",
|
"GMLib_ModAPI",
|
||||||
"registerBrewingMixRecipe",
|
"registerBrewingMixRecipe",
|
||||||
[](std::string recipe_id, std::string input, std::string output, std::string reagent) -> void {
|
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
||||||
|
) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto rea = RecipeIngredient(reagent, 0, 1);
|
auto rea = RecipeIngredient(reagent, 0, 1);
|
||||||
GMLIB::Mod::JsonRecipe::registerBrewingMixRecipe(recipe_id, input, output, rea);
|
JsonRecipe::registerBrewingMixRecipe(recipe_id, input, output, rea);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ModAPI",
|
"GMLib_ModAPI",
|
||||||
"registerBrewingContainerRecipe",
|
"registerBrewingContainerRecipe",
|
||||||
[](std::string recipe_id, std::string input, std::string output, std::string reagent) -> void {
|
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
||||||
|
) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
@@ -95,22 +100,22 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
auto inp = RecipeIngredient(input, 0, 1);
|
auto inp = RecipeIngredient(input, 0, 1);
|
||||||
auto outp = RecipeIngredient(output, 0, 1);
|
auto outp = RecipeIngredient(output, 0, 1);
|
||||||
auto rea = RecipeIngredient(reagent, 0, 1);
|
auto rea = RecipeIngredient(reagent, 0, 1);
|
||||||
GMLIB::Mod::JsonRecipe::registerBrewingContainerRecipe(recipe_id, inp, outp, rea);
|
JsonRecipe::registerBrewingContainerRecipe(recipe_id, inp, outp, rea);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ModAPI",
|
"GMLib_ModAPI",
|
||||||
"registerSmithingTransformRecipe",
|
"registerSmithingTransformRecipe",
|
||||||
[](std::string recipe_id,
|
[](std::string const& recipe_id,
|
||||||
std::string smithing_template,
|
std::string const& smithing_template,
|
||||||
std::string base,
|
std::string const& base,
|
||||||
std::string addition,
|
std::string const& addition,
|
||||||
std::string result) -> void {
|
std::string const& result) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GMLIB::Mod::JsonRecipe::registerSmithingTransformRecipe(
|
JsonRecipe::registerSmithingTransformRecipe(
|
||||||
recipe_id,
|
recipe_id,
|
||||||
smithing_template,
|
smithing_template,
|
||||||
base,
|
base,
|
||||||
@@ -122,66 +127,72 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ModAPI",
|
"GMLib_ModAPI",
|
||||||
"registerSmithingTrimRecipe",
|
"registerSmithingTrimRecipe",
|
||||||
[](std::string recipe_id, std::string smithing_template, std::string base, std::string addition) -> void {
|
[](std::string const& recipe_id,
|
||||||
|
std::string const& smithing_template,
|
||||||
|
std::string const& base,
|
||||||
|
std::string const& addition) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GMLIB::Mod::JsonRecipe::registerSmithingTrimRecipe(recipe_id, smithing_template, base, addition);
|
JsonRecipe::registerSmithingTrimRecipe(recipe_id, smithing_template, base, addition);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ModAPI",
|
"GMLib_ModAPI",
|
||||||
"registerStoneCutterRecipe",
|
"registerStoneCutterRecipe",
|
||||||
[](std::string recipe_id,
|
[](std::string const& recipe_id,
|
||||||
std::string input,
|
std::string const& input,
|
||||||
int input_data,
|
int input_data,
|
||||||
std::string output,
|
std::string const& output,
|
||||||
int output_data,
|
int output_data,
|
||||||
int output_count) -> void {
|
int output_count) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
auto level = GMLIB_Level::getInstance();
|
||||||
if (!level) {
|
if (!level) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto inp = RecipeIngredient(input, 0, 1);
|
auto inp = RecipeIngredient(input, 0, 1);
|
||||||
auto outp = RecipeIngredient(output, 0, 1);
|
auto outp = RecipeIngredient(output, 0, 1);
|
||||||
GMLIB::Mod::JsonRecipe::registerStoneCutterRecipe(recipe_id, inp, outp);
|
JsonRecipe::registerStoneCutterRecipe(recipe_id, inp, outp);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
// 错误方块清理
|
// 错误方块清理
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "setUnknownBlockCleaner", []() -> void {
|
RemoteCall::exportAs("GMLib_ModAPI", "setUnknownBlockCleaner", []() -> void {
|
||||||
GMLIB::Mod::VanillaFix::setAutoCleanUnknownBlockEnabled();
|
VanillaFix::setAutoCleanUnknownBlockEnabled();
|
||||||
});
|
});
|
||||||
// 实验性
|
// 实验性
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void {
|
RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void {
|
||||||
auto map = GMLIB_Level::getAllExperiments();
|
auto list = GMLIB_Level::getAllExperiments();
|
||||||
if (map.count(experiment_id)) {
|
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||||
|
if (set.contains((AllExperiments)experiment_id)) {
|
||||||
GMLIB_Level::addExperimentsRequire((AllExperiments)experiment_id);
|
GMLIB_Level::addExperimentsRequire((AllExperiments)experiment_id);
|
||||||
} else {
|
} else {
|
||||||
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
ll::Logger("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 {
|
||||||
auto level = GMLIB_Level::getInstance();
|
if (GMLIB_Level::getInstance()) {
|
||||||
if (!level) {
|
auto list = GMLIB_Level::getAllExperiments();
|
||||||
return;
|
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||||
|
if (set.contains((AllExperiments)experiment_id)) {
|
||||||
|
GMLIB_Level::getInstance()->setExperimentEnabled(((AllExperiments)experiment_id), value);
|
||||||
|
} else ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
||||||
}
|
}
|
||||||
auto map = GMLIB_Level::getAllExperiments();
|
|
||||||
if (map.count(experiment_id)) {
|
|
||||||
GMLIB_Level::getInstance()->setExperimentEnabled(((AllExperiments)experiment_id), value);
|
|
||||||
} else ll::Logger("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 {
|
||||||
auto level = GMLIB_Level::getInstance();
|
if (GMLIB_Level::getInstance()) {
|
||||||
if (!level) {
|
auto list = GMLIB_Level::getAllExperiments();
|
||||||
return false;
|
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||||
}
|
if (set.contains((AllExperiments)experiment_id)) {
|
||||||
auto map = GMLIB_Level::getAllExperiments();
|
return GMLIB_Level::getInstance()->getExperimentEnabled(((AllExperiments)experiment_id));
|
||||||
if (map.count(experiment_id)) {
|
} else {
|
||||||
return GMLIB_Level::getInstance()->getExperimentEnabled(((AllExperiments)experiment_id));
|
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
||||||
} else {
|
return false;
|
||||||
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLib_ModAPI", "setFixI18nEnabled", []() -> void {
|
||||||
|
VanillaFix::setFixI18nEnabled();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
+49
-21
@@ -2,42 +2,51 @@
|
|||||||
|
|
||||||
void Export_Legacy_GMLib_ServerAPI() {
|
void Export_Legacy_GMLib_ServerAPI() {
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void {
|
||||||
GMLIB_Level::addEducationEditionRequired();
|
GMLIB_Level::tryEnableEducationEdition();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void {
|
||||||
GMLIB_Level::forceEnableAbilityCommand();
|
GMLIB_Level::tryRegisterAbilityCommand();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void {
|
||||||
GMLIB_Level::setForceAchievementsEnabled();
|
GMLIB_Level::setForceAchievementsEnabled();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void { GMLIB_Level::setForceTrustSkin(); });
|
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void { GMLIB_Level::trustAllSkins(); });
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "enableCoResourcePack", []() -> void { GMLIB_Level::setCoResourcePack(); });
|
RemoteCall::exportAs("GMLib_ServerAPI", "enableCoResourcePack", []() -> void {
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
GMLIB_Level::requireServerResourcePackAndAllowClientResourcePack();
|
||||||
auto level = GMLIB_Level::getInstance();
|
|
||||||
if (!level) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return level->getLevelName();
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setLevelName", [](std::string name) -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
||||||
auto level = GMLIB_Level::getInstance();
|
if (auto level = GMLIB_Level::getInstance()) {
|
||||||
if (!level) {
|
return level->getLevelName();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
return level->setLevelName(name);
|
return {};
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLib_ServerAPI", "setLevelName", [](std::string const& name) -> void {
|
||||||
|
if (auto level = GMLIB_Level::getInstance()) {
|
||||||
|
level->setLevelName(name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelSeed", []() -> std::string {
|
||||||
|
if (auto level = GMLIB_Level::getInstance()) {
|
||||||
|
return std::to_string(level->getSeed());
|
||||||
|
}
|
||||||
|
return {};
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setFakeSeed", [](int64_t seed) -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setFakeSeed", [](int64_t seed) -> void {
|
||||||
return GMLIB_Level::setFakeSeed(seed);
|
return GMLIB_Level::setFakeSeed(seed);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "spawnEntity", [](std::pair<Vec3, int> pos, std::string name) -> Actor* {
|
RemoteCall::exportAs(
|
||||||
return GMLIB_Spawner::spawnEntity(pos.first, pos.second, name);
|
"GMLib_ServerAPI",
|
||||||
});
|
"spawnEntity",
|
||||||
|
[](std::pair<Vec3, int> pos, std::string const& name) -> Actor* {
|
||||||
|
return GMLIB_Spawner::spawnEntity(pos.first, pos.second, name).as_ptr();
|
||||||
|
}
|
||||||
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ServerAPI",
|
"GMLib_ServerAPI",
|
||||||
"shootProjectile",
|
"shootProjectile",
|
||||||
[](Actor* owner, std::string name, float speed, float offset) -> Actor* {
|
[](Actor* owner, std::string const& name, float speed, float offset) -> Actor* {
|
||||||
auto ac = (GMLIB_Actor*)owner;
|
auto ac = (GMLIB_Actor*)owner;
|
||||||
return ac->shootProjectile(name, speed, offset);
|
return ac->shootProjectile(name, speed, offset).as_ptr();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -45,8 +54,27 @@ void Export_Legacy_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 = (GMLIB_Actor*)owner;
|
||||||
return ac->throwEntity(actor, speed, offset);
|
return ac->throwEntity(*actor, speed, offset);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "PlayerToEntity", [](Player* player) -> Actor* { return (Actor*)player; });
|
RemoteCall::exportAs("GMLib_ServerAPI", "PlayerToEntity", [](Player* player) -> Actor* { return (Actor*)player; });
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLib_ServerAPI",
|
||||||
|
"addFakeList",
|
||||||
|
[](const std::string& name, const std::string& xuid) -> bool {
|
||||||
|
return FakeList::addFakeList(name, xuid, ActorUniqueID(-1));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLib_ServerAPI", "removeFakeList", [](const std::string& nameOrXuid) -> bool {
|
||||||
|
return FakeList::removeFakeList(nameOrXuid);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLib_ServerAPI", "removeAllFakeList", []() -> void {
|
||||||
|
return FakeList::removeAllFakeLists();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLib_ServerAPI", "getMaxPlayers", []() -> int {
|
||||||
|
if (auto level = GMLIB_Level::getInstance()) {
|
||||||
|
return level->getMaxPlayerCount();
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
+16
-17
@@ -8,15 +8,15 @@ std::string removeBrackets(std::string a1) {
|
|||||||
return a1;
|
return a1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isParameters(std::string str) {
|
bool isParameters(std::string const& str) {
|
||||||
std::regex reg("[<]([^<>]+)[>]");
|
std::regex reg("[<]([^<>]+)[>]");
|
||||||
return std::regex_search(removeBrackets(str), reg);
|
return std::regex_search(removeBrackets(str), reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetValue(std::string const& from) { return GMLIB::Server::PlaceholderAPI::getValue(from); }
|
std::string GetValue(std::string const& from) { return PlaceholderAPI::getValue(from); }
|
||||||
|
|
||||||
std::string GetValueWithPlayer(std::string const& a1, std::string const& a2) {
|
std::string GetValueWithPlayer(std::string const& a1, std::string const& a2) {
|
||||||
return GMLIB::Server::PlaceholderAPI::getValue(a1, ll::service::bedrock::getLevel()->getPlayer(a2));
|
return PlaceholderAPI::getValue(a1, ll::service::bedrock::getLevel()->getPlayer(a2));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool registerPlayerPlaceholder(
|
bool registerPlayerPlaceholder(
|
||||||
@@ -25,19 +25,20 @@ bool registerPlayerPlaceholder(
|
|||||||
std::string const& PAPIName
|
std::string const& PAPIName
|
||||||
) {
|
) {
|
||||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||||
|
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||||
if (isParameters(PAPIName)) {
|
if (isParameters(PAPIName)) {
|
||||||
auto Call = RemoteCall::importAs<std::string(Player * pl, std::unordered_map<std::string, std::string>)>(
|
auto Call = RemoteCall::importAs<std::string(Player * pl, std::unordered_map<std::string, std::string>)>(
|
||||||
PluginName,
|
PluginName,
|
||||||
FuncName
|
FuncName
|
||||||
);
|
);
|
||||||
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
|
PlaceholderAPI::registerPlayerPlaceholder(
|
||||||
PAPIName,
|
PAPIName,
|
||||||
[Call](Player* sp, std::unordered_map<std::string, std::string> map) { return Call(sp, map); },
|
[Call](Player* sp, std::unordered_map<std::string, std::string> map) { return Call(sp, map); },
|
||||||
PluginName
|
PluginName
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
auto Call = RemoteCall::importAs<std::string(Player * pl)>(PluginName, FuncName);
|
auto Call = RemoteCall::importAs<std::string(Player * pl)>(PluginName, FuncName);
|
||||||
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
|
PlaceholderAPI::registerPlayerPlaceholder(
|
||||||
PAPIName,
|
PAPIName,
|
||||||
[Call](Player* sp) { return Call(sp); },
|
[Call](Player* sp) { return Call(sp); },
|
||||||
PluginName
|
PluginName
|
||||||
@@ -54,21 +55,18 @@ bool registerServerPlaceholder(
|
|||||||
std::string const& PAPIName
|
std::string const& PAPIName
|
||||||
) {
|
) {
|
||||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||||
|
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||||
if (isParameters(PAPIName)) {
|
if (isParameters(PAPIName)) {
|
||||||
auto Call =
|
auto Call =
|
||||||
RemoteCall::importAs<std::string(std::unordered_map<std::string, std::string>)>(PluginName, FuncName);
|
RemoteCall::importAs<std::string(std::unordered_map<std::string, std::string>)>(PluginName, FuncName);
|
||||||
GMLIB::Server::PlaceholderAPI::registerServerPlaceholder(
|
PlaceholderAPI::registerServerPlaceholder(
|
||||||
PAPIName,
|
PAPIName,
|
||||||
[Call](std::unordered_map<std::string, std::string> map) { return Call(map); },
|
[Call](std::unordered_map<std::string, std::string> map) { return Call(map); },
|
||||||
PluginName
|
PluginName
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
||||||
GMLIB::Server::PlaceholderAPI::registerServerPlaceholder(
|
PlaceholderAPI::registerServerPlaceholder(PAPIName, [Call]() { return Call(); }, PluginName);
|
||||||
PAPIName,
|
|
||||||
[Call]() { return Call(); },
|
|
||||||
PluginName
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -82,16 +80,17 @@ bool registerStaticPlaceholder(
|
|||||||
int num
|
int num
|
||||||
) {
|
) {
|
||||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||||
|
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||||
if (isParameters(PAPIName)) {
|
if (isParameters(PAPIName)) {
|
||||||
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
||||||
if (num == -1) {
|
if (num == -1) {
|
||||||
GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder(
|
PlaceholderAPI::registerStaticPlaceholder(
|
||||||
PAPIName,
|
PAPIName,
|
||||||
[Call] { return Call(); },
|
[Call] { return Call(); },
|
||||||
PluginName
|
PluginName
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder(
|
PlaceholderAPI::registerStaticPlaceholder(
|
||||||
PAPIName,
|
PAPIName,
|
||||||
num,
|
num,
|
||||||
[Call] { return Call(); },
|
[Call] { return Call(); },
|
||||||
@@ -105,14 +104,14 @@ bool registerStaticPlaceholder(
|
|||||||
}
|
}
|
||||||
|
|
||||||
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::translateString(str, pl);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string translateString(std::string const& str) { return GMLIB::Server::PlaceholderAPI::translateString(str); }
|
std::string translateString(std::string const& str) { return PlaceholderAPI::translateString(str); }
|
||||||
|
|
||||||
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() { return PlaceholderAPI::getAllPAPI(); }
|
||||||
|
|
||||||
} // namespace PAPIRemoteCall
|
} // namespace PAPIRemoteCall
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"format_version": 2,
|
"format_version": 2,
|
||||||
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
||||||
"version": "0.12.1",
|
"version": "0.13.2",
|
||||||
"info": {
|
"info": {
|
||||||
"name": "GMLIB-LegacyRemoteCallApi",
|
"name": "GMLIB-LegacyRemoteCallApi",
|
||||||
"description": "Legacy RemoteCall API for GMLIB",
|
"description": "Legacy RemoteCall API for GMLIB",
|
||||||
@@ -14,9 +14,9 @@
|
|||||||
"library"
|
"library"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.12.1/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
|
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.13.2/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"github.com/GroupMountain/GMLIB": ">=0.12.1"
|
"github.com/GroupMountain/GMLIB": ">=0.13.0"
|
||||||
},
|
},
|
||||||
"files": {
|
"files": {
|
||||||
"place": [
|
"place": [
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
add_rules("mode.debug", "mode.release")
|
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")
|
||||||
|
|
||||||
if not has_config("vs_runtime") then
|
if not has_config("vs_runtime") then
|
||||||
set_runtimes("MD")
|
set_runtimes("MD")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Option 1: Use the latest version of LeviLamina released on GitHub.
|
-- Option 1: Use the latest version of LeviLamina released on GitHub.
|
||||||
add_requires("levilamina")
|
add_requires("levilaminalibrary")
|
||||||
add_requires("legacyremotecall")
|
add_requires("legacyremotecall")
|
||||||
|
add_requires("gmlib")
|
||||||
|
|
||||||
-- Option 2: Use a specific version of LeviLamina released on GitHub.
|
-- Option 2: Use a specific version of LeviLamina released on GitHub.
|
||||||
-- add_requires("levilamina x.x.x")
|
-- add_requires("levilamina x.x.x")
|
||||||
@@ -53,16 +55,13 @@ target("GMLIB-LegacyRemoteCallApi") -- Change this to your plugin name.
|
|||||||
add_files(
|
add_files(
|
||||||
"src/**.cpp"
|
"src/**.cpp"
|
||||||
)
|
)
|
||||||
add_links(
|
|
||||||
"SDK-GMLIB/Lib/GMLIB"
|
|
||||||
)
|
|
||||||
add_includedirs(
|
add_includedirs(
|
||||||
"SDK-GMLIB",
|
|
||||||
"src"
|
"src"
|
||||||
)
|
)
|
||||||
add_packages(
|
add_packages(
|
||||||
"levilamina",
|
"levilaminalibrary",
|
||||||
"legacyremotecall"
|
"legacyremotecall",
|
||||||
|
"gmlib"
|
||||||
)
|
)
|
||||||
add_shflags(
|
add_shflags(
|
||||||
"/DELAYLOAD:bedrock_server.dll" -- Magic to import symbols from BDS
|
"/DELAYLOAD:bedrock_server.dll" -- Magic to import symbols from BDS
|
||||||
|
|||||||
Reference in New Issue
Block a user