Compare commits
186 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/
|
||||||
|
|||||||
@@ -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,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:
|
||||||
@@ -38,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 58cec5c0c5
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[];
|
||||||
|
}
|
||||||
+109
-27
@@ -1,57 +1,139 @@
|
|||||||
const PAPIgetValueAPI = ll.import("BEPlaceholderAPI", "GetValue")
|
const PlaceholderAPI = {
|
||||||
const PAPIgetValueByPlayerAPI = ll.import("BEPlaceholderAPI", "GetValueWithPlayer")
|
/** 获取一个服务器变量的值 @type {function(string):string} */
|
||||||
const PAPIregisterPlayerPlaceholderAPI = ll.import("BEPlaceholderAPI", "registerPlayerPlaceholder")
|
getValueAPI: ll.import("BEPlaceholderAPI", "GetValue"),
|
||||||
const PAPIregisterServerPlaceholderAPI = ll.import("BEPlaceholderAPI", "registerServerPlaceholder")
|
/** 获取一个玩家变量的值 @type {function(string,Player):string} */
|
||||||
const PAPIregisterStaticPlaceholderAPI = ll.import("BEPlaceholderAPI", "registerStaticPlaceholder")
|
getValueByPlayerAPI: ll.import("BEPlaceholderAPI", "GetValueWithPlayer"),
|
||||||
const PAPItranslateStringAPI = ll.import("BEPlaceholderAPI", "translateString")
|
/** 注册一个玩家变量 @type {function(string,string,string):boolean} */
|
||||||
const PAPIunRegisterPlaceholderAPI = ll.import("BEPlaceholderAPI", "unRegisterPlaceholder")
|
registerPlayerPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerPlayerPlaceholder"),
|
||||||
const PAPIgetAllPAPI = ll.import("BEPlaceholderAPI", "getAllPAPI")
|
/** 注册一个服务器变量 @type {function(string,string,string):boolean} */
|
||||||
|
registerServerPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerServerPlaceholder"),
|
||||||
Function.prototype.getName = function () {
|
/** 注册一个静态变量 @type {function(string,string,string,number):boolean} */
|
||||||
|
registerStaticPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerStaticPlaceholder"),
|
||||||
return this.name || this.toString().match(/function\s*([^(]*)\(/)[1]
|
/** 翻译包含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 {
|
class PAPI {
|
||||||
constructor() {
|
constructor() {
|
||||||
throw new Error("Static class cannot be instantiated");
|
throw new Error("Static class cannot be instantiated");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册一个玩家PAPI变量
|
||||||
|
* @param {function} func 变量调用的函数
|
||||||
|
* @param {string} PluginName 插件名字
|
||||||
|
* @param {string} PAPIName PAPI变量名
|
||||||
|
* @returns {boolean} 是否注册成功
|
||||||
|
*/
|
||||||
static registerPlayerPlaceholder(func, PluginName, PAPIName) {
|
static registerPlayerPlaceholder(func, PluginName, PAPIName) {
|
||||||
|
ll.export(func, PluginName, func.getName());
|
||||||
ll.export(func, PluginName, func.getName())
|
return PlaceholderAPI.registerPlayerPlaceholderAPI(PluginName, func.getName(), PAPIName);
|
||||||
PAPIregisterPlayerPlaceholderAPI(PluginName, func.getName(), PAPIName)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册一个服务器PAPI变量
|
||||||
|
* @param {function} func 变量调用的函数
|
||||||
|
* @param {string} PluginName 插件名字
|
||||||
|
* @param {string} PAPIName PAPI变量名
|
||||||
|
* @returns {boolean} 是否注册成功
|
||||||
|
*/
|
||||||
static registerServerPlaceholder(func, PluginName, PAPIName) {
|
static registerServerPlaceholder(func, PluginName, PAPIName) {
|
||||||
ll.export(func, PluginName, func.getName())
|
ll.export(func, PluginName, func.getName());
|
||||||
PAPIregisterServerPlaceholderAPI(PluginName, func.getName(), PAPIName)
|
return PlaceholderAPI.registerServerPlaceholderAPI(PluginName, func.getName(), PAPIName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册一个静态PAPI变量
|
||||||
|
* @param {function} func 变量调用的函数
|
||||||
|
* @param {string} PluginName 插件名字
|
||||||
|
* @param {string} PAPIName PAPI变量名
|
||||||
|
* @param {number} [UpdateInterval=50] 更新间隔
|
||||||
|
* @returns {boolean} 是否注册成功
|
||||||
|
*/
|
||||||
static registerStaticPlaceholder(func, PluginName, PAPIName, UpdateInterval = 50) {
|
static registerStaticPlaceholder(func, PluginName, PAPIName, UpdateInterval = 50) {
|
||||||
ll.export(func, PluginName, func.getName())
|
ll.export(func, PluginName, func.getName());
|
||||||
PAPIregisterStaticPlaceholderAPI(PluginName, func.getName(), PAPIName, UpdateInterval)
|
return PlaceholderAPI.registerStaticPlaceholderAPI(PluginName, func.getName(), PAPIName, UpdateInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取一个服务器变量的值
|
||||||
|
* @param {string} key PAPI变量名
|
||||||
|
* @returns {string} 值
|
||||||
|
*/
|
||||||
static getValue(key) {
|
static getValue(key) {
|
||||||
return PAPIgetValueAPI(key)
|
return PlaceholderAPI.getValueAPI(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static getValueByPlayer(key, xuid) {
|
/**
|
||||||
return PAPIgetValueByPlayerAPI(key, xuid)
|
* 获取一个玩家变量的值
|
||||||
|
* @param {string} key PAPI变量名
|
||||||
|
* @param {Player} pl 玩家对象
|
||||||
|
* @returns {string} 值
|
||||||
|
*/
|
||||||
|
static getValueByPlayer(key, pl) {
|
||||||
|
return PlaceholderAPI.getValueByPlayerAPI(key, pl);
|
||||||
}
|
}
|
||||||
|
|
||||||
static translateString(str, xuid = "") {
|
/**
|
||||||
return PAPItranslateStringAPI(str, xuid)
|
* 翻译带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) {
|
static unRegisterPlaceholder(str) {
|
||||||
return PAPIunRegisterPlaceholderAPI(str)
|
return PlaceholderAPI.unRegisterPlaceholderAPI(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有已注册的PAPI变量
|
||||||
|
* @returns {Array.<string>} 已注册的PAPI变量数组
|
||||||
|
*/
|
||||||
static getAllPAPI() {
|
static getAllPAPI() {
|
||||||
return PAPIgetAllPAPI();
|
return PlaceholderAPI.getAllPAPI();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+251
@@ -0,0 +1,251 @@
|
|||||||
|
/** 事件监听接口 */
|
||||||
|
declare class Event {
|
||||||
|
/** 生物捡起物品 */
|
||||||
|
static listen(
|
||||||
|
/** 事件名 */
|
||||||
|
event: "onMobDie",
|
||||||
|
/** 监听函数 */
|
||||||
|
listener: (
|
||||||
|
/** 尝试捡起物品的实体对象 */
|
||||||
|
entity: Entity,
|
||||||
|
/** 掉落物实体对象 */
|
||||||
|
itemEntity: Entity
|
||||||
|
) => boolean | void
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 客户端登录后事件(不可以拦截) */
|
||||||
|
static listen(
|
||||||
|
/** 事件名 */
|
||||||
|
event: "onClientLogin",
|
||||||
|
/** 监听函数 */
|
||||||
|
listener: (
|
||||||
|
/** 玩家的游戏名字 */
|
||||||
|
realName: string,
|
||||||
|
/** 玩家的uuid */
|
||||||
|
uuid: string,
|
||||||
|
/** 玩家在服务端的xuid */
|
||||||
|
serverXuid: string,
|
||||||
|
/** 玩家在客户端的xuid */
|
||||||
|
clientXuid: string
|
||||||
|
) => void
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 天气改变事件事件 */
|
||||||
|
static listen(
|
||||||
|
/** 事件名 */
|
||||||
|
event: "onWeatherChange",
|
||||||
|
/** 监听函数 */
|
||||||
|
listener: (
|
||||||
|
/** 雷暴天气等级 */
|
||||||
|
lightningLevel: number,
|
||||||
|
/** 雨天天气等级 */
|
||||||
|
rainLevel: number,
|
||||||
|
/** 雷暴持续时间(刻) */
|
||||||
|
lightningLastTick: number,
|
||||||
|
/** 雨天持续时间(刻) */
|
||||||
|
rainingLastTick: number
|
||||||
|
) => boolean | void
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 掉落物尝试生成 */
|
||||||
|
static listen(
|
||||||
|
event: "onItemTrySpawn",
|
||||||
|
listener: (
|
||||||
|
/** 物品对象 */
|
||||||
|
item: Item,
|
||||||
|
/** 尝试生成的坐标对象 */
|
||||||
|
pos: FloatPos,
|
||||||
|
/** 创建掉落物的实体uniqueId */
|
||||||
|
spawnerUniqueId: number
|
||||||
|
) => boolean | void
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 掉落物生成完毕(不可以拦截) */
|
||||||
|
static listen(
|
||||||
|
/** 事件名 */
|
||||||
|
event: "onItemSpawned",
|
||||||
|
/** 回调函数 */
|
||||||
|
listener: (
|
||||||
|
/** 物品对象 */
|
||||||
|
item: Item,
|
||||||
|
/** 掉落物实体对象 */
|
||||||
|
entity: Entity,
|
||||||
|
/** 实体生成的坐标 */
|
||||||
|
pos: FloatPos,
|
||||||
|
/** 创建掉落物的实体uniqueId */
|
||||||
|
spawnerUniqueId: number
|
||||||
|
) => void
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 实体切换维度 */
|
||||||
|
static listen(
|
||||||
|
/** 事件名 */
|
||||||
|
event: "onEntityTryChangeDim",
|
||||||
|
/** 回调函数 */
|
||||||
|
listener: (
|
||||||
|
/** 切换维度的实体对象 */
|
||||||
|
entity: Entity,
|
||||||
|
/** 前往到的维度ID */
|
||||||
|
dimid: number
|
||||||
|
) => boolean | void
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 实体切换维度后(不可拦截) */
|
||||||
|
static listen(
|
||||||
|
/** 事件名 */
|
||||||
|
event: "onEntityChangeDim",
|
||||||
|
/** 回调函数 */
|
||||||
|
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,28 @@
|
|||||||
|
/** 事件创建函数 @type {function(string,string):boolean} */
|
||||||
|
const CallEvent = ll.import("GMLIB_Event_API", "callCustomEvent");
|
||||||
|
/** 获取事件ID函数 @type {function():string} */
|
||||||
|
const getNextEventId = ll.import("GMLIB_Event_API", "getNextScriptEventId");
|
||||||
|
|
||||||
|
/** 事件类 */
|
||||||
|
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(`GMLIB Script Event "${event}" does not exist !`);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { Event };
|
||||||
@@ -0,0 +1,182 @@
|
|||||||
|
// // const getNextCallbackId = ll.import("GMLIB_FormAPI", "getNextFormCallbackId");
|
||||||
|
|
||||||
|
// class ServerSettingForm {
|
||||||
|
// constructor() {
|
||||||
|
// throw new Error("Static class cannot be instantiated");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static getDefaultPriority() {
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "getDefaultPriority")();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static hasTitle() {
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "hasTitle")();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static getTitle() {
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "getTitle")();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static setTitle(title, forceModify = false) {
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "setTitle")(title, forceModify);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static hasIcon() {
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "hasIcon")();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static getIconData() {
|
||||||
|
// return hasIcon() ? ll.import("GMLIB_ServerSettingForm", "getIconData")() : null;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static getIconType() {
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "getIconType")();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static setIcon(data, type = 0, forceModify = false) {
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "setIcon")(data, type, forceModify);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static addLabel(
|
||||||
|
// text,
|
||||||
|
// playerDetector = (pl) => { return true; },
|
||||||
|
// priority = this.getDefaultPriority()
|
||||||
|
// ) {
|
||||||
|
// let detectorId = getNextCallbackId();
|
||||||
|
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "addLabel")(text, detectorId, priority);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// static addInput(
|
||||||
|
// text,
|
||||||
|
// placeholder,
|
||||||
|
// defaultVal,
|
||||||
|
// callback = (pl, input) => { },
|
||||||
|
// playerDetector = (pl) => { return true; },
|
||||||
|
// priority = this.getDefaultPriority()
|
||||||
|
// ) {
|
||||||
|
// let callbackId = getNextCallbackId();
|
||||||
|
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||||
|
// let detectorId = getNextCallbackId();
|
||||||
|
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "addInput")(text, placeholder, defaultVal, callbackId, detectorId, priority);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static addToggle(
|
||||||
|
// text,
|
||||||
|
// defaultVal = false,
|
||||||
|
// callback = (pl, input) => { },
|
||||||
|
// playerDetector = (pl) => { return true; },
|
||||||
|
// priority = this.getDefaultPriority()
|
||||||
|
// ) {
|
||||||
|
// let callbackId = getNextCallbackId();
|
||||||
|
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||||
|
// let detectorId = getNextCallbackId();
|
||||||
|
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "addToggle")(text, defaultVal, callbackId, detectorId, priority);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static addDropdown(
|
||||||
|
// text,
|
||||||
|
// options,
|
||||||
|
// defaultVal = 0,
|
||||||
|
// callback = (pl, input) => { },
|
||||||
|
// playerDetector = (pl) => { return true; },
|
||||||
|
// priority = this.getDefaultPriority()
|
||||||
|
// ) {
|
||||||
|
// let callbackId = getNextCallbackId();
|
||||||
|
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||||
|
// let detectorId = getNextCallbackId();
|
||||||
|
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "addDropdown")(text, options, defaultVal, callbackId, detectorId, priority);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static addSlider(
|
||||||
|
// text,
|
||||||
|
// min,
|
||||||
|
// max,
|
||||||
|
// step = 0.0,
|
||||||
|
// defaultVal = 0.0,
|
||||||
|
// callback = (pl, input) => { },
|
||||||
|
// playerDetector = (pl) => { return true; },
|
||||||
|
// priority = this.getDefaultPriority()
|
||||||
|
// ) {
|
||||||
|
// let callbackId = getNextCallbackId();
|
||||||
|
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||||
|
// let detectorId = getNextCallbackId();
|
||||||
|
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "addSlider")(text, min, max, step, defaultVal, callbackId, detectorId, priority);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static addStepSlider(
|
||||||
|
// text,
|
||||||
|
// steps,
|
||||||
|
// defaultVal = 0,
|
||||||
|
// callback = (pl, input) => { },
|
||||||
|
// playerDetector = (pl) => { return true; },
|
||||||
|
// priority = this.getDefaultPriority()
|
||||||
|
// ) {
|
||||||
|
// let callbackId = getNextCallbackId();
|
||||||
|
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||||
|
// let detectorId = getNextCallbackId();
|
||||||
|
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "addStepSlider")(text, steps, defaultVal, callbackId, detectorId, priority);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static removeElement(id) {
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "removeElement")(id);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// class NpcDialogueForm {
|
||||||
|
// constructor(npcName, sceneName, dialogue) {
|
||||||
|
// this.mFormId = ll.import("GMLIB_NpcDialogueForm", "createForm")(npcName, sceneName, dialogue);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// addButton(button) {
|
||||||
|
// return ll.import("GMLIB_NpcDialogueForm", "addButton")(this.mFormId, button);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// sendTo(pl, callback = (pl, index, type) => { }, free = true) {
|
||||||
|
// let callbackId = getNextCallbackId();
|
||||||
|
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||||
|
// ll.import("GMLIB_NpcDialogueForm", "sendTo")(this.mFormId, pl, callbackId);
|
||||||
|
// if (free) {
|
||||||
|
// this.destroy();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// destroy() {
|
||||||
|
// ll.import("GMLIB_NpcDialogueForm", "destroyForm")(this.mFormId);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// class ChestForm {
|
||||||
|
// constructor(npcName, sceneName, dialogue) {
|
||||||
|
// this.mFormId = ll.import("GMLIB_NpcDialogueForm", "createForm")(npcName, sceneName, dialogue);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// addButton(button) {
|
||||||
|
// return ll.import("GMLIB_NpcDialogueForm", "addButton")(this.mFormId, button);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// sendTo(pl, free = true) {
|
||||||
|
// //let callbackId = getNextCallbackId();
|
||||||
|
// //ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||||
|
// //ll.import("GMLIB_NpcDialogueForm", "sendTo")(this.mFormId, pl, callbackId);
|
||||||
|
// //if (free) {
|
||||||
|
// // this.destroy();
|
||||||
|
// //}
|
||||||
|
// }
|
||||||
|
|
||||||
|
// destroy() {
|
||||||
|
// //ll.import("GMLIB_NpcDialogueForm", "destroyForm")(this.mFormId);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// module.exports = {
|
||||||
|
// ServerSettingForm,
|
||||||
|
// NpcDialogueForm,
|
||||||
|
// ChestForm
|
||||||
|
// };
|
||||||
Vendored
+1678
File diff suppressed because it is too large
Load Diff
+2866
-81
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.4",
|
||||||
|
"author": "GroupMountain",
|
||||||
"type": "native",
|
"type": "native",
|
||||||
|
"passive": true,
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
{
|
{
|
||||||
"name": "GMLIB"
|
"name": "GMLIB"
|
||||||
|
|||||||
@@ -88,10 +88,11 @@ 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 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()
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
#include "Global.h"
|
||||||
|
using namespace ll::hash_utils;
|
||||||
|
|
||||||
|
class LegacyScriptBinaryStreamManager {
|
||||||
|
private:
|
||||||
|
int64 mNextBinaryStreamId = 0;
|
||||||
|
std::unordered_map<uint64, std::shared_ptr<GMLIB_BinaryStream>> mBinaryStream;
|
||||||
|
|
||||||
|
public:
|
||||||
|
uint getNextId() { return mNextBinaryStreamId++; }
|
||||||
|
|
||||||
|
void cretateBinaryStream(uint id) { mBinaryStream[id] = std::make_shared<GMLIB_BinaryStream>(); }
|
||||||
|
|
||||||
|
void removeBinaryStream(uint64 id) { mBinaryStream.erase(id); }
|
||||||
|
|
||||||
|
std::shared_ptr<GMLIB_BinaryStream> getBinaryStream(uint64 id) {
|
||||||
|
return mBinaryStream.contains(id) ? mBinaryStream.at(id) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
static LegacyScriptBinaryStreamManager& getInstance() {
|
||||||
|
static std::unique_ptr<LegacyScriptBinaryStreamManager> instance;
|
||||||
|
if (!instance) instance = std::make_unique<LegacyScriptBinaryStreamManager>();
|
||||||
|
return *instance;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#define BinaryStreamManager LegacyScriptBinaryStreamManager::getInstance()
|
||||||
|
#define EXPORTAPI(funcName, type, fuc) \
|
||||||
|
RemoteCall::exportAs("GMLIB_BinaryStream_API", funcName, [](uint64 id, type value) -> void { \
|
||||||
|
auto bs = BinaryStreamManager.getBinaryStream(id); \
|
||||||
|
if (bs != nullptr) fuc; \
|
||||||
|
})
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct Info;
|
||||||
|
template <typename T, typename R, typename A, typename... AS>
|
||||||
|
struct Info<R (T::*)(A, AS...)> {
|
||||||
|
using ArgT = A;
|
||||||
|
};
|
||||||
|
#define EXPORTAPI2(T) EXPORTAPI(#T, Info<decltype(&GMLIB_BinaryStream::T)>::ArgT, bs->T(value))
|
||||||
|
|
||||||
|
void Export_BinaryStream_API() {
|
||||||
|
RemoteCall::exportAs("GMLIB_BinaryStream_API", "create", []() -> uint64 {
|
||||||
|
auto id = BinaryStreamManager.getNextId();
|
||||||
|
BinaryStreamManager.cretateBinaryStream(id);
|
||||||
|
return id;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_BinaryStream_API", "reset", [](uint64 id) -> void {
|
||||||
|
if (BinaryStreamManager.getBinaryStream(id) == nullptr) BinaryStreamManager.cretateBinaryStream(id);
|
||||||
|
else BinaryStreamManager.getBinaryStream(id)->reset();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_BinaryStream_API", "sendTo", [](uint64 id, Player* player) -> void {
|
||||||
|
if (auto bs = BinaryStreamManager.getBinaryStream(id); bs != nullptr) bs->sendTo(*player);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_BinaryStream_API", "destroy", [](uint64 id) -> void {
|
||||||
|
BinaryStreamManager.removeBinaryStream(id);
|
||||||
|
});
|
||||||
|
EXPORTAPI("writePacketHeader", int, bs->writePacketHeader((MinecraftPacketIds)value));
|
||||||
|
EXPORTAPI("writeUuid", std::string const&, bs->writeUuid(mce::UUID::fromString(value)));
|
||||||
|
EXPORTAPI("writeItem", ItemStack*, bs->writeType(NetworkItemStackDescriptor(*value)));
|
||||||
|
EXPORTAPI("writeString", std::string const&, bs->writeString(value));
|
||||||
|
EXPORTAPI("writeCompoundTag", CompoundTag*, bs->writeCompoundTag(*value));
|
||||||
|
EXPORTAPI2(writeBool);
|
||||||
|
EXPORTAPI2(writeByte);
|
||||||
|
EXPORTAPI2(writeDouble);
|
||||||
|
EXPORTAPI2(writeFloat);
|
||||||
|
EXPORTAPI2(writeSignedBigEndianInt);
|
||||||
|
EXPORTAPI2(writeSignedInt);
|
||||||
|
EXPORTAPI2(writeSignedInt64);
|
||||||
|
EXPORTAPI2(writeSignedShort);
|
||||||
|
EXPORTAPI2(writeUnsignedChar);
|
||||||
|
EXPORTAPI2(writeUnsignedInt);
|
||||||
|
EXPORTAPI2(writeUnsignedInt64);
|
||||||
|
EXPORTAPI2(writeUnsignedShort);
|
||||||
|
EXPORTAPI2(writeUnsignedVarInt);
|
||||||
|
EXPORTAPI2(writeUnsignedVarInt64);
|
||||||
|
EXPORTAPI2(writeVarInt);
|
||||||
|
EXPORTAPI2(writeVarInt64);
|
||||||
|
}
|
||||||
+850
-63
@@ -1,94 +1,881 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
|
bool isInteger(const std::string& str) {
|
||||||
|
std::regex pattern("^[+-]?\\d+$");
|
||||||
|
return std::regex_match(str, pattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
ActorUniqueID parseScriptUniqueID(std::string const& uniqueId) {
|
||||||
|
return isInteger(uniqueId) ? ActorUniqueID(std::stoll(uniqueId)) : ActorUniqueID::INVALID_ID;
|
||||||
|
}
|
||||||
|
|
||||||
void Export_Compatibility_API() {
|
void Export_Compatibility_API() {
|
||||||
RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> float {
|
RemoteCall::exportAs("GMLIB_API", "unregisterRecipe", [](std::string const& id) -> bool {
|
||||||
auto level = GMLIB_Level::getLevel();
|
return GMLIB_Level::getInstance().has_value() ? GMLIB::Mod::CustomRecipe::unregisterRecipe(id) : false;
|
||||||
if (!level) {
|
});
|
||||||
return 0.0f;
|
RemoteCall::exportAs("GMLIB_API", "setCustomPackPath", [](std::string const& path) -> void {
|
||||||
}
|
GMLIB::Mod::CustomPacks::addCustomPackPath(path);
|
||||||
return level->getServerMspt();
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> double {
|
||||||
|
return GMLIB_Level::getInstance().transform(
|
||||||
|
[](GMLIB_Level& level) -> double { return level.getServerMspt(); }
|
||||||
|
).value_or(0.0);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getServerCurrentTps", []() -> float {
|
RemoteCall::exportAs("GMLIB_API", "getServerCurrentTps", []() -> float {
|
||||||
auto level = GMLIB_Level::getLevel();
|
return GMLIB_Level::getInstance()
|
||||||
if (!level) {
|
.transform([](GMLIB_Level& level) -> float { return level.getServerCurrentTps(); })
|
||||||
return 0.0f;
|
.value_or(0.0);
|
||||||
}
|
|
||||||
return level->getServerCurrentTps();
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getServerAverageTps", []() -> float {
|
RemoteCall::exportAs("GMLIB_API", "getServerAverageTps", []() -> double {
|
||||||
auto level = GMLIB_Level::getLevel();
|
return GMLIB_Level::getInstance()
|
||||||
if (!level) {
|
.transform([](GMLIB_Level& level) -> double { return level.getServerAverageTps(); })
|
||||||
return 0.0f;
|
.value_or(0.0);
|
||||||
}
|
|
||||||
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;
|
||||||
});
|
for (auto& uuid : GMLIB_Player::getAllUuids()) {
|
||||||
RemoteCall::exportAs("GMLIB_API", "getAllExperiments", []() -> std::vector<int> {
|
result.push_back(uuid.asString());
|
||||||
auto map = GMLIB_Level::getAllExperiments();
|
|
||||||
std::vector<int> result;
|
|
||||||
for (auto& key : map) {
|
|
||||||
result.push_back(key.first);
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getExperimentTranslatedName", [](int id) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerNbt", [](std::string const& uuid) -> std::unique_ptr<CompoundTag> {
|
||||||
auto map = GMLIB_Level::getAllExperimentsTranslateKeys();
|
return std::move(GMLIB_Player::getPlayerNbt(mce::UUID::fromString(uuid)));
|
||||||
if (map.count(id)) {
|
});
|
||||||
return std::string(map[id]);
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setPlayerNbt",
|
||||||
|
[](std::string const& uuid, CompoundTag* nbt, bool forceCreate) -> bool {
|
||||||
|
return GMLIB_Player::setPlayerNbt(mce::UUID::fromString(uuid), (GMLIB_CompoundTag&)*nbt, forceCreate);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setPlayerNbtTags",
|
||||||
|
[](std::string const& uuid, CompoundTag* nbt, std::vector<std::string> tags) -> bool {
|
||||||
|
return GMLIB_Player::setPlayerNbtTags(mce::UUID::fromString(uuid), (GMLIB_CompoundTag&)*nbt, tags);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "deletePlayerNbt", [](std::string const& uuid) -> bool {
|
||||||
|
return GMLIB_Player::deletePlayerNbt(mce::UUID::fromString(uuid));
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getAllExperiments", []() -> std::vector<int> {
|
||||||
|
std::vector<int> result;
|
||||||
|
for (auto& key : GMLIB_Level::getAllExperiments()) {
|
||||||
|
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 ft = GMLIB::Server::FloatingTextManager::createStatic(text, pos.first, pos.second, papi);
|
||||||
|
GMLIB::Server::FloatingTextManager::getInstance().add(ft);
|
||||||
|
return ft->getRuntimeID();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "setFloatingTextData", [](int id, std::string const& text) -> bool {
|
||||||
|
return GMLIB::Server::FloatingTextManager::getInstance()
|
||||||
|
.getFloatingText(id)
|
||||||
|
.transform([&text](GMLIB::Server::FloatingTextBase& ft) -> bool {
|
||||||
|
ft.setText(text);
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
.has_value();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "deleteFloatingText", [](int id) -> bool {
|
||||||
|
return GMLIB::Server::FloatingTextManager::getInstance().remove(id);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "sendFloatingTextToPlayer", [](int id, Player* pl) -> bool {
|
||||||
|
return GMLIB::Server::FloatingTextManager::getInstance()
|
||||||
|
.getFloatingText(id)
|
||||||
|
.transform([&pl](GMLIB::Server::FloatingTextBase& ft) -> bool {
|
||||||
|
ft.sendTo(*pl);
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
.has_value();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "sendFloatingText", [](int id) -> bool {
|
||||||
|
return GMLIB::Server::FloatingTextManager::getInstance()
|
||||||
|
.getFloatingText(id)
|
||||||
|
.transform([](GMLIB::Server::FloatingTextBase& ft) -> bool {
|
||||||
|
ft.sendToClients();
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
.has_value();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "removeFloatingTextFromPlayer", [](int id, Player* pl) -> bool {
|
||||||
|
return GMLIB::Server::FloatingTextManager::getInstance()
|
||||||
|
.getFloatingText(id)
|
||||||
|
.transform([&pl](GMLIB::Server::FloatingTextBase& ft) -> bool {
|
||||||
|
ft.removeFrom(*pl);
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
.has_value();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "removeFloatingText", [](int id) -> bool {
|
||||||
|
return GMLIB::Server::FloatingTextManager::getInstance()
|
||||||
|
.getFloatingText(id)
|
||||||
|
.transform([](GMLIB::Server::FloatingTextBase& ft) -> bool {
|
||||||
|
ft.removeFromClients();
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
.has_value();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "updateClientFloatingTextData", [](int id, Player* pl) -> bool {
|
||||||
|
return GMLIB::Server::FloatingTextManager::getInstance()
|
||||||
|
.getFloatingText(id)
|
||||||
|
.transform([&pl](GMLIB::Server::FloatingTextBase& ft) -> bool {
|
||||||
|
ft.update(*pl);
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
.has_value();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "updateAllClientsFloatingTextData", [](int id) -> bool {
|
||||||
|
return GMLIB::Server::FloatingTextManager::getInstance()
|
||||||
|
.getFloatingText(id)
|
||||||
|
.transform([](GMLIB::Server::FloatingTextBase& ft) -> bool {
|
||||||
|
ft.updateClients();
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
.has_value();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "isVersionMatched", [](int a, int b, int c) -> bool {
|
||||||
|
return LIB_VERSION >= GMLIB::Version(a, b, c, "", "");
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getVersion_LRCA", []() -> std::string { return LIB_VERSION.asString(); });
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getVersion_GMLIB", []() -> std::string {
|
||||||
|
return GMLIB::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 {
|
||||||
|
return GMLIB_Level::getInstance().has_value() ? I18nAPI::getCurrentLanguageCode() : "unknown";
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getSupportedLanguages", []() -> std::vector<std::string> {
|
||||||
|
return GMLIB_Level::getInstance() ? I18nAPI::getSupportedLanguageCodes() : std::vector<std::string>();
|
||||||
|
});
|
||||||
|
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> {
|
||||||
|
return GMLIB_Player::getPlayerPosition(mce::UUID::fromString(uuid))
|
||||||
|
.value_or(std::pair<BlockPos, int>({0, 0, 0}, -1));
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setPlayerPosition",
|
||||||
|
[](std::string const& uuid, std::pair<BlockPos, int> pos) -> bool {
|
||||||
|
return GMLIB_Player::setPlayerPosition(mce::UUID::fromString(uuid), pos.first, pos.second);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "playerHasScore", [](std::string const& uuid, std::string const& obj) -> bool {
|
||||||
|
return GMLIB_Player::getPlayerScore(mce::UUID::fromString(uuid), obj).has_value();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getPlayerScore", [](std::string const& uuid, std::string const& obj) -> int {
|
||||||
|
return GMLIB_Player::getPlayerScore(mce::UUID::fromString(uuid), obj).value_or(0);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"addPlayerScore",
|
||||||
|
[](std::string const& uuid, std::string const& obj, int value) -> bool {
|
||||||
|
return GMLIB_Player::setPlayerScore(mce::UUID::fromString(uuid), obj, value, PlayerScoreSetFunction::Add)
|
||||||
|
.has_value();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"reducePlayerScore",
|
||||||
|
[](std::string const& uuid, std::string const& obj, int value) -> bool {
|
||||||
|
return GMLIB_Player::setPlayerScore(
|
||||||
|
mce::UUID::fromString(uuid),
|
||||||
|
obj,
|
||||||
|
value,
|
||||||
|
PlayerScoreSetFunction::Subtract
|
||||||
|
)
|
||||||
|
.has_value();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setPlayerScore",
|
||||||
|
[](std::string const& uuid, std::string const& obj, int value) -> bool {
|
||||||
|
return GMLIB_Player::setPlayerScore(mce::UUID::fromString(uuid), obj, value).has_value();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "resetPlayerScore", [](std::string const& uuid, std::string const& obj) -> bool {
|
||||||
|
return GMLIB_Player::resetPlayerScore(mce::UUID::fromString(uuid), obj);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "resetPlayerScores", [](std::string const& uuid) -> bool {
|
||||||
|
return GMLIB_Player::resetPlayerScore(mce::UUID::fromString(uuid));
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"entityHasScore",
|
||||||
|
[](std::string const& uniqueId, std::string const& obj) -> bool {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->getScore(obj, parseScriptUniqueID(uniqueId)).has_value();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getEntityScore", [](std::string const& uniqueId, std::string const& obj) -> int {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->getScore(obj, parseScriptUniqueID(uniqueId)).value_or(0);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"addEntityScore",
|
||||||
|
[](std::string const& uniqueId, std::string const& obj, int value) -> bool {
|
||||||
|
return GMLIB_Scoreboard::getInstance()
|
||||||
|
->setScore(obj, parseScriptUniqueID(uniqueId), value, PlayerScoreSetFunction::Add)
|
||||||
|
.has_value();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"reduceEntityScore",
|
||||||
|
[](std::string const& uniqueId, std::string const& obj, int value) -> bool {
|
||||||
|
return GMLIB_Scoreboard::getInstance()
|
||||||
|
->setScore(obj, parseScriptUniqueID(uniqueId), value, PlayerScoreSetFunction::Subtract)
|
||||||
|
.has_value();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setEntityScore",
|
||||||
|
[](std::string const& uniqueId, std::string const& obj, int value) -> bool {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->setScore(obj, parseScriptUniqueID(uniqueId), value).has_value();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"resetEntityScore",
|
||||||
|
[](std::string const& uniqueId, std::string const& obj) -> bool {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->resetScore(obj, parseScriptUniqueID(uniqueId));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "resetEntityScores", [](std::string const& uniqueId) -> bool {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->resetScore(parseScriptUniqueID(uniqueId));
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"fakePlayerHasScore",
|
||||||
|
[](std::string const& name, std::string const& obj) -> bool {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->getScore(obj, name).has_value();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getFakePlayerScore", [](std::string const& name, std::string const& obj) -> int {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->getScore(obj, name).value_or(0);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"addFakePlayerScore",
|
||||||
|
[](std::string const& name, std::string const& obj, int value) -> bool {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->setScore(obj, name, value, PlayerScoreSetFunction::Add).has_value();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"reduceFakePlayerScore",
|
||||||
|
[](std::string const& name, std::string const& obj, int value) -> bool {
|
||||||
|
return GMLIB_Scoreboard::getInstance()
|
||||||
|
->setScore(obj, name, value, PlayerScoreSetFunction::Subtract)
|
||||||
|
.has_value();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"setFakePlayerScore",
|
||||||
|
[](std::string const& name, std::string const& obj, int value) -> bool {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->setScore(obj, name, value).has_value();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
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 {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->addObjective(obj).has_value();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"addObjectiveWithDisplayName",
|
||||||
|
[](std::string const& obj, std::string const& displayName) -> bool {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->addObjective(obj, displayName).has_value();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getDisplayName", [](std::string const& obj) -> std::string {
|
||||||
|
return GMLIB_Scoreboard::getInstance()->getObjectiveDisplayName(obj).value_or("");
|
||||||
|
});
|
||||||
|
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> {
|
||||||
|
std::vector<std::string> result;
|
||||||
|
for (auto& obj : GMLIB_Scoreboard::getInstance()->getObjectives()) {
|
||||||
|
result.push_back(obj->getName());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardPlayers", []() -> std::vector<std::string> {
|
||||||
|
std::vector<std::string> result;
|
||||||
|
for (auto& uuid : GMLIB_Scoreboard::getInstance()->getAllPlayerUuids()) {
|
||||||
|
result.push_back(uuid.asString());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardFakePlayers", []() -> std::vector<std::string> {
|
||||||
|
std::vector<std::string> result;
|
||||||
|
for (auto& name : GMLIB_Scoreboard::getInstance()->getAllFakePlayers()) {
|
||||||
|
result.push_back(name);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardEntities", []() -> std::vector<std::string> {
|
||||||
|
std::vector<std::string> result;
|
||||||
|
for (auto& uniqueId : GMLIB_Scoreboard::getInstance()->getAllEntities()) {
|
||||||
|
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;
|
||||||
|
for (auto& uuid : GMLIB_Scoreboard::getInstance()->getAllPlayerUuids()) {
|
||||||
|
result.push_back({
|
||||||
|
{"Type", "Player" },
|
||||||
|
{"Uuid", uuid.asString()}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
for (auto& name : GMLIB_Scoreboard::getInstance()->getAllFakePlayers()) {
|
||||||
|
result.push_back({
|
||||||
|
{"Type", "FakePlayer"},
|
||||||
|
{"Name", name }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
for (auto& uniqueId : GMLIB_Scoreboard::getInstance()->getAllEntities()) {
|
||||||
|
result.push_back({
|
||||||
|
{"Type", "Entity" },
|
||||||
|
{"UniqueId", std::to_string(uniqueId.id)}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
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* {
|
||||||
|
return ll::service::getLevel()->getPlayer(parseScriptUniqueID(uniqueId));
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getEntityFromUniqueId", [](std::string const& uniqueId) -> Actor* {
|
||||||
|
return ll::service::getLevel()->fetchEntity(parseScriptUniqueID(uniqueId));
|
||||||
|
});
|
||||||
|
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 res = ((GMLIB_Player*)pl)->getSpawnPoint();
|
||||||
|
return {res.first, res.second};
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "setPlayerSpawnPoint", [](Player* pl, std::pair<BlockPos, int> pos) -> void {
|
||||||
|
((GMLIB_Player*)pl)->setSpawnPoint(pos.first, pos.second);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "clearPlayerSpawnPoint", [](Player* pl) -> void {
|
||||||
|
((GMLIB_Player*)pl)->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 {
|
||||||
|
return GMLIB::UserCache::getXuidByUuid(mce::UUID::fromString(uuid)).value_or("");
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getXuidByName", [](std::string const& name) -> std::string {
|
||||||
|
return GMLIB::UserCache::getXuidByName(name).value_or("");
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getNameByUuid", [](std::string const& uuid) -> std::string {
|
||||||
|
return GMLIB::UserCache::getNameByUuid(mce::UUID::fromString(uuid)).value_or("");
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getNameByXuid", [](std::string const& xuid) -> std::string {
|
||||||
|
return GMLIB::UserCache::getNameByXuid(xuid).value_or("");
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getUuidByXuid", [](std::string const& xuid) -> std::string {
|
||||||
|
return GMLIB::UserCache::getUuidByXuid(xuid)
|
||||||
|
.transform([](mce::UUID&& uuid) -> std::string { return uuid.asString(); })
|
||||||
|
.value_or("");
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getUuidByName", [](std::string const& name) -> std::string {
|
||||||
|
return GMLIB::UserCache::getUuidByName(name)
|
||||||
|
.transform([](mce::UUID&& uuid) -> std::string { return uuid.asString(); })
|
||||||
|
.value_or("");
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"getAllPlayerInfo",
|
||||||
|
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
||||||
|
std::vector<std::unordered_map<std::string, std::string>> result;
|
||||||
|
GMLIB::UserCache::forEach([&result](const GMLIB::UserCache::UserCacheEntry& entry) -> void {
|
||||||
|
result.push_back({
|
||||||
|
{"Name", entry.mName },
|
||||||
|
{"Xuid", entry.mXuid },
|
||||||
|
{"Uuid", entry.mUuid.asString()}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getBlockRuntimeId", [](std::string const& blockName, short legacyData) -> uint {
|
||||||
|
return Block::tryGetFromRegistry(blockName, legacyData)
|
||||||
|
.transform([](const Block& block) -> uint { return block.getRuntimeId(); })
|
||||||
|
.value_or(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 {
|
||||||
|
return Block::tryGetFromRegistry(blockName)
|
||||||
|
.transform([](const Block& block) -> std::string { return block.buildDescriptionId(); })
|
||||||
|
.value_or("tile.unknown.name");
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"getBlockLightEmission",
|
||||||
|
[](std::string const& blockName, short legacyData) -> char {
|
||||||
|
return Block::tryGetFromRegistry(blockName)
|
||||||
|
.transform([](const Block& block) -> char { return (char)block.getLightEmission().value; })
|
||||||
|
.value_or(-1);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"getGameRules",
|
||||||
|
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
||||||
|
std::vector<std::unordered_map<std::string, std::string>> result;
|
||||||
|
for (auto& gameRule : ll::service::getLevel()->getGameRules().getRules()) {
|
||||||
|
switch (gameRule.getType()) {
|
||||||
|
case GameRule::Type::Bool:
|
||||||
|
result.push_back({
|
||||||
|
{"Name", gameRule.getName() },
|
||||||
|
{"Type", "Bool" },
|
||||||
|
{"Value", std::to_string(gameRule.getBool())}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case GameRule::Type::Float:
|
||||||
|
result.push_back({
|
||||||
|
{"Name", gameRule.getName() },
|
||||||
|
{"Type", "Float" },
|
||||||
|
{"Value", std::to_string(gameRule.getFloat())}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case GameRule::Type::Int:
|
||||||
|
result.push_back({
|
||||||
|
{"Name", gameRule.getName() },
|
||||||
|
{"Type", "Int" },
|
||||||
|
{"Value", std::to_string(gameRule.getInt())}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case GameRule::Type::Invalid:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getLegalEnchants", [](ItemStack const* item) -> std::vector<std::string> {
|
||||||
|
std::vector<std::string> result;
|
||||||
|
for (auto& enchant : EnchantUtils::getLegalEnchants(item->getItem())) {
|
||||||
|
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 "";
|
return "";
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"createFloatingText",
|
"applyEnchant",
|
||||||
[](std::pair<Vec3, int> pos, std::string text, bool papi) -> int {
|
[](ItemStack* item, std::string const& typeName, int level, bool allowNonVanilla) -> bool {
|
||||||
auto ft = new GMLIB::Server::FloatingText(text, pos.first, pos.second, papi);
|
return EnchantUtils::applyEnchant(
|
||||||
return ft->getRuntimeID();
|
*item,
|
||||||
|
Enchant::getEnchantTypeFromName(HashedString(typeName)),
|
||||||
|
level,
|
||||||
|
allowNonVanilla
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "setFloatingTextData", [](int id, std::string text) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "removeEnchants", [](ItemStack* item) -> void {
|
||||||
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
EnchantUtils::removeEnchants(*item);
|
||||||
if (ft) {
|
});
|
||||||
ft->setText(text);
|
RemoteCall::exportAs("GMLIB_API", "hasEnchant", [](ItemStack* item, std::string const& typeName) -> bool {
|
||||||
return true;
|
return EnchantUtils::hasEnchant(Enchant::getEnchantTypeFromName(HashedString(typeName)), *item);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getEnchantLevel", [](ItemStack* item, std::string const& typeName) -> int {
|
||||||
|
return EnchantUtils::getEnchantLevel(Enchant::getEnchantTypeFromName(HashedString(typeName)), *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* item, int cost) -> void {
|
||||||
|
(*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;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "deleteFloatingText", [](int id) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "setPlayerUIItem", [](Player* player, int slot, ItemStack const* item) -> void {
|
||||||
return GMLIB::Server::FloatingText::deleteFloatingText(id);
|
player->setPlayerUIItem((PlayerUISlot)slot, *item);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "sendFloatingTextToPlayer", [](int id, Player* pl) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerUIItem", [](Player* player, int slot) -> ItemStack* {
|
||||||
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
return const_cast<ItemStack*>(&player->getPlayerUIItem((PlayerUISlot)slot));
|
||||||
if (ft) {
|
});
|
||||||
ft->sendToClient(pl);
|
RemoteCall::exportAs(
|
||||||
return true;
|
"GMLIB_API",
|
||||||
|
"sendInventorySlotPacket",
|
||||||
|
[](Player* player, int containerId, int slot, ItemStack const* item) -> void {
|
||||||
|
InventorySlotPacket((ContainerID)containerId, slot, *item).sendTo(*player);
|
||||||
}
|
}
|
||||||
return false;
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getContainerType", [](Container* container) -> std::string {
|
||||||
|
return magic_enum::enum_name(container->getContainerType()).data();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "sendFloatingText", [](int id) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "hasPlayerNbt", [](std::string const& uuid) -> bool {
|
||||||
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
return GMLIB_Player::getPlayerNbt(mce::UUID::fromString(uuid)) != nullptr;
|
||||||
if (ft) {
|
});
|
||||||
ft->sendToAllClients();
|
RemoteCall::exportAs("GMLIB_API", "getItemMaxCount", [](ItemStack const* item) -> int {
|
||||||
return true;
|
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 false;
|
return 0;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "removeFloatingTextFromPlayer", [](int id, Player* pl) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDuration", [](Actor* entity, int effectId) -> int {
|
||||||
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
if (auto effect = entity->getEffect(effectId)) {
|
||||||
if (ft) {
|
return effect->mDuration;
|
||||||
ft->removeFromClient(pl);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return 0;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "removeFloatingText", [](int id) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDurationEasy", [](Actor* entity, int effectId) -> int {
|
||||||
auto ft = GMLIB::Server::FloatingText::getFloatingText(id);
|
if (auto effect = entity->getEffect(effectId)) {
|
||||||
if (ft) {
|
return effect->mDurationEasy;
|
||||||
ft->removeFromAllClients();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
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 {
|
||||||
|
return ll::service::getLevel().transform(
|
||||||
|
[](Level& level) -> int { return (int)level.getDifficulty(); }
|
||||||
|
).value_or(-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 {
|
||||||
|
return ll::service::getLevel().transform(
|
||||||
|
[](Level& level) -> int { return (int)level.getDefaultGameType(); }
|
||||||
|
).value_or(-1);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "setDefaultGameMode", [](int gameMode) -> void {
|
||||||
|
if (auto level = ll::service::getLevel()) {
|
||||||
|
level->setDefaultGameType((GameType)gameMode);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"registerCustomShapelessRecipe",
|
||||||
|
[](std::string const& recipe_id, std::vector<std::string> ingredients, ItemStack* result) -> void {
|
||||||
|
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||||
|
std::vector<Recipes::Type> types;
|
||||||
|
char rt = 'A';
|
||||||
|
for (auto& ing : ingredients) {
|
||||||
|
types.emplace_back(ing, rt++, 1, 0);
|
||||||
|
}
|
||||||
|
GMLIB::Mod::CustomRecipe::registerShapelessCraftingTableRecipe(recipe_id, types, *result);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"registerCustomShapedRecipe",
|
||||||
|
[](std::string const& recipe_id,
|
||||||
|
std::vector<std::string> shape,
|
||||||
|
std::vector<std::string> ingredients,
|
||||||
|
ItemStack* result) -> void {
|
||||||
|
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||||
|
std::vector<Recipes::Type> types;
|
||||||
|
char rt = 'A';
|
||||||
|
for (auto& ing : ingredients) {
|
||||||
|
types.emplace_back(ing, rt++, 1, 0);
|
||||||
|
}
|
||||||
|
GMLIB::Mod::CustomRecipe::registerShapedCraftingTableRecipe(recipe_id, shape, types, *result);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
@@ -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,38 @@
|
|||||||
|
#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();
|
||||||
|
Export_BinaryStream_API();
|
||||||
|
// Export_Form_API();
|
||||||
|
logger.info("GMLIB-LegacyRemoteCallApi Loaded!");
|
||||||
|
logger.info(
|
||||||
|
"Loaded Version: {} with {}",
|
||||||
|
fmt::format(fg(fmt::color::pink), "GMLIB-" + GMLIB::Version::getLibVersionString()),
|
||||||
|
fmt::format(fg(fmt::color::light_green), "GMLIB-LegacyRemoteCallApi-" + LIB_VERSION.asString())
|
||||||
|
);
|
||||||
|
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(gmlib::LegacyRemoteCallApi, gmlib::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,249 @@
|
|||||||
|
#include "Global.h"
|
||||||
|
using namespace ll::hash_utils;
|
||||||
|
|
||||||
|
class LegacyScriptEventManager {
|
||||||
|
private:
|
||||||
|
int64 mNextEventId = 0;
|
||||||
|
std::unordered_map<uint64, ll::event::ListenerPtr> mEventListeners;
|
||||||
|
|
||||||
|
public:
|
||||||
|
std::string getNextEventId() {
|
||||||
|
mNextEventId++;
|
||||||
|
return "GMLIB_EVENT_" + std::to_string(mNextEventId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void emplaceListener(std::string const& scriptEventId, ll::event::ListenerPtr listenerPtr) {
|
||||||
|
mEventListeners[doHash(scriptEventId)] = std::move(listenerPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void removeListener(std::string const& scriptEventId) {
|
||||||
|
ll::event::EventBus::getInstance().removeListener(mEventListeners[doHash(scriptEventId)]);
|
||||||
|
mEventListeners.erase(doHash(scriptEventId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
static LegacyScriptEventManager& getInstance() {
|
||||||
|
static std::unique_ptr<LegacyScriptEventManager> instance;
|
||||||
|
if (!instance) {
|
||||||
|
instance = std::make_unique<LegacyScriptEventManager>();
|
||||||
|
}
|
||||||
|
return *instance;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#define REGISTER_EVENT_LISTEN(eventType, callFunction, eventParams, cancelFunction, otherFunction) \
|
||||||
|
eventManager.emplaceListener( \
|
||||||
|
eventId, \
|
||||||
|
eventBus.emplaceListener<eventType>([eventName, eventId, &eventBus, &eventManager](eventType& ev) -> void { \
|
||||||
|
if (!RemoteCall::hasFunc(eventName, eventId)) { \
|
||||||
|
eventManager.removeListener(eventId); \
|
||||||
|
return; \
|
||||||
|
} \
|
||||||
|
bool result = true; \
|
||||||
|
try { \
|
||||||
|
otherFunction; \
|
||||||
|
result = RemoteCall::importAs<bool callFunction>(eventName, eventId) eventParams; \
|
||||||
|
} catch (...) {} \
|
||||||
|
if (!result) cancelFunction; \
|
||||||
|
}) \
|
||||||
|
); \
|
||||||
|
return true;
|
||||||
|
|
||||||
|
void Export_Event_API() {
|
||||||
|
RemoteCall::exportAs("GMLIB_Event_API", "getNextScriptEventId", []() -> std::string {
|
||||||
|
return LegacyScriptEventManager::getInstance().getNextEventId();
|
||||||
|
});
|
||||||
|
auto& eventBus = ll::event::EventBus::getInstance();
|
||||||
|
auto& eventManager = LegacyScriptEventManager::getInstance();
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_Event_API",
|
||||||
|
"callCustomEvent",
|
||||||
|
[&eventBus, &eventManager](std::string const& eventName, std::string const& eventId) -> bool {
|
||||||
|
if (!RemoteCall::hasFunc(eventName, eventId)) return false;
|
||||||
|
switch (doHash(eventName)) {
|
||||||
|
case doHash("onClientLogin"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::PacketEvent::ClientLoginAfterEvent,
|
||||||
|
(std::string const& realName,
|
||||||
|
std::string const& uuid,
|
||||||
|
std::string const& serverXuid,
|
||||||
|
std::string const& clientXuid),
|
||||||
|
(ev.getRealName(), ev.getUuid().asString(), ev.getServerAuthXuid(), ev.getClientAuthXuid()),
|
||||||
|
logger.error("Event \"onClientLogin\" cannot be intercepted"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
case doHash("onWeatherChange"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::LevelEvent::WeatherUpdateBeforeEvent,
|
||||||
|
(int lightningLevel, int rainLevel, int lightningLast, int rainLast),
|
||||||
|
(ev.getLightningLevel(), ev.getRainLevel(), ev.getLightningLastTick(), ev.getRainingLastTick()),
|
||||||
|
ev.cancel(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
case doHash("onMobPick"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::EntityEvent::MobPickupItemBeforeEvent,
|
||||||
|
(Actor * mob, Actor * item),
|
||||||
|
(&ev.self(), (Actor*)&ev.getItemActor()),
|
||||||
|
ev.cancel(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
case doHash("onItemTrySpawn"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::EntityEvent::ItemActorSpawnBeforeEvent,
|
||||||
|
(const ItemStack* item, std::pair<Vec3, int> position, int64 spawnerUniqueId),
|
||||||
|
(&ev.getItem(),
|
||||||
|
{ev.getPosition(), ev.getBlockSource().getDimensionId().id},
|
||||||
|
ev.getSpawner().has_value() ? ev.getSpawner()->getOrCreateUniqueID().id : -1),
|
||||||
|
ev.cancel(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
case doHash("onItemSpawned"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::EntityEvent::ItemActorSpawnAfterEvent,
|
||||||
|
(const ItemStack* item, Actor* itemActor, std::pair<Vec3, int> position, int64 spawnerUniqueId),
|
||||||
|
(&ev.getItem(),
|
||||||
|
(Actor*)&ev.getItemActor(),
|
||||||
|
{ev.getPosition(), ev.getBlockSource().getDimensionId().id},
|
||||||
|
ev.getSpawner().has_value() ? ev.getSpawner()->getOrCreateUniqueID().id : -1),
|
||||||
|
logger.error("Event \"onItemSpawned\" cannot be intercepted"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
case doHash("onEntityTryChangeDim"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::EntityEvent::ActorChangeDimensionBeforeEvent,
|
||||||
|
(Actor * entity, int toDimId),
|
||||||
|
(&ev.self(), ev.getToDimensionId()),
|
||||||
|
ev.cancel(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
case doHash("onLeaveBed"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::PlayerEvent::PlayerStopSleepBeforeEvent,
|
||||||
|
(Player * pl),
|
||||||
|
(&ev.self()),
|
||||||
|
ev.cancel(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
case doHash("onDeathMessage"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::EntityEvent::DeathMessageAfterEvent,
|
||||||
|
(std::string const& message, std::vector<std::string>, Actor* dead),
|
||||||
|
(ev.getDeathMessage().first, ev.getDeathMessage().second, &ev.self()),
|
||||||
|
logger.error("Event \"onDeathMessage\" cannot be intercepted"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
case doHash("onMobHurted"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::EntityEvent::MobHurtAfterEvent,
|
||||||
|
(Actor * mob, Actor * source, float damage, int cause),
|
||||||
|
(&ev.self(), source, ev.getDamage(), (int)damageSource.getCause()),
|
||||||
|
logger.error("Event \"onMobHurted\" cannot be intercepted"),
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
case doHash("onEndermanTake"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::EntityEvent::EndermanTakeBlockBeforeEvent,
|
||||||
|
(Actor * mob),
|
||||||
|
(&ev.self()),
|
||||||
|
ev.cancel(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
case doHash("onEntityChangeDim"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::EntityEvent::ActorChangeDimensionAfterEvent,
|
||||||
|
(Actor * mob, int fromDimId),
|
||||||
|
(&ev.self(), ev.getFromDimensionId()),
|
||||||
|
logger.error("Event \"onEntityChangeDim\" cannot be intercepted"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
case doHash("onDragonRespawn"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::EntityEvent::DragonRespawnBeforeEvent,
|
||||||
|
(int64 enderDragonUniqueID),
|
||||||
|
(ev.getEnderDragon().id),
|
||||||
|
ev.cancel(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
case doHash("onProjectileTryCreate"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::EntityEvent::ProjectileCreateBeforeEvent,
|
||||||
|
(Actor * mob, int64 uniqueId),
|
||||||
|
(&ev.self(), ev.getShooter() ? ev.getShooter()->getOrCreateUniqueID().id : -1),
|
||||||
|
ev.cancel(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
case doHash("onProjectileCreate"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::EntityEvent::ProjectileCreateAfterEvent,
|
||||||
|
(Actor * mob, int64 uniqueId),
|
||||||
|
(&ev.self(), ev.getShooter() ? ev.getShooter()->getOrCreateUniqueID().id : -1),
|
||||||
|
logger.error("Event \"onProjectileCreate\" cannot be intercepted"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
case doHash("onSpawnWanderingTrader"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::EntityEvent::SpawnWanderingTraderBeforeEvent,
|
||||||
|
(std::pair<BlockPos, int> pos),
|
||||||
|
({ev.getPos(), ev.getRegion().getDimensionId()}),
|
||||||
|
ev.cancel(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
case doHash("onHandleRequestAction"): {
|
||||||
|
// clang-format off
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::PlayerEvent::HandleRequestActionBeforeEvent,
|
||||||
|
(
|
||||||
|
Player * player,
|
||||||
|
std::string const& actionType,
|
||||||
|
int count,
|
||||||
|
std::string const& sourceContainerNetId,
|
||||||
|
int sourceSlot,
|
||||||
|
std::string const& destinationContainerNetId,
|
||||||
|
int destinationSlot
|
||||||
|
),
|
||||||
|
(
|
||||||
|
(Player*)&ev.self(),
|
||||||
|
magic_enum::enum_name(requestAction.mActionType).data(),
|
||||||
|
(int)requestAction.mAmount,
|
||||||
|
magic_enum::enum_name(requestAction.mSrc.mOpenContainerNetId).data(),
|
||||||
|
(int)requestAction.mSrc.mSlot,
|
||||||
|
magic_enum::enum_name(requestAction.mDst.mOpenContainerNetId).data(),
|
||||||
|
(int)requestAction.mDst.mSlot
|
||||||
|
),
|
||||||
|
ev.cancel(),
|
||||||
|
auto& requestAction = (ItemStackRequestActionTransferBase&)ev.getRequestAction();
|
||||||
|
)
|
||||||
|
// clang-format on
|
||||||
|
}
|
||||||
|
case doHash("onSendContainerClosePacket"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::PacketEvent::ContainerClosePacketSendAfterEvent,
|
||||||
|
(Player * player, int ContainerNetId),
|
||||||
|
(ev.getServerNetworkHandler()
|
||||||
|
.getServerPlayer(ev.getNetworkIdentifier(), ev.getPacket().mClientSubId),
|
||||||
|
(int)ev.getPacket().mContainerId),
|
||||||
|
logger.error("Event \"onSendContainerClosePacket\" cannot be intercepted"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
case doHash("onServerStopping"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
ll::event::server::ServerStoppingEvent,
|
||||||
|
(),
|
||||||
|
(),
|
||||||
|
logger.error("Event \"onServerStopping\" cannot be intercepted"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
+288
@@ -0,0 +1,288 @@
|
|||||||
|
// #include "Global.h"
|
||||||
|
|
||||||
|
// using namespace ll::hash_utils;
|
||||||
|
|
||||||
|
// class LegacyScriptFormManager {
|
||||||
|
// private:
|
||||||
|
// int64 mNextFormCallbackId = 0;
|
||||||
|
// int64 mNextFormId = 0;
|
||||||
|
// std::unordered_map<int64, std::unique_ptr<gmlib::form::NpcDialogueForm>> mNpcDialogueForms;
|
||||||
|
// // std::unordered_map<int64, std::unique_ptr<ChestForm>> mChestForms;
|
||||||
|
|
||||||
|
// public:
|
||||||
|
// // std::string getNextFormCallbackId() {
|
||||||
|
// // return "GMLIB_FormApi_" + std::to_string(mNextFormCallbackId++);
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// int64 getNextFormId() {
|
||||||
|
// mNextFormId++;
|
||||||
|
// return mNextFormId;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// int64 createNpcDialogueForm(std::string const& npcName, std::string const& sceneName, std::string const& dialogue) {
|
||||||
|
// auto formId = LegacyScriptFormManager::getInstance().getNextFormId();
|
||||||
|
// auto formPtr = std::make_unique<gmlib::form::NpcDialogueForm>(npcName, sceneName, dialogue);
|
||||||
|
// mNpcDialogueForms[formId] = std::move(formPtr);
|
||||||
|
// return formId;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// bool destroyNpcDialogueForm(int64 formId) {
|
||||||
|
// if (mNpcDialogueForms.contains(formId)) {
|
||||||
|
// mNpcDialogueForms.erase(formId);
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// optional_ref<gmlib::form::NpcDialogueForm> getNpcDialogueForm(int64 formId) {
|
||||||
|
// if (mNpcDialogueForms.contains(formId)) {
|
||||||
|
// return mNpcDialogueForms[formId].get();
|
||||||
|
// }
|
||||||
|
// return {};
|
||||||
|
// }
|
||||||
|
|
||||||
|
// /*
|
||||||
|
// int64 createChestForm(std::string const& npcName, std::string const& sceneName, std::string const& dialogue) {
|
||||||
|
// auto formId = LegacyScriptFormManager::getInstance().getNextFormId();
|
||||||
|
// auto formPtr = std::make_unique<ChestForm>(npcName, sceneName, dialogue);
|
||||||
|
// mChestForms[formId] = std::move(formPtr);
|
||||||
|
// return formId;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// bool destroyChestForm(int64 formId) {
|
||||||
|
// if (mChestForms.contains(formId)) {
|
||||||
|
// mChestForms.erase(formId);
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// optional_ref<ChestForm> getChestForm(int64 formId) {
|
||||||
|
// if (mChestForms.contains(formId)) {
|
||||||
|
// return mChestForms[formId].get();
|
||||||
|
// }
|
||||||
|
// return {};
|
||||||
|
// }
|
||||||
|
|
||||||
|
// */
|
||||||
|
// public:
|
||||||
|
// static LegacyScriptFormManager& getInstance() {
|
||||||
|
// static std::unique_ptr<LegacyScriptFormManager> instance;
|
||||||
|
// if (!instance) {
|
||||||
|
// instance = std::make_unique<LegacyScriptFormManager>();
|
||||||
|
// }
|
||||||
|
// return *instance;
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
|
// #define PLAYER_DETECROR \
|
||||||
|
// [detectorId, result](::Player& pl) -> bool { \
|
||||||
|
// try { \
|
||||||
|
// if (RemoteCall::hasFunc("GMLIB_FORM_CALLBACK", detectorId)) { \
|
||||||
|
// auto const& detector = RemoteCall::importAs<bool(::Player*)>("GMLIB_FORM_CALLBACK", detectorId); \
|
||||||
|
// return detector(&pl); \
|
||||||
|
// } else { \
|
||||||
|
// gmlib::form::ServerSettingForm::removeElement(result); \
|
||||||
|
// } \
|
||||||
|
// } catch (...) {} \
|
||||||
|
// return false; \
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #define CALLBACK_TYPE(type) \
|
||||||
|
// [callbackId, result](Player& pl, type data) { \
|
||||||
|
// try { \
|
||||||
|
// if (RemoteCall::hasFunc("GMLIB_FORM_CALLBACK", callbackId)) { \
|
||||||
|
// auto const& callback = RemoteCall::importAs<void(Player*, type)>("GMLIB_FORM_CALLBACK", callbackId); \
|
||||||
|
// callback(&pl, data); \
|
||||||
|
// } else { \
|
||||||
|
// gmlib::form::ServerSettingForm::removeElement(result); \
|
||||||
|
// } \
|
||||||
|
// } catch (...) {} \
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #define CALLBACK_TYPE_NORMAL \
|
||||||
|
// [callbackId](::Player& pl) { \
|
||||||
|
// try { \
|
||||||
|
// if (RemoteCall::hasFunc("GMLIB_FORM_CALLBACK", callbackId)) { \
|
||||||
|
// auto const& callback = RemoteCall::importAs<void(::Player*)>("GMLIB_FORM_CALLBACK", callbackId); \
|
||||||
|
// callback(&pl); \
|
||||||
|
// } \
|
||||||
|
// } catch (...) {} \
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// void Export_Form_API() {
|
||||||
|
// //////////////////////////////// Form Manager /////////////////////////////////
|
||||||
|
// // RemoteCall::exportAs("GMLIB_FormAPI", "getNextFormCallbackId", []() -> std::string {
|
||||||
|
// // return LegacyScriptFormManager::getInstance().getNextFormCallbackId();
|
||||||
|
// // });
|
||||||
|
// ////////////////////////////// ServerSettingForm //////////////////////////////
|
||||||
|
// RemoteCall::exportAs("GMLIB_ServerSettingForm", "getDefaultPriority", []() -> int {
|
||||||
|
// return gmlib::form::ServerSettingForm::getDefaultPriority();
|
||||||
|
// });
|
||||||
|
// RemoteCall::exportAs("GMLIB_ServerSettingForm", "hasTitle", []() -> bool { return gmlib::form::ServerSettingForm::hasTitle(); });
|
||||||
|
// RemoteCall::exportAs("GMLIB_ServerSettingForm", "getTitle", []() -> std::string {
|
||||||
|
// return gmlib::form::ServerSettingForm::getTitle();
|
||||||
|
// });
|
||||||
|
// RemoteCall::exportAs("GMLIB_gmlib::form::ServerSettingForm", "setTitle", [](std::string const& title, bool forceModify) -> bool {
|
||||||
|
// return gmlib::form::ServerSettingForm::setTitle(title, forceModify);
|
||||||
|
// });
|
||||||
|
// RemoteCall::exportAs("GMLIB_gmlib::form::ServerSettingForm", "hasIcon", []() -> bool { return gmlib::form::ServerSettingForm::hasIcon(); });
|
||||||
|
// RemoteCall::exportAs("GMLIB_gmlib::form::ServerSettingForm", "getIconData", []() -> std::string {
|
||||||
|
// return gmlib::form::ServerSettingForm::getIconData().value_or("");
|
||||||
|
// });
|
||||||
|
// RemoteCall::exportAs("GMLIB_gmlib::form::ServerSettingForm", "getIconType", []() -> int {
|
||||||
|
// return gmlib::form::ServerSettingForm::getIconType()
|
||||||
|
// .transform([](gmlib::form::IconType&& type) -> int { return (int)type; })
|
||||||
|
// .value_or(-1);
|
||||||
|
// });
|
||||||
|
// RemoteCall::exportAs(
|
||||||
|
// "GMLIB_gmlib::form::ServerSettingForm",
|
||||||
|
// "setIcon",
|
||||||
|
// [](std::string const& title, uchar type, bool forceModify) -> bool {
|
||||||
|
// return gmlib::form::ServerSettingForm::setIcon(title, gmlib::form::IconType(type), forceModify);
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// RemoteCall::exportAs(
|
||||||
|
// "GMLIB_gmlib::form::ServerSettingForm",
|
||||||
|
// "addLabel",
|
||||||
|
// [](std::string const& text, std::string const& detectorId, int priority) -> uint {
|
||||||
|
// uint result = gmlib::form::ServerSettingForm::addLabel(text, PLAYER_DETECROR, priority);
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// RemoteCall::exportAs(
|
||||||
|
// "GMLIB_gmlib::form::ServerSettingForm",
|
||||||
|
// "addInput",
|
||||||
|
// [](std::string const& text,
|
||||||
|
// std::string const& placeholder,
|
||||||
|
// std::string const& defaultVal,
|
||||||
|
// std::string const& callbackId,
|
||||||
|
// std::string const& detectorId,
|
||||||
|
// int priority) -> uint {
|
||||||
|
// uint result = gmlib::form::ServerSettingForm::addInput(
|
||||||
|
// text,
|
||||||
|
// placeholder,
|
||||||
|
// defaultVal,
|
||||||
|
// CALLBACK_TYPE(std::string const&),
|
||||||
|
// PLAYER_DETECROR,
|
||||||
|
// priority
|
||||||
|
// );
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// RemoteCall::exportAs(
|
||||||
|
// "GMLIB_gmlib::form::ServerSettingForm",
|
||||||
|
// "addToggle",
|
||||||
|
// [](std::string const& text,
|
||||||
|
// bool defaultVal,
|
||||||
|
// std::string const& callbackId,
|
||||||
|
// std::string const& detectorId,
|
||||||
|
// int priority) -> uint {
|
||||||
|
// uint result = gmlib::form::ServerSettingForm::addToggle(text, defaultVal, CALLBACK_TYPE(bool), PLAYER_DETECROR, priority);
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// RemoteCall::exportAs(
|
||||||
|
// "GMLIB_gmlib::form::ServerSettingForm",
|
||||||
|
// "addDropdown",
|
||||||
|
// [](std::string const& text,
|
||||||
|
// std::vector<std::string> options,
|
||||||
|
// int64 defaultVal,
|
||||||
|
// std::string const& callbackId,
|
||||||
|
// std::string const& detectorId,
|
||||||
|
// int priority) -> uint {
|
||||||
|
// uint result = gmlib::form::ServerSettingForm::addDropdown(
|
||||||
|
// text,
|
||||||
|
// options,
|
||||||
|
// defaultVal,
|
||||||
|
// CALLBACK_TYPE(int64),
|
||||||
|
// PLAYER_DETECROR,
|
||||||
|
// priority
|
||||||
|
// );
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// RemoteCall::exportAs(
|
||||||
|
// "GMLIB_gmlib::form::ServerSettingForm",
|
||||||
|
// "addSlider",
|
||||||
|
// [](std::string const& text,
|
||||||
|
// double min,
|
||||||
|
// double max,
|
||||||
|
// double step,
|
||||||
|
// double defaultVal,
|
||||||
|
// std::string const& callbackId,
|
||||||
|
// std::string const& detectorId,
|
||||||
|
// int priority) -> uint {
|
||||||
|
// uint result = gmlib::form::ServerSettingForm::addSlider(
|
||||||
|
// text,
|
||||||
|
// min,
|
||||||
|
// max,
|
||||||
|
// step,
|
||||||
|
// defaultVal,
|
||||||
|
// CALLBACK_TYPE(double),
|
||||||
|
// PLAYER_DETECROR,
|
||||||
|
// priority
|
||||||
|
// );
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// RemoteCall::exportAs(
|
||||||
|
// "GMLIB_gmlib::form::ServerSettingForm",
|
||||||
|
// "addStepSlider",
|
||||||
|
// [](std::string const& text,
|
||||||
|
// std::vector<std::string> steps,
|
||||||
|
// int64 defaultVal,
|
||||||
|
// std::string const& callbackId,
|
||||||
|
// std::string const& detectorId,
|
||||||
|
// int priority) -> uint {
|
||||||
|
// uint result = gmlib::form::ServerSettingForm::addStepSlider(
|
||||||
|
// text,
|
||||||
|
// steps,
|
||||||
|
// defaultVal,
|
||||||
|
// CALLBACK_TYPE(int64),
|
||||||
|
// PLAYER_DETECROR,
|
||||||
|
// priority
|
||||||
|
// );
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// RemoteCall::exportAs("GMLIB_gmlib::form::ServerSettingForm", "removeElement", [](uint id) -> bool {
|
||||||
|
// return gmlib::form::ServerSettingForm::removeElement(id);
|
||||||
|
// });
|
||||||
|
// ////////////////////////////// NpcDialogueForm //////////////////////////////
|
||||||
|
// RemoteCall::exportAs(
|
||||||
|
// "GMLIB_NpcDialogueForm",
|
||||||
|
// "createForm",
|
||||||
|
// [](std::string const& npcName, std::string const& sceneName, std::string const& dialogue) -> int64 {
|
||||||
|
// return LegacyScriptFormManager::getInstance().createNpcDialogueForm(npcName, sceneName, dialogue);
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// RemoteCall::exportAs("GMLIB_NpcDialogueForm", "destroyForm", [](int64 formId) -> bool {
|
||||||
|
// return LegacyScriptFormManager::getInstance().destroyNpcDialogueForm(formId);
|
||||||
|
// });
|
||||||
|
// RemoteCall::exportAs(
|
||||||
|
// "GMLIB_NpcDialogueForm",
|
||||||
|
// "addButton",
|
||||||
|
// [](int64 formId, std::string const& button, std::string const& callbackId) -> void {
|
||||||
|
// if (auto formPtr = LegacyScriptFormManager::getInstance().getNpcDialogueForm(formId)) {
|
||||||
|
// formPtr->addButton(button, CALLBACK_TYPE_NORMAL);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// RemoteCall::exportAs(
|
||||||
|
// "GMLIB_NpcDialogueForm",
|
||||||
|
// "onPlayerClose",
|
||||||
|
// [](int64 formId, std::string const& callbackId) -> void {
|
||||||
|
// if (auto formPtr = LegacyScriptFormManager::getInstance().getNpcDialogueForm(formId)) {
|
||||||
|
// formPtr->onPlayerClose(CALLBACK_TYPE_NORMAL);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// RemoteCall::exportAs("GMLIB_NpcDialogueForm", "sendTo", [](int64 formId, ::Player* pl) -> void {
|
||||||
|
// if (auto formPtr = LegacyScriptFormManager::getInstance().getNpcDialogueForm(formId)) {
|
||||||
|
// formPtr->sendTo(*pl);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// ////////////////////////////// ChestForm //////////////////////////////
|
||||||
|
// }
|
||||||
+12
-2
@@ -1,8 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <GMLIB/include_lib.h>
|
#include <include_all.h>
|
||||||
|
|
||||||
#include <RemoteCallAPI.h>
|
#include <RemoteCallAPI.h>
|
||||||
|
|
||||||
#define PLUGIN_NAME "GMLIB-LRCA"
|
#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 4
|
||||||
|
|
||||||
|
#define LIB_VERSION GMLIB::Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH)
|
||||||
|
|
||||||
extern ll::Logger logger;
|
extern ll::Logger logger;
|
||||||
|
|
||||||
@@ -10,3 +17,6 @@ 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 ExportPAPI();
|
||||||
|
extern void Export_Event_API();
|
||||||
|
extern void Export_BinaryStream_API();
|
||||||
|
// extern void Export_Form_API();
|
||||||
|
|||||||
+94
-103
@@ -2,14 +2,9 @@
|
|||||||
|
|
||||||
std::unordered_set<std::string> HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"};
|
std::unordered_set<std::string> HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"};
|
||||||
|
|
||||||
std::variant<std::string, std::vector<RecipeIngredient>> makeRecipeUnlockingKey(std::string& key) {
|
std::variant<std::string, std::vector<RecipeIngredient>> makeRecipeUnlockingKey(std::string const& key) {
|
||||||
if (HardCodedKeys.count(key)) {
|
if (HardCodedKeys.count(key)) return key;
|
||||||
return key;
|
return std::vector<RecipeIngredient>({RecipeIngredient(key, 0, 1)});
|
||||||
}
|
|
||||||
std::vector<RecipeIngredient> result;
|
|
||||||
auto item = RecipeIngredient(key, 0, 1);
|
|
||||||
result.emplace_back(item);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Export_Legacy_GMLib_ModAPI() {
|
void Export_Legacy_GMLib_ModAPI() {
|
||||||
@@ -17,100 +12,96 @@ 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::getLevel();
|
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||||
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);
|
types.emplace_back(ing, 0, 1);
|
||||||
types.push_back(key);
|
|
||||||
}
|
}
|
||||||
auto res = RecipeIngredient(result, 0, count);
|
GMLIB::Mod::JsonRecipe::registerShapelessCraftingTableRecipe(
|
||||||
auto unl = makeRecipeUnlockingKey(unlock);
|
recipe_id,
|
||||||
GMLIB::Mod::CustomRecipe::registerShapelessCraftingTableRecipe(recipe_id, types, res, unl);
|
types,
|
||||||
|
RecipeIngredient(result, 0, count),
|
||||||
|
makeRecipeUnlockingKey(unlock)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
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::getLevel();
|
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||||
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);
|
types.push_back(RecipeIngredient(ing, 0, 1));
|
||||||
types.push_back(key);
|
|
||||||
}
|
}
|
||||||
auto res = RecipeIngredient(result, 0, count);
|
GMLIB::Mod::JsonRecipe::registerShapedCraftingTableRecipe(
|
||||||
auto unl = makeRecipeUnlockingKey(unlock);
|
recipe_id,
|
||||||
GMLIB::Mod::CustomRecipe::registerShapedCraftingTableRecipe(recipe_id, shape, types, res, unl);
|
shape,
|
||||||
|
types,
|
||||||
|
RecipeIngredient(result, 0, count),
|
||||||
|
makeRecipeUnlockingKey(unlock)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
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,
|
||||||
auto level = GMLIB_Level::getLevel();
|
std::string const& input,
|
||||||
if (!level) {
|
std::string const& output,
|
||||||
return;
|
std::vector<std::string> tags) -> void {
|
||||||
}
|
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||||
auto inp = RecipeIngredient(input, 0, 1);
|
GMLIB::Mod::JsonRecipe::registerFurnaceRecipe(
|
||||||
auto outp = RecipeIngredient(output, 0, 1);
|
recipe_id,
|
||||||
GMLIB::Mod::CustomRecipe::registerFurnaceRecipe(recipe_id, inp, outp, tags);
|
RecipeIngredient(input, 0, 1),
|
||||||
|
RecipeIngredient(output, 0, 1),
|
||||||
|
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
|
||||||
auto level = GMLIB_Level::getLevel();
|
) -> void {
|
||||||
if (!level) {
|
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||||
return;
|
GMLIB::Mod::JsonRecipe::registerBrewingMixRecipe(recipe_id, input, output, RecipeIngredient(reagent, 0, 1));
|
||||||
}
|
|
||||||
auto rea = RecipeIngredient(reagent, 0, 1);
|
|
||||||
GMLIB::Mod::CustomRecipe::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
|
||||||
auto level = GMLIB_Level::getLevel();
|
) -> void {
|
||||||
if (!level) {
|
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||||
return;
|
GMLIB::Mod::JsonRecipe::registerBrewingContainerRecipe(
|
||||||
}
|
recipe_id,
|
||||||
auto inp = RecipeIngredient(input, 0, 1);
|
RecipeIngredient(input, 0, 1),
|
||||||
auto outp = RecipeIngredient(output, 0, 1);
|
RecipeIngredient(output, 0, 1),
|
||||||
auto rea = RecipeIngredient(reagent, 0, 1);
|
RecipeIngredient(reagent, 0, 1)
|
||||||
GMLIB::Mod::CustomRecipe::registerBrewingContainerRecipe(recipe_id, inp, outp, rea);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ModAPI",
|
"GMLib_ModAPI",
|
||||||
"registerSmithingTransformRecipe",
|
"registerSmithingTransformRecipe",
|
||||||
[](std::string recipe_id,
|
[](std::string const& recipe_id,
|
||||||
std::string smithing_template,
|
std::string const& smithing_template,
|
||||||
std::string base,
|
std::string const& base,
|
||||||
std::string addition,
|
std::string const& addition,
|
||||||
std::string result) -> void {
|
std::string const& result) -> void {
|
||||||
auto level = GMLIB_Level::getLevel();
|
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||||
if (!level) {
|
GMLIB::Mod::JsonRecipe::registerSmithingTransformRecipe(
|
||||||
return;
|
|
||||||
}
|
|
||||||
GMLIB::Mod::CustomRecipe::registerSmithingTransformRecipe(
|
|
||||||
recipe_id,
|
recipe_id,
|
||||||
smithing_template,
|
smithing_template,
|
||||||
base,
|
base,
|
||||||
@@ -122,30 +113,29 @@ 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,
|
||||||
auto level = GMLIB_Level::getLevel();
|
std::string const& smithing_template,
|
||||||
if (!level) {
|
std::string const& base,
|
||||||
return;
|
std::string const& addition) -> void {
|
||||||
}
|
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||||
GMLIB::Mod::CustomRecipe::registerSmithingTrimRecipe(recipe_id, smithing_template, base, addition);
|
GMLIB::Mod::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::getLevel();
|
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||||
if (!level) {
|
GMLIB::Mod::JsonRecipe::registerStoneCutterRecipe(
|
||||||
return;
|
recipe_id,
|
||||||
}
|
RecipeIngredient(input, 0, 1),
|
||||||
auto inp = RecipeIngredient(input, 0, 1);
|
RecipeIngredient(output, 0, 1)
|
||||||
auto outp = RecipeIngredient(output, 0, 1);
|
);
|
||||||
GMLIB::Mod::CustomRecipe::registerStoneCutterRecipe(recipe_id, inp, outp);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
// 错误方块清理
|
// 错误方块清理
|
||||||
@@ -154,34 +144,35 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
});
|
});
|
||||||
// 实验性
|
// 实验性
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void {
|
RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void {
|
||||||
auto map = GMLIB_Level::getAllExperiments();
|
auto list = GMLIB_Level::getAllExperiments();
|
||||||
if (map.count(experiment_id)) {
|
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||||
|
if (set.contains((AllExperiments)experiment_id)) {
|
||||||
GMLIB_Level::addExperimentsRequire((AllExperiments)experiment_id);
|
GMLIB_Level::addExperimentsRequire((AllExperiments)experiment_id);
|
||||||
} else {
|
} else {
|
||||||
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "setExperimentEnabled", [](int experiment_id, bool value) -> void {
|
RemoteCall::exportAs("GMLib_ModAPI", "setExperimentEnabled", [](int experiment_id, bool value) -> void {
|
||||||
auto level = GMLIB_Level::getLevel();
|
if (GMLIB_Level::getInstance()) {
|
||||||
if (!level) {
|
auto list = GMLIB_Level::getAllExperiments();
|
||||||
return;
|
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||||
|
if (set.contains((AllExperiments)experiment_id)) {
|
||||||
|
GMLIB_Level::getInstance()->setExperimentEnabled(((AllExperiments)experiment_id), value);
|
||||||
|
} else ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
||||||
}
|
}
|
||||||
auto map = GMLIB_Level::getAllExperiments();
|
|
||||||
if (map.count(experiment_id)) {
|
|
||||||
GMLIB_Level::getLevel()->setExperimentEnabled(((AllExperiments)experiment_id), value);
|
|
||||||
} else ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "getExperimentEnabled", [](int experiment_id) -> bool {
|
RemoteCall::exportAs("GMLib_ModAPI", "getExperimentEnabled", [](int experiment_id) -> bool {
|
||||||
auto level = GMLIB_Level::getLevel();
|
if (GMLIB_Level::getInstance()) {
|
||||||
if (!level) {
|
auto list = GMLIB_Level::getAllExperiments();
|
||||||
return false;
|
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||||
}
|
if (set.contains((AllExperiments)experiment_id)) {
|
||||||
auto map = GMLIB_Level::getAllExperiments();
|
return GMLIB_Level::getInstance()->getExperimentEnabled(((AllExperiments)experiment_id));
|
||||||
if (map.count(experiment_id)) {
|
}
|
||||||
return GMLIB_Level::getLevel()->getExperimentEnabled(((AllExperiments)experiment_id));
|
|
||||||
} else {
|
|
||||||
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLib_ModAPI", "setFixI18nEnabled", []() -> void {
|
||||||
|
GMLIB::Mod::VanillaFix::setFixI18nEnabled();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
+47
-26
@@ -2,46 +2,49 @@
|
|||||||
|
|
||||||
void Export_Legacy_GMLib_ServerAPI() {
|
void Export_Legacy_GMLib_ServerAPI() {
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void {
|
||||||
GMLIB_Level::addEducationEditionRequired();
|
GMLIB_Level::tryEnableEducationEdition();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void {
|
||||||
GMLIB_Level::forceEnableAbilityCommand();
|
GMLIB_Level::tryRegisterAbilityCommand();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void {
|
||||||
GMLIB_Level::setForceAchievementsEnabled();
|
GMLIB_Level::setForceAchievementsEnabled();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void { GMLIB_Level::setForceTrustSkin(); });
|
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void { GMLIB_Level::trustAllSkins(); });
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "enableCoResourcePack", []() -> void { GMLIB_Level::setCoResourcePack(); });
|
RemoteCall::exportAs("GMLib_ServerAPI", "enableCoResourcePack", []() -> void {
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
GMLIB_Level::requireServerResourcePackAndAllowClientResourcePack();
|
||||||
auto level = GMLIB_Level::getLevel();
|
|
||||||
if (!level) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return level->getLevelName();
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setLevelName", [](std::string name) -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
||||||
auto level = GMLIB_Level::getLevel();
|
return GMLIB_Level::getInstance()
|
||||||
if (!level) {
|
.transform([](GMLIB_Level& level) -> std::string { return level.getLevelName(); })
|
||||||
return;
|
.value_or("");
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLib_ServerAPI", "setLevelName", [](std::string const& name) -> void {
|
||||||
|
if (auto level = GMLIB_Level::getInstance()) {
|
||||||
|
level->setLevelName(name);
|
||||||
}
|
}
|
||||||
return level->setLevelName(name);
|
});
|
||||||
|
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelSeed", []() -> std::string {
|
||||||
|
return GMLIB_Level::getInstance()
|
||||||
|
.transform([](GMLIB_Level& level) -> std::string { return std::to_string(level.getSeed()); })
|
||||||
|
.value_or("");
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setFakeSeed", [](int64_t seed) -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setFakeSeed", [](int64_t seed) -> void {
|
||||||
auto level = GMLIB_Level::getLevel();
|
return GMLIB_Level::setFakeSeed(seed);
|
||||||
if (!level) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return level->setFakeSeed(seed);
|
|
||||||
});
|
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "spawnEntity", [](std::pair<Vec3, int> pos, std::string name) -> Actor* {
|
|
||||||
return GMLIB_Spawner::spawnEntity(pos.first, pos.second, name);
|
|
||||||
});
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLib_ServerAPI",
|
||||||
|
"spawnEntity",
|
||||||
|
[](std::pair<Vec3, int> pos, std::string const& name) -> Actor* {
|
||||||
|
return GMLIB_Spawner::spawnEntity(pos.first, pos.second, name).as_ptr();
|
||||||
|
}
|
||||||
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLib_ServerAPI",
|
"GMLib_ServerAPI",
|
||||||
"shootProjectile",
|
"shootProjectile",
|
||||||
[](Actor* owner, std::string name, float speed, float offset) -> Actor* {
|
[](Actor* owner, std::string const& name, float speed, float offset) -> Actor* {
|
||||||
auto ac = (GMLIB_Actor*)owner;
|
auto ac = (GMLIB_Actor*)owner;
|
||||||
return ac->shootProjectile(name, speed, offset);
|
return ac->shootProjectile(name, speed, offset).as_ptr();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -49,8 +52,26 @@ void Export_Legacy_GMLib_ServerAPI() {
|
|||||||
"throwEntity",
|
"throwEntity",
|
||||||
[](Actor* owner, Actor* actor, float speed, float offset) -> bool {
|
[](Actor* owner, Actor* actor, float speed, float offset) -> bool {
|
||||||
auto ac = (GMLIB_Actor*)owner;
|
auto ac = (GMLIB_Actor*)owner;
|
||||||
return ac->throwEntity(actor, speed, offset);
|
return ac->throwEntity(*actor, speed, offset);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "PlayerToEntity", [](Player* player) -> Actor* { return (Actor*)player; });
|
RemoteCall::exportAs("GMLib_ServerAPI", "PlayerToEntity", [](Player* player) -> Actor* { return (Actor*)player; });
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLib_ServerAPI",
|
||||||
|
"addFakeList",
|
||||||
|
[](const std::string& name, const std::string& xuid) -> bool {
|
||||||
|
return GMLIB::Server::FakeList::addFakeList(name, xuid, ActorUniqueID(-1));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLib_ServerAPI", "removeFakeList", [](const std::string& nameOrXuid) -> bool {
|
||||||
|
return GMLIB::Server::FakeList::removeFakeList(nameOrXuid);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLib_ServerAPI", "removeAllFakeList", []() -> void {
|
||||||
|
return GMLIB::Server::FakeList::removeAllFakeLists();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLib_ServerAPI", "getMaxPlayers", []() -> int {
|
||||||
|
return GMLIB_Level::getInstance().transform(
|
||||||
|
[](GMLIB_Level& level) -> int { return level.getMaxPlayerCount(); }
|
||||||
|
).value_or(0);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
+37
-38
@@ -8,51 +8,54 @@ std::string removeBrackets(std::string a1) {
|
|||||||
return a1;
|
return a1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isParameters(std::string str) {
|
bool isParameters(std::string const& str) {
|
||||||
std::regex reg("[<]([^<>]+)[>]");
|
std::regex reg("[<]([^<>]+)[>]");
|
||||||
return std::regex_search(removeBrackets(str), reg);
|
return std::regex_search(removeBrackets(str), reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetValue(std::string const& from) { return GMLIB::Server::PlaceholderAPI::getValue(from); }
|
std::string GetValue(std::string const& from) { return GMLIB::Server::PlaceholderAPI::getValue(from); }
|
||||||
|
|
||||||
std::string GetValueWithPlayer(std::string const& a1, std::string const& a2) {
|
std::string GetValueWithPlayer(std::string const& key, Player* player) {
|
||||||
return GMLIB::Server::PlaceholderAPI::getValue(a1, ll::service::bedrock::getLevel()->getPlayer(a2));
|
return GMLIB::Server::PlaceholderAPI::getValue(key, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
bool registerPlayerPlaceholder(
|
||||||
registerPlayerPlaceholder(std::string const& PluginName, std::string const& FuncName, std::string const& PAPIName) {
|
std::string const& PluginName,
|
||||||
|
std::string const& FuncName,
|
||||||
|
std::string const& PAPIName
|
||||||
|
) {
|
||||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||||
|
GMLIB::Server::PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||||
if (isParameters(PAPIName)) {
|
if (isParameters(PAPIName)) {
|
||||||
auto Call =
|
auto Call = RemoteCall::importAs<std::string(Player * pl, std::unordered_map<std::string, std::string>)>(
|
||||||
RemoteCall::importAs<std::string(std::string const& arg, std::unordered_map<std::string, std::string>)>(
|
PluginName,
|
||||||
PluginName,
|
FuncName
|
||||||
FuncName
|
);
|
||||||
);
|
|
||||||
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
|
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
|
||||||
PAPIName,
|
PAPIName,
|
||||||
[Call](Player* sp, std::unordered_map<std::string, std::string> map) {
|
[Call](Player* sp, std::unordered_map<std::string, std::string> map) { return Call(sp, map); },
|
||||||
return Call(sp->getXuid(), map);
|
|
||||||
},
|
|
||||||
PluginName
|
PluginName
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
auto Call = RemoteCall::importAs<std::string(std::string const& arg)>(PluginName, FuncName);
|
auto Call = RemoteCall::importAs<std::string(Player * pl)>(PluginName, FuncName);
|
||||||
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
|
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
|
||||||
PAPIName,
|
PAPIName,
|
||||||
[Call](Player* sp) { return Call(sp->getXuid()); },
|
[Call](Player* sp) { return Call(sp); },
|
||||||
PluginName
|
PluginName
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
return true;
|
||||||
// logger.error("Function no find({}:{})", PluginName, FuncName);
|
|
||||||
return "Function no find";
|
|
||||||
}
|
}
|
||||||
return "Register Success";
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
bool registerServerPlaceholder(
|
||||||
registerServerPlaceholder(std::string const& PluginName, std::string const& FuncName, std::string const& PAPIName) {
|
std::string const& PluginName,
|
||||||
|
std::string const& FuncName,
|
||||||
|
std::string const& PAPIName
|
||||||
|
) {
|
||||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||||
|
GMLIB::Server::PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||||
if (isParameters(PAPIName)) {
|
if (isParameters(PAPIName)) {
|
||||||
auto Call =
|
auto Call =
|
||||||
RemoteCall::importAs<std::string(std::unordered_map<std::string, std::string>)>(PluginName, FuncName);
|
RemoteCall::importAs<std::string(std::unordered_map<std::string, std::string>)>(PluginName, FuncName);
|
||||||
@@ -63,26 +66,21 @@ registerServerPlaceholder(std::string const& PluginName, std::string const& Func
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
||||||
GMLIB::Server::PlaceholderAPI::registerServerPlaceholder(
|
GMLIB::Server::PlaceholderAPI::registerServerPlaceholder(PAPIName, [Call]() { return Call(); }, PluginName);
|
||||||
PAPIName,
|
|
||||||
[Call]() { return Call(); },
|
|
||||||
PluginName
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
return true;
|
||||||
// logger.error("Function no find({}:{})", PluginName, FuncName);
|
|
||||||
return "Function no find";
|
|
||||||
}
|
}
|
||||||
return "Register Success";
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string registerStaticPlaceholder(
|
bool registerStaticPlaceholder(
|
||||||
std::string const& PluginName,
|
std::string const& PluginName,
|
||||||
std::string const& FuncName,
|
std::string const& FuncName,
|
||||||
std::string const& PAPIName,
|
std::string const& PAPIName,
|
||||||
int num
|
int num
|
||||||
) {
|
) {
|
||||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||||
|
GMLIB::Server::PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||||
if (isParameters(PAPIName)) {
|
if (isParameters(PAPIName)) {
|
||||||
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
||||||
if (num == -1) {
|
if (num == -1) {
|
||||||
@@ -100,18 +98,18 @@ std::string registerStaticPlaceholder(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
return true;
|
||||||
// logger.error("Function no find({}:{})", PluginName, FuncName);
|
|
||||||
return "Function no find";
|
|
||||||
}
|
}
|
||||||
return "Register Success";
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string translateString(std::string const& str, std::string const& xuid) {
|
std::string translateStringWithPlayer(std::string const& str, Player* pl) {
|
||||||
return GMLIB::Server::PlaceholderAPI::translate(str, ll::service::bedrock::getLevel()->getPlayerByXuid(xuid));
|
return GMLIB::Server::PlaceholderAPI::translateString(str, pl);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool unRegisterPlaceholder(std::string const& str) { return GMLIB::Server::PlaceholderAPI::unRegisterPlaceholder(str); }
|
std::string translateString(std::string const& str) { return GMLIB::Server::PlaceholderAPI::translateString(str); }
|
||||||
|
|
||||||
|
bool unRegisterPlaceholder(std::string const& str) { return GMLIB::Server::PlaceholderAPI::unregisterPlaceholder(str); }
|
||||||
|
|
||||||
std::vector<std::string> getAllPAPI() { return GMLIB::Server::PlaceholderAPI::getAllPAPI(); }
|
std::vector<std::string> getAllPAPI() { return GMLIB::Server::PlaceholderAPI::getAllPAPI(); }
|
||||||
|
|
||||||
@@ -127,6 +125,7 @@ void ExportPAPI() {
|
|||||||
EXPORTAPI(PAPIRemoteCall::GetValue);
|
EXPORTAPI(PAPIRemoteCall::GetValue);
|
||||||
EXPORTAPI(PAPIRemoteCall::GetValueWithPlayer);
|
EXPORTAPI(PAPIRemoteCall::GetValueWithPlayer);
|
||||||
EXPORTAPI(PAPIRemoteCall::translateString);
|
EXPORTAPI(PAPIRemoteCall::translateString);
|
||||||
|
EXPORTAPI(PAPIRemoteCall::translateStringWithPlayer);
|
||||||
EXPORTAPI(PAPIRemoteCall::unRegisterPlaceholder);
|
EXPORTAPI(PAPIRemoteCall::unRegisterPlaceholder);
|
||||||
EXPORTAPI(PAPIRemoteCall::getAllPAPI);
|
EXPORTAPI(PAPIRemoteCall::getAllPAPI);
|
||||||
}
|
}
|
||||||
@@ -1,29 +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();
|
|
||||||
ExportPAPI();
|
|
||||||
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
|
|
||||||
+8
-7
@@ -1,21 +1,22 @@
|
|||||||
{
|
{
|
||||||
"format_version": 2,
|
"format_version": 2,
|
||||||
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
||||||
"version": "0.8.2",
|
"version": "0.13.4",
|
||||||
"info": {
|
"info": {
|
||||||
"name": "GMLIB-LegacyRemoteCallApi",
|
"name": "GMLIB-LegacyRemoteCallApi",
|
||||||
"description": "Legacy RemoteCall API for GMLIB",
|
"description": "Legacy RemoteCall API for GMLIB",
|
||||||
|
"source": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
||||||
"author": "GroupMountain",
|
"author": "GroupMountain",
|
||||||
"tags": [
|
"tags": [
|
||||||
"LeviLamina",
|
"levilamina",
|
||||||
"GMLIB",
|
"gmlib",
|
||||||
"GMLIB-LegacyRemoteCallApi",
|
"lse",
|
||||||
"Library"
|
"library"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.8.2/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
|
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.13.4/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"github.com/GroupMountain/GMLIB": ">=0.8.1"
|
"github.com/GroupMountain/GMLIB": ">=0.13.0"
|
||||||
},
|
},
|
||||||
"files": {
|
"files": {
|
||||||
"place": [
|
"place": [
|
||||||
|
|||||||
@@ -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 0.13.7")
|
||||||
|
|
||||||
-- 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