Compare commits
1 Commits
@@ -11,14 +11,12 @@ jobs:
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- uses: xmake-io/github-action-setup-xmake@v1
|
||||
with:
|
||||
xmake-version: 3.0.0
|
||||
|
||||
- run: |
|
||||
xmake repo -u
|
||||
|
||||
- run: |
|
||||
xmake f -a x64 -m release -p windows -y
|
||||
xmake f -a x64 -m release -p windows -v -y
|
||||
|
||||
- run: |
|
||||
xmake -w -y
|
||||
|
||||
@@ -11,14 +11,12 @@ jobs:
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- uses: xmake-io/github-action-setup-xmake@v1
|
||||
with:
|
||||
xmake-version: 3.0.0
|
||||
|
||||
- run: |
|
||||
xmake repo -u
|
||||
|
||||
- run: |
|
||||
xmake f -a x64 -m release -p windows -y
|
||||
xmake f -a x64 -m release -p windows -v -y
|
||||
|
||||
- run: |
|
||||
xmake -w -y
|
||||
|
||||
Vendored
+3
-3
@@ -12,7 +12,7 @@ export class PAPI {
|
||||
pluginsName: string,
|
||||
/** PAPI变量 */
|
||||
PAPIName: string
|
||||
): void;
|
||||
): boolean;
|
||||
|
||||
/** 注册一个服务器PAPI变量 */
|
||||
static registerServerPlaceholder(
|
||||
@@ -25,7 +25,7 @@ export class PAPI {
|
||||
pluginsName: string,
|
||||
/** PAPI变量 */
|
||||
PAPIName: string
|
||||
): void;
|
||||
): boolean;
|
||||
|
||||
/** 注册一个静态PAPI变量 */
|
||||
static registerStaticPlaceholder(
|
||||
@@ -37,7 +37,7 @@ export class PAPI {
|
||||
PAPIName: string,
|
||||
/** 更新时间 */
|
||||
UpdateInterval: number
|
||||
): void;
|
||||
): boolean;
|
||||
|
||||
/** 获取一个服务器变量的值 */
|
||||
static getValue(
|
||||
|
||||
+40
-15
@@ -1,22 +1,47 @@
|
||||
const PlaceholderAPI = {
|
||||
/** 获取一个服务器变量的值 @type {function(string):string} */
|
||||
getValueAPI: ll.imports("BEPlaceholderAPI", "GetValue"),
|
||||
getValueAPI: ll.import("BEPlaceholderAPI", "GetValue"),
|
||||
/** 获取一个玩家变量的值 @type {function(string,Player):string} */
|
||||
getValueByPlayerAPI: ll.imports("BEPlaceholderAPI", "GetValueWithPlayer"),
|
||||
getValueByPlayerAPI: ll.import("BEPlaceholderAPI", "GetValueWithPlayer"),
|
||||
/** 注册一个玩家变量 @type {function(string,string,string):boolean} */
|
||||
registerPlayerPlaceholderAPI: ll.imports("BEPlaceholderAPI", "registerPlayerPlaceholder"),
|
||||
registerPlayerPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerPlayerPlaceholder"),
|
||||
/** 注册一个服务器变量 @type {function(string,string,string):boolean} */
|
||||
registerServerPlaceholderAPI: ll.imports("BEPlaceholderAPI", "registerServerPlaceholder"),
|
||||
registerServerPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerServerPlaceholder"),
|
||||
/** 注册一个静态变量 @type {function(string,string,string,number):boolean} */
|
||||
registerStaticPlaceholderAPI: ll.imports("BEPlaceholderAPI", "registerStaticPlaceholder"),
|
||||
registerStaticPlaceholderAPI: ll.import("BEPlaceholderAPI", "registerStaticPlaceholder"),
|
||||
/** 翻译包含PAPI服务器变量的字符串 @type {function(string):string} */
|
||||
translateStringAPI: ll.imports("BEPlaceholderAPI", "translateString"),
|
||||
translateStringAPI: ll.import("BEPlaceholderAPI", "translateString"),
|
||||
/** 翻译包含PAPI玩家变量的字符串 @type {function(string,Player):string} */
|
||||
translateStringWithPlayerAPI: ll.imports("BEPlaceholderAPI", "translateStringWithPlayer"),
|
||||
translateStringWithPlayerAPI: ll.import("BEPlaceholderAPI", "translateStringWithPlayer"),
|
||||
/** 注销PAPI变量 @type {function(string):boolean} */
|
||||
unRegisterPlaceholderAPI: ll.imports("BEPlaceholderAPI", "unRegisterPlaceholder"),
|
||||
unRegisterPlaceholderAPI: ll.import("BEPlaceholderAPI", "unRegisterPlaceholder"),
|
||||
/** 获取所有已注册的PAPI变量 @type {function():Array.<string>} */
|
||||
getAllPAPI: ll.imports("BEPlaceholderAPI", "getAllPAPI")
|
||||
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变量类 */
|
||||
@@ -33,8 +58,8 @@ class PAPI {
|
||||
* @returns {boolean} 是否注册成功
|
||||
*/
|
||||
static registerPlayerPlaceholder(func, PluginName, PAPIName) {
|
||||
ll.export(func, PluginName, `Placeholder_${PAPIName}`);
|
||||
PlaceholderAPI.registerPlayerPlaceholderAPI(PluginName, `Placeholder_${PAPIName}`, PAPIName);
|
||||
ll.export(func, PluginName, func.getName());
|
||||
return PlaceholderAPI.registerPlayerPlaceholderAPI(PluginName, func.getName(), PAPIName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,8 +70,8 @@ class PAPI {
|
||||
* @returns {boolean} 是否注册成功
|
||||
*/
|
||||
static registerServerPlaceholder(func, PluginName, PAPIName) {
|
||||
ll.export(func, PluginName, `Placeholder_${PAPIName}`);
|
||||
PlaceholderAPI.registerServerPlaceholderAPI(PluginName, `Placeholder_${PAPIName}`, PAPIName);
|
||||
ll.export(func, PluginName, func.getName());
|
||||
return PlaceholderAPI.registerServerPlaceholderAPI(PluginName, func.getName(), PAPIName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,8 +83,8 @@ class PAPI {
|
||||
* @returns {boolean} 是否注册成功
|
||||
*/
|
||||
static registerStaticPlaceholder(func, PluginName, PAPIName, UpdateInterval = 50) {
|
||||
ll.export(func, PluginName, `Placeholder_${PAPIName}`);
|
||||
PlaceholderAPI.registerStaticPlaceholderAPI(PluginName, `Placeholder_${PAPIName}`, PAPIName, UpdateInterval);
|
||||
ll.export(func, PluginName, func.getName());
|
||||
return PlaceholderAPI.registerStaticPlaceholderAPI(PluginName, func.getName(), PAPIName, UpdateInterval);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+6
-48
@@ -1,54 +1,12 @@
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
const getPluginName = () => {
|
||||
if (getPluginName.PluginNameCache) return getPluginName.PluginNameCache;
|
||||
|
||||
return getPluginName.PluginNameCache = (() => {
|
||||
if (ll.getCurrentPluginInfo) return ll.getCurrentPluginInfo().name;
|
||||
|
||||
const error = new Error("getPluginName");
|
||||
switch (ll.scriptEngineVersion) {
|
||||
case "QuickJS": {
|
||||
if (!error.stack) break;
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes("<anonymous>")) {
|
||||
return line.slice(
|
||||
line.indexOf("(") + 1,
|
||||
line.indexOf("\\")
|
||||
);
|
||||
}
|
||||
if (line.includes("<eval>")) {
|
||||
return line.slice(
|
||||
line.indexOf("/", line.indexOf("/") + 1) + 1,
|
||||
line.indexOf("\\")
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "V8 12.4.254.21-node.21": {
|
||||
try {
|
||||
const selfFileName = require('path').basename(__filename);
|
||||
const pluginDirectory = Object.entries(
|
||||
require('module')._pathCache
|
||||
).find(
|
||||
([key, _]) => key.includes(selfFileName)
|
||||
)[0].split("\u0000")[1];
|
||||
const directories = pluginDirectory.split("\\");
|
||||
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||
if (pluginName) return pluginName;
|
||||
} catch { }
|
||||
|
||||
if (!error.stack) break;
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes(".js") && /:\d+:\d+$/.test(line)) {
|
||||
const directories = line.split("\\");
|
||||
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||
if (pluginName) return pluginName;
|
||||
throw new Error("getPluginName");
|
||||
} catch (error) {
|
||||
return error.stack.trim().match(/plugins\\(.*)\\.*\.js:[0-9]+\)$/i)?.[1] || "Unknown";
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
return "Unknown";
|
||||
})();
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
|
||||
+24
-24
@@ -1,4 +1,4 @@
|
||||
// // const getNextCallbackId = ll.imports("GMLIB_FormAPI", "getNextFormCallbackId");
|
||||
// // const getNextCallbackId = ll.import("GMLIB_FormAPI", "getNextFormCallbackId");
|
||||
|
||||
// class ServerSettingForm {
|
||||
// constructor() {
|
||||
@@ -6,35 +6,35 @@
|
||||
// }
|
||||
|
||||
// static getDefaultPriority() {
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "getDefaultPriority")();
|
||||
// return ll.import("GMLIB_ServerSettingForm", "getDefaultPriority")();
|
||||
// }
|
||||
|
||||
// static hasTitle() {
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "hasTitle")();
|
||||
// return ll.import("GMLIB_ServerSettingForm", "hasTitle")();
|
||||
// }
|
||||
|
||||
// static getTitle() {
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "getTitle")();
|
||||
// return ll.import("GMLIB_ServerSettingForm", "getTitle")();
|
||||
// }
|
||||
|
||||
// static setTitle(title, forceModify = false) {
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "setTitle")(title, forceModify);
|
||||
// return ll.import("GMLIB_ServerSettingForm", "setTitle")(title, forceModify);
|
||||
// }
|
||||
|
||||
// static hasIcon() {
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "hasIcon")();
|
||||
// return ll.import("GMLIB_ServerSettingForm", "hasIcon")();
|
||||
// }
|
||||
|
||||
// static getIconData() {
|
||||
// return hasIcon() ? ll.imports("GMLIB_ServerSettingForm", "getIconData")() : null;
|
||||
// return hasIcon() ? ll.import("GMLIB_ServerSettingForm", "getIconData")() : null;
|
||||
// }
|
||||
|
||||
// static getIconType() {
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "getIconType")();
|
||||
// return ll.import("GMLIB_ServerSettingForm", "getIconType")();
|
||||
// }
|
||||
|
||||
// static setIcon(data, type = 0, forceModify = false) {
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "setIcon")(data, type, forceModify);
|
||||
// return ll.import("GMLIB_ServerSettingForm", "setIcon")(data, type, forceModify);
|
||||
// }
|
||||
|
||||
// static addLabel(
|
||||
@@ -44,7 +44,7 @@
|
||||
// ) {
|
||||
// let detectorId = getNextCallbackId();
|
||||
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "addLabel")(text, detectorId, priority);
|
||||
// return ll.import("GMLIB_ServerSettingForm", "addLabel")(text, detectorId, priority);
|
||||
// }
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||
// let detectorId = getNextCallbackId();
|
||||
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "addInput")(text, placeholder, defaultVal, callbackId, detectorId, priority);
|
||||
// return ll.import("GMLIB_ServerSettingForm", "addInput")(text, placeholder, defaultVal, callbackId, detectorId, priority);
|
||||
// }
|
||||
|
||||
// static addToggle(
|
||||
@@ -74,7 +74,7 @@
|
||||
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||
// let detectorId = getNextCallbackId();
|
||||
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "addToggle")(text, defaultVal, callbackId, detectorId, priority);
|
||||
// return ll.import("GMLIB_ServerSettingForm", "addToggle")(text, defaultVal, callbackId, detectorId, priority);
|
||||
// }
|
||||
|
||||
// static addDropdown(
|
||||
@@ -89,7 +89,7 @@
|
||||
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||
// let detectorId = getNextCallbackId();
|
||||
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "addDropdown")(text, options, defaultVal, callbackId, detectorId, priority);
|
||||
// return ll.import("GMLIB_ServerSettingForm", "addDropdown")(text, options, defaultVal, callbackId, detectorId, priority);
|
||||
// }
|
||||
|
||||
// static addSlider(
|
||||
@@ -106,7 +106,7 @@
|
||||
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||
// let detectorId = getNextCallbackId();
|
||||
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "addSlider")(text, min, max, step, defaultVal, callbackId, detectorId, priority);
|
||||
// return ll.import("GMLIB_ServerSettingForm", "addSlider")(text, min, max, step, defaultVal, callbackId, detectorId, priority);
|
||||
// }
|
||||
|
||||
// static addStepSlider(
|
||||
@@ -121,57 +121,57 @@
|
||||
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||
// let detectorId = getNextCallbackId();
|
||||
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "addStepSlider")(text, steps, defaultVal, callbackId, detectorId, priority);
|
||||
// return ll.import("GMLIB_ServerSettingForm", "addStepSlider")(text, steps, defaultVal, callbackId, detectorId, priority);
|
||||
// }
|
||||
|
||||
// static removeElement(id) {
|
||||
// return ll.imports("GMLIB_ServerSettingForm", "removeElement")(id);
|
||||
// return ll.import("GMLIB_ServerSettingForm", "removeElement")(id);
|
||||
// }
|
||||
// }
|
||||
|
||||
// class NpcDialogueForm {
|
||||
// constructor(npcName, sceneName, dialogue) {
|
||||
// this.mFormId = ll.imports("GMLIB_NpcDialogueForm", "createForm")(npcName, sceneName, dialogue);
|
||||
// this.mFormId = ll.import("GMLIB_NpcDialogueForm", "createForm")(npcName, sceneName, dialogue);
|
||||
// }
|
||||
|
||||
// addButton(button) {
|
||||
// return ll.imports("GMLIB_NpcDialogueForm", "addButton")(this.mFormId, 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.imports("GMLIB_NpcDialogueForm", "sendTo")(this.mFormId, pl, callbackId);
|
||||
// ll.import("GMLIB_NpcDialogueForm", "sendTo")(this.mFormId, pl, callbackId);
|
||||
// if (free) {
|
||||
// this.destroy();
|
||||
// }
|
||||
// }
|
||||
|
||||
// destroy() {
|
||||
// ll.imports("GMLIB_NpcDialogueForm", "destroyForm")(this.mFormId);
|
||||
// ll.import("GMLIB_NpcDialogueForm", "destroyForm")(this.mFormId);
|
||||
// }
|
||||
// }
|
||||
|
||||
// class ChestForm {
|
||||
// constructor(npcName, sceneName, dialogue) {
|
||||
// this.mFormId = ll.imports("GMLIB_NpcDialogueForm", "createForm")(npcName, sceneName, dialogue);
|
||||
// this.mFormId = ll.import("GMLIB_NpcDialogueForm", "createForm")(npcName, sceneName, dialogue);
|
||||
// }
|
||||
|
||||
// addButton(button) {
|
||||
// return ll.imports("GMLIB_NpcDialogueForm", "addButton")(this.mFormId, 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.imports("GMLIB_NpcDialogueForm", "sendTo")(this.mFormId, pl, callbackId);
|
||||
// //ll.import("GMLIB_NpcDialogueForm", "sendTo")(this.mFormId, pl, callbackId);
|
||||
// //if (free) {
|
||||
// // this.destroy();
|
||||
// //}
|
||||
// }
|
||||
|
||||
// destroy() {
|
||||
// //ll.imports("GMLIB_NpcDialogueForm", "destroyForm")(this.mFormId);
|
||||
// //ll.import("GMLIB_NpcDialogueForm", "destroyForm")(this.mFormId);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
Vendored
+167
-199
@@ -183,34 +183,19 @@ export class Minecraft {
|
||||
pos: IntPos
|
||||
): void;
|
||||
|
||||
/**
|
||||
* @deprecated 已删
|
||||
* 启用教育版内容
|
||||
*/
|
||||
/** 启用教育版内容 */
|
||||
static setEducationFeatureEnabled(): void;
|
||||
|
||||
/**
|
||||
* @deprecated 已删
|
||||
* 注册Ability命令
|
||||
*/
|
||||
/** 注册Ability命令 */
|
||||
static registerAbilityCommand(): void;
|
||||
|
||||
/**
|
||||
* @deprecated 已删
|
||||
* 启用Xbox成就
|
||||
*/
|
||||
/** 启用Xbox成就 */
|
||||
static setEnableAchievement(): void;
|
||||
|
||||
/**
|
||||
* @deprecated 已删
|
||||
* 信任所有玩家皮肤
|
||||
*/
|
||||
/** 信任所有玩家皮肤 */
|
||||
static setForceTrustSkins(): void;
|
||||
|
||||
/**
|
||||
* @deprecated 已删
|
||||
* 启用资源包双端共存
|
||||
*/
|
||||
/** 启用资源包双端共存 */
|
||||
static enableCoResourcePack(): void;
|
||||
|
||||
/** 获取存档名称 */
|
||||
@@ -221,19 +206,13 @@ export class Minecraft {
|
||||
name: string
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
* @deprecated 已删
|
||||
* 设置假种子
|
||||
*/
|
||||
/** 设置假种子 */
|
||||
static setFakeSeed(
|
||||
/** 要设置的假种子 */
|
||||
seed: number | undefined
|
||||
): void;
|
||||
|
||||
/**
|
||||
* @deprecated 已删
|
||||
* 启用错误方块清理
|
||||
*/
|
||||
/** 启用错误方块清理 */
|
||||
static setUnknownBlockCleaner(): void;
|
||||
|
||||
/** 强制生成实体 */
|
||||
@@ -330,10 +309,7 @@ export class Minecraft {
|
||||
/** 移除所有虚假列表玩家 */
|
||||
static removeAllFakeLists(): boolean;
|
||||
|
||||
/**
|
||||
* @deprecated 已删
|
||||
* 启用I18n修复
|
||||
*/
|
||||
/** 启用I18n修复 */
|
||||
static setFixI18nEnabled(): void;
|
||||
|
||||
/** 保存NBT至文件 */
|
||||
@@ -383,7 +359,7 @@ export class Minecraft {
|
||||
): string;
|
||||
|
||||
/** 通过附魔ID获取附魔命名空间ID */
|
||||
static getEnchantTypeNameFromId(
|
||||
static getMaxPlayers(
|
||||
/** 附魔ID */
|
||||
id: number
|
||||
): string | null;
|
||||
@@ -391,14 +367,6 @@ export class Minecraft {
|
||||
/** 获取最大玩家数 */
|
||||
static getMaxPlayers(): number;
|
||||
|
||||
/** 设置最大玩家数 */
|
||||
static setMaxPlayers(
|
||||
/** 最大玩家数 */
|
||||
count: number,
|
||||
/** 是否忽略原版限制 */
|
||||
ignoreVanillaLimit?: boolean
|
||||
): void;
|
||||
|
||||
/** 玩家是否拥有NBT */
|
||||
static hasPlayerNbt(
|
||||
/** 玩家的uuid */
|
||||
@@ -1078,12 +1046,12 @@ export class UserCache {
|
||||
|
||||
/** 获取玩家信息 */
|
||||
static getPlayerInfo(
|
||||
/** 玩家名 或 xuid 或 uuid 或 serverId 或 uniqueId */
|
||||
/** 玩家名 或 xuid 或 uuid */
|
||||
playerIdentifier: string
|
||||
): { Xuid: string, Uuid: string, Name: string, ServerId: string, ActorUniqueID: string } | null;
|
||||
): { Xuid: String, Uuid: string, Name: string } | null;
|
||||
|
||||
/** 获取所有玩家信息 */
|
||||
static getAllPlayerInfo(): { Xuid: string, Uuid: string, Name: string, ServerId: string, ActorUniqueID: string }[]
|
||||
static getAllPlayerInfo(): { Xuid: String; Uuid: string; Name: string; }[]
|
||||
}
|
||||
|
||||
type PacketDataItem = (
|
||||
@@ -1381,158 +1349,161 @@ export class GMLIB_BinaryStream {
|
||||
|
||||
export enum ActorType {
|
||||
Undefined = 1,
|
||||
TypeMask = 255,
|
||||
Mob = 256,
|
||||
PathfinderMob = 768,
|
||||
Monster = 2816,
|
||||
Animal = 4864,
|
||||
TamableAnimal = 21248,
|
||||
Ambient = 33024,
|
||||
UndeadMob = 68352,
|
||||
ZombieMonster = 199424,
|
||||
Arthropod = 264960,
|
||||
Minecart = 524288,
|
||||
SkeletonMonster = 1116928,
|
||||
EquineAnimal = 2118400,
|
||||
Projectile = 4194304,
|
||||
AbstractArrow = 8388608,
|
||||
WaterAnimal = 8960,
|
||||
VillagerBase = 16777984,
|
||||
Chicken = 4874,
|
||||
Cow = 4875,
|
||||
Pig = 4876,
|
||||
Sheep = 4877,
|
||||
Wolf = 21262,
|
||||
Villager = 16777999,
|
||||
MushroomCow = 4880,
|
||||
Squid = 8977,
|
||||
Rabbit = 4882,
|
||||
Bat = 33043,
|
||||
IronGolem = 788,
|
||||
SnowGolem = 789,
|
||||
Ocelot = 21270,
|
||||
Horse = 2118423,
|
||||
PolarBear = 4892,
|
||||
Llama = 4893,
|
||||
Parrot = 21278,
|
||||
Dolphin = 8991,
|
||||
Donkey = 2118424,
|
||||
Mule = 2118425,
|
||||
SkeletonHorse = 2186010,
|
||||
ZombieHorse = 2186011,
|
||||
Zombie = 199456,
|
||||
Creeper = 2849,
|
||||
Skeleton = 1116962,
|
||||
Spider = 264995,
|
||||
PigZombie = 68388,
|
||||
Slime = 2853,
|
||||
EnderMan = 2854,
|
||||
Silverfish = 264999,
|
||||
CaveSpider = 265000,
|
||||
Ghast = 2857,
|
||||
LavaSlime = 2858,
|
||||
Blaze = 2859,
|
||||
ZombieVillager = 199468,
|
||||
Witch = 2861,
|
||||
Stray = 1116974,
|
||||
Husk = 199471,
|
||||
WitherSkeleton = 1116976,
|
||||
Guardian = 2865,
|
||||
ElderGuardian = 2866,
|
||||
Npc = 307,
|
||||
WitherBoss = 68404,
|
||||
Dragon = 2869,
|
||||
Shulker = 2870,
|
||||
Endermite = 265015,
|
||||
Agent = 312,
|
||||
Vindicator = 2873,
|
||||
Phantom = 68410,
|
||||
IllagerBeast = 2875,
|
||||
ArmorStand = 317,
|
||||
TripodCamera = 318,
|
||||
Player = 319,
|
||||
ItemEntity = 64,
|
||||
PrimedTnt = 65,
|
||||
FallingBlock = 66,
|
||||
MovingBlock = 67,
|
||||
ExperiencePotion = 4194372,
|
||||
Experience = 69,
|
||||
EyeOfEnder = 70,
|
||||
EnderCrystal = 71,
|
||||
FireworksRocket = 72,
|
||||
Trident = 12582985,
|
||||
Turtle = 4938,
|
||||
Cat = 21323,
|
||||
ShulkerBullet = 4194380,
|
||||
FishingHook = 77,
|
||||
Chalkboard = 78,
|
||||
DragonFireball = 4194383,
|
||||
Arrow = 12582992,
|
||||
Snowball = 4194385,
|
||||
ThrownEgg = 4194386,
|
||||
Painting = 83,
|
||||
LargeFireball = 4194389,
|
||||
ThrownPotion = 4194390,
|
||||
Enderpearl = 4194391,
|
||||
LeashKnot = 88,
|
||||
WitherSkull = 4194393,
|
||||
BoatRideable = 90,
|
||||
WitherSkullDangerous = 4194395,
|
||||
LightningBolt = 93,
|
||||
SmallFireball = 4194398,
|
||||
AreaEffectCloud = 95,
|
||||
LingeringPotion = 4194405,
|
||||
LlamaSpit = 4194406,
|
||||
EvocationFang = 4194407,
|
||||
EvocationIllager = 2920,
|
||||
Vex = 2921,
|
||||
MinecartRideable = 524372,
|
||||
MinecartHopper = 524384,
|
||||
MinecartTNT = 524385,
|
||||
MinecartChest = 524386,
|
||||
MinecartFurnace = 524387,
|
||||
MinecartCommandBlock = 524388,
|
||||
IceBomb = 4194410,
|
||||
Balloon = 107,
|
||||
Pufferfish = 9068,
|
||||
Salmon = 9069,
|
||||
Drowned = 199534,
|
||||
Tropicalfish = 9071,
|
||||
Fish = 9072,
|
||||
Panda = 4977,
|
||||
Pillager = 2930,
|
||||
VillagerV2 = 16778099,
|
||||
ZombieVillagerV2 = 199540,
|
||||
Shield = 117,
|
||||
WanderingTrader = 886,
|
||||
Lectern = 119,
|
||||
ElderGuardianGhost = 2936,
|
||||
Fox = 4985,
|
||||
Bee = 378,
|
||||
Piglin = 379,
|
||||
Hoglin = 4988,
|
||||
Strider = 4989,
|
||||
Zoglin = 68478,
|
||||
PiglinBrute = 383,
|
||||
Goat = 4992,
|
||||
GlowSquid = 9089,
|
||||
Axolotl = 4994,
|
||||
Warden = 2947,
|
||||
Frog = 4996,
|
||||
Tadpole = 9093,
|
||||
Allay = 390,
|
||||
ChestBoatRideable = 218,
|
||||
TraderLlama = 5021,
|
||||
Camel = 5002,
|
||||
Sniffer = 5003,
|
||||
Breeze = 2956,
|
||||
BreezeWindChargeProjectile = 4194445,
|
||||
Armadillo = 5006,
|
||||
WindChargeProjectile = 4194447,
|
||||
Bogged = 1117072,
|
||||
OminousItemSpawner = 145,
|
||||
Creaking = 2962,
|
||||
HappyGhast = 5011,
|
||||
TypeMask = 0b11111111,
|
||||
None = 0,
|
||||
Mob = 1 << 8,
|
||||
PathfinderMob = 1 << 9 | Mob,
|
||||
UnknownType = 1 << 10,
|
||||
Monster = 1 << 11 | PathfinderMob,
|
||||
Animal = 1 << 12 | PathfinderMob,
|
||||
WaterAnimal = 1 << 13 | PathfinderMob,
|
||||
TamableAnimal = 1 << 14 | Animal,
|
||||
Ambient = 1 << 15 | Mob,
|
||||
UndeadMob = 1 << 16 | Monster,
|
||||
ZombieMonster = 1 << 17 | UndeadMob,
|
||||
Arthropod = 1 << 18 | Monster,
|
||||
Minecart = 1 << 19,
|
||||
SkeletonMonster = 1 << 20 | UndeadMob,
|
||||
EquineAnimal = 1 << 21 | TamableAnimal,
|
||||
Projectile = 1 << 22,
|
||||
AbstractArrow = 1 << 23,
|
||||
VillagerBase = 1 << 24 | PathfinderMob,
|
||||
|
||||
Chicken = 10 | Animal,
|
||||
Cow = 11 | Animal,
|
||||
Pig = 12 | Animal,
|
||||
Sheep = 13 | Animal,
|
||||
Wolf = 14 | TamableAnimal,
|
||||
Villager = 15 | VillagerBase,
|
||||
MushroomCow = 16 | Animal,
|
||||
Squid = 17 | WaterAnimal,
|
||||
Rabbit = 18 | Animal,
|
||||
Bat = 19 | Ambient,
|
||||
IronGolem = 20 | PathfinderMob,
|
||||
SnowGolem = 21 | PathfinderMob,
|
||||
Ocelot = 22 | TamableAnimal,
|
||||
Horse = 23 | EquineAnimal,
|
||||
Donkey = 24 | EquineAnimal,
|
||||
Mule = 25 | EquineAnimal,
|
||||
SkeletonHorse = 26 | EquineAnimal | UndeadMob,
|
||||
ZombieHorse = 27 | EquineAnimal | UndeadMob,
|
||||
PolarBear = 28 | Animal,
|
||||
Llama = 29 | Animal,
|
||||
Parrot = 30 | TamableAnimal,
|
||||
Dolphin = 31 | WaterAnimal,
|
||||
Zombie = 32 | ZombieMonster,
|
||||
Creeper = 33 | Monster,
|
||||
Skeleton = 34 | SkeletonMonster,
|
||||
Spider = 35 | Arthropod,
|
||||
PigZombie = 36 | UndeadMob,
|
||||
Slime = 37 | Monster,
|
||||
EnderMan = 38 | Monster,
|
||||
Silverfish = 39 | Arthropod,
|
||||
CaveSpider = 40 | Arthropod,
|
||||
Ghast = 41 | Monster,
|
||||
LavaSlime = 42 | Monster,
|
||||
Blaze = 43 | Monster,
|
||||
ZombieVillager = 44 | ZombieMonster,
|
||||
Witch = 45 | Monster,
|
||||
Stray = 46 | SkeletonMonster,
|
||||
Husk = 47 | ZombieMonster,
|
||||
WitherSkeleton = 48 | SkeletonMonster,
|
||||
Guardian = 49 | Monster,
|
||||
ElderGuardian = 50 | Monster,
|
||||
Npc = 51 | Mob,
|
||||
WitherBoss = 52 | UndeadMob,
|
||||
Dragon = 53 | Monster,
|
||||
Shulker = 54 | Monster,
|
||||
Endermite = 55 | Arthropod,
|
||||
Agent = 56 | Mob,
|
||||
Vindicator = 57 | Monster,
|
||||
Phantom = 58 | UndeadMob,
|
||||
IllagerBeast = 59 | Monster,
|
||||
UNUSED60 = 60,
|
||||
ArmorStand = 61 | Mob,
|
||||
TripodCamera = 62 | Mob,
|
||||
Player = 63 | Mob,
|
||||
ItemEntity = 64 | None,
|
||||
PrimedTnt = 65 | None,
|
||||
FallingBlock = 66 | None,
|
||||
MovingBlock = 67 | None,
|
||||
ExperiencePotion = 68 | Projectile,
|
||||
Experience = 69 | None,
|
||||
EyeOfEnder = 70 | None,
|
||||
EnderCrystal = 71 | None,
|
||||
FireworksRocket = 72 | None,
|
||||
Trident = 73 | Projectile | AbstractArrow,
|
||||
Turtle = 74 | Animal,
|
||||
Cat = 75 | TamableAnimal,
|
||||
ShulkerBullet = 76 | Projectile,
|
||||
FishingHook = 77 | None,
|
||||
Chalkboard = 78 | None,
|
||||
DragonFireball = 79 | Projectile,
|
||||
Arrow = 80 | Projectile | AbstractArrow,
|
||||
Snowball = 81 | Projectile,
|
||||
ThrownEgg = 82 | Projectile,
|
||||
Painting = 83 | None,
|
||||
MinecartRideable = 84 | Minecart,
|
||||
LargeFireball = 85 | Projectile,
|
||||
ThrownPotion = 86 | Projectile,
|
||||
Enderpearl = 87 | Projectile,
|
||||
LeashKnot = 88 | None,
|
||||
WitherSkull = 89 | Projectile,
|
||||
BoatRideable = 90 | None,
|
||||
WitherSkullDangerous = 91 | Projectile,
|
||||
UNUSED92 = 92,
|
||||
LightningBolt = 93 | None,
|
||||
SmallFireball = 94 | Projectile,
|
||||
AreaEffectCloud = 95 | None,
|
||||
MinecartHopper = 96 | Minecart,
|
||||
MinecartTNT = 97 | Minecart,
|
||||
MinecartChest = 98 | Minecart,
|
||||
MinecartFurnace = 99 | Minecart,
|
||||
MinecartCommandBlock = 100 | Minecart,
|
||||
LingeringPotion = 101 | Projectile,
|
||||
LlamaSpit = 102 | Projectile,
|
||||
EvocationFang = 103 | Projectile,
|
||||
EvocationIllager = 104 | Monster,
|
||||
Vex = 105 | Monster,
|
||||
IceBomb = 106 | Projectile,
|
||||
Balloon = 107 | None,
|
||||
Pufferfish = 108 | WaterAnimal,
|
||||
Salmon = 109 | WaterAnimal,
|
||||
Drowned = 110 | ZombieMonster,
|
||||
Tropicalfish = 111 | WaterAnimal,
|
||||
Fish = 112 | WaterAnimal,
|
||||
Panda = 113 | Animal,
|
||||
Pillager = 114 | Monster,
|
||||
VillagerV2 = 115 | VillagerBase,
|
||||
ZombieVillagerV2 = 116 | ZombieMonster,
|
||||
Shield = 117 | None,
|
||||
WanderingTrader = 118 | PathfinderMob,
|
||||
Lectern = 119 | None,
|
||||
ElderGuardianGhost = 120 | Monster,
|
||||
Fox = 121 | Animal,
|
||||
Bee = 122 | Mob,
|
||||
Piglin = 123 | Mob,
|
||||
Hoglin = 124 | Animal,
|
||||
Strider = 125 | Animal,
|
||||
Zoglin = 126 | UndeadMob,
|
||||
PiglinBrute = 127 | Mob,
|
||||
Goat = 128 | Animal,
|
||||
GlowSquid = 129 | WaterAnimal,
|
||||
Axolotl = 130 | Animal,
|
||||
Warden = 131 | Monster,
|
||||
Frog = 132 | Animal,
|
||||
Tadpole = 133 | WaterAnimal,
|
||||
Allay = 134 | Mob,
|
||||
ChestBoatRideable = 136 | BoatRideable,
|
||||
TraderLlama = 137 | Llama,
|
||||
Camel = 138 | Animal,
|
||||
Sniffer = 139 | Animal,
|
||||
Breeze = 140 | Monster,
|
||||
BreezeWindChargeProjectile = 141 | Projectile,
|
||||
Armadillo = 142 | Animal,
|
||||
WindChargeProjectile = 143 | Projectile,
|
||||
Bogged = 144 | SkeletonMonster,
|
||||
OminousItemSpawner = 145
|
||||
}
|
||||
|
||||
interface Player {
|
||||
@@ -1585,9 +1556,6 @@ interface Player {
|
||||
slot: number
|
||||
): Item;
|
||||
|
||||
/** (GMLIB & Glacie)获取客户端版本协议*/
|
||||
getNetworkProtocolVersion(): number
|
||||
|
||||
/** (GMLIB)发送更新更新物品数据包 */
|
||||
sendInventorySlotPacket(
|
||||
/** 容器ID */
|
||||
|
||||
+384
-406
File diff suppressed because it is too large
Load Diff
Vendored
-42
@@ -1,42 +0,0 @@
|
||||
/** 翻译带PAPI变量文本 */
|
||||
export function translate(
|
||||
/** 要翻译的文本 */
|
||||
value: String,
|
||||
/** 实体对象 */
|
||||
actor?: Entity,
|
||||
/** 目标翻译语言 */
|
||||
language?: String
|
||||
): String;
|
||||
|
||||
/** 注册PAPI变量 */
|
||||
export function registerPlaceholder(
|
||||
/** papi变量 */
|
||||
placeholder: String,
|
||||
/** 回调 */
|
||||
callback: (
|
||||
/** 实体对象 */ actor: Entity,
|
||||
/** 参数 */ params: String[],
|
||||
/** 目标翻译语言 */language: String
|
||||
) => String | undefined
|
||||
): void;
|
||||
|
||||
/** 注销PAPI变量 */
|
||||
export function unregisterPlaceholder(
|
||||
/** papi变量 */
|
||||
placeholder: String
|
||||
): Boolean;
|
||||
|
||||
/** 根据模组名注销PAPI变量 */
|
||||
export function unregisterPlaceholderFromModName(
|
||||
/** 模组名 */
|
||||
modName: String
|
||||
): Boolean;
|
||||
|
||||
/** 获取一个papi变量的值 */
|
||||
export function getValue(
|
||||
/** papi变量名 */
|
||||
placeholder: String,
|
||||
actor?: Entity,
|
||||
params?: Record<String, String>,
|
||||
language?: string
|
||||
): Boolean;
|
||||
@@ -1,83 +0,0 @@
|
||||
/// <reference path='d:/dts/dts/helperlib/src/index.d.ts'/>
|
||||
|
||||
const getPluginName = () => {
|
||||
if (getPluginName.PluginNameCache) return getPluginName.PluginNameCache;
|
||||
|
||||
return getPluginName.PluginNameCache = (() => {
|
||||
if (ll.getCurrentPluginInfo) return ll.getCurrentPluginInfo().name;
|
||||
|
||||
const error = new Error("getPluginName");
|
||||
switch (ll.scriptEngineVersion) {
|
||||
case "QuickJS": {
|
||||
if (!error.stack) break;
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes("<anonymous>")) {
|
||||
return line.slice(
|
||||
line.indexOf("(") + 1,
|
||||
line.indexOf("\\")
|
||||
);
|
||||
}
|
||||
if (line.includes("<eval>")) {
|
||||
return line.slice(
|
||||
line.indexOf("/", line.indexOf("/") + 1) + 1,
|
||||
line.indexOf("\\")
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "V8 12.4.254.21-node.21": {
|
||||
try {
|
||||
const selfFileName = require('path').basename(__filename);
|
||||
const pluginDirectory = Object.entries(
|
||||
require('module')._pathCache
|
||||
).find(
|
||||
([key, _]) => key.includes(selfFileName)
|
||||
)[0].split("\u0000")[1];
|
||||
const directories = pluginDirectory.split("\\");
|
||||
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||
if (pluginName) return pluginName;
|
||||
} catch { }
|
||||
|
||||
if (!error.stack) break;
|
||||
const /** @type {string} */ line = error.stack.trim().split("\n").pop().trim();
|
||||
if (line.includes(".js") && /:\d+:\d+$/.test(line)) {
|
||||
const directories = line.split("\\");
|
||||
const pluginName = directories[directories.findIndex(value => value === "plugins") + 1].trim();
|
||||
if (pluginName) return pluginName;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
return "Unknown";
|
||||
})();
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
translate(value, actor = undefined, language = "") {
|
||||
return actor instanceof LLSE_Entity
|
||||
? ll.imports("PlaceholderAPI", "translateFromActor")(value, actor, language)
|
||||
: ll.imports("PlaceholderAPI", "translate")(value, language);
|
||||
},
|
||||
registerPlaceholder(placeholder, callback) {
|
||||
const pluginName = getPluginName();
|
||||
ll.exports((...args) => {
|
||||
if(!args[0].uniqueId) args[0] = undefined;
|
||||
return callback(...args) ?? "<std::nullopt>";
|
||||
}, pluginName, `Placeholder_${placeholder}`);
|
||||
ll.imports("PlaceholderAPI", "registerPlaceholder")(placeholder, `Placeholder_${placeholder}`, pluginName);
|
||||
},
|
||||
unregisterPlaceholder(placeholder) {
|
||||
return ll.imports("PlaceholderAPI", "unregisterPlaceholder")(placeholder);
|
||||
},
|
||||
unregisterPlaceholderFromModName(placeholder) {
|
||||
return ll.imports("PlaceholderAPI", "unregisterPlaceholderFromModName")(placeholder);
|
||||
},
|
||||
getValue(placeholder, actor = undefined, params = {}, language = "") {
|
||||
if (actor instanceof LLSE_Player) actor = ll.imports("GMLib_ServerAPI", "PlayerToEntity")(actor);
|
||||
const result = actor instanceof LLSE_Entity
|
||||
? ll.imports("PlaceholderAPI", "getValueFromActor")(placeholder, actor, params, language)
|
||||
: ll.imports("PlaceholderAPI", "getValue")(placeholder, params, language);
|
||||
return result !== "<std::nullopt>" ? result : undefined;
|
||||
}
|
||||
};
|
||||
+3
-9
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "${modName}",
|
||||
"entry": "${modFile}",
|
||||
"version": "${modVersion}",
|
||||
"name": "${pluginName}",
|
||||
"entry": "${pluginFile}",
|
||||
"version": "0.13.6",
|
||||
"author": "GroupMountain",
|
||||
"type": "native",
|
||||
"passive": true,
|
||||
@@ -11,12 +11,6 @@
|
||||
},
|
||||
{
|
||||
"name": "LegacyRemoteCall"
|
||||
},
|
||||
{
|
||||
"name": "iListenAttentively"
|
||||
},
|
||||
{
|
||||
"name": "ModAPI"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
function beautify_json(value, indent)
|
||||
import("core.base.json")
|
||||
local json_text = ""
|
||||
local stack = {}
|
||||
|
||||
local function escape_str(s)
|
||||
return string.gsub(s, '[%c\\"]', function(c)
|
||||
local replacements = {['\b'] = '\\b', ['\f'] = '\\f', ['\n'] = '\\n', ['\r'] = '\\r', ['\t'] = '\\t', ['"'] = '\\"', ['\\'] = '\\\\'}
|
||||
return replacements[c] or string.format('\\u%04x', c:byte())
|
||||
end)
|
||||
end
|
||||
|
||||
local function is_null(v)
|
||||
return v == json.null
|
||||
end
|
||||
|
||||
local function is_empty_table(t)
|
||||
if type(t) ~= 'table' then return false end
|
||||
for _ in pairs(t) do
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
local function is_array(t)
|
||||
return type(t) == 'table' and json.is_marked_as_array(t) or #t > 0
|
||||
end
|
||||
|
||||
local function serialize(val, level)
|
||||
local spaces = string.rep(" ", level * indent)
|
||||
|
||||
if type(val) == "table" and not stack[val] then
|
||||
if is_empty_table(val) then
|
||||
json_text = json_text .. (is_array(val) and "[]" or "{}")
|
||||
return
|
||||
end
|
||||
|
||||
stack[val] = true
|
||||
local isArray = is_array(val)
|
||||
json_text = json_text .. (isArray and "[\n" or "{\n")
|
||||
|
||||
local keys = isArray and {} or {}
|
||||
for k in pairs(val) do
|
||||
table.insert(keys, k)
|
||||
end
|
||||
if not isArray then
|
||||
table.sort(keys)
|
||||
end
|
||||
|
||||
for _, k in ipairs(keys) do
|
||||
local v = val[k]
|
||||
json_text = json_text .. spaces .. (isArray and "" or '"' .. escape_str(tostring(k)) .. '": ')
|
||||
serialize(v, level + 1)
|
||||
json_text = json_text .. ",\n"
|
||||
end
|
||||
|
||||
json_text = string.sub(json_text, 1, -3) .. "\n" .. string.rep(" ", (level - 1) * indent) .. (isArray and "]" or "}")
|
||||
stack[val] = nil
|
||||
elseif type(val) == "string" then
|
||||
json_text = json_text .. '"' .. escape_str(val) .. '"'
|
||||
elseif type(val) == "number" then
|
||||
if val % 1 == 0 then
|
||||
json_text = json_text .. tostring(math.floor(val))
|
||||
else
|
||||
json_text = json_text .. tostring(val)
|
||||
end
|
||||
elseif type(val) == "boolean" then
|
||||
json_text = json_text .. tostring(val)
|
||||
elseif is_null(val) then
|
||||
json_text = json_text .. "null"
|
||||
else
|
||||
error("Invalid value type: " .. type(val))
|
||||
end
|
||||
end
|
||||
serialize(value, 1)
|
||||
return json_text
|
||||
end
|
||||
|
||||
function string_formatter(str, variables)
|
||||
return str:gsub("%${(.-)}", function(var)
|
||||
return variables[var] or "${" .. var .. "}"
|
||||
end)
|
||||
end
|
||||
|
||||
function pack_plugin(target,plugin_define)
|
||||
import("lib.detect.find_file")
|
||||
|
||||
local manifest_path = find_file("manifest.json", os.projectdir())
|
||||
if manifest_path then
|
||||
local manifest = io.readfile(manifest_path)
|
||||
local bindir = path.join(os.projectdir(), "bin/DLL")
|
||||
local pdbdir = path.join(os.projectdir(), "bin/PDB")
|
||||
local outputdir = path.join(bindir, plugin_define.pluginName)
|
||||
local targetfile = path.join(outputdir, plugin_define.pluginFile)
|
||||
local pdbfile = path.join(pdbdir, path.basename(plugin_define.pluginFile) .. ".pdb")
|
||||
local libfile = path.join(os.projectdir(), "lib")
|
||||
local manifestfile = path.join(outputdir, "manifest.json")
|
||||
local oritargetfile = target:targetfile()
|
||||
local oripdbfile = path.join(path.directory(oritargetfile), path.basename(oritargetfile) .. ".pdb")
|
||||
|
||||
os.mkdir(outputdir)
|
||||
os.cp(oritargetfile, targetfile)
|
||||
if os.isfile(oripdbfile) then
|
||||
os.cp(oripdbfile, pdbfile)
|
||||
end
|
||||
os.cp(libfile, outputdir)
|
||||
|
||||
formattedmanifest = string_formatter(manifest, plugin_define)
|
||||
io.writefile(manifestfile,formattedmanifest)
|
||||
cprint("${bright green}[Plugin Packer]: ${reset}plugin already generated to " .. outputdir)
|
||||
else
|
||||
cprint("${bright yellow}warn: ${reset}not found manifest.json in root dir!")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return {
|
||||
pack_plugin = pack_plugin,
|
||||
beautify_json = beautify_json,
|
||||
string_formatter = string_formatter
|
||||
}
|
||||
+10
-15
@@ -1,19 +1,20 @@
|
||||
#include "Global.h"
|
||||
using namespace ll::hash_utils;
|
||||
|
||||
class LegacyScriptBinaryStreamManager {
|
||||
private:
|
||||
int64 mNextBinaryStreamId = 0;
|
||||
std::unordered_map<uint64, std::shared_ptr<GMBinaryStream>> mBinaryStream;
|
||||
std::unordered_map<uint64, std::shared_ptr<GMLIB_BinaryStream>> mBinaryStream;
|
||||
|
||||
public:
|
||||
uint getNextId() { return mNextBinaryStreamId++; }
|
||||
|
||||
void cretateBinaryStream(uint id) { mBinaryStream[id] = std::make_shared<GMBinaryStream>(); }
|
||||
void cretateBinaryStream(uint id) { mBinaryStream[id] = std::make_shared<GMLIB_BinaryStream>(); }
|
||||
|
||||
uint64 copyBinaryStream(uint id) {
|
||||
auto nextId = getNextId();
|
||||
cretateBinaryStream(nextId);
|
||||
if (auto bs = getBinaryStream(nextId); bs != nullptr) {
|
||||
if(auto bs = getBinaryStream(nextId); bs !=nullptr){
|
||||
getBinaryStream(nextId)->mBuffer = getBinaryStream(id)->mBuffer;
|
||||
}
|
||||
return nextId;
|
||||
@@ -21,7 +22,7 @@ public:
|
||||
|
||||
void removeBinaryStream(uint64 id) { mBinaryStream.erase(id); }
|
||||
|
||||
std::shared_ptr<GMBinaryStream> getBinaryStream(uint64 id) {
|
||||
std::shared_ptr<GMLIB_BinaryStream> getBinaryStream(uint64 id) {
|
||||
return mBinaryStream.contains(id) ? mBinaryStream.at(id) : nullptr;
|
||||
}
|
||||
|
||||
@@ -46,7 +47,7 @@ template <typename T, typename R, typename A, typename... AS>
|
||||
struct Info<R (T::*)(A, AS...)> {
|
||||
using ArgT = A;
|
||||
};
|
||||
#define EXPORTAPI2(T) EXPORTAPI(#T, Info<decltype(&BinaryStream::T)>::ArgT, bs->T(value))
|
||||
#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 {
|
||||
@@ -59,26 +60,19 @@ void Export_BinaryStream_API() {
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_BinaryStream_API", "reset", [](uint64 id) -> void {
|
||||
if (BinaryStreamManager.getBinaryStream(id) == nullptr) BinaryStreamManager.cretateBinaryStream(id);
|
||||
else {
|
||||
auto bs = BinaryStreamManager.getBinaryStream(id);
|
||||
bs->mBuffer.clear();
|
||||
bs->mReadPointer = 0;
|
||||
bs->mHasOverflowed = false;
|
||||
}
|
||||
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(static_cast<GMPlayer&>(*player));
|
||||
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->writeNetworkItemStackDescriptor(NetworkItemStackDescriptor(*value)));
|
||||
EXPORTAPI("writeItem", ItemStack*, bs->writeType(NetworkItemStackDescriptor(*value)));
|
||||
EXPORTAPI("writeString", std::string const&, bs->writeString(value));
|
||||
EXPORTAPI("writeCompoundTag", CompoundTag*, bs->writeCompoundTag(*value));
|
||||
EXPORTAPI("writeUnsignedChar", uchar, bs->writeUnsignedChar(value));
|
||||
EXPORTAPI2(writeBool);
|
||||
EXPORTAPI2(writeByte);
|
||||
EXPORTAPI2(writeDouble);
|
||||
@@ -87,6 +81,7 @@ void Export_BinaryStream_API() {
|
||||
EXPORTAPI2(writeSignedInt);
|
||||
EXPORTAPI2(writeSignedInt64);
|
||||
EXPORTAPI2(writeSignedShort);
|
||||
EXPORTAPI2(writeUnsignedChar);
|
||||
EXPORTAPI2(writeUnsignedInt);
|
||||
EXPORTAPI2(writeUnsignedInt64);
|
||||
EXPORTAPI2(writeUnsignedShort);
|
||||
|
||||
+247
-381
File diff suppressed because it is too large
Load Diff
+2
-10
@@ -9,7 +9,6 @@ LegacyRemoteCallApi& LegacyRemoteCallApi::getInstance() {
|
||||
}
|
||||
|
||||
bool LegacyRemoteCallApi::load() {
|
||||
(void)CustomRecipeRegistry::getInstance();
|
||||
Export_Legacy_GMLib_ModAPI();
|
||||
Export_Legacy_GMLib_ServerAPI();
|
||||
Export_Compatibility_API();
|
||||
@@ -21,8 +20,8 @@ bool LegacyRemoteCallApi::load() {
|
||||
logger->info("GMLIB-LegacyRemoteCallApi Loaded!");
|
||||
logger->info(
|
||||
"Loaded Version: {} with {}",
|
||||
fmt::format(fg(fmt::color::pink), "GMLIB-" GMLIB_FILE_VERSION_STRING),
|
||||
fmt::format(fg(fmt::color::light_green), "GMLIB-LegacyRemoteCallApi-{}", LIB_VERSION.to_string())
|
||||
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");
|
||||
@@ -36,10 +35,3 @@ bool LegacyRemoteCallApi::disable() { return true; }
|
||||
} // namespace gmlib
|
||||
|
||||
LL_REGISTER_MOD(gmlib::LegacyRemoteCallApi, gmlib::LegacyRemoteCallApi::getInstance());
|
||||
|
||||
|
||||
ll::thread::ThreadPoolExecutor const& getThreadPoolExecutor() {
|
||||
return gmlib::LegacyRemoteCallApi::getInstance().getThreadPoolExecutor();
|
||||
}
|
||||
|
||||
ll::io::Logger& getLogger() { return gmlib::LegacyRemoteCallApi::getInstance().getSelf().getLogger(); }
|
||||
+1
-5
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
#include <ll/api/mod/NativeMod.h>
|
||||
#include <ll/api/mod/RegisterHelper.h>
|
||||
#include <ll/api/thread/ThreadPoolExecutor.h>
|
||||
|
||||
namespace gmlib {
|
||||
|
||||
@@ -10,7 +9,7 @@ class LegacyRemoteCallApi {
|
||||
public:
|
||||
static LegacyRemoteCallApi& getInstance();
|
||||
|
||||
LegacyRemoteCallApi() : mSelf(*ll::mod::NativeMod::current()), mThreadPoolExecutor(getSelf().getName()) {}
|
||||
LegacyRemoteCallApi() : mSelf(*ll::mod::NativeMod::current()) {}
|
||||
|
||||
[[nodiscard]] ll::mod::NativeMod& getSelf() const { return mSelf; }
|
||||
|
||||
@@ -27,11 +26,8 @@ public:
|
||||
// /// @return True if the plugin is unloaded successfully.
|
||||
// bool unload();
|
||||
|
||||
ll::thread::ThreadPoolExecutor& getThreadPoolExecutor() { return mThreadPoolExecutor; }
|
||||
|
||||
private:
|
||||
ll::mod::NativeMod& mSelf;
|
||||
ll::thread::ThreadPoolExecutor mThreadPoolExecutor;
|
||||
};
|
||||
|
||||
} // namespace gmlib
|
||||
|
||||
+116
-76
@@ -1,4 +1,6 @@
|
||||
#include "Global.h"
|
||||
#include "ll/api/service/Bedrock.h"
|
||||
#include "ll/api/utils/ErrorUtils.h"
|
||||
using namespace ll::hash_utils;
|
||||
|
||||
class EventManager {
|
||||
@@ -26,6 +28,7 @@ public:
|
||||
|
||||
bool removeListener(ullong id) {
|
||||
if (ll::event::EventBus::getInstance().removeListener(mEventIds[id])) {
|
||||
ll::mod::NativeMod::current()->getLogger().warn("Removed listener with id {}", id);
|
||||
mEventIds[id] = nullptr;
|
||||
return true;
|
||||
}
|
||||
@@ -83,177 +86,208 @@ void Export_Event_API() {
|
||||
}
|
||||
case doHash("gmlib::ClientLoginAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::ClientLoginAfterEvent,
|
||||
GMLIB::Event::PacketEvent::ClientLoginAfterEvent,
|
||||
(std::string const& realName,
|
||||
std::string const& uuid,
|
||||
std::string const& serverXuid,
|
||||
std::string const& clientXuid),
|
||||
(event.realName(), event.uuid().asString(), event.serverAuthXuid(), event.clientAuthXuid()),
|
||||
(event.getRealName(),
|
||||
event.getUuid().asString(),
|
||||
event.getServerAuthXuid(),
|
||||
event.getClientAuthXuid()),
|
||||
if (result) event.disConnectClient();
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::WeatherUpdateBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::WeatherUpdateBeforeEvent,
|
||||
GMLIB::Event::LevelEvent::WeatherUpdateBeforeEvent,
|
||||
(float rainLevel, int rainTime, float lightningLevel, int lightningTime, bool isCancelled),
|
||||
(event.rainLevel(),
|
||||
event.rainTime(),
|
||||
event.lightningLevel(),
|
||||
event.lightningTime(),
|
||||
(event.getRainLevel(),
|
||||
event.getRainingLastTick(),
|
||||
event.getLightningLevel(),
|
||||
event.getLightningLastTick(),
|
||||
event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::WeatherUpdateAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::WeatherUpdateAfterEvent,
|
||||
GMLIB::Event::LevelEvent::WeatherUpdateAfterEvent,
|
||||
(float rainLevel, int rainTime, float lightningLevel, int lightningTime),
|
||||
(event.rainLevel(), event.rainTime(), event.lightningLevel(), event.lightningTime()),
|
||||
(event.getRainLevel(),
|
||||
event.getRainingLastTick(),
|
||||
event.getLightningLevel(),
|
||||
event.getLightningLastTick()),
|
||||
,
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::MobPickupItemBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(ila::mc::ActorPickupItemBeforeEvent,
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::MobPickupItemBeforeEvent,
|
||||
(Actor * mob, Actor * item, bool isCancelled),
|
||||
(&event.self(), (Actor*)&event.itemActor(), event.isCancelled()),
|
||||
event.setCancelled(result););
|
||||
(&event.self(), (Actor*)&event.getItemActor(), event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::MobPickupItemAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::ActorPickupItemAfterEvent,
|
||||
GMLIB::Event::EntityEvent::MobPickupItemAfterEvent,
|
||||
(Actor * mob, Actor * item),
|
||||
(&event.self(), (Actor*)&event.itemActor()),
|
||||
(&event.self(), (Actor*)&event.getItemActor()),
|
||||
,
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::ItemActorSpawnBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::SpawnItemActorBeforeEvent,
|
||||
GMLIB::Event::EntityEvent::ItemActorSpawnBeforeEvent,
|
||||
(ItemStack * item, std::pair<Vec3, int> position, int64 spawnerUniqueId, bool isCancelled),
|
||||
(&event.item(),
|
||||
{event.pos(), event.blockSource().getDimensionId().id},
|
||||
event.spawner() ? event.spawner()->getOrCreateUniqueID().rawID : -1,
|
||||
(&event.getItem(),
|
||||
{event.getPosition(), event.getBlockSource().getDimensionId().id},
|
||||
event.getSpawner().has_value() ? event.getSpawner()->getOrCreateUniqueID().rawID : -1,
|
||||
event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::ItemActorSpawnAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::SpawnItemActorAfterEvent,
|
||||
GMLIB::Event::EntityEvent::ItemActorSpawnAfterEvent,
|
||||
(Actor * item, std::pair<Vec3, int> position, int64 spawnerUniqueId),
|
||||
(&event.itemActor(),
|
||||
{event.pos(), event.blockSource().getDimensionId().id},
|
||||
event.spawner() ? event.spawner()->getOrCreateUniqueID().rawID : -1),
|
||||
(&event.self(),
|
||||
{event.getPosition(), event.getBlockSource().getDimensionId().id},
|
||||
event.getSpawner().has_value() ? event.getSpawner()->getOrCreateUniqueID().rawID : -1),
|
||||
,
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::ActorChangeDimensionBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(ila::mc::ActorChangeDimensionBeforeEvent,
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::ActorChangeDimensionBeforeEvent,
|
||||
(Actor * entity, int toDimId, bool isCancelled),
|
||||
(&event.self(), event.toDimensionId(), event.isCancelled()),
|
||||
event.setCancelled(result););
|
||||
(&event.self(), event.getToDimensionId(), event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::ActorChangeDimensionAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::ActorChangeDimensionAfterEvent,
|
||||
GMLIB::Event::EntityEvent::ActorChangeDimensionAfterEvent,
|
||||
(Actor * entity, int fromDimId, int toDimId),
|
||||
(&event.self(), event.fromDimensionId(), event.toDimensionId()),
|
||||
(&event.self(), event.getFromDimensionId(), event.getToDimensionId()),
|
||||
,
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::PlayerStartSleepBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(ila::mc::PlayerStartSleepBeforeEvent,
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::PlayerEvent::PlayerStartSleepBeforeEvent,
|
||||
(Player * entity, BlockPos pos, bool isCancelled),
|
||||
(&event.self(), event.pos(), event.isCancelled()),
|
||||
event.setCancelled(result););
|
||||
(&event.self(), event.getPosition(), event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::PlayerStartSleepAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerStartSleepAfterEvent,
|
||||
GMLIB::Event::PlayerEvent::PlayerStartSleepAfterEvent,
|
||||
(Player * entity, BlockPos pos, int result),
|
||||
(&event.self(), event.pos(), (int)event.result()),
|
||||
(&event.self(), event.getPosition(), (int)event.getResult()),
|
||||
,
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::PlayerStopSleepBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerStopSleepBeforeEvent,
|
||||
GMLIB::Event::PlayerEvent::PlayerStopSleepBeforeEvent,
|
||||
(Player * entity, bool forcefulWakeUp, bool updateLevelList, bool isCancelled),
|
||||
(&event.self(), event.forcefulWakeUp(), event.updateLevelList(), false),
|
||||
|
||||
(&event.self(), event.isForcefulWakeUp(), event.isUpdateLevelList(), event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::PlayerStopSleepAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerStopSleepAfterEvent,
|
||||
GMLIB::Event::PlayerEvent::PlayerStopSleepAfterEvent,
|
||||
(Player * entity, bool forcefulWakeUp, bool updateLevelList, bool),
|
||||
(&event.self(), event.forcefulWakeUp(), event.updateLevelList(), false),
|
||||
(&event.self(), event.isForcefulWakeUp(), event.isUpdateLevelList(), false),
|
||||
,
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::DeathMessageAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::DeathMessageAfterEvent,
|
||||
GMLIB::Event::EntityEvent::DeathMessageAfterEvent,
|
||||
(std::string const& message, std::vector<std::string>, Actor* dead),
|
||||
(event.result().first, event.result().second, &event.self()),
|
||||
(event.getDeathMessage().first, event.getDeathMessage().second, &event.self()),
|
||||
,
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::MobHurtAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::MobHealthChangeAfterEvent,
|
||||
GMLIB::Event::EntityEvent::MobHurtAfterEvent,
|
||||
(Actor * mob, Actor * source, float damage, int cause),
|
||||
(&event.self(), source, event.oldValue() - event.newValue(), (int)damageSource->mCause),
|
||||
(&event.self(), source, -event.getDamage(), (int)damageSource.getCause()),
|
||||
,
|
||||
if (event.newValue() > event.oldValue()) return;
|
||||
auto& damageSource = event.buff().mSource;
|
||||
auto& damageSource = event.getSource();
|
||||
Actor* source = nullptr;
|
||||
if (damageSource->isEntitySource()) {
|
||||
auto uniqueId = damageSource->getDamagingEntityUniqueID();
|
||||
if (damageSource.isEntitySource()) {
|
||||
auto uniqueId = damageSource.getDamagingEntityUniqueID();
|
||||
source = ll::service::getLevel()->fetchEntity(uniqueId, false);
|
||||
if (source->getOwner()) source = source->getOwner();
|
||||
}
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::EndermanTakeBlockBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(ila::mc::MobTakeBlockBeforeEvent,
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::EndermanTakeBlockBeforeEvent,
|
||||
(Actor * mob, bool isCancelled),
|
||||
(&event.self(), event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
, if (!event.self().isType(ActorType::EnderMan)) return;);
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::DragonRespawnBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(ila::mc::DragonRespawnBeforeEvent,
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::DragonRespawnBeforeEvent,
|
||||
(bool isCancelled),
|
||||
(event.isCancelled()),
|
||||
event.setCancelled(result););
|
||||
event.setCancelled(result);
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::DragonRespawnAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(ila::mc::DragonRespawnAfterEvent, (Actor * mob), (&event.self()), );
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::DragonRespawnAfterEvent,
|
||||
(Actor * mob),
|
||||
(event.getEnderDragon()),
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::ProjectileCreateBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(ila::mc::ProjectileCreateBeforeEvent,
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::ProjectileCreateBeforeEvent,
|
||||
(Actor * mob, int64 uniqueId, bool isCancelled),
|
||||
(&event.self(), event.self().getOwnerId().rawID, event.isCancelled()),
|
||||
event.setCancelled(result););
|
||||
(&event.self(),
|
||||
event.getShooter() ? event.getShooter()->getOrCreateUniqueID().rawID : -1,
|
||||
event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::ProjectileCreateAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::ProjectileCreateAfterEvent,
|
||||
GMLIB::Event::EntityEvent::ProjectileCreateAfterEvent,
|
||||
(Actor * mob, int64 uniqueId),
|
||||
(&event.self(), event.self().getOwnerId().rawID),
|
||||
(&event.self(), event.getShooter() ? event.getShooter()->getOrCreateUniqueID().rawID : -1),
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::SpawnWanderingTraderBeforeEvent"): {
|
||||
REGISTER_EVENT_LISTEN(ila::mc::SpawnWanderingTraderBeforeEvent,
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::SpawnWanderingTraderBeforeEvent,
|
||||
(std::pair<BlockPos, int> pos, bool isCancelled),
|
||||
({event.pos(), event.blockSource().getDimensionId()}, event.isCancelled()),
|
||||
event.setCancelled(result););
|
||||
({event.getPos(), event.getRegion().getDimensionId()}, event.isCancelled()),
|
||||
event.setCancelled(result);
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::SpawnWanderingTraderAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
GMLIB::Event::EntityEvent::SpawnWanderingTraderAfterEvent,
|
||||
(std::pair<BlockPos, int> pos),
|
||||
({event.getPos(), event.getRegion().getDimensionId()}),
|
||||
);
|
||||
}
|
||||
case doHash("gmlib::HandleRequestActionBeforeEvent"): {
|
||||
// clang-format off
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerRequestItemActionBeforeEvent,
|
||||
GMLIB::Event::PlayerEvent::HandleRequestActionBeforeEvent,
|
||||
(
|
||||
Player * player,
|
||||
std::string const& actionType,
|
||||
@@ -265,23 +299,24 @@ void Export_Event_API() {
|
||||
bool isCancelled
|
||||
),
|
||||
(
|
||||
(Player*)&event.self(),
|
||||
magic_enum::enum_name(event.actionType()).data(),
|
||||
event.amount(),
|
||||
magic_enum::enum_name(event.src().mFullContainerName.mName).data(),
|
||||
(int)event.src().mSlot,
|
||||
magic_enum::enum_name(event.dst().mFullContainerName.mName).data(),
|
||||
(int)event.dst().mSlot,
|
||||
&event.self(),
|
||||
magic_enum::enum_name(requestAction.mActionType).data(),
|
||||
(int)requestAction.mAmount,
|
||||
magic_enum::enum_name(requestAction.mSrc->mFullContainerName.mName).data(),
|
||||
(int)requestAction.mSrc->mSlot,
|
||||
magic_enum::enum_name(requestAction.mDst->mFullContainerName.mName).data(),
|
||||
(int)requestAction.mDst->mSlot,
|
||||
event.isCancelled()
|
||||
),
|
||||
event.setCancelled(result);,
|
||||
auto& requestAction = (ItemStackRequestActionTransferBase&)event.getRequestAction();
|
||||
);
|
||||
// clang-format on
|
||||
}
|
||||
case doHash("gmlib::HandleRequestActionAfterEvent"): {
|
||||
// clang-format off
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerRequestItemActionAfterEvent,
|
||||
GMLIB::Event::PlayerEvent::HandleRequestActionAfterEvent,
|
||||
(
|
||||
Player * player,
|
||||
std::string const& actionType,
|
||||
@@ -292,23 +327,28 @@ void Export_Event_API() {
|
||||
int destinationSlot
|
||||
),
|
||||
(
|
||||
(Player*)&event.self(),
|
||||
magic_enum::enum_name(event.actionType()).data(),
|
||||
event.amount(),
|
||||
magic_enum::enum_name(event.src().mFullContainerName.mName).data(),
|
||||
(int)event.src().mSlot,
|
||||
magic_enum::enum_name(event.dst().mFullContainerName.mName).data(),
|
||||
(int)event.dst().mSlot
|
||||
&event.self(),
|
||||
magic_enum::enum_name(requestAction.mActionType).data(),
|
||||
(int)requestAction.mAmount,
|
||||
magic_enum::enum_name(requestAction.mSrc->mFullContainerName.mName).data(),
|
||||
(int)requestAction.mSrc->mSlot,
|
||||
magic_enum::enum_name(requestAction.mDst->mFullContainerName.mName).data(),
|
||||
(int)requestAction.mDst->mSlot
|
||||
),
|
||||
,
|
||||
auto& requestAction = (ItemStackRequestActionTransferBase&)event.getRequestAction();
|
||||
);
|
||||
// clang-format on
|
||||
}
|
||||
case doHash("gmlib::ContainerClosePacketSendAfterEvent"): {
|
||||
REGISTER_EVENT_LISTEN(
|
||||
ila::mc::PlayerCloseContainerAfterEvent,
|
||||
GMLIB::Event::PacketEvent::ContainerClosePacketSendAfterEvent,
|
||||
(Player * player, int containerId, bool serverInitiatedClose, bool),
|
||||
(&event.self(), (int)event.containerId(), event.serverInitiatedClose(), false),
|
||||
(ll::service::getServerNetworkHandler()
|
||||
->_getServerPlayer(event.getNetworkIdentifier(), event.getPacket().mClientSubId),
|
||||
(int)event.getPacket().mContainerId,
|
||||
event.getPacket().mServerInitiatedClose,
|
||||
false),
|
||||
,
|
||||
);
|
||||
}
|
||||
|
||||
+6
-45
@@ -1,36 +1,15 @@
|
||||
#pragma once
|
||||
// clang-format off
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4996)
|
||||
#pragma include_alias("mc/world/item/HumanoidArmorItem.h", "modapi/item/types/mc/HumanoidArmorItem.h")
|
||||
#include <gmlib/include_ll.h>
|
||||
#include <gmlib/include_lib.h>
|
||||
#include <gmlib/include_mc.h>
|
||||
#include <ila/include_all.h>
|
||||
#include <modapi/addons/AddonsLoader.h>
|
||||
#include <modapi/recipe/CustomRecipeRegistry.h>
|
||||
#include <modapi/item/CustomItemRegistry.h>
|
||||
#include <include_all.h>
|
||||
|
||||
#include <RemoteCallAPI.h>
|
||||
using namespace gmlib;
|
||||
using namespace gmlib::ui;
|
||||
using namespace gmlib::i18n;
|
||||
using namespace gmlib::memory;
|
||||
using namespace modapi;
|
||||
#pragma warning(pop)
|
||||
// clang-format on
|
||||
|
||||
#define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA")
|
||||
|
||||
#define LIB_VERSION_MAJOR 1
|
||||
#define LIB_VERSION_MINOR 7
|
||||
#define LIB_VERSION_PATCH 1
|
||||
#define LIB_VERSION_PRERELEASE std::nullopt
|
||||
#define LIB_VERSION_MAJOR 0
|
||||
#define LIB_VERSION_MINOR 13
|
||||
#define LIB_VERSION_PATCH 6
|
||||
|
||||
#ifdef LIB_VERSION_PRERELEASE
|
||||
#define LIB_VERSION ll::data::Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH, LIB_VERSION_PRERELEASE)
|
||||
#else
|
||||
#define LIB_VERSION ll::data::Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH)
|
||||
#endif
|
||||
#define LIB_VERSION GMLIB::Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH)
|
||||
|
||||
extern void Export_Legacy_GMLib_ModAPI();
|
||||
extern void Export_Legacy_GMLib_ServerAPI();
|
||||
@@ -38,22 +17,4 @@ extern void Export_Compatibility_API();
|
||||
extern void ExportPAPI();
|
||||
extern void Export_Event_API();
|
||||
extern void Export_BinaryStream_API();
|
||||
extern ll::thread::ThreadPoolExecutor const& getThreadPoolExecutor();
|
||||
extern ll::io::Logger& getLogger();
|
||||
// extern void Export_Form_API();
|
||||
|
||||
|
||||
template <>
|
||||
struct fmt::formatter<ActorUniqueID> : fmt::formatter<int64> {
|
||||
template <class FormatContext>
|
||||
auto format(ActorUniqueID const& t, FormatContext& ctx) const {
|
||||
return formatter<int64>::format(t.rawID, ctx);
|
||||
}
|
||||
};
|
||||
template <>
|
||||
struct fmt::formatter<mce::UUID> : fmt::formatter<std::string> {
|
||||
template <class FormatContext>
|
||||
auto format(mce::UUID const& t, FormatContext& ctx) const {
|
||||
return formatter<std::string>::format(t.asString(), ctx);
|
||||
}
|
||||
};
|
||||
+75
-62
@@ -1,10 +1,10 @@
|
||||
#include "Global.h"
|
||||
|
||||
ICustomRecipe::UnlockingRequirement makeRecipeUnlockingKey(std::string const& key) {
|
||||
if (auto context = magic_enum::enum_cast<RecipeUnlockingContext>(key)) {
|
||||
return ICustomRecipe::UnlockingRequirement(*context);
|
||||
}
|
||||
return ICustomRecipe::UnlockingRequirement({ICustomRecipe::Ingredient(key)});
|
||||
std::unordered_set<std::string> HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"};
|
||||
|
||||
std::variant<std::string, std::vector<RecipeIngredient>> makeRecipeUnlockingKey(std::string const& key) {
|
||||
if (HardCodedKeys.count(key)) return key;
|
||||
return std::vector<RecipeIngredient>({RecipeIngredient(key, 0, 1)});
|
||||
}
|
||||
|
||||
void Export_Legacy_GMLib_ModAPI() {
|
||||
@@ -17,13 +17,17 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& result,
|
||||
int count,
|
||||
std::string const& unlock) -> void {
|
||||
if (!GMLevel::getInstance().has_value()) return;
|
||||
std::vector<ICustomRecipe::Ingredient> types;
|
||||
for (auto& ing : ingredients) {
|
||||
types.emplace_back(ICustomRecipe::Ingredient{ing, 1});
|
||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
std::vector<RecipeIngredient> types;
|
||||
for (auto ing : ingredients) {
|
||||
types.emplace_back(ing, 0, 1);
|
||||
}
|
||||
CustomRecipeRegistry::getInstance()
|
||||
.registerShapelessRecipe(recipe_id, types, ItemInstance(result, count), makeRecipeUnlockingKey(unlock));
|
||||
GMLIB::Mod::JsonRecipe::registerShapelessCraftingTableRecipe(
|
||||
recipe_id,
|
||||
types,
|
||||
RecipeIngredient(result, 0, count),
|
||||
makeRecipeUnlockingKey(unlock)
|
||||
);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -35,17 +39,16 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& result,
|
||||
int count,
|
||||
std::string const& unlock) -> void {
|
||||
if (!GMLevel::getInstance().has_value()) return;
|
||||
ICustomShapedRecipe::ShapedIngredients types;
|
||||
char index = 'A';
|
||||
for (auto& ing : ingredients) {
|
||||
types.add(std::string(1, index++), ICustomRecipe::Ingredient{ing});
|
||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
std::vector<RecipeIngredient> types;
|
||||
for (auto ing : ingredients) {
|
||||
types.push_back(RecipeIngredient(ing, 0, 1));
|
||||
}
|
||||
CustomRecipeRegistry::getInstance().registerShapedRecipe(
|
||||
GMLIB::Mod::JsonRecipe::registerShapedCraftingTableRecipe(
|
||||
recipe_id,
|
||||
shape,
|
||||
types,
|
||||
ItemInstance(result, count),
|
||||
RecipeIngredient(result, 0, count),
|
||||
makeRecipeUnlockingKey(unlock)
|
||||
);
|
||||
}
|
||||
@@ -57,9 +60,13 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& input,
|
||||
std::string const& output,
|
||||
std::vector<std::string> tags) -> void {
|
||||
if (!GMLevel::getInstance().has_value()) return;
|
||||
CustomRecipeRegistry::getInstance()
|
||||
.registerFurnaceRecipe(ICustomRecipe::Ingredient{input}, ItemInstance{output}, tags);
|
||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
GMLIB::Mod::JsonRecipe::registerFurnaceRecipe(
|
||||
recipe_id,
|
||||
RecipeIngredient(input, 0, 1),
|
||||
RecipeIngredient(output, 0, 1),
|
||||
tags
|
||||
);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -67,12 +74,8 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
"registerBrewingMixRecipe",
|
||||
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
||||
) -> void {
|
||||
if (!GMLevel::getInstance().has_value()) return;
|
||||
CustomRecipeRegistry::getInstance().registerBrewingRecipe(
|
||||
ICustomRecipe::Ingredient{input},
|
||||
ICustomRecipe::Ingredient{reagent},
|
||||
ICustomRecipe::Ingredient{output}
|
||||
);
|
||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
GMLIB::Mod::JsonRecipe::registerBrewingMixRecipe(recipe_id, input, output, RecipeIngredient(reagent, 0, 1));
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -80,11 +83,12 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
"registerBrewingContainerRecipe",
|
||||
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
||||
) -> void {
|
||||
if (!GMLevel::getInstance().has_value()) return;
|
||||
CustomRecipeRegistry::getInstance().registerBrewingRecipe(
|
||||
ICustomRecipe::Ingredient{input},
|
||||
ICustomRecipe::Ingredient{reagent},
|
||||
ICustomRecipe::Ingredient{output}
|
||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
GMLIB::Mod::JsonRecipe::registerBrewingContainerRecipe(
|
||||
recipe_id,
|
||||
RecipeIngredient(input, 0, 1),
|
||||
RecipeIngredient(output, 0, 1),
|
||||
RecipeIngredient(reagent, 0, 1)
|
||||
);
|
||||
}
|
||||
);
|
||||
@@ -96,13 +100,13 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& base,
|
||||
std::string const& addition,
|
||||
std::string const& result) -> void {
|
||||
if (!GMLevel::getInstance().has_value()) return;
|
||||
CustomRecipeRegistry::getInstance().registerSmithingTransformRecipe(
|
||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
GMLIB::Mod::JsonRecipe::registerSmithingTransformRecipe(
|
||||
recipe_id,
|
||||
ICustomRecipe::Ingredient{smithing_template},
|
||||
ICustomRecipe::Ingredient{base},
|
||||
ICustomRecipe::Ingredient{addition},
|
||||
ItemInstance{result}
|
||||
smithing_template,
|
||||
base,
|
||||
addition,
|
||||
result
|
||||
);
|
||||
}
|
||||
);
|
||||
@@ -113,13 +117,8 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& smithing_template,
|
||||
std::string const& base,
|
||||
std::string const& addition) -> void {
|
||||
if (!GMLevel::getInstance().has_value()) return;
|
||||
CustomRecipeRegistry::getInstance().registerSmithingTrimRecipe(
|
||||
recipe_id,
|
||||
ICustomRecipe::Ingredient{smithing_template},
|
||||
ICustomRecipe::Ingredient{base},
|
||||
ICustomRecipe::Ingredient{addition}
|
||||
);
|
||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
GMLIB::Mod::JsonRecipe::registerSmithingTrimRecipe(recipe_id, smithing_template, base, addition);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
@@ -131,35 +130,49 @@ void Export_Legacy_GMLib_ModAPI() {
|
||||
std::string const& output,
|
||||
int output_data,
|
||||
int output_count) -> void {
|
||||
if (!GMLevel::getInstance().has_value()) return;
|
||||
CustomRecipeRegistry::getInstance().registerStoneCutterRecipe(
|
||||
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||
GMLIB::Mod::JsonRecipe::registerStoneCutterRecipe(
|
||||
recipe_id,
|
||||
ICustomRecipe::Ingredient{input, 1, input_data},
|
||||
{output, output_count, output_data}
|
||||
RecipeIngredient(input, 0, 1),
|
||||
RecipeIngredient(output, 0, 1)
|
||||
);
|
||||
}
|
||||
);
|
||||
// 错误方块清理
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "setUnknownBlockCleaner", []() -> void {
|
||||
getLogger().error("setUnknownBlockCleaner is not implemented");
|
||||
GMLIB::Mod::VanillaFix::setAutoCleanUnknownBlockEnabled();
|
||||
});
|
||||
// 实验性
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void {
|
||||
GMLevel::getInstance().and_then([&](GMLevel& level) {
|
||||
level.setExperimentEnabled((AllExperiments)experiment_id);
|
||||
return true;
|
||||
});
|
||||
auto list = GMLIB_Level::getAllExperiments();
|
||||
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||
if (set.contains((AllExperiments)experiment_id)) {
|
||||
GMLIB_Level::addExperimentsRequire((AllExperiments)experiment_id);
|
||||
} else {
|
||||
ll::io::LoggerRegistry::getInstance().getOrCreate("Server")->error("Experiment ID '{}' does not exist!", experiment_id);
|
||||
}
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "setExperimentEnabled", [](int experiment_id, bool value) -> void {
|
||||
GMLevel::getInstance().and_then([&](GMLevel& level) {
|
||||
level.setExperimentEnabled((AllExperiments)experiment_id, value);
|
||||
return true;
|
||||
});
|
||||
if (GMLIB_Level::getInstance()) {
|
||||
auto list = GMLIB_Level::getAllExperiments();
|
||||
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||
if (set.contains((AllExperiments)experiment_id)) {
|
||||
GMLIB_Level::getInstance()->setExperimentEnabled(((AllExperiments)experiment_id), value);
|
||||
} else ll::io::LoggerRegistry::getInstance().getOrCreate("Server")->error("Experiment ID '{}' does not exist!", experiment_id);
|
||||
}
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "getExperimentEnabled", [](int experiment_id) -> bool {
|
||||
return GMLevel::getInstance()
|
||||
.transform([&](GMLevel& level) { return level.getExperimentEnabled((AllExperiments)experiment_id); })
|
||||
.value_or(false);
|
||||
if (GMLIB_Level::getInstance()) {
|
||||
auto list = GMLIB_Level::getAllExperiments();
|
||||
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||
if (set.contains((AllExperiments)experiment_id)) {
|
||||
return GMLIB_Level::getInstance()->getExperimentEnabled(((AllExperiments)experiment_id));
|
||||
}
|
||||
ll::io::LoggerRegistry::getInstance().getOrCreate("Server")->error("Experiment ID '{}' does not exist!", experiment_id);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "setFixI18nEnabled", []() -> void {
|
||||
GMLIB::Mod::VanillaFix::setFixI18nEnabled();
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ModAPI", "setFixI18nEnabled", []() -> void {});
|
||||
}
|
||||
+24
-34
@@ -2,62 +2,57 @@
|
||||
|
||||
void Export_Legacy_GMLib_ServerAPI() {
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEducationFeatureEnabled", []() -> void {
|
||||
getLogger().error("GMLib_ServerAPI::setEducationFeatureEnabled is not implemented");
|
||||
GMLIB_Level::tryEnableEducationEdition();
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "registerAbilityCommand", []() -> void {
|
||||
getLogger().error("GMLib_ServerAPI::registerAbilityCommand is not implemented");
|
||||
GMLIB_Level::tryRegisterAbilityCommand();
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setEnableAchievement", []() -> void {
|
||||
getLogger().error("GMLib_ServerAPI::setEnableAchievement is not implemented");
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void {
|
||||
getLogger().error("GMLib_ServerAPI::setForceTrustSkins is not implemented");
|
||||
GMLIB_Level::setForceAchievementsEnabled();
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setForceTrustSkins", []() -> void { GMLIB_Level::trustAllSkins(); });
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "enableCoResourcePack", []() -> void {
|
||||
getLogger().error("GMLib_ServerAPI::enableCoResourcePack is not implemented");
|
||||
GMLIB_Level::requireServerResourcePackAndAllowClientResourcePack();
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
||||
return GMLevel::getInstance().transform(
|
||||
[](GMLevel& level) -> std::string { return level.getLevelName(); }
|
||||
).value_or("");
|
||||
return GMLIB_Level::getInstance()
|
||||
.transform([](GMLIB_Level& level) -> std::string { return level.getLevelName(); })
|
||||
.value_or("");
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setLevelName", [](std::string const& name) -> void {
|
||||
if (auto level = GMLevel::getInstance()) {
|
||||
if (auto level = GMLIB_Level::getInstance()) {
|
||||
level->setLevelName(name);
|
||||
}
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelSeed", []() -> std::string {
|
||||
return GMLevel::getInstance()
|
||||
.transform([](GMLevel& level) -> std::string { return std::to_string(level.getSeed()); })
|
||||
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 {
|
||||
getLogger().error("GMLib_ServerAPI::setFakeSeed is not implemented");
|
||||
return GMLIB_Level::setFakeSeed(seed);
|
||||
});
|
||||
RemoteCall::exportAs(
|
||||
"GMLib_ServerAPI",
|
||||
"spawnEntity",
|
||||
[](std::pair<Vec3, int> pos, std::string const& name) -> Actor* {
|
||||
return GMSpawner::spawnEntity(pos.first, pos.second, name).as_ptr();
|
||||
return GMLIB_Spawner::spawnEntity(pos.first, pos.second, name).as_ptr();
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
"GMLib_ServerAPI",
|
||||
"shootProjectile",
|
||||
[](Actor* owner, std::string const& name, float speed, float offset) -> Actor* {
|
||||
auto actor = GMSpawner::spawnEntity(owner->getPosition(), owner->getDimensionId(), name);
|
||||
if (!actor) return nullptr;
|
||||
((GMActor*)owner)->setProjectile((GMActor&)*actor, speed, offset);
|
||||
return actor.as_ptr();
|
||||
auto ac = (GMLIB_Actor*)owner;
|
||||
return ac->shootProjectile(name, speed, offset).as_ptr();
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs(
|
||||
"GMLib_ServerAPI",
|
||||
"throwEntity",
|
||||
[](Actor* owner, Actor* actor, float speed, float offset) -> bool {
|
||||
auto ac = (GMActor*)owner;
|
||||
ac->setProjectile((GMActor&)*actor, speed, offset);
|
||||
return true;
|
||||
auto ac = (GMLIB_Actor*)owner;
|
||||
return ac->throwEntity(*actor, speed, offset);
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "PlayerToEntity", [](Player* player) -> Actor* { return (Actor*)player; });
|
||||
@@ -65,23 +60,18 @@ void Export_Legacy_GMLib_ServerAPI() {
|
||||
"GMLib_ServerAPI",
|
||||
"addFakeList",
|
||||
[](const std::string& name, const std::string& xuid) -> bool {
|
||||
PlayerListAPI::push_back(name, xuid);
|
||||
return true;
|
||||
return GMLIB::Server::FakeList::addFakeList(name, xuid, ActorUniqueID(-1));
|
||||
}
|
||||
);
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "removeFakeList", [](const std::string& nameOrXuid) -> bool {
|
||||
PlayerListAPI::erase(nameOrXuid);
|
||||
return true;
|
||||
return GMLIB::Server::FakeList::removeFakeList(nameOrXuid);
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "removeAllFakeList", []() -> void {
|
||||
return GMLIB::Server::FakeList::removeAllFakeLists();
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "removeAllFakeList", []() -> void { PlayerListAPI::clear(); });
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "getMaxPlayers", []() -> int {
|
||||
return GMLevel::getInstance().transform(
|
||||
[](GMLevel& level) -> int { return level.getMaxPlayerCount(); }
|
||||
return GMLIB_Level::getInstance().transform(
|
||||
[](GMLIB_Level& level) -> int { return level.getMaxPlayerCount(); }
|
||||
).value_or(0);
|
||||
});
|
||||
RemoteCall::exportAs("GMLib_ServerAPI", "setMaxPlayers", [&](int count, bool ignoreVanillaLimit) {
|
||||
if (auto level = GMLevel::getInstance(); level) {
|
||||
level->setMaxPlayerCount(count, ignoreVanillaLimit);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+68
-164
@@ -2,210 +2,122 @@
|
||||
#include <regex>
|
||||
|
||||
namespace PAPIRemoteCall {
|
||||
std::string GetValue(std::string const& from) {
|
||||
return PlaceholderAPI::getInstance().getValue(from, std::nullopt).value_or("");
|
||||
|
||||
std::string removeBrackets(std::string a1) {
|
||||
a1.erase(a1.find_last_not_of("%") + 1);
|
||||
return a1;
|
||||
}
|
||||
|
||||
bool isParameters(std::string const& str) {
|
||||
std::regex reg("[<]([^<>]+)[>]");
|
||||
return std::regex_search(removeBrackets(str), reg);
|
||||
}
|
||||
|
||||
std::string GetValue(std::string const& from) { return GMLIB::Server::PlaceholderAPI::getValue(from); }
|
||||
|
||||
std::string GetValueWithPlayer(std::string const& key, Player* player) {
|
||||
return PlaceholderAPI::getInstance().getValue(key, (GMActor*)player).value_or("");
|
||||
return GMLIB::Server::PlaceholderAPI::getValue(key, player);
|
||||
}
|
||||
|
||||
void registerPlayerPlaceholder(
|
||||
bool registerPlayerPlaceholder(
|
||||
std::string const& PluginName,
|
||||
std::string const& FuncName,
|
||||
std::string const& PAPIName
|
||||
) {
|
||||
if (!RemoteCall::hasFunc(PluginName, FuncName)) return;
|
||||
auto func = [=]() -> void {
|
||||
PlaceholderAPI::getInstance().unregisterPlaceholder(PAPIName);
|
||||
std::weak_ptr mod = ll::mod::ModManagerRegistry::getInstance().getMod(PluginName);
|
||||
if (mod.expired()) return;
|
||||
PlaceholderAPI::getInstance().registerPlaceholder(
|
||||
PAPIName,
|
||||
[Call = RemoteCall::importAs<std::string(Player * pl, std::unordered_map<std::string, std::string>)>(
|
||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||
GMLIB::Server::PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||
if (isParameters(PAPIName)) {
|
||||
auto Call = RemoteCall::importAs<std::string(Player * pl, std::unordered_map<std::string, std::string>)>(
|
||||
PluginName,
|
||||
FuncName
|
||||
)](optional_ref<Actor> actor, ll::SmallStringMap<std::string> const& params, auto&&...
|
||||
) -> std::optional<std::string> {
|
||||
if (actor.has_value() && ((Actor*)actor.as_ptr())->isPlayer()) {
|
||||
std::unordered_map<std::string, std::string> paramMap;
|
||||
for (auto& [key, val] : params) {
|
||||
paramMap[key] = val;
|
||||
}
|
||||
return Call((Player*)actor.as_ptr(), paramMap);
|
||||
}
|
||||
return std::nullopt;
|
||||
},
|
||||
false,
|
||||
mod
|
||||
);
|
||||
};
|
||||
if (ll::mod::ModManagerRegistry::getInstance().hasMod(PluginName)) {
|
||||
func();
|
||||
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
|
||||
PAPIName,
|
||||
[Call](Player* sp, std::unordered_map<std::string, std::string> map) { return Call(sp, map); },
|
||||
PluginName
|
||||
);
|
||||
} else {
|
||||
getThreadPoolExecutor().execute(func);
|
||||
auto Call = RemoteCall::importAs<std::string(Player * pl)>(PluginName, FuncName);
|
||||
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
|
||||
PAPIName,
|
||||
[Call](Player* sp) { return Call(sp); },
|
||||
PluginName
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void registerServerPlaceholder(
|
||||
bool registerServerPlaceholder(
|
||||
std::string const& PluginName,
|
||||
std::string const& FuncName,
|
||||
std::string const& PAPIName
|
||||
) {
|
||||
if (!RemoteCall::hasFunc(PluginName, FuncName)) return;
|
||||
auto func = [=]() -> void {
|
||||
PlaceholderAPI::getInstance().unregisterPlaceholder(PAPIName);
|
||||
std::weak_ptr mod = ll::mod::ModManagerRegistry::getInstance().getMod(PluginName);
|
||||
if (mod.expired()) return;
|
||||
PlaceholderAPI::getInstance().registerPlaceholder(
|
||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||
GMLIB::Server::PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||
if (isParameters(PAPIName)) {
|
||||
auto Call =
|
||||
RemoteCall::importAs<std::string(std::unordered_map<std::string, std::string>)>(PluginName, FuncName);
|
||||
GMLIB::Server::PlaceholderAPI::registerServerPlaceholder(
|
||||
PAPIName,
|
||||
[Call = RemoteCall::importAs<std::string(std::unordered_map<std::string, std::string>)>(
|
||||
PluginName,
|
||||
FuncName
|
||||
)](auto, ll::SmallStringMap<std::string> const& params, auto&&...) -> std::optional<std::string> {
|
||||
std::unordered_map<std::string, std::string> paramMap;
|
||||
for (auto& [key, val] : params) {
|
||||
paramMap[key] = val;
|
||||
}
|
||||
return Call(paramMap);
|
||||
},
|
||||
false,
|
||||
mod
|
||||
[Call](std::unordered_map<std::string, std::string> map) { return Call(map); },
|
||||
PluginName
|
||||
);
|
||||
};
|
||||
if (ll::mod::ModManagerRegistry::getInstance().hasMod(PluginName)) {
|
||||
func();
|
||||
} else {
|
||||
getThreadPoolExecutor().execute(func);
|
||||
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
||||
GMLIB::Server::PlaceholderAPI::registerServerPlaceholder(PAPIName, [Call]() { return Call(); }, PluginName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void registerStaticPlaceholder(
|
||||
bool registerStaticPlaceholder(
|
||||
std::string const& PluginName,
|
||||
std::string const& FuncName,
|
||||
std::string const& PAPIName,
|
||||
int num
|
||||
) {
|
||||
if (!RemoteCall::hasFunc(PluginName, FuncName)) return;
|
||||
auto func = [=]() -> void {
|
||||
PlaceholderAPI::getInstance().unregisterPlaceholder(PAPIName);
|
||||
std::weak_ptr mod = ll::mod::ModManagerRegistry::getInstance().getMod(PluginName);
|
||||
if (mod.expired()) return;
|
||||
PlaceholderAPI::getInstance().registerPlaceholder(
|
||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||
GMLIB::Server::PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||
if (isParameters(PAPIName)) {
|
||||
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
||||
if (num == -1) {
|
||||
GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder(
|
||||
PAPIName,
|
||||
[Call = RemoteCall::importAs<std::string()>(PluginName, FuncName)](auto&&...
|
||||
) -> std::optional<std::string> { return Call(); },
|
||||
false,
|
||||
mod
|
||||
[Call] { return Call(); },
|
||||
PluginName
|
||||
);
|
||||
};
|
||||
if (ll::mod::ModManagerRegistry::getInstance().hasMod(PluginName)) {
|
||||
func();
|
||||
} else {
|
||||
getThreadPoolExecutor().execute(func);
|
||||
GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder(
|
||||
PAPIName,
|
||||
num,
|
||||
[Call] { return Call(); },
|
||||
PluginName
|
||||
);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string translateStringWithPlayer(std::string const& str, Player* pl) {
|
||||
return PlaceholderAPI::getInstance().translate(str, (GMActor*)pl);
|
||||
return GMLIB::Server::PlaceholderAPI::translateString(str, pl);
|
||||
}
|
||||
|
||||
std::string translateString(std::string const& str) {
|
||||
return PlaceholderAPI::getInstance().translate(str, std::nullopt);
|
||||
}
|
||||
std::string translateString(std::string const& str) { return GMLIB::Server::PlaceholderAPI::translateString(str); }
|
||||
|
||||
bool unRegisterPlaceholder(std::string const& str) { return PlaceholderAPI::getInstance().unregisterPlaceholder(str); }
|
||||
bool unRegisterPlaceholder(std::string const& str) { return GMLIB::Server::PlaceholderAPI::unregisterPlaceholder(str); }
|
||||
|
||||
std::vector<std::string> getAllPAPI() {
|
||||
std::vector<std::string> result;
|
||||
for (auto& papi : PlaceholderAPI::getInstance().getAllPlaceholderData()) {
|
||||
result.push_back(papi.first);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
std::vector<std::string> getAllPAPI() { return GMLIB::Server::PlaceholderAPI::getAllPAPI(); }
|
||||
|
||||
} // namespace PAPIRemoteCall
|
||||
|
||||
namespace NewPapiRemoteCall {
|
||||
std::string translate(std::string const& value, std::string const& language) {
|
||||
return PlaceholderAPI::getInstance().translate(value, std::nullopt, language);
|
||||
}
|
||||
std::string translateFromActor(std::string const& value, Actor* actor, std::string const& language) {
|
||||
return PlaceholderAPI::getInstance().translate(value, (GMActor*)actor, language);
|
||||
}
|
||||
void registerPlaceholder(std::string const& placeholder, std::string const& funcName, std::string const& pluginName) {
|
||||
if (!RemoteCall::hasFunc(pluginName, funcName)) return;
|
||||
auto func = [=]() -> void {
|
||||
if (std::weak_ptr mod = ll::mod::ModManagerRegistry::getInstance().getMod(pluginName); !mod.expired()) {
|
||||
PlaceholderAPI::getInstance().unregisterPlaceholder(placeholder);
|
||||
PlaceholderAPI::getInstance().registerPlaceholder(
|
||||
placeholder,
|
||||
[Call = RemoteCall::importAs<
|
||||
std::string(Actor*, std::unordered_map<std::string, std::string>, std::string)>(
|
||||
pluginName,
|
||||
funcName
|
||||
)](optional_ref<Actor> actor, ll::SmallStringMap<std::string> const& params, std::string const& language
|
||||
) -> std::optional<std::string> {
|
||||
std::unordered_map<std::string, std::string> paramMap;
|
||||
for (auto& [key, val] : params) {
|
||||
paramMap[key] = val;
|
||||
}
|
||||
auto result = Call((Actor*)actor.as_ptr(), paramMap, language);
|
||||
return result == "<std::nullopt>" ? std::nullopt : std::optional(result);
|
||||
},
|
||||
false,
|
||||
mod
|
||||
);
|
||||
}
|
||||
};
|
||||
if (ll::mod::ModManagerRegistry::getInstance().hasMod(pluginName)) {
|
||||
func();
|
||||
} else {
|
||||
getThreadPoolExecutor().execute(func);
|
||||
}
|
||||
}
|
||||
bool unregisterPlaceholder(std::string const& placeholder) {
|
||||
return PlaceholderAPI::getInstance().unregisterPlaceholder(placeholder);
|
||||
}
|
||||
bool unregisterPlaceholderFromModName(std::string const& pluginName) {
|
||||
std::weak_ptr plugin = ll::mod::ModManagerRegistry::getInstance().getMod(pluginName);
|
||||
if (plugin.expired()) return false;
|
||||
return PlaceholderAPI::getInstance().unregisterPlaceholder(plugin);
|
||||
}
|
||||
std::string getValue(
|
||||
std::string const& placeholder,
|
||||
std::unordered_map<std::string, std::string> params,
|
||||
std::string const& language
|
||||
) {
|
||||
ll::SmallStringMap<std::string> paramMap;
|
||||
for (auto& [key, val] : params) {
|
||||
paramMap[key] = val;
|
||||
}
|
||||
return PlaceholderAPI::getInstance()
|
||||
.getValue(placeholder, std::nullopt, paramMap, language)
|
||||
.value_or("<std::nullopt>");
|
||||
}
|
||||
std::string getValueFromActor(
|
||||
std::string const& placeholder,
|
||||
Actor* actor,
|
||||
std::unordered_map<std::string, std::string> params,
|
||||
std::string const& language
|
||||
) {
|
||||
ll::SmallStringMap<std::string> paramMap;
|
||||
for (auto& [key, val] : params) {
|
||||
paramMap[key] = val;
|
||||
}
|
||||
return PlaceholderAPI::getInstance()
|
||||
.getValue(placeholder, (GMActor*)actor, paramMap, language)
|
||||
.value_or("<std::nullopt>");
|
||||
}
|
||||
} // namespace NewPapiRemoteCall
|
||||
|
||||
#define EXPORTAPI(T) \
|
||||
RemoteCall::exportAs("BEPlaceholderAPI", ll::utils::string_utils::replaceAll(#T, "PAPIRemoteCall::", ""), T);
|
||||
|
||||
#define EXPORTAPI2(T) RemoteCall::exportAs("PlaceholderAPI", #T, NewPapiRemoteCall::T);
|
||||
|
||||
void ExportPAPI() {
|
||||
EXPORTAPI(PAPIRemoteCall::registerPlayerPlaceholder);
|
||||
EXPORTAPI(PAPIRemoteCall::registerServerPlaceholder);
|
||||
@@ -216,12 +128,4 @@ void ExportPAPI() {
|
||||
EXPORTAPI(PAPIRemoteCall::translateStringWithPlayer);
|
||||
EXPORTAPI(PAPIRemoteCall::unRegisterPlaceholder);
|
||||
EXPORTAPI(PAPIRemoteCall::getAllPAPI);
|
||||
|
||||
EXPORTAPI2(translate);
|
||||
EXPORTAPI2(translateFromActor);
|
||||
EXPORTAPI2(registerPlaceholder);
|
||||
EXPORTAPI2(unregisterPlaceholder);
|
||||
EXPORTAPI2(unregisterPlaceholderFromModName);
|
||||
EXPORTAPI2(getValue);
|
||||
EXPORTAPI2(getValueFromActor);
|
||||
}
|
||||
+12
-30
@@ -1,47 +1,29 @@
|
||||
{
|
||||
"format_version": 3,
|
||||
"format_uuid": "289f771f-2c9a-4d73-9f3f-8492495a924d",
|
||||
"format_version": 2,
|
||||
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
||||
"version": "1.9.0",
|
||||
"version": "0.13.6",
|
||||
"info": {
|
||||
"name": "GMLIB-LegacyRemoteCallApi",
|
||||
"description": "Legacy RemoteCall API for GMLIB",
|
||||
"source": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
||||
"author": "GroupMountain",
|
||||
"tags": [
|
||||
"platform:levilamina",
|
||||
"type:mod",
|
||||
"levilamina",
|
||||
"gmlib",
|
||||
"lse",
|
||||
"library"
|
||||
],
|
||||
"avatar_url": "https://raw.githubusercontent.com/GroupMountain/GMLIB-LegacyRemoteCallApi/refs/heads/main/icon.jpg"
|
||||
]
|
||||
},
|
||||
"variants": [
|
||||
{
|
||||
"platform": "win-x64",
|
||||
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.13.6/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
|
||||
"dependencies": {
|
||||
"github.com/LiteLDev/LeviLamina": ">=1.7.0",
|
||||
"github.com/GroupMountain/GMLIB-Release": ">=1.7.0",
|
||||
"github.com/GroupMountain/ModAPI-Release": ">=0.3.0",
|
||||
"github.com/MiracleForest/iListenAttentively-Release": ">=0.10.0"
|
||||
"github.com/GroupMountain/GMLIB": ">=0.13.9"
|
||||
},
|
||||
"assets": [
|
||||
"files": {
|
||||
"place": [
|
||||
{
|
||||
"type": "zip",
|
||||
"urls": [
|
||||
"https://{{tooth}}/releases/download/v{{version}}/GMLIB-LegacyRemoteCallApi-windows-x64.zip"
|
||||
],
|
||||
"placements": [
|
||||
{
|
||||
"type": "dir",
|
||||
"src": "GMLIB-LegacyRemoteCallApi",
|
||||
"dest": "plugins/GMLIB-LegacyRemoteCallApi/"
|
||||
"src": "GMLIB-LegacyRemoteCallApi/*",
|
||||
"dest": "plugins/GMLIB-LegacyRemoteCallApi"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"remove_files": [
|
||||
"plugins/GMLIB-LegacyRemoteCallApi"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2,31 +2,28 @@ add_rules("mode.debug", "mode.release")
|
||||
|
||||
add_repositories("liteldev-repo https://github.com/LiteLDev/xmake-repo.git")
|
||||
add_repositories("groupmountain-repo https://github.com/GroupMountain/xmake-repo.git")
|
||||
add_repositories("miracleforest-repo https://github.com/MiracleForest/xmake-repo.git")
|
||||
|
||||
if not has_config("vs_runtime") then
|
||||
set_runtimes("MD")
|
||||
end
|
||||
|
||||
add_requires("levilamina 050b392575227db10340075328e833c1a0f41e27", {configs = {target_type = "server"}})
|
||||
add_requires("legacyremotecall")
|
||||
add_requires("levibuildscript 0.6.0")
|
||||
add_requires("ilistenattentively 0.11.0")
|
||||
add_requires("gmlib 1.9.0")
|
||||
add_requires("modapi 0.4.0")
|
||||
add_requires("levilamina 1.0.0-rc.3", {configs = {target_type = "server"}})
|
||||
add_requires("legacyremotecall 0.9.0-rc.1")
|
||||
add_requires("gmlib 0.13.10")
|
||||
add_requires("levibuildscript 0.3.0")
|
||||
|
||||
target("GMLIB-LegacyRemoteCallApi")
|
||||
add_cxflags(
|
||||
"/EHa",
|
||||
"/utf-8",
|
||||
"/bigobj"
|
||||
"/utf-8"
|
||||
)
|
||||
add_defines(
|
||||
"NOMINMAX",
|
||||
"UNICODE",
|
||||
"_HAS_CXX23=1"
|
||||
"_HAS_CXX17",
|
||||
"_HAS_CXX20",
|
||||
"_HAS_CXX23"
|
||||
)
|
||||
add_defines("LL_PLAT_S") --TODO: check client compatibility
|
||||
add_files(
|
||||
"src/**.cpp"
|
||||
)
|
||||
@@ -36,20 +33,21 @@ target("GMLIB-LegacyRemoteCallApi")
|
||||
add_packages(
|
||||
"levilamina",
|
||||
"legacyremotecall",
|
||||
"ilistenattentively",
|
||||
"gmlib",
|
||||
"modapi"
|
||||
"gmlib"
|
||||
)
|
||||
add_rules("@levibuildscript/linkrule")
|
||||
add_rules("@levibuildscript/modpacker")
|
||||
set_exceptions("none")
|
||||
set_kind("shared")
|
||||
set_languages("cxx20")
|
||||
set_symbols("debug")
|
||||
|
||||
after_build(function (target)
|
||||
local target_path = path.join("bin", target:name(), "lib")
|
||||
if os.exists(target_path) then
|
||||
os.rm(target_path)
|
||||
end
|
||||
os.cp("lib", target_path)
|
||||
local plugin_packer = import("scripts.after_build")
|
||||
|
||||
local plugin_define = {
|
||||
pluginName = target:name(),
|
||||
pluginFile = path.filename(target:targetfile()),
|
||||
}
|
||||
|
||||
plugin_packer.pack_plugin(target,plugin_define)
|
||||
end)
|
||||
Reference in New Issue
Block a user