Compare commits
171 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
|
||||||
@@ -29,4 +27,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
||||||
path: |
|
path: |
|
||||||
bin/
|
bin/DLL/
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: PDB
|
||||||
|
path: |
|
||||||
|
bin/PDB/
|
||||||
|
|||||||
@@ -7,9 +7,12 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: Checkout repository
|
||||||
|
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.3"
|
||||||
|
|
||||||
- run: |
|
- run: |
|
||||||
xmake repo -u
|
xmake repo -u
|
||||||
@@ -24,7 +27,13 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
||||||
path: |
|
path: |
|
||||||
bin/
|
bin/DLL/
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: PDB
|
||||||
|
path: |
|
||||||
|
bin/PDB/
|
||||||
|
|
||||||
upload-to-release:
|
upload-to-release:
|
||||||
needs:
|
needs:
|
||||||
@@ -33,24 +42,35 @@ jobs:
|
|||||||
contents: write
|
contents: write
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: actions/download-artifact@v3
|
- name: Download Plugin
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
||||||
path: release/
|
path: release/Plugin/
|
||||||
|
|
||||||
- run: |
|
- name: Download PDB
|
||||||
cp LICENSE README.md release/
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: PDB
|
||||||
|
path: release/PDB/
|
||||||
|
|
||||||
|
- name: Copy additional files
|
||||||
|
run: |
|
||||||
|
cp LICENSE README.md release/Plugin/
|
||||||
|
|
||||||
- name: Archive release
|
- name: Archive release
|
||||||
run: |
|
run: |
|
||||||
cd release
|
cd release/Plugin
|
||||||
zip -r ../${{ github.event.repository.name }}-windows-x64.zip *
|
zip -r ../${{ github.event.repository.name }}-windows-x64.zip *
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
- uses: softprops/action-gh-release@v1
|
- name: Create GitHub Release
|
||||||
|
id: create_release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
append_body: true
|
|
||||||
files: |
|
files: |
|
||||||
${{ github.event.repository.name }}-windows-x64.zip
|
release/${{ github.event.repository.name }}-windows-x64.zip
|
||||||
|
release/PDB/${{ github.event.repository.name }}.pdb
|
||||||
|
|||||||
@@ -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 1c2918e15d
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[];
|
||||||
|
}
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
const PlaceholderAPI = {
|
||||||
|
/** 获取一个服务器变量的值 @type {function(string):string} */
|
||||||
|
getValueAPI: ll.import("BEPlaceholderAPI", "GetValue"),
|
||||||
|
/** 获取一个玩家变量的值 @type {function(string,Player):string} */
|
||||||
|
getValueByPlayerAPI: ll.import("BEPlaceholderAPI", "GetValueWithPlayer"),
|
||||||
|
/** 注册一个玩家变量 @type {function(string,string,string):boolean} */
|
||||||
|
registerPlayerPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerPlayerPlaceholder"),
|
||||||
|
/** 注册一个服务器变量 @type {function(string,string,string):boolean} */
|
||||||
|
registerServerPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerServerPlaceholder"),
|
||||||
|
/** 注册一个静态变量 @type {function(string,string,string,number):boolean} */
|
||||||
|
registerStaticPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerStaticPlaceholder"),
|
||||||
|
/** 翻译包含PAPI服务器变量的字符串 @type {function(string):string} */
|
||||||
|
translateStringAPI: ll.import("BEPlaceholderAPI", "translateString"),
|
||||||
|
/** 翻译包含PAPI玩家变量的字符串 @type {function(string,Player):string} */
|
||||||
|
translateStringWithPlayerAPI: ll.import("BEPlaceholderAPI", "translateStringWithPlayer"),
|
||||||
|
/** 注销PAPI变量 @type {function(string):boolean} */
|
||||||
|
unRegisterPlaceholderAPI: ll.import("BEPlaceholderAPI", "unRegisterPlaceholder"),
|
||||||
|
/** 获取所有已注册的PAPI变量 @type {function():Array.<string>} */
|
||||||
|
getAllPAPI: ll.import("BEPlaceholderAPI", "getAllPAPI")
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** PAPI变量类 */
|
||||||
|
class PAPI {
|
||||||
|
constructor() {
|
||||||
|
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) {
|
||||||
|
ll.export(func, PluginName, func.getName());
|
||||||
|
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) {
|
||||||
|
ll.export(func, PluginName, func.getName());
|
||||||
|
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) {
|
||||||
|
ll.export(func, PluginName, func.getName());
|
||||||
|
return PlaceholderAPI.registerStaticPlaceholderAPI(PluginName, func.getName(), PAPIName, UpdateInterval);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取一个服务器变量的值
|
||||||
|
* @param {string} key PAPI变量名
|
||||||
|
* @returns {string} 值
|
||||||
|
*/
|
||||||
|
static getValue(key) {
|
||||||
|
return PlaceholderAPI.getValueAPI(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取一个玩家变量的值
|
||||||
|
* @param {string} key PAPI变量名
|
||||||
|
* @param {Player} pl 玩家对象
|
||||||
|
* @returns {string} 值
|
||||||
|
*/
|
||||||
|
static getValueByPlayer(key, pl) {
|
||||||
|
return PlaceholderAPI.getValueByPlayerAPI(key, pl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 翻译带PAPI变量的字符串
|
||||||
|
* @param {string} str 字符串
|
||||||
|
* @param {Player} pl 玩家对象
|
||||||
|
* @returns {string} 翻译结果
|
||||||
|
*/
|
||||||
|
static translateString(str, pl = null) {
|
||||||
|
if (pl) {
|
||||||
|
return PlaceholderAPI.translateStringWithPlayerAPI(str, pl);
|
||||||
|
}
|
||||||
|
return PlaceholderAPI.translateStringAPI(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注销一个PAPI变量
|
||||||
|
* @param {string} str PAPI变量名
|
||||||
|
* @returns {boolean} 是否注销成功
|
||||||
|
*/
|
||||||
|
static unRegisterPlaceholder(str) {
|
||||||
|
return PlaceholderAPI.unRegisterPlaceholderAPI(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有已注册的PAPI变量
|
||||||
|
* @returns {Array.<string>} 已注册的PAPI变量数组
|
||||||
|
*/
|
||||||
|
static getAllPAPI() {
|
||||||
|
return PlaceholderAPI.getAllPAPI();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
PAPI
|
||||||
|
};
|
||||||
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;
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/** 事件创建函数 @type {function(string,string):boolean} */
|
||||||
|
const CallEvent = ll.import("GMLIB_API", "callCustomEvent");
|
||||||
|
|
||||||
|
/** 事件ID @type {number} */
|
||||||
|
let NextEventId = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取事件ID标识名
|
||||||
|
* @returns {string} 事件ID标识名
|
||||||
|
*/
|
||||||
|
function getNextEventId() {
|
||||||
|
NextEventId++;
|
||||||
|
return "GMLIB_Event_" + NextEventId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 事件类 */
|
||||||
|
class Event {
|
||||||
|
constructor() {
|
||||||
|
throw new Error("Static class cannot be instantiated");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监听事件
|
||||||
|
* @param {string} event 事件名称
|
||||||
|
* @param {function} callback 回调
|
||||||
|
* @returns {boolean} 是否创建成功
|
||||||
|
*/
|
||||||
|
static listen(event, callback) {
|
||||||
|
let eventId = getNextEventId();
|
||||||
|
ll.export(callback, event, eventId);
|
||||||
|
let result = CallEvent(event, eventId);
|
||||||
|
if (!result) {
|
||||||
|
logger.error(`Cannot listen event "${event}"!`);
|
||||||
|
logger.error(`Event "${event}" No Found!`);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
Event
|
||||||
|
};
|
||||||
Vendored
+1373
File diff suppressed because it is too large
Load Diff
+2640
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "${pluginName}",
|
"name": "${pluginName}",
|
||||||
"entry": "${pluginFile}",
|
"entry": "${pluginFile}",
|
||||||
|
"version": "0.13.2",
|
||||||
|
"author": "GroupMountain",
|
||||||
"type": "native",
|
"type": "native",
|
||||||
|
"passive": true,
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
{
|
{
|
||||||
"name": "GMLIB"
|
"name": "GMLIB"
|
||||||
|
|||||||
@@ -88,10 +88,12 @@ function pack_plugin(target,plugin_define)
|
|||||||
local manifest_path = find_file("manifest.json", os.projectdir())
|
local manifest_path = find_file("manifest.json", os.projectdir())
|
||||||
if manifest_path then
|
if manifest_path then
|
||||||
local manifest = io.readfile(manifest_path)
|
local manifest = io.readfile(manifest_path)
|
||||||
local bindir = path.join(os.projectdir(), "bin")
|
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 outputdir = path.join(bindir, plugin_define.pluginName)
|
||||||
local targetfile = path.join(outputdir, plugin_define.pluginFile)
|
local targetfile = path.join(outputdir, plugin_define.pluginFile)
|
||||||
local pdbfile = path.join(outputdir, path.basename(plugin_define.pluginFile) .. ".pdb")
|
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 manifestfile = path.join(outputdir, "manifest.json")
|
||||||
local oritargetfile = target:targetfile()
|
local oritargetfile = target:targetfile()
|
||||||
local oripdbfile = path.join(path.directory(oritargetfile), path.basename(oritargetfile) .. ".pdb")
|
local oripdbfile = path.join(path.directory(oritargetfile), path.basename(oritargetfile) .. ".pdb")
|
||||||
@@ -101,6 +103,7 @@ function pack_plugin(target,plugin_define)
|
|||||||
if os.isfile(oripdbfile) then
|
if os.isfile(oripdbfile) then
|
||||||
os.cp(oripdbfile, pdbfile)
|
os.cp(oripdbfile, pdbfile)
|
||||||
end
|
end
|
||||||
|
os.cp(libfile, outputdir)
|
||||||
|
|
||||||
formattedmanifest = string_formatter(manifest, plugin_define)
|
formattedmanifest = string_formatter(manifest, plugin_define)
|
||||||
io.writefile(manifestfile,formattedmanifest)
|
io.writefile(manifestfile,formattedmanifest)
|
||||||
|
|||||||
+949
-4
@@ -1,16 +1,961 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
#include <regex>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
bool isInteger(const std::string& str) {
|
||||||
|
std::regex pattern("^[+-]?\\d+$");
|
||||||
|
return std::regex_match(str, pattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
ActorUniqueID parseScriptUniqueID(std::string const& uniqueId) {
|
||||||
|
if (!isInteger(uniqueId)) {
|
||||||
|
return ActorUniqueID::INVALID_ID;
|
||||||
|
}
|
||||||
|
return ActorUniqueID(std::stoll(uniqueId));
|
||||||
|
}
|
||||||
|
|
||||||
void Export_Compatibility_API() {
|
void Export_Compatibility_API() {
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "unregisterRecipe", [](std::string const& id) -> bool {
|
||||||
|
auto level = GMLIB_Level::getInstance();
|
||||||
|
if (!level) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return CustomRecipe::unregisterRecipe(id);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "setCustomPackPath", [](std::string const& path) -> void {
|
||||||
|
CustomPacks::addCustomPackPath(path);
|
||||||
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> float {
|
RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> float {
|
||||||
return GMLIB_Level::getLevel()->getServerMspt();
|
auto level = GMLIB_Level::getInstance();
|
||||||
|
if (!level) {
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
return level->getServerMspt();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getServerCurrentTps", []() -> float {
|
RemoteCall::exportAs("GMLIB_API", "getServerCurrentTps", []() -> float {
|
||||||
return GMLIB_Level::getLevel()->getServerCurrentTps();
|
auto level = GMLIB_Level::getInstance();
|
||||||
|
if (!level) {
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
return level->getServerCurrentTps();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getServerAverageTps", []() -> float {
|
RemoteCall::exportAs("GMLIB_API", "getServerAverageTps", []() -> float {
|
||||||
return GMLIB_Level::getLevel()->getServerAverageTps();
|
auto level = GMLIB_Level::getInstance();
|
||||||
|
if (!level) {
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
return level->getServerAverageTps();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getAllPlayerUuids", []() -> std::vector<std::string> {
|
RemoteCall::exportAs("GMLIB_API", "getAllPlayerUuids", []() -> std::vector<std::string> {
|
||||||
return GMLIB_Player::getAllUuids();
|
std::vector<std::string> result;
|
||||||
|
std::vector<mce::UUID> uuids = GMLIB_Player::getAllUuids();
|
||||||
|
for (auto& uuid : uuids) {
|
||||||
|
result.push_back(uuid.asString());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getPlayerNbt", [](std::string const& uuid) -> std::unique_ptr<CompoundTag> {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
return std::move(GMLIB_Player::getPlayerNbt(uid));
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setPlayerNbt",
|
||||||
|
[](std::string const& uuid, CompoundTag* nbt, bool forceCreate) -> bool {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
return GMLIB_Player::setPlayerNbt(uid, *nbt, forceCreate);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setPlayerNbtTags",
|
||||||
|
[](std::string const& uuid, CompoundTag* nbt, std::vector<std::string> tags) -> bool {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
return GMLIB_Player::setPlayerNbtTags(uid, *nbt, tags);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "deletePlayerNbt", [](std::string const& uuid) -> bool {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
return GMLIB_Player::deletePlayerNbt(uid);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getAllExperiments", []() -> std::vector<int> {
|
||||||
|
auto list = GMLIB_Level::getAllExperiments();
|
||||||
|
std::vector<int> result;
|
||||||
|
for (auto& key : list) {
|
||||||
|
result.push_back((int)key);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getExperimentTranslateKey", [](int id) -> std::string {
|
||||||
|
std::string result;
|
||||||
|
try {
|
||||||
|
result = Experiments::getExperimentTextID(AllExperiments(id));
|
||||||
|
} catch (...) {}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"createFloatingText",
|
||||||
|
[](std::pair<Vec3, int> pos, std::string const& text, bool papi) -> int {
|
||||||
|
auto& manager = FloatingTextManager::getInstance();
|
||||||
|
auto ft = manager.createStatic(text, pos.first, pos.second, papi);
|
||||||
|
manager.add(ft);
|
||||||
|
return ft->getRuntimeID();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "setFloatingTextData", [](int id, std::string const& text) -> bool {
|
||||||
|
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
||||||
|
ft->setText(text);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "deleteFloatingText", [](int id) -> bool {
|
||||||
|
return FloatingTextManager::getInstance().remove(id);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "sendFloatingTextToPlayer", [](int id, Player* pl) -> bool {
|
||||||
|
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
||||||
|
ft->sendTo(*pl);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "sendFloatingText", [](int id) -> bool {
|
||||||
|
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
||||||
|
ft->sendToClients();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "removeFloatingTextFromPlayer", [](int id, Player* pl) -> bool {
|
||||||
|
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
||||||
|
ft->removeFrom(*pl);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "removeFloatingText", [](int id) -> bool {
|
||||||
|
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
||||||
|
ft->removeFromClients();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "updateClientFloatingTextData", [](int id, Player* pl) -> bool {
|
||||||
|
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
||||||
|
ft->update(*pl);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "updateAllClientsFloatingTextData", [](int id) -> bool {
|
||||||
|
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
||||||
|
ft->updateClients();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "isVersionMatched", [](int a, int b, int c) -> bool {
|
||||||
|
auto version = Version(a, b, c, "", "");
|
||||||
|
return LIB_VERSION >= version;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getVersion_LRCA", []() -> std::string { return LIB_VERSION.asString(); });
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getVersion_GMLIB", []() -> std::string {
|
||||||
|
return Version::getLibVersionString();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"resourcePackDefaultTranslate",
|
||||||
|
[](std::string const& key, std::vector<std::string> params) -> std::string { return I18nAPI::get(key, params); }
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"resourcePackTranslate",
|
||||||
|
[](std::string const& key, std::vector<std::string> params, std::string const& code) -> std::string {
|
||||||
|
return I18nAPI::get(key, params, code);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "chooseResourcePackI18nLanguage", [](std::string const& code) -> void {
|
||||||
|
if (GMLIB_Level::getInstance()) {
|
||||||
|
I18nAPI::chooseLanguage(code);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getResourcePackI18nLanguage", []() -> std::string {
|
||||||
|
if (GMLIB_Level::getInstance()) {
|
||||||
|
return I18nAPI::getCurrentLanguageCode();
|
||||||
|
}
|
||||||
|
return "unknown";
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getSupportedLanguages", []() -> std::vector<std::string> {
|
||||||
|
if (GMLIB_Level::getInstance()) {
|
||||||
|
return I18nAPI::getSupportedLanguageCodes();
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "loadLanguage", [](std::string const& code, std::string const& lang) -> void {
|
||||||
|
if (GMLIB_Level::getInstance()) {
|
||||||
|
I18nAPI::loadLanguage(code, lang);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"updateOrCreateLanguageFile",
|
||||||
|
[](std::string const& code, std::unordered_map<std::string, std::string> lang, std::string const& path
|
||||||
|
) -> void {
|
||||||
|
if (GMLIB_Level::getInstance()) {
|
||||||
|
I18nAPI::updateOrCreateLanguageFile(path, code, lang);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "loadLanguagePath", [](std::string const& path) -> void {
|
||||||
|
if (GMLIB_Level::getInstance()) {
|
||||||
|
I18nAPI::loadLanguagesFromDirectory(path);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getPlayerPosition", [](std::string const& uuid) -> std::pair<BlockPos, int> {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
auto pos = GMLIB_Player::getPlayerPosition(uid);
|
||||||
|
if (pos.has_value()) {
|
||||||
|
return pos.value();
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
{0, 0, 0},
|
||||||
|
-1
|
||||||
|
};
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setPlayerPosition",
|
||||||
|
[](std::string const& uuid, std::pair<BlockPos, int> pos) -> bool {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
return GMLIB_Player::setPlayerPosition(uid, pos.first, pos.second);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "playerHasScore", [](std::string const& uuid, std::string const& obj) -> bool {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
if (auto result = GMLIB_Player::getPlayerScore(uid, obj)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getPlayerScore", [](std::string const& uuid, std::string const& obj) -> int {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
if (auto result = GMLIB_Player::getPlayerScore(uid, obj)) {
|
||||||
|
return result.value();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"addPlayerScore",
|
||||||
|
[](std::string const& uuid, std::string const& obj, int value) -> bool {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
if (auto res = GMLIB_Player::setPlayerScore(uid, obj, value, PlayerScoreSetFunction::Add)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"reducePlayerScore",
|
||||||
|
[](std::string const& uuid, std::string const& obj, int value) -> bool {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
if (auto res = GMLIB_Player::setPlayerScore(uid, obj, value, PlayerScoreSetFunction::Subtract)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setPlayerScore",
|
||||||
|
[](std::string const& uuid, std::string const& obj, int value) -> bool {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
if (auto res = GMLIB_Player::setPlayerScore(uid, obj, value)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "resetPlayerScore", [](std::string const& uuid, std::string const& obj) -> bool {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
return GMLIB_Player::resetPlayerScore(uid, obj);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "resetPlayerScores", [](std::string const& uuid) -> bool {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
return GMLIB_Player::resetPlayerScore(uid);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"entityHasScore",
|
||||||
|
[](std::string const& uniqueId, std::string const& obj) -> bool {
|
||||||
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
|
if (auto result = GMLIB_Scoreboard::getInstance()->getScore(obj, auid)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getEntityScore", [](std::string const& uniqueId, std::string const& obj) -> int {
|
||||||
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
|
if (auto result = GMLIB_Scoreboard::getInstance()->getScore(obj, auid)) {
|
||||||
|
return result.value();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"addEntityScore",
|
||||||
|
[](std::string const& uniqueId, std::string const& obj, int value) -> bool {
|
||||||
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
|
if (auto res = GMLIB_Scoreboard::getInstance()->setScore(obj, auid, value, PlayerScoreSetFunction::Add)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"reduceEntityScore",
|
||||||
|
[](std::string const& uniqueId, std::string const& obj, int value) -> bool {
|
||||||
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
|
if (auto res =
|
||||||
|
GMLIB_Scoreboard::getInstance()->setScore(obj, auid, value, PlayerScoreSetFunction::Subtract)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setEntityScore",
|
||||||
|
[](std::string const& uniqueId, std::string const& obj, int value) -> bool {
|
||||||
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
|
if (auto res = GMLIB_Scoreboard::getInstance()->setScore(obj, auid, value)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"resetEntityScore",
|
||||||
|
[](std::string const& uniqueId, std::string const& obj) -> bool {
|
||||||
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
|
return GMLIB_Scoreboard::getInstance()->resetScore(obj, auid);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "resetEntityScores", [](std::string const& uniqueId) -> bool {
|
||||||
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
|
return GMLIB_Scoreboard::getInstance()->resetScore(auid);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"fakePlayerHasScore",
|
||||||
|
[](std::string const& name, std::string const& obj) -> bool {
|
||||||
|
if (auto result = GMLIB_Scoreboard::getInstance()->getScore(obj, name)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getFakePlayerScore", [](std::string const& name, std::string const& obj) -> int {
|
||||||
|
if (auto result = GMLIB_Scoreboard::getInstance()->getScore(obj, name)) {
|
||||||
|
return result.value();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"addFakePlayerScore",
|
||||||
|
[](std::string const& name, std::string const& obj, int value) -> bool {
|
||||||
|
if (auto res = GMLIB_Scoreboard::getInstance()->setScore(obj, name, value, PlayerScoreSetFunction::Add)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"reduceFakePlayerScore",
|
||||||
|
[](std::string const& name, std::string const& obj, int value) -> bool {
|
||||||
|
if (auto res =
|
||||||
|
GMLIB_Scoreboard::getInstance()->setScore(obj, name, value, PlayerScoreSetFunction::Subtract)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setFakePlayerScore",
|
||||||
|
[](std::string const& name, std::string const& obj, int value) -> bool {
|
||||||
|
if (auto res = GMLIB_Scoreboard::getInstance()->setScore(obj, name, value)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"resetFakePlayerScore",
|
||||||
|
[](std::string const& name, std::string const& obj) -> bool {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->resetScore(obj, name);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "resetFakePlayerScores", [](std::string const& name) -> bool {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->resetScore(name);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "addObjective", [](std::string const& obj) -> bool {
|
||||||
|
if (auto res = GMLIB_Scoreboard::getInstance()->addObjective(obj)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"addObjectiveWithDisplayName",
|
||||||
|
[](std::string const& obj, std::string const& displayName) -> bool {
|
||||||
|
if (auto res = GMLIB_Scoreboard::getInstance()->addObjective(obj, displayName)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getDisplayName", [](std::string const& obj) -> std::string {
|
||||||
|
if (auto result = GMLIB_Scoreboard::getInstance()->getObjectiveDisplayName(obj)) {
|
||||||
|
return result.value();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setDisplayName",
|
||||||
|
[](std::string const& obj, std::string const& displayName) -> bool {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->setObjectiveDisplayName(obj, displayName);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "removeObjective", [](std::string const& obj) -> bool {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->removeObjective(obj);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setDisplayObjective",
|
||||||
|
[](std::string const& obj, std::string const& slot, int order) -> void {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->setObjectiveDisplay(obj, slot, (ObjectiveSortOrder)order);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "clearDisplayObjective", [](std::string const& slot) -> void {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->clearObjectiveDisplay(slot);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getAllObjectives", []() -> std::vector<std::string> {
|
||||||
|
auto objs = GMLIB_Scoreboard::getInstance()->getObjectives();
|
||||||
|
std::vector<std::string> result;
|
||||||
|
for (auto& obj : objs) {
|
||||||
|
result.push_back(obj->getName());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardPlayers", []() -> std::vector<std::string> {
|
||||||
|
auto uuids = GMLIB_Scoreboard::getInstance()->getAllPlayerUuids();
|
||||||
|
std::vector<std::string> result;
|
||||||
|
for (auto& uuid : uuids) {
|
||||||
|
result.push_back(uuid.asString());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardFakePlayers", []() -> std::vector<std::string> {
|
||||||
|
auto names = GMLIB_Scoreboard::getInstance()->getAllFakePlayers();
|
||||||
|
std::vector<std::string> result;
|
||||||
|
for (auto& name : names) {
|
||||||
|
result.push_back(name);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardEntities", []() -> std::vector<std::string> {
|
||||||
|
auto uniqueIds = GMLIB_Scoreboard::getInstance()->getAllEntities();
|
||||||
|
std::vector<std::string> result;
|
||||||
|
for (auto& uniqueId : uniqueIds) {
|
||||||
|
result.push_back(std::to_string(uniqueId.id));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"getAllTrackedTargets",
|
||||||
|
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
||||||
|
std::vector<std::unordered_map<std::string, std::string>> result;
|
||||||
|
auto uuids = GMLIB_Scoreboard::getInstance()->getAllPlayerUuids();
|
||||||
|
for (auto& uuid : uuids) {
|
||||||
|
std::unordered_map<std::string, std::string> data;
|
||||||
|
data["Type"] = "Player";
|
||||||
|
data["Uuid"] = uuid.asString();
|
||||||
|
result.push_back(data);
|
||||||
|
}
|
||||||
|
auto names = GMLIB_Scoreboard::getInstance()->getAllFakePlayers();
|
||||||
|
for (auto& name : names) {
|
||||||
|
std::unordered_map<std::string, std::string> data;
|
||||||
|
data["Type"] = "FakePlayer";
|
||||||
|
data["Name"] = name;
|
||||||
|
result.push_back(data);
|
||||||
|
}
|
||||||
|
auto uniqueIds = GMLIB_Scoreboard::getInstance()->getAllEntities();
|
||||||
|
for (auto& uniqueId : uniqueIds) {
|
||||||
|
std::unordered_map<std::string, std::string> data;
|
||||||
|
data["Type"] = "Entity";
|
||||||
|
data["UniqueId"] = std::to_string(uniqueId.id);
|
||||||
|
result.push_back(data);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getPlayerFromUuid", [](std::string const& uuid) -> Player* {
|
||||||
|
return ll::service::getLevel()->getPlayer(mce::UUID::fromString(uuid));
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getPlayerFromUniqueId", [](std::string const& uniqueId) -> Actor* {
|
||||||
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
|
return ll::service::getLevel()->getPlayer(auid);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getEntityFromUniqueId", [](std::string const& uniqueId) -> Actor* {
|
||||||
|
auto auid = parseScriptUniqueID(uniqueId);
|
||||||
|
return ll::service::getLevel()->fetchEntity(auid);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getWorldSpawn", []() -> std::pair<BlockPos, int> {
|
||||||
|
return {GMLIB_Level::getInstance()->getWorldSpawn(), 0};
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "setWorldSpawn", [](std::pair<BlockPos, int> pos) -> bool {
|
||||||
|
if (pos.second != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
GMLIB_Level::getInstance()->setWorldSpawn(pos.first);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getPlayerSpawnPoint", [](Player* pl) -> std::pair<BlockPos, int> {
|
||||||
|
auto player = (GMLIB_Player*)pl;
|
||||||
|
auto res = player->getSpawnPoint();
|
||||||
|
return {res.first, res.second};
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "setPlayerSpawnPoint", [](Player* pl, std::pair<BlockPos, int> pos) -> void {
|
||||||
|
auto player = (GMLIB_Player*)pl;
|
||||||
|
player->setSpawnPoint(pos.first, pos.second);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "clearPlayerSpawnPoint", [](Player* pl) -> void {
|
||||||
|
auto player = (GMLIB_Player*)pl;
|
||||||
|
player->clearSpawnPoint();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"mergePatchJson",
|
||||||
|
[](std::string const& oldJson, std::string const& patchJson) -> std::string {
|
||||||
|
auto oldData = nlohmann::ordered_json::parse(oldJson);
|
||||||
|
auto newData = nlohmann::ordered_json::parse(patchJson);
|
||||||
|
oldData.merge_patch(newData);
|
||||||
|
return oldData.dump();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getXuidByUuid", [](std::string const& uuid) -> std::string {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
auto result = UserCache::getXuidByUuid(uid);
|
||||||
|
return result ? result.value() : "";
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getNameByUuid", [](std::string const& uuid) -> std::string {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
auto result = UserCache::getNameByUuid(uid);
|
||||||
|
return result ? result.value() : "";
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getUuidByXuid", [](std::string const& xuid) -> std::string {
|
||||||
|
auto result = UserCache::getUuidByXuid(xuid);
|
||||||
|
return result ? result.value().asString() : "";
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getNameByXuid", [](std::string const& xuid) -> std::string {
|
||||||
|
auto result = UserCache::getNameByXuid(xuid);
|
||||||
|
return result ? result.value() : "";
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getXuidByName", [](std::string const& name) -> std::string {
|
||||||
|
auto result = UserCache::getXuidByName(name);
|
||||||
|
return result ? result.value() : "";
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getUuidByName", [](std::string const& name) -> std::string {
|
||||||
|
auto result = UserCache::getUuidByName(name);
|
||||||
|
return result ? result.value().asString() : "";
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getUuidByName", [](std::string const& name) -> std::string {
|
||||||
|
auto result = UserCache::getUuidByName(name);
|
||||||
|
return result ? result.value().asString() : "";
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"getAllPlayerInfo",
|
||||||
|
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
||||||
|
std::vector<std::unordered_map<std::string, std::string>> result;
|
||||||
|
UserCache::forEach([&result](const UserCache::UserCacheEntry& entry) {
|
||||||
|
std::unordered_map<std::string, std::string> info;
|
||||||
|
info["Name"] = entry.mName;
|
||||||
|
info["Xuid"] = entry.mXuid;
|
||||||
|
info["Uuid"] = entry.mUuid.asString();
|
||||||
|
result.push_back(info);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getBlockRuntimeId", [](std::string const& blockName, short legacyData) -> uint {
|
||||||
|
if (auto block = Block::tryGetFromRegistry(blockName, legacyData)) {
|
||||||
|
return block->getRuntimeId();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKey", [](Block const* block) -> std::string {
|
||||||
|
return block->buildDescriptionId();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getItemTranslateKey", [](ItemStack* item) -> std::string {
|
||||||
|
return item->getDescriptionId();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getEntityTranslateKey", [](Actor* entity) -> std::string {
|
||||||
|
return entity->getEntityLocNameString();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"readNbtFromFile",
|
||||||
|
[](std::string const& path, bool isBinary) -> std::unique_ptr<CompoundTag> {
|
||||||
|
if (auto nbt = GMLIB_CompoundTag::readFromFile(path, isBinary)) {
|
||||||
|
return std::make_unique<CompoundTag>(nbt.value());
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"saveNbtToFile",
|
||||||
|
[](std::string const& path, CompoundTag* nbt, bool isBinary) -> bool {
|
||||||
|
return GMLIB_CompoundTag::saveToFile(path, *nbt, isBinary);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getBlockDestroySpeed", [](Block const* block) -> float {
|
||||||
|
return block->getDestroySpeed();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getDestroyBlockSpeed", [](ItemStack const* item, Block const* block) -> float {
|
||||||
|
return item->getDestroySpeed(*block);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"playerDestroyBlock",
|
||||||
|
[](Block const* block, std::pair<BlockPos, int> pos, Player* player) -> void {
|
||||||
|
return block->playerDestroy(*player, pos.first);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "itemCanDestroyBlock", [](ItemStack const* item, Block const* block) -> bool {
|
||||||
|
return item->canDestroy(block);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "itemCanDestroyInCreative", [](ItemStack const* item) -> bool {
|
||||||
|
if (auto itemDef = item->getItem()) {
|
||||||
|
return itemDef->canDestroyInCreative();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "itemCanDestroySpecial", [](ItemStack const* item, Block const* block) -> bool {
|
||||||
|
return item->canDestroySpecial(*block);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "blockCanDropWithAnyTool", [](Block const* block) -> bool {
|
||||||
|
return block->canDropWithAnyTool();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "blockIsAlwaysDestroyable", [](Block const* block) -> bool {
|
||||||
|
return block->getMaterial().isAlwaysDestroyable();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"blockPlayerWillDestroy",
|
||||||
|
[](Block const* block, Player* player, std::pair<BlockPos, int> pos) -> bool {
|
||||||
|
return block->playerWillDestroy(*player, pos.first);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "playerAttack", [](Player* player, Actor* entity) -> bool {
|
||||||
|
return player->attack(*entity, ActorDamageCause::EntityAttack);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "playerPullInEntity", [](Player* player, Actor* entity) -> bool {
|
||||||
|
return player->pullInEntity(*entity);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKeyFromName", [](std::string const& blockName) -> std::string {
|
||||||
|
if (auto block = Block::tryGetFromRegistry(blockName)) {
|
||||||
|
return block->buildDescriptionId();
|
||||||
|
}
|
||||||
|
return "tile.unknown.name";
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"getBlockLightEmission",
|
||||||
|
[](std::string const& blockName, short legacyData) -> char {
|
||||||
|
if (auto block = Block::tryGetFromRegistry(blockName, legacyData)) {
|
||||||
|
return (char)block->getLightEmission().value;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"getGameRules",
|
||||||
|
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
||||||
|
auto gameRules = ll::service::getLevel()->getGameRules().getRules();
|
||||||
|
std::vector<std::unordered_map<std::string, std::string>> result;
|
||||||
|
for (auto& gameRule : gameRules) {
|
||||||
|
std::unordered_map<std::string, std::string> data;
|
||||||
|
data["Name"] = gameRule.getName();
|
||||||
|
switch (gameRule.getType()) {
|
||||||
|
case GameRule::Type::Bool:
|
||||||
|
data["Type"] = "Bool";
|
||||||
|
data["Value"] = std::to_string(gameRule.getBool());
|
||||||
|
break;
|
||||||
|
case GameRule::Type::Float:
|
||||||
|
data["Type"] = "Float";
|
||||||
|
data["Value"] = std::to_string(gameRule.getFloat());
|
||||||
|
break;
|
||||||
|
case GameRule::Type::Int:
|
||||||
|
data["Type"] = "Int";
|
||||||
|
data["Value"] = std::to_string(gameRule.getInt());
|
||||||
|
break;
|
||||||
|
case GameRule::Type::Invalid:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
result.push_back(data);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getLegalEnchants", [](ItemStack const* item) -> std::vector<std::string> {
|
||||||
|
std::vector<int> enchants = EnchantUtils::getLegalEnchants(item->getItem());
|
||||||
|
std::vector<std::string> result;
|
||||||
|
for (auto& enchant : enchants) {
|
||||||
|
result.push_back(Enchant::getEnchant((Enchant::Type)enchant)->getStringId());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getEnchantTypeNameFromId", [](int id) -> std::string {
|
||||||
|
if (auto enchant = Enchant::getEnchant((Enchant::Type)id)) {
|
||||||
|
return std::string(enchant->getStringId());
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"applyEnchant",
|
||||||
|
[](ItemStack const* item, std::string const& typeName, int level, bool allowNonVanilla) -> bool {
|
||||||
|
return EnchantUtils::applyEnchant(
|
||||||
|
*(const_cast<ItemStack*>(item)),
|
||||||
|
Enchant::getEnchantTypeFromName(HashedString(typeName)),
|
||||||
|
level,
|
||||||
|
allowNonVanilla
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "removeEnchants", [](ItemStack const* item) -> void {
|
||||||
|
EnchantUtils::removeEnchants((ItemStack&)*item);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "hasEnchant", [](ItemStack const* item, std::string const& typeName) -> bool {
|
||||||
|
return EnchantUtils::hasEnchant(
|
||||||
|
Enchant::getEnchantTypeFromName(HashedString(typeName)),
|
||||||
|
*(const_cast<ItemStack*>(item))
|
||||||
|
);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getEnchantLevel", [](ItemStack const* item, std::string const& typeName) -> int {
|
||||||
|
return EnchantUtils::getEnchantLevel(
|
||||||
|
Enchant::getEnchantTypeFromName(HashedString(typeName)),
|
||||||
|
*(const_cast<ItemStack*>(item))
|
||||||
|
);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"getEnchantNameAndLevel",
|
||||||
|
[](std::string const& typeName, int level) -> std::string {
|
||||||
|
return EnchantUtils::getEnchantNameAndLevel(Enchant::getEnchantTypeFromName(HashedString(typeName)), level);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"dropPlayerItem",
|
||||||
|
[](Player* player, ItemStack const* item, bool randomly) -> bool { return player->drop(*item, randomly); }
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getPlayerRuntimeId", [](Player* player) -> uint64 {
|
||||||
|
return player->getRuntimeID().id;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getEntityRuntimeId", [](Actor* entity) -> uint64 {
|
||||||
|
return entity->getRuntimeID().id;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getEntityNameTag", [](Actor* entity) -> std::string {
|
||||||
|
return entity->getNameTag();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "ItemisUnbreakable", [](ItemStack const* item) -> bool {
|
||||||
|
return ((GMLIB_ItemStack*)item)->isUnbreakable();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "setItemUnbreakable", [](ItemStack const* item, bool value) -> void {
|
||||||
|
((GMLIB_ItemStack*)item)->setUnbreakable(value);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getItemShouldKeepOnDeath", [](ItemStack const* item) -> bool {
|
||||||
|
return ((GMLIB_ItemStack*)item)->getShouldKeepOnDeath();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "setItemShouldKeepOnDeath", [](ItemStack const* item, bool value) -> void {
|
||||||
|
((GMLIB_ItemStack*)item)->setShouldKeepOnDeath(value);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getItemLockMode", [](ItemStack const* item) -> int {
|
||||||
|
return (int)((GMLIB_ItemStack*)item)->getItemLockMode();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "setItemLockMode", [](ItemStack const* item, int value) -> void {
|
||||||
|
((GMLIB_ItemStack*)item)->setItemLockMode((ItemLockMode)value);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getItemRepairCost", [](ItemStack const* item) -> int {
|
||||||
|
return item->getBaseRepairCost();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "setItemRepairCost", [](ItemStack const* item, int cost) -> void {
|
||||||
|
(*(const_cast<ItemStack*>(item))).setRepairCost(cost);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getItemCanDestroy", [](ItemStack const* item) -> std::vector<std::string> {
|
||||||
|
std::vector<std::string> result = {};
|
||||||
|
for (auto& block : ((GMLIB_ItemStack*)item)->getCanDestroy()) {
|
||||||
|
result.push_back(block->getTypeName());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setItemCanDestroy",
|
||||||
|
[](ItemStack const* item, std::vector<std::string> blocks) -> void {
|
||||||
|
((GMLIB_ItemStack*)item)->setCanDestroy(blocks);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getItemCanPlaceOn", [](ItemStack const* item) -> std::vector<std::string> {
|
||||||
|
std::vector<std::string> result = {};
|
||||||
|
for (auto& block : ((GMLIB_ItemStack*)item)->getCanPlaceOn()) {
|
||||||
|
result.push_back(block->getTypeName());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setItemCanPlaceOn",
|
||||||
|
[](ItemStack const* item, std::vector<std::string> blocks) -> void {
|
||||||
|
((GMLIB_ItemStack*)item)->setCanPlaceOn(blocks);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getPlayerHungry", [](Player* player) -> float {
|
||||||
|
return player->getMutableAttribute(Player::HUNGER)->getCurrentValue();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getPlayerArmorCoverPercentage", [](Player* player) -> float {
|
||||||
|
return player->getArmorCoverPercentage();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getPlayerArmorValue", [](Player* player) -> int {
|
||||||
|
return player->getArmorValue();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getEntityOwnerUniqueId", [](Actor* entity) -> int64 {
|
||||||
|
return entity->getOwnerId().id;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getItemCategoryName", [](ItemStack const* item) -> std::string {
|
||||||
|
return item->getCategoryName();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getItemCustomName", [](ItemStack const* item) -> std::string {
|
||||||
|
return item->getCustomName();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getItemEffecName", [](ItemStack const* item) -> std::string {
|
||||||
|
return item->getEffectName();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "itemIsFood", [](ItemStack const* item) -> bool {
|
||||||
|
if (auto itemDef = item->getItem()) {
|
||||||
|
return itemDef->isFood();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "setPlayerUIItem", [](Player* player, int slot, ItemStack const* item) -> void {
|
||||||
|
player->setPlayerUIItem((PlayerUISlot)slot, *item);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getPlayerUIItem", [](Player* player, int slot) -> ItemStack* {
|
||||||
|
return const_cast<ItemStack*>(&player->getPlayerUIItem((PlayerUISlot)slot));
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"sendInventorySlotPacket",
|
||||||
|
[](Player* player, int containerId, int slot, ItemStack const* item) -> void {
|
||||||
|
InventorySlotPacket((ContainerID)containerId, slot, *item).sendTo(*player);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getContainerType", [](Container* container) -> std::string {
|
||||||
|
return magic_enum::enum_name(container->getContainerType()).data();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "hasPlayerNbt", [](std::string const& uuid) -> bool {
|
||||||
|
auto uid = mce::UUID::fromString(uuid);
|
||||||
|
return GMLIB_Player::getPlayerNbt(uid) ? true : false;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getItemMaxCount", [](ItemStack const* item) -> int {
|
||||||
|
return item->getMaxStackSize();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "entityHasFamily", [](Actor* entity, std::string const& family) -> bool {
|
||||||
|
return entity->hasFamily(HashedString(family));
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getPlayerDestroyBlockProgress", [](Player* player, Block const* block) -> float {
|
||||||
|
return player->getDestroyProgress(*block);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectVisible", [](Actor* entity, int effectId) -> bool {
|
||||||
|
if (auto effect = entity->getEffect(effectId)) {
|
||||||
|
return effect->mEffectVisible;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDuration", [](Actor* entity, int effectId) -> int {
|
||||||
|
if (auto effect = entity->getEffect(effectId)) {
|
||||||
|
return effect->mDuration;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDurationEasy", [](Actor* entity, int effectId) -> int {
|
||||||
|
if (auto effect = entity->getEffect(effectId)) {
|
||||||
|
return effect->mDurationEasy;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDurationHard", [](Actor* entity, int effectId) -> int {
|
||||||
|
if (auto effect = entity->getEffect(effectId)) {
|
||||||
|
return effect->mDurationHard;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDurationNormal", [](Actor* entity, int effectId) -> int {
|
||||||
|
if (auto effect = entity->getEffect(effectId)) {
|
||||||
|
return effect->mDurationNormal;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectAmplifier", [](Actor* entity, int effectId) -> int {
|
||||||
|
if (auto effect = entity->getEffect(effectId)) {
|
||||||
|
return effect->mAmplifier;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectAmbient", [](Actor* entity, int effectId) -> bool {
|
||||||
|
if (auto effect = entity->getEffect(effectId)) {
|
||||||
|
return effect->mAmbient;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "entityHasEffect", [](Actor* entity, int effectId) -> int {
|
||||||
|
return entity->hasEffect(*MobEffect::getById(effectId));
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getGameDifficulty", []() -> int {
|
||||||
|
if (auto level = ll::service::getLevel()) {
|
||||||
|
return (int)level->getDifficulty();
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "setGameDifficulty", [](int difficulty) -> void {
|
||||||
|
if (auto level = ll::service::getLevel()) {
|
||||||
|
level->setDifficulty((Difficulty)difficulty);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getDefaultGameMode", []() -> int {
|
||||||
|
if (auto level = ll::service::getLevel()) {
|
||||||
|
return (int)level->getDefaultGameType();
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "setDefaultGameMode", [](int gameMode) -> void {
|
||||||
|
if (auto level = ll::service::getLevel()) {
|
||||||
|
level->setDefaultGameType((GameType)gameMode);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#include <memory>
|
|
||||||
|
|
||||||
#include <ll/api/plugin/NativePlugin.h>
|
|
||||||
|
|
||||||
#include "Plugin.h"
|
|
||||||
|
|
||||||
namespace plugin {
|
|
||||||
|
|
||||||
// The global plugin instance.
|
|
||||||
std::unique_ptr<Plugin> plugin = nullptr;
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
_declspec(dllexport) bool ll_plugin_load(ll::plugin::NativePlugin& self) {
|
|
||||||
plugin = std::make_unique<plugin::Plugin>(self);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @warning Unloading the plugin may cause a crash if the plugin has not released all of its
|
|
||||||
/// resources. If you are unsure, keep this function commented out.
|
|
||||||
// _declspec(dllexport) bool ll_plugin_unload(ll::plugin::Plugin&) {
|
|
||||||
// plugin.reset();
|
|
||||||
//
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
_declspec(dllexport) bool ll_plugin_enable(ll::plugin::NativePlugin&) { return plugin->enable(); }
|
|
||||||
|
|
||||||
_declspec(dllexport) bool ll_plugin_disable(ll::plugin::NativePlugin&) { return plugin->disable(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace plugin
|
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
#include "Entry.h"
|
||||||
|
#include "Global.h"
|
||||||
|
|
||||||
|
ll::Logger logger(PLUGIN_NAME);
|
||||||
|
|
||||||
|
namespace GMLIB {
|
||||||
|
|
||||||
|
std::unique_ptr<LegacyRemoteCallApi>& LegacyRemoteCallApi::getInstance() {
|
||||||
|
static std::unique_ptr<LegacyRemoteCallApi> instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LegacyRemoteCallApi::load() {
|
||||||
|
Export_Legacy_GMLib_ModAPI();
|
||||||
|
Export_Legacy_GMLib_ServerAPI();
|
||||||
|
Export_Compatibility_API();
|
||||||
|
ExportPAPI();
|
||||||
|
Export_Event_API();
|
||||||
|
logger.info("GMLIB-LegacyRemoteCallApi Loaded!");
|
||||||
|
logger.info(
|
||||||
|
"Loaded Version: {} with {}",
|
||||||
|
fmt::format(fg(fmt::color::pink), "GMLIB-" + Version::getLibVersionString()),
|
||||||
|
fmt::format(fg(fmt::color::light_green), "GMLIB-LegacyRemoteCallApi-" + LIB_VERSION.asString())
|
||||||
|
);
|
||||||
|
logger.info("Author: GroupMountain");
|
||||||
|
logger.info("Repository: https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LegacyRemoteCallApi::enable() { return true; }
|
||||||
|
|
||||||
|
bool LegacyRemoteCallApi::disable() { return true; }
|
||||||
|
|
||||||
|
} // namespace GMLIB
|
||||||
|
|
||||||
|
LL_REGISTER_MOD(LegacyRemoteCallApi, LegacyRemoteCallApi::getInstance());
|
||||||
+33
@@ -0,0 +1,33 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <ll/api/mod/NativeMod.h>
|
||||||
|
#include <ll/api/mod/RegisterHelper.h>
|
||||||
|
|
||||||
|
namespace GMLIB {
|
||||||
|
|
||||||
|
class LegacyRemoteCallApi {
|
||||||
|
|
||||||
|
public:
|
||||||
|
static std::unique_ptr<LegacyRemoteCallApi>& getInstance();
|
||||||
|
|
||||||
|
LegacyRemoteCallApi(ll::mod::NativeMod& self) : mSelf(self) {}
|
||||||
|
|
||||||
|
[[nodiscard]] ll::mod::NativeMod& getSelf() const { return mSelf; }
|
||||||
|
|
||||||
|
/// @return True if the plugin is loaded successfully.
|
||||||
|
bool load();
|
||||||
|
|
||||||
|
/// @return True if the plugin is enabled successfully.
|
||||||
|
bool enable();
|
||||||
|
|
||||||
|
/// @return True if the plugin is disabled successfully.
|
||||||
|
bool disable();
|
||||||
|
|
||||||
|
// TODO: Implement this method if you need to unload the plugin.
|
||||||
|
// /// @return True if the plugin is unloaded successfully.
|
||||||
|
// bool unload();
|
||||||
|
|
||||||
|
private:
|
||||||
|
ll::mod::NativeMod& mSelf;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace GMLIB
|
||||||
@@ -0,0 +1,333 @@
|
|||||||
|
#include "Global.h"
|
||||||
|
using namespace ll::hash_utils;
|
||||||
|
|
||||||
|
void Export_Event_API() {
|
||||||
|
auto eventBus = &ll::event::EventBus::getInstance();
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"callCustomEvent",
|
||||||
|
[eventBus](std::string const& eventName, std::string const& eventId) -> bool {
|
||||||
|
if (!RemoteCall::hasFunc(eventName, eventId)) return false;
|
||||||
|
switch (doHash(eventName)) {
|
||||||
|
case doHash("onClientLogin"): {
|
||||||
|
auto Call = RemoteCall::importAs<bool(
|
||||||
|
std::string const& realName,
|
||||||
|
std::string const& uuid,
|
||||||
|
std::string const& serverXuid,
|
||||||
|
std::string const& clientXuid
|
||||||
|
)>(eventName, eventId);
|
||||||
|
eventBus->emplaceListener<Event::PacketEvent::ClientLoginAfterEvent>(
|
||||||
|
[Call](Event::PacketEvent::ClientLoginAfterEvent& ev) {
|
||||||
|
try {
|
||||||
|
Call(
|
||||||
|
ev.getRealName(),
|
||||||
|
ev.getUuid().asString(),
|
||||||
|
ev.getServerAuthXuid(),
|
||||||
|
ev.getClientAuthXuid()
|
||||||
|
);
|
||||||
|
} catch (...) {}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case doHash("onWeatherChange"): {
|
||||||
|
auto Call =
|
||||||
|
RemoteCall::importAs<bool(int lightningLevel, int rainLevel, int lightningLast, int rainLast)>(
|
||||||
|
eventName,
|
||||||
|
eventId
|
||||||
|
);
|
||||||
|
eventBus->emplaceListener<Event::LevelEvent::WeatherUpdateBeforeEvent>(
|
||||||
|
[Call](Event::LevelEvent::WeatherUpdateBeforeEvent& ev) {
|
||||||
|
bool result = true;
|
||||||
|
try {
|
||||||
|
result = Call(
|
||||||
|
ev.getLightningLevel(),
|
||||||
|
ev.getRainLevel(),
|
||||||
|
ev.getLightningLastTick(),
|
||||||
|
ev.getRainingLastTick()
|
||||||
|
);
|
||||||
|
} catch (...) {}
|
||||||
|
if (!result) {
|
||||||
|
ev.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case doHash("onMobPick"): {
|
||||||
|
auto Call = RemoteCall::importAs<bool(Actor * mob, Actor * item)>(eventName, eventId);
|
||||||
|
eventBus->emplaceListener<Event::EntityEvent::MobPickupItemBeforeEvent>(
|
||||||
|
[Call](Event::EntityEvent::MobPickupItemBeforeEvent& ev) {
|
||||||
|
bool result = true;
|
||||||
|
try {
|
||||||
|
result = Call(&ev.self(), (Actor*)&ev.getItemActor());
|
||||||
|
} catch (...) {}
|
||||||
|
if (!result) {
|
||||||
|
ev.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case doHash("onItemTrySpawn"): {
|
||||||
|
auto Call =
|
||||||
|
RemoteCall::importAs<bool(const ItemStack* item, std::pair<Vec3, int> position, Actor* spawner)>(
|
||||||
|
eventName,
|
||||||
|
eventId
|
||||||
|
);
|
||||||
|
eventBus->emplaceListener<Event::EntityEvent::ItemActorSpawnBeforeEvent>(
|
||||||
|
[Call](Event::EntityEvent::ItemActorSpawnBeforeEvent& ev) {
|
||||||
|
auto pos = ev.getPosition();
|
||||||
|
auto dimid = ev.getBlockSource().getDimensionId().id;
|
||||||
|
std::pair<Vec3, int> lsePos = {pos, dimid};
|
||||||
|
bool result = true;
|
||||||
|
try {
|
||||||
|
result = Call(&ev.getItem(), lsePos, ev.getSpawner());
|
||||||
|
} catch (...) {}
|
||||||
|
if (!result) {
|
||||||
|
ev.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case doHash("onItemSpawned"): {
|
||||||
|
auto Call = RemoteCall::importAs<
|
||||||
|
bool(const ItemStack* item, Actor* itemActor, std::pair<Vec3, int> position, Actor* spawner)>(
|
||||||
|
eventName,
|
||||||
|
eventId
|
||||||
|
);
|
||||||
|
eventBus->emplaceListener<Event::EntityEvent::ItemActorSpawnAfterEvent>(
|
||||||
|
[Call](Event::EntityEvent::ItemActorSpawnAfterEvent& ev) {
|
||||||
|
auto pos = ev.getPosition();
|
||||||
|
auto dimid = ev.getBlockSource().getDimensionId().id;
|
||||||
|
std::pair<Vec3, int> lsePos = {pos, dimid};
|
||||||
|
try {
|
||||||
|
Call(&ev.getItem(), (Actor*)&ev.getItemActor(), lsePos, ev.getSpawner());
|
||||||
|
} catch (...) {}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case doHash("onEntityChangeDim"): {
|
||||||
|
auto Call = RemoteCall::importAs<bool(Actor * entity, int toDimId)>(eventName, eventId);
|
||||||
|
eventBus->emplaceListener<Event::EntityEvent::ActorChangeDimensionBeforeEvent>(
|
||||||
|
[Call](Event::EntityEvent::ActorChangeDimensionBeforeEvent& ev) {
|
||||||
|
bool result = true;
|
||||||
|
try {
|
||||||
|
result = Call(&ev.self(), ev.getToDimensionId());
|
||||||
|
} catch (...) {}
|
||||||
|
if (!result) {
|
||||||
|
ev.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case doHash("onLeaveBed"): {
|
||||||
|
auto Call = RemoteCall::importAs<bool(Player * pl)>(eventName, eventId);
|
||||||
|
eventBus->emplaceListener<Event::PlayerEvent::PlayerStopSleepBeforeEvent>(
|
||||||
|
[Call](Event::PlayerEvent::PlayerStopSleepBeforeEvent& ev) {
|
||||||
|
bool result = true;
|
||||||
|
try {
|
||||||
|
result = Call(&ev.self());
|
||||||
|
} catch (...) {}
|
||||||
|
if (!result) {
|
||||||
|
ev.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case doHash("onDeathMessage"): {
|
||||||
|
auto Call =
|
||||||
|
RemoteCall::importAs<bool(std::string const& message, std::vector<std::string>, Actor* dead)>(
|
||||||
|
eventName,
|
||||||
|
eventId
|
||||||
|
);
|
||||||
|
eventBus->emplaceListener<Event::EntityEvent::DeathMessageAfterEvent>(
|
||||||
|
[Call](Event::EntityEvent::DeathMessageAfterEvent& ev) {
|
||||||
|
auto msg = ev.getDeathMessage();
|
||||||
|
auto source = ev.getDamageSource();
|
||||||
|
try {
|
||||||
|
Call(msg.first, msg.second, &ev.self());
|
||||||
|
} catch (...) {}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case doHash("onMobHurted"): {
|
||||||
|
auto Call = RemoteCall::importAs<bool(Actor * mob, Actor * source, float damage, int cause)>(
|
||||||
|
eventName,
|
||||||
|
eventId
|
||||||
|
);
|
||||||
|
eventBus->emplaceListener<Event::EntityEvent::MobHurtAfterEvent>(
|
||||||
|
[Call](Event::EntityEvent::MobHurtAfterEvent& ev) {
|
||||||
|
auto& damageSource = ev.getSource();
|
||||||
|
Actor* source = nullptr;
|
||||||
|
if (damageSource.isEntitySource()) {
|
||||||
|
auto uniqueId = damageSource.getDamagingEntityUniqueID();
|
||||||
|
source = ll::service::getLevel()->fetchEntity(uniqueId);
|
||||||
|
if (source->getOwner()) {
|
||||||
|
source = source->getOwner();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Call(&ev.self(), source, ev.getDamage(), (int)damageSource.getCause());
|
||||||
|
} catch (...) {}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case doHash("onEndermanTake"): {
|
||||||
|
auto Call = RemoteCall::importAs<bool(Actor * mob)>(eventName, eventId);
|
||||||
|
eventBus->emplaceListener<Event::EntityEvent::EndermanTakeBlockBeforeEvent>(
|
||||||
|
[Call](Event::EntityEvent::EndermanTakeBlockBeforeEvent& ev) {
|
||||||
|
bool result = true;
|
||||||
|
try {
|
||||||
|
result = Call(&ev.self());
|
||||||
|
} catch (...) {}
|
||||||
|
if (!result) {
|
||||||
|
ev.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
+14
-1
@@ -1,11 +1,24 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <include_all.h>
|
#include <include_all.h>
|
||||||
|
|
||||||
#include <RemoteCallAPI.h>
|
#include <RemoteCallAPI.h>
|
||||||
|
|
||||||
#define PLUGIN_NAME "GMLIB-LRCA"
|
using namespace GMLIB;
|
||||||
|
using namespace Server;
|
||||||
|
using namespace Mod;
|
||||||
|
|
||||||
|
#define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA")
|
||||||
|
|
||||||
|
#define LIB_VERSION_MAJOR 0
|
||||||
|
#define LIB_VERSION_MINOR 13
|
||||||
|
#define LIB_VERSION_PATCH 2
|
||||||
|
|
||||||
|
#define LIB_VERSION Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH)
|
||||||
|
|
||||||
extern ll::Logger logger;
|
extern ll::Logger logger;
|
||||||
|
|
||||||
extern void Export_Legacy_GMLib_ModAPI();
|
extern void Export_Legacy_GMLib_ModAPI();
|
||||||
extern void Export_Legacy_GMLib_ServerAPI();
|
extern void Export_Legacy_GMLib_ServerAPI();
|
||||||
extern void Export_Compatibility_API();
|
extern void Export_Compatibility_API();
|
||||||
|
extern void ExportPAPI();
|
||||||
|
extern void Export_Event_API();
|
||||||
+97
-44
@@ -1,9 +1,8 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
std::unordered_set<std::string> HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"};
|
std::unordered_set<std::string> HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"};
|
||||||
std::unordered_set<int> ExperimentsList = {6, 7, 8, 9, 10, 12, 15, 16};
|
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
@@ -18,11 +17,15 @@ 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();
|
||||||
|
if (!level) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
std::vector<RecipeIngredient> types;
|
std::vector<RecipeIngredient> types;
|
||||||
for (auto ing : ingredients) {
|
for (auto ing : ingredients) {
|
||||||
auto key = RecipeIngredient(ing, 0, 1);
|
auto key = RecipeIngredient(ing, 0, 1);
|
||||||
@@ -30,18 +33,22 @@ 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::CustomRecipe::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();
|
||||||
|
if (!level) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
std::vector<RecipeIngredient> types;
|
std::vector<RecipeIngredient> types;
|
||||||
for (auto ing : ingredients) {
|
for (auto ing : ingredients) {
|
||||||
auto key = RecipeIngredient(ing, 0, 1);
|
auto key = RecipeIngredient(ing, 0, 1);
|
||||||
@@ -49,45 +56,66 @@ 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::CustomRecipe::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();
|
||||||
|
if (!level) {
|
||||||
|
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::CustomRecipe::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();
|
||||||
|
if (!level) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
auto rea = RecipeIngredient(reagent, 0, 1);
|
auto rea = RecipeIngredient(reagent, 0, 1);
|
||||||
GMLIB::Mod::CustomRecipe::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();
|
||||||
|
if (!level) {
|
||||||
|
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);
|
||||||
auto rea = RecipeIngredient(reagent, 0, 1);
|
auto rea = RecipeIngredient(reagent, 0, 1);
|
||||||
GMLIB::Mod::CustomRecipe::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 {
|
||||||
GMLIB::Mod::CustomRecipe::registerSmithingTransformRecipe(
|
auto level = GMLIB_Level::getInstance();
|
||||||
|
if (!level) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JsonRecipe::registerSmithingTransformRecipe(
|
||||||
recipe_id,
|
recipe_id,
|
||||||
smithing_template,
|
smithing_template,
|
||||||
base,
|
base,
|
||||||
@@ -99,47 +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,
|
||||||
GMLIB::Mod::CustomRecipe::registerSmithingTrimRecipe(recipe_id, smithing_template, base, addition);
|
std::string const& smithing_template,
|
||||||
|
std::string const& base,
|
||||||
|
std::string const& addition) -> void {
|
||||||
|
auto level = GMLIB_Level::getInstance();
|
||||||
|
if (!level) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
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();
|
||||||
|
if (!level) {
|
||||||
|
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::CustomRecipe::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 {
|
||||||
if (ExperimentsList.count(experiment_id)) {
|
auto list = GMLIB_Level::getAllExperiments();
|
||||||
|
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||||
|
if (set.contains((AllExperiments)experiment_id)) {
|
||||||
GMLIB_Level::addExperimentsRequire((AllExperiments)experiment_id);
|
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 {
|
||||||
if (ExperimentsList.count(experiment_id)) {
|
if (GMLIB_Level::getInstance()) {
|
||||||
GMLIB_Level::getLevel()->setExperimentEnabled(((AllExperiments)experiment_id), value);
|
auto list = GMLIB_Level::getAllExperiments();
|
||||||
} else ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||||
});
|
if (set.contains((AllExperiments)experiment_id)) {
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "getExperimentEnabled", [](int experiment_id) -> bool {
|
GMLIB_Level::getInstance()->setExperimentEnabled(((AllExperiments)experiment_id), value);
|
||||||
if (ExperimentsList.count(experiment_id)) {
|
} else ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
||||||
return GMLIB_Level::getLevel()->getExperimentEnabled(((AllExperiments)experiment_id));
|
|
||||||
} else {
|
|
||||||
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
RemoteCall::exportAs("GMLib_ModAPI", "getExperimentEnabled", [](int experiment_id) -> bool {
|
||||||
|
if (GMLIB_Level::getInstance()) {
|
||||||
|
auto list = GMLIB_Level::getAllExperiments();
|
||||||
|
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||||
|
if (set.contains((AllExperiments)experiment_id)) {
|
||||||
|
return GMLIB_Level::getInstance()->getExperimentEnabled(((AllExperiments)experiment_id));
|
||||||
|
} else {
|
||||||
|
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLib_ModAPI", "setFixI18nEnabled", []() -> void {
|
||||||
|
VanillaFix::setFixI18nEnabled();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
+59
-28
@@ -2,48 +2,79 @@
|
|||||||
|
|
||||||
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", "addFloatingTextPacket", [](std::string text, std::pair<Vec3, int> pos, int dimid) -> int {
|
|
||||||
auto ft = new FloatingText(text, pos.first, pos.second);
|
|
||||||
return ft->mRuntimeId;
|
|
||||||
});
|
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "deleteFloatingTextPacket", [](int id) -> void {
|
|
||||||
FloatingText::deleteFloatingText(id);
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void {
|
||||||
GMLIB_Level::setForceAchievementsEnabled();
|
GMLIB_Level::setForceAchievementsEnabled();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void { GMLIB_Level::trustAllSkins(); });
|
||||||
GMLIB_Level::setForceTrustSkin();
|
|
||||||
});
|
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "enableCoResourcePack", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "enableCoResourcePack", []() -> void {
|
||||||
GMLIB_Level::setCoResourcePack();
|
GMLIB_Level::requireServerResourcePackAndAllowClientResourcePack();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
||||||
return GMLIB_Level::getLevel()->getLevelName();
|
if (auto level = GMLIB_Level::getInstance()) {
|
||||||
|
return level->getLevelName();
|
||||||
|
}
|
||||||
|
return {};
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setLevelName", [](std::string name) -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setLevelName", [](std::string const& name) -> void {
|
||||||
GMLIB_Level::getLevel()->setLevelName(name);
|
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 {
|
||||||
GMLIB_Level::getLevel()->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(
|
||||||
|
"GMLib_ServerAPI",
|
||||||
|
"shootProjectile",
|
||||||
|
[](Actor* owner, std::string const& name, float speed, float offset) -> Actor* {
|
||||||
|
auto ac = (GMLIB_Actor*)owner;
|
||||||
|
return ac->shootProjectile(name, speed, offset).as_ptr();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLib_ServerAPI",
|
||||||
|
"throwEntity",
|
||||||
|
[](Actor* owner, Actor* actor, float speed, float offset) -> bool {
|
||||||
|
auto ac = (GMLIB_Actor*)owner;
|
||||||
|
return ac->throwEntity(*actor, speed, offset);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
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", "shootProjectile", [](Actor* owner, std::string name, float speed, float offset) -> Actor* {
|
RemoteCall::exportAs("GMLib_ServerAPI", "removeAllFakeList", []() -> void {
|
||||||
auto ac = (GMLIB_Actor*)owner;
|
return FakeList::removeAllFakeLists();
|
||||||
return ac->shootProjectile(name, speed, offset);
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "throwEntity", [](Actor* owner, Actor* actor, float speed, float offset) -> bool {
|
RemoteCall::exportAs("GMLib_ServerAPI", "getMaxPlayers", []() -> int {
|
||||||
auto ac = (GMLIB_Actor*)owner;
|
if (auto level = GMLIB_Level::getInstance()) {
|
||||||
return ac->throwEntity(actor, speed, offset);
|
return level->getMaxPlayerCount();
|
||||||
});
|
}
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "PlayerToEntity", [](Player* player) -> Actor* {
|
return {};
|
||||||
return (Actor*)player;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
// This file will make your plugin use LeviLamina's memory operators by default.
|
||||||
|
// This improves the memory management of your plugin and is recommended to use.
|
||||||
|
// You should not modify anything in this file.
|
||||||
|
|
||||||
|
#define LL_MEMORY_OPERATORS
|
||||||
|
|
||||||
|
#include <ll/api/memory/MemoryOperators.h>
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
#include "Global.h"
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
|
namespace PAPIRemoteCall {
|
||||||
|
|
||||||
|
std::string removeBrackets(std::string a1) {
|
||||||
|
a1.erase(a1.find_last_not_of("%") + 1);
|
||||||
|
return a1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isParameters(std::string const& str) {
|
||||||
|
std::regex reg("[<]([^<>]+)[>]");
|
||||||
|
return std::regex_search(removeBrackets(str), reg);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GetValue(std::string const& from) { return PlaceholderAPI::getValue(from); }
|
||||||
|
|
||||||
|
std::string GetValueWithPlayer(std::string const& a1, std::string const& a2) {
|
||||||
|
return PlaceholderAPI::getValue(a1, ll::service::bedrock::getLevel()->getPlayer(a2));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool registerPlayerPlaceholder(
|
||||||
|
std::string const& PluginName,
|
||||||
|
std::string const& FuncName,
|
||||||
|
std::string const& PAPIName
|
||||||
|
) {
|
||||||
|
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||||
|
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||||
|
if (isParameters(PAPIName)) {
|
||||||
|
auto Call = RemoteCall::importAs<std::string(Player * pl, std::unordered_map<std::string, std::string>)>(
|
||||||
|
PluginName,
|
||||||
|
FuncName
|
||||||
|
);
|
||||||
|
PlaceholderAPI::registerPlayerPlaceholder(
|
||||||
|
PAPIName,
|
||||||
|
[Call](Player* sp, std::unordered_map<std::string, std::string> map) { return Call(sp, map); },
|
||||||
|
PluginName
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
auto Call = RemoteCall::importAs<std::string(Player * pl)>(PluginName, FuncName);
|
||||||
|
PlaceholderAPI::registerPlayerPlaceholder(
|
||||||
|
PAPIName,
|
||||||
|
[Call](Player* sp) { return Call(sp); },
|
||||||
|
PluginName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool registerServerPlaceholder(
|
||||||
|
std::string const& PluginName,
|
||||||
|
std::string const& FuncName,
|
||||||
|
std::string const& PAPIName
|
||||||
|
) {
|
||||||
|
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||||
|
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||||
|
if (isParameters(PAPIName)) {
|
||||||
|
auto Call =
|
||||||
|
RemoteCall::importAs<std::string(std::unordered_map<std::string, std::string>)>(PluginName, FuncName);
|
||||||
|
PlaceholderAPI::registerServerPlaceholder(
|
||||||
|
PAPIName,
|
||||||
|
[Call](std::unordered_map<std::string, std::string> map) { return Call(map); },
|
||||||
|
PluginName
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
||||||
|
PlaceholderAPI::registerServerPlaceholder(PAPIName, [Call]() { return Call(); }, PluginName);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool registerStaticPlaceholder(
|
||||||
|
std::string const& PluginName,
|
||||||
|
std::string const& FuncName,
|
||||||
|
std::string const& PAPIName,
|
||||||
|
int num
|
||||||
|
) {
|
||||||
|
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||||
|
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||||
|
if (isParameters(PAPIName)) {
|
||||||
|
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
||||||
|
if (num == -1) {
|
||||||
|
PlaceholderAPI::registerStaticPlaceholder(
|
||||||
|
PAPIName,
|
||||||
|
[Call] { return Call(); },
|
||||||
|
PluginName
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
PlaceholderAPI::registerStaticPlaceholder(
|
||||||
|
PAPIName,
|
||||||
|
num,
|
||||||
|
[Call] { return Call(); },
|
||||||
|
PluginName
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string translateStringWithPlayer(std::string const& str, Player* pl) {
|
||||||
|
return PlaceholderAPI::translateString(str, pl);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string translateString(std::string const& str) { return PlaceholderAPI::translateString(str); }
|
||||||
|
|
||||||
|
bool unRegisterPlaceholder(std::string const& str) { return PlaceholderAPI::unregisterPlaceholder(str); }
|
||||||
|
|
||||||
|
std::vector<std::string> getAllPAPI() { return PlaceholderAPI::getAllPAPI(); }
|
||||||
|
|
||||||
|
} // namespace PAPIRemoteCall
|
||||||
|
|
||||||
|
#define EXPORTAPI(T) \
|
||||||
|
RemoteCall::exportAs("BEPlaceholderAPI", ll::utils::string_utils::replaceAll(#T, "PAPIRemoteCall::", ""), T);
|
||||||
|
|
||||||
|
void ExportPAPI() {
|
||||||
|
EXPORTAPI(PAPIRemoteCall::registerPlayerPlaceholder);
|
||||||
|
EXPORTAPI(PAPIRemoteCall::registerServerPlaceholder);
|
||||||
|
EXPORTAPI(PAPIRemoteCall::registerStaticPlaceholder);
|
||||||
|
EXPORTAPI(PAPIRemoteCall::GetValue);
|
||||||
|
EXPORTAPI(PAPIRemoteCall::GetValueWithPlayer);
|
||||||
|
EXPORTAPI(PAPIRemoteCall::translateString);
|
||||||
|
EXPORTAPI(PAPIRemoteCall::translateStringWithPlayer);
|
||||||
|
EXPORTAPI(PAPIRemoteCall::unRegisterPlaceholder);
|
||||||
|
EXPORTAPI(PAPIRemoteCall::getAllPAPI);
|
||||||
|
}
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
#include "Plugin.h"
|
|
||||||
#include "Global.h"
|
|
||||||
|
|
||||||
ll::Logger logger(PLUGIN_NAME);
|
|
||||||
|
|
||||||
namespace plugin {
|
|
||||||
|
|
||||||
Plugin::Plugin(ll::plugin::NativePlugin& self) : mSelf(self) {
|
|
||||||
// Code for loading the plugin goes here.
|
|
||||||
Export_Legacy_GMLib_ModAPI();
|
|
||||||
Export_Legacy_GMLib_ServerAPI();
|
|
||||||
Export_Compatibility_API();
|
|
||||||
logger.info("GMLIB-LegacyRemoteCallApi Loaded!");
|
|
||||||
logger.info("Author: GroupMountain");
|
|
||||||
logger.info("Repository: https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi");
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Plugin::enable() {
|
|
||||||
// Code for enabling the plugin goes here.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Plugin::disable() {
|
|
||||||
// Code for disabling the plugin goes here.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace plugin
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <ll/api/plugin/NativePlugin.h>
|
|
||||||
|
|
||||||
namespace plugin {
|
|
||||||
|
|
||||||
class Plugin {
|
|
||||||
public:
|
|
||||||
explicit Plugin(ll::plugin::NativePlugin& self);
|
|
||||||
|
|
||||||
Plugin(Plugin&&) = delete;
|
|
||||||
Plugin(const Plugin&) = delete;
|
|
||||||
Plugin& operator=(Plugin&&) = delete;
|
|
||||||
Plugin& operator=(const Plugin&) = delete;
|
|
||||||
|
|
||||||
~Plugin() = default;
|
|
||||||
|
|
||||||
/// @return True if the plugin is enabled successfully.
|
|
||||||
bool enable();
|
|
||||||
|
|
||||||
/// @return True if the plugin is disabled successfully.
|
|
||||||
bool disable();
|
|
||||||
|
|
||||||
private:
|
|
||||||
ll::plugin::NativePlugin& mSelf;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace plugin
|
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"format_version": 2,
|
||||||
|
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
||||||
|
"version": "0.13.2",
|
||||||
|
"info": {
|
||||||
|
"name": "GMLIB-LegacyRemoteCallApi",
|
||||||
|
"description": "Legacy RemoteCall API for GMLIB",
|
||||||
|
"source": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
||||||
|
"author": "GroupMountain",
|
||||||
|
"tags": [
|
||||||
|
"levilamina",
|
||||||
|
"gmlib",
|
||||||
|
"lse",
|
||||||
|
"library"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.13.2/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
|
||||||
|
"dependencies": {
|
||||||
|
"github.com/GroupMountain/GMLIB": ">=0.13.0"
|
||||||
|
},
|
||||||
|
"files": {
|
||||||
|
"place": [
|
||||||
|
{
|
||||||
|
"src": "GMLIB-LegacyRemoteCallApi/*",
|
||||||
|
"dest": "plugins/GMLIB-LegacyRemoteCallApi"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +1,16 @@
|
|||||||
add_rules("mode.debug", "mode.release", "mode.releasedbg")
|
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")
|
||||||
@@ -47,28 +49,27 @@ target("GMLIB-LegacyRemoteCallApi") -- Change this to your plugin name.
|
|||||||
"/utf-8"
|
"/utf-8"
|
||||||
)
|
)
|
||||||
add_defines(
|
add_defines(
|
||||||
"_HAS_CXX23=1" -- To enable C++23 features
|
"NOMINMAX",
|
||||||
|
"UNICODE"
|
||||||
)
|
)
|
||||||
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
|
||||||
)
|
)
|
||||||
set_exceptions("none") -- To avoid conflicts with /EHa
|
set_exceptions("none") -- To avoid conflicts with /EHa
|
||||||
set_kind("shared")
|
set_kind("shared")
|
||||||
set_languages("cxx23")
|
set_languages("c++23")
|
||||||
|
set_symbols("debug")
|
||||||
|
|
||||||
after_build(function (target)
|
after_build(function (target)
|
||||||
local plugin_packer = import("scripts.after_build")
|
local plugin_packer = import("scripts.after_build")
|
||||||
|
|||||||
Reference in New Issue
Block a user