Compare commits
49 Commits
@@ -11,8 +11,6 @@ jobs:
|
|||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- uses: xmake-io/github-action-setup-xmake@v1
|
- uses: xmake-io/github-action-setup-xmake@v1
|
||||||
with:
|
|
||||||
xmake-version: "2.9.3"
|
|
||||||
|
|
||||||
- run: |
|
- run: |
|
||||||
xmake repo -u
|
xmake repo -u
|
||||||
@@ -23,14 +21,8 @@ jobs:
|
|||||||
- run: |
|
- run: |
|
||||||
xmake -w -y
|
xmake -w -y
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
||||||
path: |
|
path: |
|
||||||
bin/DLL/
|
bin/
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: PDB
|
|
||||||
path: |
|
|
||||||
bin/PDB/
|
|
||||||
@@ -11,8 +11,6 @@ jobs:
|
|||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- uses: xmake-io/github-action-setup-xmake@v1
|
- uses: xmake-io/github-action-setup-xmake@v1
|
||||||
with:
|
|
||||||
xmake-version: "2.9.3"
|
|
||||||
|
|
||||||
- run: |
|
- run: |
|
||||||
xmake repo -u
|
xmake repo -u
|
||||||
@@ -23,17 +21,11 @@ jobs:
|
|||||||
- run: |
|
- run: |
|
||||||
xmake -w -y
|
xmake -w -y
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
||||||
path: |
|
path: |
|
||||||
bin/DLL/
|
bin/
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: PDB
|
|
||||||
path: |
|
|
||||||
bin/PDB/
|
|
||||||
|
|
||||||
upload-to-release:
|
upload-to-release:
|
||||||
needs:
|
needs:
|
||||||
@@ -45,32 +37,23 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Download Plugin
|
- name: Download Mod
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
name: ${{ github.event.repository.name }}-windows-x64-${{ github.sha }}
|
||||||
path: release/Plugin/
|
path: artifact
|
||||||
|
|
||||||
- name: Download PDB
|
|
||||||
uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: PDB
|
|
||||||
path: release/PDB/
|
|
||||||
|
|
||||||
- name: Copy additional files
|
- name: Copy additional files
|
||||||
run: |
|
run: |
|
||||||
cp LICENSE README.md release/Plugin/
|
cp -v LICENSE README.md artifact/
|
||||||
|
|
||||||
- name: Archive release
|
- name: Archive release
|
||||||
run: |
|
run: |
|
||||||
cd release/Plugin
|
|
||||||
zip -r ../${{ github.event.repository.name }}-windows-x64.zip *
|
zip -r ../${{ github.event.repository.name }}-windows-x64.zip *
|
||||||
cd ..
|
working-directory: artifact
|
||||||
|
|
||||||
- name: Create GitHub Release
|
- name: Create GitHub Release
|
||||||
id: create_release
|
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
files: |
|
files: |
|
||||||
release/${{ github.event.repository.name }}-windows-x64.zip
|
${{ github.event.repository.name }}-windows-x64.zip
|
||||||
release/PDB/${{ github.event.repository.name }}.pdb
|
|
||||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
declare class PAPI {
|
export class PAPI {
|
||||||
/** 注册一个玩家PAPI变量 */
|
/** 注册一个玩家PAPI变量 */
|
||||||
static registerPlayerPlaceholder(
|
static registerPlayerPlaceholder(
|
||||||
/** PAPI调用函数 */
|
/** PAPI调用函数 */
|
||||||
|
|||||||
Vendored
+852
-209
File diff suppressed because it is too large
Load Diff
+164
-36
@@ -1,42 +1,170 @@
|
|||||||
/** 事件创建函数 @type {function(string,string):boolean} */
|
|
||||||
const CallEvent = ll.import("GMLIB_API", "callCustomEvent");
|
|
||||||
|
|
||||||
/** 事件ID @type {number} */
|
|
||||||
let NextEventId = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取事件ID标识名
|
* @returns {string}
|
||||||
* @returns {string} 事件ID标识名
|
|
||||||
*/
|
*/
|
||||||
function getNextEventId() {
|
const getPluginName = () => {
|
||||||
NextEventId++;
|
try {
|
||||||
return "GMLIB_Event_" + NextEventId;
|
throw new Error("getPluginName");
|
||||||
}
|
} catch (error) {
|
||||||
|
return error.stack.trim().match(/plugins\\(.*)\\.*\.js:[0-9]+\)$/i)?.[1] || "Unknown";
|
||||||
/** 事件类 */
|
|
||||||
class Event {
|
|
||||||
constructor() {
|
|
||||||
throw new Error("Static class cannot be instantiated");
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
/**
|
|
||||||
* 监听事件
|
|
||||||
* @param {string} event 事件名称
|
|
||||||
* @param {function} callback 回调
|
|
||||||
* @returns {boolean} 是否创建成功
|
|
||||||
*/
|
|
||||||
static listen(event, callback) {
|
|
||||||
let eventId = getNextEventId();
|
|
||||||
ll.export(callback, event, eventId);
|
|
||||||
let result = CallEvent(event, eventId);
|
|
||||||
if (!result) {
|
|
||||||
logger.error(`Cannot listen event "${event}"!`);
|
|
||||||
logger.error(`Event "${event}" No Found!`);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
Event
|
Event: {
|
||||||
|
/**
|
||||||
|
* 事件订阅记录
|
||||||
|
* 例如: {事件名: [事件ID, ...], ...}
|
||||||
|
* @type {Object.<string, number[]>}
|
||||||
|
*/
|
||||||
|
mEventData: {},
|
||||||
|
/**
|
||||||
|
* 事件异常处理回调
|
||||||
|
* @param {Error} error
|
||||||
|
* @param {string} eventName
|
||||||
|
* @param {number} eventID
|
||||||
|
* @param {string} pluginName
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
mErrorHanlerCallback: (error, eventName, eventID, pluginName) => {
|
||||||
|
logger.error(`Info: ${pluginName}-${eventName}-${eventID} Exception: ${error.message}\n${error.stack}`);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监听事件(兼容旧版)
|
||||||
|
* @param {string} eventName
|
||||||
|
* @param {function} callback
|
||||||
|
* @param {boolean}
|
||||||
|
*/
|
||||||
|
listen: function (eventName, callback) {
|
||||||
|
try {
|
||||||
|
if (typeof callback !== "function") return false;
|
||||||
|
const eventReflection = {
|
||||||
|
onServerStopping: "ll::ServerStoppingEvent",
|
||||||
|
onClientLogin: "gmlib::ClientLoginAfterEvent",
|
||||||
|
onWeatherChange: "gmlib::WeatherUpdateBeforeEvent",
|
||||||
|
onMobPick: "gmlib::MobPickupItemBeforeEvent",
|
||||||
|
onItemTrySpawn: "gmlib::ItemActorSpawnBeforeEvent",
|
||||||
|
onItemSpawned: "gmlib::ItemActorSpawnAfterEvent",
|
||||||
|
onEntityTryChangeDim: "gmlib::ActorChangeDimensionBeforeEvent",
|
||||||
|
onLeaveBed: "gmlib::PlayerStopSleepBeforeEvent",
|
||||||
|
onDeathMessage: "gmlib::DeathMessageAfterEvent",
|
||||||
|
onMobHurted: "gmlib::MobHurtAfterEvent",
|
||||||
|
onEndermanTake: "gmlib::EndermanTakeBlockBeforeEvent",
|
||||||
|
onEntityChangeDim: "gmlib::ActorChangeDimensionAfterEvent",
|
||||||
|
onDragonRespawn: "gmlib::DragonRespawnBeforeEvent",
|
||||||
|
onProjectileTryCreate: "gmlib::ProjectileCreateBeforeEvent",
|
||||||
|
onProjectileCreate: "gmlib::ProjectileCreateAfterEvent",
|
||||||
|
onSpawnWanderingTrader: "gmlib::SpawnWanderingTraderBeforeEvent",
|
||||||
|
onHandleRequestAction: "gmlib::HandleRequestActionBeforeEvent",
|
||||||
|
onSendContainerClosePacket: "gmlib::ContainerClosePacketSendAfterEvent"
|
||||||
|
};
|
||||||
|
this.emplaceListener(eventReflection[eventName] ?? eventName, event => {
|
||||||
|
const result = callback(...event.params);
|
||||||
|
if (typeof (result) === "boolean" && !result) event.cancel();
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
} catch { }
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订阅事件
|
||||||
|
* @param {string} eventName
|
||||||
|
* @param {function} callback
|
||||||
|
* @param {number?} priority
|
||||||
|
* @param {string?} pluginName
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
emplaceListener: function (eventName, callback, priority = this.EventPriority.Normal, pluginName = getPluginName()) {
|
||||||
|
if (typeof callback !== "function") throw new Error("callback must be a function!");
|
||||||
|
const /** @type {number} */ eventId = ll.imports("GMLIB_Event_API", "emplaceListener")(pluginName, eventName, priority);
|
||||||
|
if (eventId === -1) throw new Error(`Event ${eventName} creation failed!`);
|
||||||
|
ll.exports((...data) => {
|
||||||
|
let /** @type {boolean} */ result = typeof (data.slice(-1)[0]) === "boolean" ? data.pop() : false;
|
||||||
|
try {
|
||||||
|
callback({
|
||||||
|
params: data,
|
||||||
|
cancel: () => result = true,
|
||||||
|
setCancelled: (/** @type {boolean} */value) => { result = value; },
|
||||||
|
isCancelled: () => result,
|
||||||
|
getId: () => eventId,
|
||||||
|
getEventType: () => eventName
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
try {
|
||||||
|
this.mErrorHanlerCallback(error, eventName, eventId, pluginName);
|
||||||
|
} catch { }
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}, pluginName, eventName + "_" + eventId);
|
||||||
|
(this.mEventData[eventName] ??= []).push(eventId);
|
||||||
|
return eventId;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消事件订阅
|
||||||
|
* @param {number} eventId
|
||||||
|
* @param {boolean}
|
||||||
|
*/
|
||||||
|
removeListener: function (eventId) {
|
||||||
|
const result = ll.imports("GMLIB_Event_API", "removeListener")(eventId);
|
||||||
|
if (result) {
|
||||||
|
for (let [eventName, eventIds] of Object.entries(this.mEventData)) {
|
||||||
|
this.mEventData[eventName] = eventIds.filter(id => id !== eventId);
|
||||||
|
if (this.mEventData[eventName].length === 0) delete this.mEventData[eventName];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断事件订阅是否存在
|
||||||
|
* @param {number} eventId
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
hasListener: function (eventId) {
|
||||||
|
return ll.imports("GMLIB_Event_API", "hasListener")(eventId);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取订阅事件优先级
|
||||||
|
* @param {number} eventId
|
||||||
|
* @returns {number?}
|
||||||
|
*/
|
||||||
|
getListenerPriority: function (eventId) {
|
||||||
|
const priority = ll.imports("GMLIB_Event_API", "getListenerPriority")(eventId);
|
||||||
|
return priority === -1 ? undefined : priority;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取订阅事件列表
|
||||||
|
* @param {string | undefined} eventName
|
||||||
|
* @returns {number[] | Object.<string, number[]>}
|
||||||
|
*/
|
||||||
|
getListener: function (eventName) {
|
||||||
|
return eventName === undefined ? this.mEventData : this.mEventData[eventName] ?? [];
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置异常处理回调
|
||||||
|
* @param {function(Error, string, number, string): void} callback
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
setErrorHanlerCallback: function (callback) {
|
||||||
|
if (callback === undefined || typeof callback !== "function") return false;
|
||||||
|
this.mErrorHanlerCallback = callback;
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 事件优先级
|
||||||
|
*/
|
||||||
|
EventPriority: {
|
||||||
|
Highest: 0,
|
||||||
|
High: 100,
|
||||||
|
Normal: 200,
|
||||||
|
Low: 300,
|
||||||
|
Lowest: 400
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,182 @@
|
|||||||
|
// // const getNextCallbackId = ll.import("GMLIB_FormAPI", "getNextFormCallbackId");
|
||||||
|
|
||||||
|
// class ServerSettingForm {
|
||||||
|
// constructor() {
|
||||||
|
// throw new Error("Static class cannot be instantiated");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static getDefaultPriority() {
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "getDefaultPriority")();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static hasTitle() {
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "hasTitle")();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static getTitle() {
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "getTitle")();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static setTitle(title, forceModify = false) {
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "setTitle")(title, forceModify);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static hasIcon() {
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "hasIcon")();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static getIconData() {
|
||||||
|
// return hasIcon() ? ll.import("GMLIB_ServerSettingForm", "getIconData")() : null;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static getIconType() {
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "getIconType")();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static setIcon(data, type = 0, forceModify = false) {
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "setIcon")(data, type, forceModify);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static addLabel(
|
||||||
|
// text,
|
||||||
|
// playerDetector = (pl) => { return true; },
|
||||||
|
// priority = this.getDefaultPriority()
|
||||||
|
// ) {
|
||||||
|
// let detectorId = getNextCallbackId();
|
||||||
|
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "addLabel")(text, detectorId, priority);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// static addInput(
|
||||||
|
// text,
|
||||||
|
// placeholder,
|
||||||
|
// defaultVal,
|
||||||
|
// callback = (pl, input) => { },
|
||||||
|
// playerDetector = (pl) => { return true; },
|
||||||
|
// priority = this.getDefaultPriority()
|
||||||
|
// ) {
|
||||||
|
// let callbackId = getNextCallbackId();
|
||||||
|
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||||
|
// let detectorId = getNextCallbackId();
|
||||||
|
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "addInput")(text, placeholder, defaultVal, callbackId, detectorId, priority);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static addToggle(
|
||||||
|
// text,
|
||||||
|
// defaultVal = false,
|
||||||
|
// callback = (pl, input) => { },
|
||||||
|
// playerDetector = (pl) => { return true; },
|
||||||
|
// priority = this.getDefaultPriority()
|
||||||
|
// ) {
|
||||||
|
// let callbackId = getNextCallbackId();
|
||||||
|
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||||
|
// let detectorId = getNextCallbackId();
|
||||||
|
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "addToggle")(text, defaultVal, callbackId, detectorId, priority);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static addDropdown(
|
||||||
|
// text,
|
||||||
|
// options,
|
||||||
|
// defaultVal = 0,
|
||||||
|
// callback = (pl, input) => { },
|
||||||
|
// playerDetector = (pl) => { return true; },
|
||||||
|
// priority = this.getDefaultPriority()
|
||||||
|
// ) {
|
||||||
|
// let callbackId = getNextCallbackId();
|
||||||
|
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||||
|
// let detectorId = getNextCallbackId();
|
||||||
|
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "addDropdown")(text, options, defaultVal, callbackId, detectorId, priority);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static addSlider(
|
||||||
|
// text,
|
||||||
|
// min,
|
||||||
|
// max,
|
||||||
|
// step = 0.0,
|
||||||
|
// defaultVal = 0.0,
|
||||||
|
// callback = (pl, input) => { },
|
||||||
|
// playerDetector = (pl) => { return true; },
|
||||||
|
// priority = this.getDefaultPriority()
|
||||||
|
// ) {
|
||||||
|
// let callbackId = getNextCallbackId();
|
||||||
|
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||||
|
// let detectorId = getNextCallbackId();
|
||||||
|
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "addSlider")(text, min, max, step, defaultVal, callbackId, detectorId, priority);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static addStepSlider(
|
||||||
|
// text,
|
||||||
|
// steps,
|
||||||
|
// defaultVal = 0,
|
||||||
|
// callback = (pl, input) => { },
|
||||||
|
// playerDetector = (pl) => { return true; },
|
||||||
|
// priority = this.getDefaultPriority()
|
||||||
|
// ) {
|
||||||
|
// let callbackId = getNextCallbackId();
|
||||||
|
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||||
|
// let detectorId = getNextCallbackId();
|
||||||
|
// ll.export(playerDetector, "GMLIB_FORM_CALLBACK", detectorId);
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "addStepSlider")(text, steps, defaultVal, callbackId, detectorId, priority);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// static removeElement(id) {
|
||||||
|
// return ll.import("GMLIB_ServerSettingForm", "removeElement")(id);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// class NpcDialogueForm {
|
||||||
|
// constructor(npcName, sceneName, dialogue) {
|
||||||
|
// this.mFormId = ll.import("GMLIB_NpcDialogueForm", "createForm")(npcName, sceneName, dialogue);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// addButton(button) {
|
||||||
|
// return ll.import("GMLIB_NpcDialogueForm", "addButton")(this.mFormId, button);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// sendTo(pl, callback = (pl, index, type) => { }, free = true) {
|
||||||
|
// let callbackId = getNextCallbackId();
|
||||||
|
// ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||||
|
// ll.import("GMLIB_NpcDialogueForm", "sendTo")(this.mFormId, pl, callbackId);
|
||||||
|
// if (free) {
|
||||||
|
// this.destroy();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// destroy() {
|
||||||
|
// ll.import("GMLIB_NpcDialogueForm", "destroyForm")(this.mFormId);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// class ChestForm {
|
||||||
|
// constructor(npcName, sceneName, dialogue) {
|
||||||
|
// this.mFormId = ll.import("GMLIB_NpcDialogueForm", "createForm")(npcName, sceneName, dialogue);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// addButton(button) {
|
||||||
|
// return ll.import("GMLIB_NpcDialogueForm", "addButton")(this.mFormId, button);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// sendTo(pl, free = true) {
|
||||||
|
// //let callbackId = getNextCallbackId();
|
||||||
|
// //ll.export(callback, "GMLIB_FORM_CALLBACK", callbackId);
|
||||||
|
// //ll.import("GMLIB_NpcDialogueForm", "sendTo")(this.mFormId, pl, callbackId);
|
||||||
|
// //if (free) {
|
||||||
|
// // this.destroy();
|
||||||
|
// //}
|
||||||
|
// }
|
||||||
|
|
||||||
|
// destroy() {
|
||||||
|
// //ll.import("GMLIB_NpcDialogueForm", "destroyForm")(this.mFormId);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// module.exports = {
|
||||||
|
// ServerSettingForm,
|
||||||
|
// NpcDialogueForm,
|
||||||
|
// ChestForm
|
||||||
|
// };
|
||||||
Vendored
+502
-19
@@ -1,5 +1,5 @@
|
|||||||
/** 静态悬浮字类 */
|
/** 静态悬浮字类 */
|
||||||
declare class StaticFloatingText {
|
export class StaticFloatingText {
|
||||||
constructor(
|
constructor(
|
||||||
/** 生成的坐标 */
|
/** 生成的坐标 */
|
||||||
pos: FloatPos,
|
pos: FloatPos,
|
||||||
@@ -73,7 +73,7 @@ declare class StaticFloatingText {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 动态悬浮字类 */
|
/** 动态悬浮字类 */
|
||||||
declare class DynamicFloatingText extends StaticFloatingText {
|
export class DynamicFloatingText extends StaticFloatingText {
|
||||||
constructor(
|
constructor(
|
||||||
/** 生成的坐标 */
|
/** 生成的坐标 */
|
||||||
pos: FloatPos,
|
pos: FloatPos,
|
||||||
@@ -113,7 +113,7 @@ declare class DynamicFloatingText extends StaticFloatingText {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 基础游戏API类 */
|
/** 基础游戏API类 */
|
||||||
declare class Minecraft {
|
export class Minecraft {
|
||||||
private constructor();
|
private constructor();
|
||||||
|
|
||||||
/** 获取服务器平均tps */
|
/** 获取服务器平均tps */
|
||||||
@@ -393,7 +393,7 @@ declare class Minecraft {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 合成表类 */
|
/** 合成表类 */
|
||||||
declare class Recipes {
|
export class Recipes {
|
||||||
private constructor();
|
private constructor();
|
||||||
|
|
||||||
/** 注销合成表 */
|
/** 注销合成表 */
|
||||||
@@ -509,10 +509,32 @@ declare class Recipes {
|
|||||||
/** 解锁条件(也可以填物品命名空间ID) */
|
/** 解锁条件(也可以填物品命名空间ID) */
|
||||||
unlock: "AlwaysUnlocked" | "PlayerHasManyItems" | "PlayerInWater" | "None" | undefined
|
unlock: "AlwaysUnlocked" | "PlayerHasManyItems" | "PlayerInWater" | "None" | undefined
|
||||||
): boolean;
|
): boolean;
|
||||||
|
|
||||||
|
/** 注册自定义有序合成表 */
|
||||||
|
static registerCustomShapedRecipe(
|
||||||
|
/** 合成表唯一标识符 */
|
||||||
|
recipeId: string,
|
||||||
|
/** 合成表摆放方式,数组元素为字符串 */
|
||||||
|
shape: [string, string, string],
|
||||||
|
/** 材料数组 */
|
||||||
|
ingredients: string[],
|
||||||
|
/** 合成结果 */
|
||||||
|
result: Item
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 注册自定义无序合成表 */
|
||||||
|
static registerCustomShapelessRecipe(
|
||||||
|
/** 合成表唯一标识符 */
|
||||||
|
recipeId: string,
|
||||||
|
/** 合成材料 */
|
||||||
|
ingredients: string[],
|
||||||
|
/** 合成结果 */
|
||||||
|
result: Item
|
||||||
|
): boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 实验性功能类 */
|
/** 实验性功能类 */
|
||||||
declare class Experiments {
|
export class Experiments {
|
||||||
private constructor();
|
private constructor();
|
||||||
|
|
||||||
/** 获取所有实验的id */
|
/** 获取所有实验的id */
|
||||||
@@ -546,7 +568,7 @@ declare class Experiments {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 计分板类 */
|
/** 计分板类 */
|
||||||
declare class Scoreboard {
|
export class Scoreboard {
|
||||||
private constructor();
|
private constructor();
|
||||||
|
|
||||||
/** 获取所有跟踪实体 */
|
/** 获取所有跟踪实体 */
|
||||||
@@ -766,7 +788,7 @@ declare class Scoreboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 仿LSE的JsonConfigFile类 */
|
/** 仿LSE的JsonConfigFile类 */
|
||||||
declare class JsonConfig {
|
export class JsonConfig {
|
||||||
constructor(
|
constructor(
|
||||||
/** 文件路径 */
|
/** 文件路径 */
|
||||||
path: string,
|
path: string,
|
||||||
@@ -810,7 +832,7 @@ declare class JsonConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** JSON语言文件 */
|
/** JSON语言文件 */
|
||||||
declare class JsonLanguage extends JsonConfig {
|
export class JsonLanguage extends JsonConfig {
|
||||||
/** 创建或打开一个 Json 语言文件 */
|
/** 创建或打开一个 Json 语言文件 */
|
||||||
constructor(
|
constructor(
|
||||||
/** 文件路径 */
|
/** 文件路径 */
|
||||||
@@ -829,7 +851,7 @@ declare class JsonLanguage extends JsonConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** JSON版翻译类 */
|
/** JSON版翻译类 */
|
||||||
declare class JsonI18n {
|
export class JsonI18n {
|
||||||
/** 加载翻译数据目录 */
|
/** 加载翻译数据目录 */
|
||||||
constructor(
|
constructor(
|
||||||
/** 目录 */
|
/** 目录 */
|
||||||
@@ -873,7 +895,7 @@ declare class JsonI18n {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 版本类 */
|
/** 版本类 */
|
||||||
declare class Version {
|
export class Version {
|
||||||
/** 创建版本对象 */
|
/** 创建版本对象 */
|
||||||
constructor(
|
constructor(
|
||||||
/** 主版本号 */
|
/** 主版本号 */
|
||||||
@@ -922,7 +944,7 @@ declare class Version {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 翻译API类 */
|
/** 翻译API类 */
|
||||||
declare class I18nAPI {
|
export class I18nAPI {
|
||||||
private constructor();
|
private constructor();
|
||||||
|
|
||||||
/** 获取键翻译 */
|
/** 获取键翻译 */
|
||||||
@@ -983,7 +1005,7 @@ declare class I18nAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 玩家信息存储类 */
|
/** 玩家信息存储类 */
|
||||||
declare class UserCache {
|
export class UserCache {
|
||||||
private constructor();
|
private constructor();
|
||||||
|
|
||||||
/** 根据uuid查xuid */
|
/** 根据uuid查xuid */
|
||||||
@@ -1032,6 +1054,458 @@ declare class UserCache {
|
|||||||
static getAllPlayerInfo(): { Xuid: String; Uuid: string; Name: string; }[]
|
static getAllPlayerInfo(): { Xuid: String; Uuid: string; Name: string; }[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PacketDataItem = (
|
||||||
|
{
|
||||||
|
id: number,
|
||||||
|
type: 0x0 | 0x1 | 0x2 | 0x3 | 0x7,
|
||||||
|
value: number
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
id: number,
|
||||||
|
type: 0x4,
|
||||||
|
value: string
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
id: number,
|
||||||
|
type: 0x5,
|
||||||
|
value: NbtCompound
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
id: number,
|
||||||
|
type: 0x6 | 0x8,
|
||||||
|
value: IntPos | FloatPos
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
type PacketData = (
|
||||||
|
| { type: "", value: PacketData | PacketData[] }
|
||||||
|
| { type: "Item", value: Item }
|
||||||
|
| { type: "CompoundTag", value: NbtCompound }
|
||||||
|
| {
|
||||||
|
type: "DataItem",
|
||||||
|
value: PacketDataItem[],
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: "ActorLink",
|
||||||
|
value: {
|
||||||
|
mA: number,
|
||||||
|
mB: number,
|
||||||
|
mType: number,
|
||||||
|
mImmediate: boolean,
|
||||||
|
mPassengerInitiated: boolean,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
| { type: "Vec3" | "BlockPos", value: FloatPos | IntPos }
|
||||||
|
| { type: "Vec2", value: DirectionAngle }
|
||||||
|
| { type: "String" | "Uuid", value: string }
|
||||||
|
| { type: "Bool", value: boolean }
|
||||||
|
| {
|
||||||
|
type:
|
||||||
|
"PacketHeader"
|
||||||
|
| "Byte"
|
||||||
|
| "Double"
|
||||||
|
| "Float"
|
||||||
|
| "SignedBigEndianInt"
|
||||||
|
| "SignedInt"
|
||||||
|
| "SignedInt64"
|
||||||
|
| "SignedShort"
|
||||||
|
| "UnsignedChar"
|
||||||
|
| "UnsignedInt"
|
||||||
|
| "UnsignedInt64"
|
||||||
|
| "UnsignedShort"
|
||||||
|
| "UnsignedVarInt"
|
||||||
|
| "UnsignedVarInt64"
|
||||||
|
| "VarInt"
|
||||||
|
| "VarInt64",
|
||||||
|
value: number,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
/** 二进制流数据包类 */
|
||||||
|
export class GMLIB_BinaryStream {
|
||||||
|
/** 数据包ID */
|
||||||
|
#id: number;
|
||||||
|
/** 数据包是否被销毁 */
|
||||||
|
#destroy: boolean;
|
||||||
|
|
||||||
|
/** 构造二进流数据包 */
|
||||||
|
constructor(
|
||||||
|
/** 数据包数据 */
|
||||||
|
data: PacketData[]?
|
||||||
|
);
|
||||||
|
|
||||||
|
/** 拷贝二进制流数据包 */
|
||||||
|
constructor(
|
||||||
|
/** 要拷贝的二进制流数据包 */
|
||||||
|
stream: GMLIB_BinaryStream
|
||||||
|
);
|
||||||
|
|
||||||
|
/** 获取数据包的ID */
|
||||||
|
getId(): number;
|
||||||
|
|
||||||
|
/** 发送数据包 */
|
||||||
|
sendTo(
|
||||||
|
/** 要发送数据包的玩家对象 */
|
||||||
|
player: Player | Entity,
|
||||||
|
/** 数据包发送后是否销毁 */
|
||||||
|
free: boolean = true
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** 发送数据包到玩家数组 */
|
||||||
|
sendToPlayers(
|
||||||
|
/** 要发送数据包的玩家对象数组 */
|
||||||
|
players: Player[] | Entity[],
|
||||||
|
/** 数据包发送后是否销毁 */
|
||||||
|
free: boolean = true
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** 发送数据包到所有玩家 */
|
||||||
|
sendToAll(
|
||||||
|
/** 数据包发送后是否销毁 */
|
||||||
|
free: boolean = true
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** 发送数据包到维度 */
|
||||||
|
sendToDimension(
|
||||||
|
/** 维度ID */
|
||||||
|
dimid: number,
|
||||||
|
/** 数据包发送后是否销毁 */
|
||||||
|
free: boolean = true
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** 销毁数据包 */
|
||||||
|
destroy(): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** 数据包是否已被销毁 */
|
||||||
|
isDestroy(): boolean;
|
||||||
|
|
||||||
|
/** 重置数据包 */
|
||||||
|
reset(): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** 转换成字符串 */
|
||||||
|
toString(): string;
|
||||||
|
|
||||||
|
/** 写入数据 */
|
||||||
|
write(
|
||||||
|
/** 数据 */
|
||||||
|
data: PacketData | PacketData[]?
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** 写入数据包头部 */
|
||||||
|
writePacketHeader(
|
||||||
|
/** 数据包ID */
|
||||||
|
id: number
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** 写入UUID */
|
||||||
|
writeUuid(
|
||||||
|
/** UUID */
|
||||||
|
value: string
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** 写入物品 */
|
||||||
|
writeItem(
|
||||||
|
/** 物品对象 */
|
||||||
|
value: Item
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** 写入NBT */
|
||||||
|
writeCompoundTag(
|
||||||
|
/** NBT */
|
||||||
|
value: NbtCompound
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** */
|
||||||
|
writeDataItem(
|
||||||
|
/** 数据项 */
|
||||||
|
value: PacketDataItem[]
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
writeActorLink(
|
||||||
|
/** 数据项 */
|
||||||
|
value: { "mA": number, "mB": number, "mType": number, "mImmediate": boolean, "mPassengerInitiated": boolean }
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** 写入浮点数坐标对象 */
|
||||||
|
writeVec3(
|
||||||
|
/** 浮点数坐标对象 */
|
||||||
|
value: FloatPos
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** 写入整数坐标对象 */
|
||||||
|
writeBlockPos(
|
||||||
|
/** 整数坐标对象 */
|
||||||
|
value: IntPos
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** */
|
||||||
|
writeVec2(
|
||||||
|
/** 数据 */
|
||||||
|
value: { "x": number, "z": number }
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** 写入字符串 */
|
||||||
|
writeString(
|
||||||
|
/** 字符串 */
|
||||||
|
value: string
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** 写入布尔值 */
|
||||||
|
writeBool(
|
||||||
|
/** 布尔值 */
|
||||||
|
value: boolean
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** 写入字节 */
|
||||||
|
writeByte(
|
||||||
|
/** 字节 */
|
||||||
|
value: number
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** 写入(双精度)浮点数 */
|
||||||
|
writeDouble(
|
||||||
|
/** 浮点数 */
|
||||||
|
value: number
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** 写入(单精度)浮点数 */
|
||||||
|
writeFloat(
|
||||||
|
/** 浮点数 */
|
||||||
|
value: number
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** */
|
||||||
|
writeSignedBigEndianInt(
|
||||||
|
/** 数值 */
|
||||||
|
value: number
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** */
|
||||||
|
writeSignedInt(
|
||||||
|
/** 数值 */
|
||||||
|
value: number
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** 写入 */
|
||||||
|
writeSignedInt64(
|
||||||
|
/** 数值 */
|
||||||
|
value: number
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** */
|
||||||
|
writeSignedShort(
|
||||||
|
/** 数值 */
|
||||||
|
value: number
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** */
|
||||||
|
writeUnsignedChar(
|
||||||
|
/** 数值 */
|
||||||
|
value: number
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** */
|
||||||
|
writeUnsignedInt(
|
||||||
|
/** 数值 */
|
||||||
|
value: number
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** */
|
||||||
|
writeUnsignedInt64(
|
||||||
|
/** 数值 */
|
||||||
|
value: number
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** */
|
||||||
|
writeUnsignedShort(
|
||||||
|
/** 数值 */
|
||||||
|
value: number
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** */
|
||||||
|
writeUnsignedVarInt(
|
||||||
|
/** 数值 */
|
||||||
|
value: number
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** */
|
||||||
|
writeUnsignedVarInt64(
|
||||||
|
/** 数值 */
|
||||||
|
value: number
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** */
|
||||||
|
writeVarInt(
|
||||||
|
/** 数值 */
|
||||||
|
value: number
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
|
||||||
|
/** */
|
||||||
|
writeVarInt64(
|
||||||
|
/** 数值 */
|
||||||
|
value: number
|
||||||
|
): GMLIB_BinaryStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum ActorType {
|
||||||
|
Undefined = 1,
|
||||||
|
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 {
|
interface Player {
|
||||||
/** (GMLIB)转换成实体对象 */
|
/** (GMLIB)转换成实体对象 */
|
||||||
toEntity(): Entity;
|
toEntity(): Entity;
|
||||||
@@ -1059,7 +1533,7 @@ interface Player {
|
|||||||
/** (GMLIB)获取玩家的rumtimeId */
|
/** (GMLIB)获取玩家的rumtimeId */
|
||||||
getRuntimeId(): number;
|
getRuntimeId(): number;
|
||||||
|
|
||||||
/** (GMLIB)获取玩家饱食度 */
|
/** (GMLIB)获取玩家饥饿值 */
|
||||||
getHungry(): number;
|
getHungry(): number;
|
||||||
|
|
||||||
/** (GMLIB)获取玩家盔甲覆盖百分比 */
|
/** (GMLIB)获取玩家盔甲覆盖百分比 */
|
||||||
@@ -1204,6 +1678,21 @@ interface Entity {
|
|||||||
/** 是否显示粒子效果 */
|
/** 是否显示粒子效果 */
|
||||||
ShowParticles: boolean
|
ShowParticles: boolean
|
||||||
}[];
|
}[];
|
||||||
|
|
||||||
|
/** 实体是否为某类型 */
|
||||||
|
isType(
|
||||||
|
/** 实体类型 */
|
||||||
|
type: ActorType
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 实体是否包含某类型 */
|
||||||
|
hasType(
|
||||||
|
/** 实体类型 */
|
||||||
|
type: ActorType
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
/** 获取实体类型ID */
|
||||||
|
getEntityTypeId(): ActorType;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Block {
|
interface Block {
|
||||||
@@ -1228,9 +1717,6 @@ interface Block {
|
|||||||
/** (GMLIB) */
|
/** (GMLIB) */
|
||||||
canDropWithAnyTool(): boolean;
|
canDropWithAnyTool(): boolean;
|
||||||
|
|
||||||
/** (GMLIB)方块是否不需要工具采集 */
|
|
||||||
isAlwaysDestroyable(): boolean;
|
|
||||||
|
|
||||||
/** (GMLIB)检测方块是否能被玩家挖掘(比如插件拦截) */
|
/** (GMLIB)检测方块是否能被玩家挖掘(比如插件拦截) */
|
||||||
playerWillDestroy(
|
playerWillDestroy(
|
||||||
/** 挖掘的玩家对象 */
|
/** 挖掘的玩家对象 */
|
||||||
@@ -1269,9 +1755,6 @@ interface Item {
|
|||||||
block: Block
|
block: Block
|
||||||
): boolean;
|
): boolean;
|
||||||
|
|
||||||
/** (GMLIB)获取物品可以拥有的附魔 */
|
|
||||||
getLegalEnchants(): string[]
|
|
||||||
|
|
||||||
/** (GMLIB)添加附魔 */
|
/** (GMLIB)添加附魔 */
|
||||||
applyEnchant(
|
applyEnchant(
|
||||||
/** 附魔的命名空间ID */
|
/** 附魔的命名空间ID */
|
||||||
|
|||||||
+771
-93
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "${pluginName}",
|
"name": "${pluginName}",
|
||||||
"entry": "${pluginFile}",
|
"entry": "${pluginFile}",
|
||||||
"version": "0.13.2",
|
"version": "0.13.6",
|
||||||
"author": "GroupMountain",
|
"author": "GroupMountain",
|
||||||
"type": "native",
|
"type": "native",
|
||||||
"passive": true,
|
"passive": true,
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
#include "Global.h"
|
||||||
|
using namespace ll::hash_utils;
|
||||||
|
|
||||||
|
class LegacyScriptBinaryStreamManager {
|
||||||
|
private:
|
||||||
|
int64 mNextBinaryStreamId = 0;
|
||||||
|
std::unordered_map<uint64, std::shared_ptr<GMLIB_BinaryStream>> mBinaryStream;
|
||||||
|
|
||||||
|
public:
|
||||||
|
uint getNextId() { return mNextBinaryStreamId++; }
|
||||||
|
|
||||||
|
void cretateBinaryStream(uint id) { mBinaryStream[id] = std::make_shared<GMLIB_BinaryStream>(); }
|
||||||
|
|
||||||
|
uint64 copyBinaryStream(uint id) {
|
||||||
|
auto nextId = getNextId();
|
||||||
|
cretateBinaryStream(nextId);
|
||||||
|
if(auto bs = getBinaryStream(nextId); bs !=nullptr){
|
||||||
|
getBinaryStream(nextId)->mBuffer = getBinaryStream(id)->mBuffer;
|
||||||
|
}
|
||||||
|
return nextId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void removeBinaryStream(uint64 id) { mBinaryStream.erase(id); }
|
||||||
|
|
||||||
|
std::shared_ptr<GMLIB_BinaryStream> getBinaryStream(uint64 id) {
|
||||||
|
return mBinaryStream.contains(id) ? mBinaryStream.at(id) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
static LegacyScriptBinaryStreamManager& getInstance() {
|
||||||
|
static std::unique_ptr<LegacyScriptBinaryStreamManager> instance;
|
||||||
|
if (!instance) instance = std::make_unique<LegacyScriptBinaryStreamManager>();
|
||||||
|
return *instance;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#define BinaryStreamManager LegacyScriptBinaryStreamManager::getInstance()
|
||||||
|
#define EXPORTAPI(funcName, type, fuc) \
|
||||||
|
RemoteCall::exportAs("GMLIB_BinaryStream_API", funcName, [](uint64 id, type value) -> void { \
|
||||||
|
auto bs = BinaryStreamManager.getBinaryStream(id); \
|
||||||
|
if (bs != nullptr) fuc; \
|
||||||
|
})
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct Info;
|
||||||
|
template <typename T, typename R, typename A, typename... AS>
|
||||||
|
struct Info<R (T::*)(A, AS...)> {
|
||||||
|
using ArgT = A;
|
||||||
|
};
|
||||||
|
#define EXPORTAPI2(T) EXPORTAPI(#T, Info<decltype(&GMLIB_BinaryStream::T)>::ArgT, bs->T(value))
|
||||||
|
|
||||||
|
void Export_BinaryStream_API() {
|
||||||
|
RemoteCall::exportAs("GMLIB_BinaryStream_API", "create", []() -> uint64 {
|
||||||
|
auto id = BinaryStreamManager.getNextId();
|
||||||
|
BinaryStreamManager.cretateBinaryStream(id);
|
||||||
|
return id;
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_BinaryStream_API", "copy", [](uint64 id) -> uint64 {
|
||||||
|
return BinaryStreamManager.copyBinaryStream(id);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_BinaryStream_API", "reset", [](uint64 id) -> void {
|
||||||
|
if (BinaryStreamManager.getBinaryStream(id) == nullptr) BinaryStreamManager.cretateBinaryStream(id);
|
||||||
|
else BinaryStreamManager.getBinaryStream(id)->reset();
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_BinaryStream_API", "sendTo", [](uint64 id, Player* player) -> void {
|
||||||
|
if (auto bs = BinaryStreamManager.getBinaryStream(id); bs != nullptr) bs->sendTo(*player);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_BinaryStream_API", "destroy", [](uint64 id) -> void {
|
||||||
|
BinaryStreamManager.removeBinaryStream(id);
|
||||||
|
});
|
||||||
|
EXPORTAPI("writePacketHeader", int, bs->writePacketHeader((MinecraftPacketIds)value));
|
||||||
|
EXPORTAPI("writeUuid", std::string const&, bs->writeUuid(mce::UUID::fromString(value)));
|
||||||
|
EXPORTAPI("writeItem", ItemStack*, bs->writeType(NetworkItemStackDescriptor(*value)));
|
||||||
|
EXPORTAPI("writeString", std::string const&, bs->writeString(value));
|
||||||
|
EXPORTAPI("writeCompoundTag", CompoundTag*, bs->writeCompoundTag(*value));
|
||||||
|
EXPORTAPI2(writeBool);
|
||||||
|
EXPORTAPI2(writeByte);
|
||||||
|
EXPORTAPI2(writeDouble);
|
||||||
|
EXPORTAPI2(writeFloat);
|
||||||
|
EXPORTAPI2(writeSignedBigEndianInt);
|
||||||
|
EXPORTAPI2(writeSignedInt);
|
||||||
|
EXPORTAPI2(writeSignedInt64);
|
||||||
|
EXPORTAPI2(writeSignedShort);
|
||||||
|
EXPORTAPI2(writeUnsignedChar);
|
||||||
|
EXPORTAPI2(writeUnsignedInt);
|
||||||
|
EXPORTAPI2(writeUnsignedInt64);
|
||||||
|
EXPORTAPI2(writeUnsignedShort);
|
||||||
|
EXPORTAPI2(writeUnsignedVarInt);
|
||||||
|
EXPORTAPI2(writeUnsignedVarInt64);
|
||||||
|
EXPORTAPI2(writeVarInt);
|
||||||
|
EXPORTAPI2(writeVarInt64);
|
||||||
|
}
|
||||||
+266
-326
@@ -1,6 +1,6 @@
|
|||||||
|
#include "GMLIB/Mod/CustomRecipe/CustomRecipe.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
bool isInteger(const std::string& str) {
|
bool isInteger(const std::string& str) {
|
||||||
std::regex pattern("^[+-]?\\d+$");
|
std::regex pattern("^[+-]?\\d+$");
|
||||||
@@ -8,80 +8,61 @@ bool isInteger(const std::string& str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ActorUniqueID parseScriptUniqueID(std::string const& uniqueId) {
|
ActorUniqueID parseScriptUniqueID(std::string const& uniqueId) {
|
||||||
if (!isInteger(uniqueId)) {
|
return isInteger(uniqueId) ? ActorUniqueID(std::stoll(uniqueId)) : ActorUniqueID::INVALID_ID();
|
||||||
return ActorUniqueID::INVALID_ID;
|
|
||||||
}
|
|
||||||
return ActorUniqueID(std::stoll(uniqueId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Export_Compatibility_API() {
|
void Export_Compatibility_API() {
|
||||||
RemoteCall::exportAs("GMLIB_API", "unregisterRecipe", [](std::string const& id) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "unregisterRecipe", [](std::string const& id) -> bool {
|
||||||
auto level = GMLIB_Level::getInstance();
|
return GMLIB_Level::getInstance().has_value() ? GMLIB::Mod::CustomRecipe::unregisterRecipe(id) : false;
|
||||||
if (!level) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return CustomRecipe::unregisterRecipe(id);
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "setCustomPackPath", [](std::string const& path) -> void {
|
RemoteCall::exportAs("GMLIB_API", "setCustomPackPath", [](std::string const& path) -> void {
|
||||||
CustomPacks::addCustomPackPath(path);
|
GMLIB::Mod::CustomPacks::addCustomPackPath(path);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> float {
|
RemoteCall::exportAs("GMLIB_API", "getServerMspt", []() -> double {
|
||||||
auto level = GMLIB_Level::getInstance();
|
return GMLIB_Level::getInstance().transform(
|
||||||
if (!level) {
|
[](GMLIB_Level& level) -> double { return level.getServerMspt(); }
|
||||||
return 0.0f;
|
).value_or(0.0);
|
||||||
}
|
|
||||||
return level->getServerMspt();
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getServerCurrentTps", []() -> float {
|
RemoteCall::exportAs("GMLIB_API", "getServerCurrentTps", []() -> float {
|
||||||
auto level = GMLIB_Level::getInstance();
|
return GMLIB_Level::getInstance()
|
||||||
if (!level) {
|
.transform([](GMLIB_Level& level) -> float { return level.getServerCurrentTps(); })
|
||||||
return 0.0f;
|
.value_or(0.0);
|
||||||
}
|
|
||||||
return level->getServerCurrentTps();
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getServerAverageTps", []() -> float {
|
RemoteCall::exportAs("GMLIB_API", "getServerAverageTps", []() -> double {
|
||||||
auto level = GMLIB_Level::getInstance();
|
return GMLIB_Level::getInstance()
|
||||||
if (!level) {
|
.transform([](GMLIB_Level& level) -> double { return level.getServerAverageTps(); })
|
||||||
return 0.0f;
|
.value_or(0.0);
|
||||||
}
|
|
||||||
return level->getServerAverageTps();
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getAllPlayerUuids", []() -> std::vector<std::string> {
|
RemoteCall::exportAs("GMLIB_API", "getAllPlayerUuids", []() -> std::vector<std::string> {
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
std::vector<mce::UUID> uuids = GMLIB_Player::getAllUuids();
|
for (auto& uuid : GMLIB_Player::getAllUuids()) {
|
||||||
for (auto& uuid : uuids) {
|
|
||||||
result.push_back(uuid.asString());
|
result.push_back(uuid.asString());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerNbt", [](std::string const& uuid) -> std::unique_ptr<CompoundTag> {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerNbt", [](std::string const& uuid) -> std::unique_ptr<CompoundTag> {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
return std::move(GMLIB_Player::getPlayerNbt(mce::UUID::fromString(uuid)));
|
||||||
return std::move(GMLIB_Player::getPlayerNbt(uid));
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"setPlayerNbt",
|
"setPlayerNbt",
|
||||||
[](std::string const& uuid, CompoundTag* nbt, bool forceCreate) -> bool {
|
[](std::string const& uuid, CompoundTag* nbt, bool forceCreate) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
return GMLIB_Player::setPlayerNbt(mce::UUID::fromString(uuid), (GMLIB_CompoundTag&)*nbt, forceCreate);
|
||||||
return GMLIB_Player::setPlayerNbt(uid, *nbt, forceCreate);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"setPlayerNbtTags",
|
"setPlayerNbtTags",
|
||||||
[](std::string const& uuid, CompoundTag* nbt, std::vector<std::string> tags) -> bool {
|
[](std::string const& uuid, CompoundTag* nbt, std::vector<std::string> tags) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
return GMLIB_Player::setPlayerNbtTags(mce::UUID::fromString(uuid), (GMLIB_CompoundTag&)*nbt, tags);
|
||||||
return GMLIB_Player::setPlayerNbtTags(uid, *nbt, tags);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "deletePlayerNbt", [](std::string const& uuid) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "deletePlayerNbt", [](std::string const& uuid) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
return GMLIB_Player::deletePlayerNbt(mce::UUID::fromString(uuid));
|
||||||
return GMLIB_Player::deletePlayerNbt(uid);
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getAllExperiments", []() -> std::vector<int> {
|
RemoteCall::exportAs("GMLIB_API", "getAllExperiments", []() -> std::vector<int> {
|
||||||
auto list = GMLIB_Level::getAllExperiments();
|
|
||||||
std::vector<int> result;
|
std::vector<int> result;
|
||||||
for (auto& key : list) {
|
for (auto& key : GMLIB_Level::getAllExperiments()) {
|
||||||
result.push_back((int)key);
|
result.push_back((int)key);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -97,71 +78,83 @@ void Export_Compatibility_API() {
|
|||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"createFloatingText",
|
"createFloatingText",
|
||||||
[](std::pair<Vec3, int> pos, std::string const& text, bool papi) -> int {
|
[](std::pair<Vec3, int> pos, std::string const& text, bool papi) -> int {
|
||||||
auto& manager = FloatingTextManager::getInstance();
|
auto ft = GMLIB::Server::FloatingTextManager::createStatic(text, pos.first, pos.second, papi);
|
||||||
auto ft = manager.createStatic(text, pos.first, pos.second, papi);
|
GMLIB::Server::FloatingTextManager::getInstance().add(ft);
|
||||||
manager.add(ft);
|
|
||||||
return ft->getRuntimeID();
|
return ft->getRuntimeID();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "setFloatingTextData", [](int id, std::string const& text) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "setFloatingTextData", [](int id, std::string const& text) -> bool {
|
||||||
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
return GMLIB::Server::FloatingTextManager::getInstance()
|
||||||
ft->setText(text);
|
.getFloatingText(id)
|
||||||
|
.transform([&text](GMLIB::Server::FloatingTextBase& ft) -> bool {
|
||||||
|
ft.setText(text);
|
||||||
return true;
|
return true;
|
||||||
}
|
})
|
||||||
return false;
|
.has_value();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "deleteFloatingText", [](int id) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "deleteFloatingText", [](int id) -> bool {
|
||||||
return FloatingTextManager::getInstance().remove(id);
|
return GMLIB::Server::FloatingTextManager::getInstance().remove(id);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "sendFloatingTextToPlayer", [](int id, Player* pl) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "sendFloatingTextToPlayer", [](int id, Player* pl) -> bool {
|
||||||
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
return GMLIB::Server::FloatingTextManager::getInstance()
|
||||||
ft->sendTo(*pl);
|
.getFloatingText(id)
|
||||||
|
.transform([&pl](GMLIB::Server::FloatingTextBase& ft) -> bool {
|
||||||
|
ft.sendTo(*pl);
|
||||||
return true;
|
return true;
|
||||||
}
|
})
|
||||||
return false;
|
.has_value();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "sendFloatingText", [](int id) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "sendFloatingText", [](int id) -> bool {
|
||||||
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
return GMLIB::Server::FloatingTextManager::getInstance()
|
||||||
ft->sendToClients();
|
.getFloatingText(id)
|
||||||
|
.transform([](GMLIB::Server::FloatingTextBase& ft) -> bool {
|
||||||
|
ft.sendToClients();
|
||||||
return true;
|
return true;
|
||||||
}
|
})
|
||||||
return false;
|
.has_value();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "removeFloatingTextFromPlayer", [](int id, Player* pl) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "removeFloatingTextFromPlayer", [](int id, Player* pl) -> bool {
|
||||||
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
return GMLIB::Server::FloatingTextManager::getInstance()
|
||||||
ft->removeFrom(*pl);
|
.getFloatingText(id)
|
||||||
|
.transform([&pl](GMLIB::Server::FloatingTextBase& ft) -> bool {
|
||||||
|
ft.removeFrom(*pl);
|
||||||
return true;
|
return true;
|
||||||
}
|
})
|
||||||
return false;
|
.has_value();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "removeFloatingText", [](int id) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "removeFloatingText", [](int id) -> bool {
|
||||||
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
return GMLIB::Server::FloatingTextManager::getInstance()
|
||||||
ft->removeFromClients();
|
.getFloatingText(id)
|
||||||
|
.transform([](GMLIB::Server::FloatingTextBase& ft) -> bool {
|
||||||
|
ft.removeFromClients();
|
||||||
return true;
|
return true;
|
||||||
}
|
})
|
||||||
return false;
|
.has_value();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "updateClientFloatingTextData", [](int id, Player* pl) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "updateClientFloatingTextData", [](int id, Player* pl) -> bool {
|
||||||
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
return GMLIB::Server::FloatingTextManager::getInstance()
|
||||||
ft->update(*pl);
|
.getFloatingText(id)
|
||||||
|
.transform([&pl](GMLIB::Server::FloatingTextBase& ft) -> bool {
|
||||||
|
ft.update(*pl);
|
||||||
return true;
|
return true;
|
||||||
}
|
})
|
||||||
return false;
|
.has_value();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "updateAllClientsFloatingTextData", [](int id) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "updateAllClientsFloatingTextData", [](int id) -> bool {
|
||||||
if (auto ft = FloatingTextManager::getInstance().getFloatingText(id)) {
|
return GMLIB::Server::FloatingTextManager::getInstance()
|
||||||
ft->updateClients();
|
.getFloatingText(id)
|
||||||
|
.transform([](GMLIB::Server::FloatingTextBase& ft) -> bool {
|
||||||
|
ft.updateClients();
|
||||||
return true;
|
return true;
|
||||||
}
|
})
|
||||||
return false;
|
.has_value();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "isVersionMatched", [](int a, int b, int c) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "isVersionMatched", [](int a, int b, int c) -> bool {
|
||||||
auto version = Version(a, b, c, "", "");
|
return LIB_VERSION >= GMLIB::Version(a, b, c, "", "");
|
||||||
return LIB_VERSION >= version;
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getVersion_LRCA", []() -> std::string { return LIB_VERSION.asString(); });
|
RemoteCall::exportAs("GMLIB_API", "getVersion_LRCA", []() -> std::string { return LIB_VERSION.asString(); });
|
||||||
RemoteCall::exportAs("GMLIB_API", "getVersion_GMLIB", []() -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getVersion_GMLIB", []() -> std::string {
|
||||||
return Version::getLibVersionString();
|
return GMLIB::Version::getLibVersionString();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
@@ -181,16 +174,10 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getResourcePackI18nLanguage", []() -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getResourcePackI18nLanguage", []() -> std::string {
|
||||||
if (GMLIB_Level::getInstance()) {
|
return GMLIB_Level::getInstance().has_value() ? I18nAPI::getCurrentLanguageCode() : "unknown";
|
||||||
return I18nAPI::getCurrentLanguageCode();
|
|
||||||
}
|
|
||||||
return "unknown";
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getSupportedLanguages", []() -> std::vector<std::string> {
|
RemoteCall::exportAs("GMLIB_API", "getSupportedLanguages", []() -> std::vector<std::string> {
|
||||||
if (GMLIB_Level::getInstance()) {
|
return GMLIB_Level::getInstance() ? I18nAPI::getSupportedLanguageCodes() : std::vector<std::string>();
|
||||||
return I18nAPI::getSupportedLanguageCodes();
|
|
||||||
}
|
|
||||||
return {};
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "loadLanguage", [](std::string const& code, std::string const& lang) -> void {
|
RemoteCall::exportAs("GMLIB_API", "loadLanguage", [](std::string const& code, std::string const& lang) -> void {
|
||||||
if (GMLIB_Level::getInstance()) {
|
if (GMLIB_Level::getInstance()) {
|
||||||
@@ -213,188 +200,132 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerPosition", [](std::string const& uuid) -> std::pair<BlockPos, int> {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerPosition", [](std::string const& uuid) -> std::pair<BlockPos, int> {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
return GMLIB_Player::getPlayerPosition(mce::UUID::fromString(uuid))
|
||||||
auto pos = GMLIB_Player::getPlayerPosition(uid);
|
.value_or(std::pair<BlockPos, int>({0, 0, 0}, -1));
|
||||||
if (pos.has_value()) {
|
|
||||||
return pos.value();
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
{0, 0, 0},
|
|
||||||
-1
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"setPlayerPosition",
|
"setPlayerPosition",
|
||||||
[](std::string const& uuid, std::pair<BlockPos, int> pos) -> bool {
|
[](std::string const& uuid, std::pair<BlockPos, int> pos) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
return GMLIB_Player::setPlayerPosition(mce::UUID::fromString(uuid), pos.first, pos.second);
|
||||||
return GMLIB_Player::setPlayerPosition(uid, pos.first, pos.second);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "playerHasScore", [](std::string const& uuid, std::string const& obj) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "playerHasScore", [](std::string const& uuid, std::string const& obj) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
return GMLIB_Player::getPlayerScore(mce::UUID::fromString(uuid), obj).has_value();
|
||||||
if (auto result = GMLIB_Player::getPlayerScore(uid, obj)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerScore", [](std::string const& uuid, std::string const& obj) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerScore", [](std::string const& uuid, std::string const& obj) -> int {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
return GMLIB_Player::getPlayerScore(mce::UUID::fromString(uuid), obj).value_or(0);
|
||||||
if (auto result = GMLIB_Player::getPlayerScore(uid, obj)) {
|
|
||||||
return result.value();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"addPlayerScore",
|
"addPlayerScore",
|
||||||
[](std::string const& uuid, std::string const& obj, int value) -> bool {
|
[](std::string const& uuid, std::string const& obj, int value) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
return GMLIB_Player::setPlayerScore(mce::UUID::fromString(uuid), obj, value, PlayerScoreSetFunction::Add)
|
||||||
if (auto res = GMLIB_Player::setPlayerScore(uid, obj, value, PlayerScoreSetFunction::Add)) {
|
.has_value();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"reducePlayerScore",
|
"reducePlayerScore",
|
||||||
[](std::string const& uuid, std::string const& obj, int value) -> bool {
|
[](std::string const& uuid, std::string const& obj, int value) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
return GMLIB_Player::setPlayerScore(
|
||||||
if (auto res = GMLIB_Player::setPlayerScore(uid, obj, value, PlayerScoreSetFunction::Subtract)) {
|
mce::UUID::fromString(uuid),
|
||||||
return true;
|
obj,
|
||||||
}
|
value,
|
||||||
return false;
|
PlayerScoreSetFunction::Subtract
|
||||||
|
)
|
||||||
|
.has_value();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"setPlayerScore",
|
"setPlayerScore",
|
||||||
[](std::string const& uuid, std::string const& obj, int value) -> bool {
|
[](std::string const& uuid, std::string const& obj, int value) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
return GMLIB_Player::setPlayerScore(mce::UUID::fromString(uuid), obj, value).has_value();
|
||||||
if (auto res = GMLIB_Player::setPlayerScore(uid, obj, value)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "resetPlayerScore", [](std::string const& uuid, std::string const& obj) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "resetPlayerScore", [](std::string const& uuid, std::string const& obj) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
return GMLIB_Player::resetPlayerScore(mce::UUID::fromString(uuid), obj);
|
||||||
return GMLIB_Player::resetPlayerScore(uid, obj);
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "resetPlayerScores", [](std::string const& uuid) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "resetPlayerScores", [](std::string const& uuid) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
return GMLIB_Player::resetPlayerScore(mce::UUID::fromString(uuid));
|
||||||
return GMLIB_Player::resetPlayerScore(uid);
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"entityHasScore",
|
"entityHasScore",
|
||||||
[](std::string const& uniqueId, std::string const& obj) -> bool {
|
[](std::string const& uniqueId, std::string const& obj) -> bool {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
return GMLIB_Scoreboard::getInstance()->getScore(obj, parseScriptUniqueID(uniqueId)).has_value();
|
||||||
if (auto result = GMLIB_Scoreboard::getInstance()->getScore(obj, auid)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityScore", [](std::string const& uniqueId, std::string const& obj) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getEntityScore", [](std::string const& uniqueId, std::string const& obj) -> int {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
return GMLIB_Scoreboard::getInstance()->getScore(obj, parseScriptUniqueID(uniqueId)).value_or(0);
|
||||||
if (auto result = GMLIB_Scoreboard::getInstance()->getScore(obj, auid)) {
|
|
||||||
return result.value();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"addEntityScore",
|
"addEntityScore",
|
||||||
[](std::string const& uniqueId, std::string const& obj, int value) -> bool {
|
[](std::string const& uniqueId, std::string const& obj, int value) -> bool {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
return GMLIB_Scoreboard::getInstance()
|
||||||
if (auto res = GMLIB_Scoreboard::getInstance()->setScore(obj, auid, value, PlayerScoreSetFunction::Add)) {
|
->setScore(obj, parseScriptUniqueID(uniqueId), value, PlayerScoreSetFunction::Add)
|
||||||
return true;
|
.has_value();
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"reduceEntityScore",
|
"reduceEntityScore",
|
||||||
[](std::string const& uniqueId, std::string const& obj, int value) -> bool {
|
[](std::string const& uniqueId, std::string const& obj, int value) -> bool {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
return GMLIB_Scoreboard::getInstance()
|
||||||
if (auto res =
|
->setScore(obj, parseScriptUniqueID(uniqueId), value, PlayerScoreSetFunction::Subtract)
|
||||||
GMLIB_Scoreboard::getInstance()->setScore(obj, auid, value, PlayerScoreSetFunction::Subtract)) {
|
.has_value();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"setEntityScore",
|
"setEntityScore",
|
||||||
[](std::string const& uniqueId, std::string const& obj, int value) -> bool {
|
[](std::string const& uniqueId, std::string const& obj, int value) -> bool {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
return GMLIB_Scoreboard::getInstance()->setScore(obj, parseScriptUniqueID(uniqueId), value).has_value();
|
||||||
if (auto res = GMLIB_Scoreboard::getInstance()->setScore(obj, auid, value)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"resetEntityScore",
|
"resetEntityScore",
|
||||||
[](std::string const& uniqueId, std::string const& obj) -> bool {
|
[](std::string const& uniqueId, std::string const& obj) -> bool {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
return GMLIB_Scoreboard::getInstance()->resetScore(obj, parseScriptUniqueID(uniqueId));
|
||||||
return GMLIB_Scoreboard::getInstance()->resetScore(obj, auid);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "resetEntityScores", [](std::string const& uniqueId) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "resetEntityScores", [](std::string const& uniqueId) -> bool {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
return GMLIB_Scoreboard::getInstance()->resetScore(parseScriptUniqueID(uniqueId));
|
||||||
return GMLIB_Scoreboard::getInstance()->resetScore(auid);
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"fakePlayerHasScore",
|
"fakePlayerHasScore",
|
||||||
[](std::string const& name, std::string const& obj) -> bool {
|
[](std::string const& name, std::string const& obj) -> bool {
|
||||||
if (auto result = GMLIB_Scoreboard::getInstance()->getScore(obj, name)) {
|
return GMLIB_Scoreboard::getInstance()->getScore(obj, name).has_value();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getFakePlayerScore", [](std::string const& name, std::string const& obj) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getFakePlayerScore", [](std::string const& name, std::string const& obj) -> int {
|
||||||
if (auto result = GMLIB_Scoreboard::getInstance()->getScore(obj, name)) {
|
return GMLIB_Scoreboard::getInstance()->getScore(obj, name).value_or(0);
|
||||||
return result.value();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"addFakePlayerScore",
|
"addFakePlayerScore",
|
||||||
[](std::string const& name, std::string const& obj, int value) -> bool {
|
[](std::string const& name, std::string const& obj, int value) -> bool {
|
||||||
if (auto res = GMLIB_Scoreboard::getInstance()->setScore(obj, name, value, PlayerScoreSetFunction::Add)) {
|
return GMLIB_Scoreboard::getInstance()->setScore(obj, name, value, PlayerScoreSetFunction::Add).has_value();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"reduceFakePlayerScore",
|
"reduceFakePlayerScore",
|
||||||
[](std::string const& name, std::string const& obj, int value) -> bool {
|
[](std::string const& name, std::string const& obj, int value) -> bool {
|
||||||
if (auto res =
|
return GMLIB_Scoreboard::getInstance()
|
||||||
GMLIB_Scoreboard::getInstance()->setScore(obj, name, value, PlayerScoreSetFunction::Subtract)) {
|
->setScore(obj, name, value, PlayerScoreSetFunction::Subtract)
|
||||||
return true;
|
.has_value();
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"setFakePlayerScore",
|
"setFakePlayerScore",
|
||||||
[](std::string const& name, std::string const& obj, int value) -> bool {
|
[](std::string const& name, std::string const& obj, int value) -> bool {
|
||||||
if (auto res = GMLIB_Scoreboard::getInstance()->setScore(obj, name, value)) {
|
return GMLIB_Scoreboard::getInstance()->setScore(obj, name, value).has_value();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -408,26 +339,17 @@ void Export_Compatibility_API() {
|
|||||||
return GMLIB_Scoreboard::getInstance()->resetScore(name);
|
return GMLIB_Scoreboard::getInstance()->resetScore(name);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "addObjective", [](std::string const& obj) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "addObjective", [](std::string const& obj) -> bool {
|
||||||
if (auto res = GMLIB_Scoreboard::getInstance()->addObjective(obj)) {
|
return GMLIB_Scoreboard::getInstance()->addObjective(obj).has_value();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"addObjectiveWithDisplayName",
|
"addObjectiveWithDisplayName",
|
||||||
[](std::string const& obj, std::string const& displayName) -> bool {
|
[](std::string const& obj, std::string const& displayName) -> bool {
|
||||||
if (auto res = GMLIB_Scoreboard::getInstance()->addObjective(obj, displayName)) {
|
return GMLIB_Scoreboard::getInstance()->addObjective(obj, displayName).has_value();
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getDisplayName", [](std::string const& obj) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getDisplayName", [](std::string const& obj) -> std::string {
|
||||||
if (auto result = GMLIB_Scoreboard::getInstance()->getObjectiveDisplayName(obj)) {
|
return GMLIB_Scoreboard::getInstance()->getObjectiveDisplayName(obj).value_or("");
|
||||||
return result.value();
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
@@ -450,34 +372,30 @@ void Export_Compatibility_API() {
|
|||||||
return GMLIB_Scoreboard::getInstance()->clearObjectiveDisplay(slot);
|
return GMLIB_Scoreboard::getInstance()->clearObjectiveDisplay(slot);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getAllObjectives", []() -> std::vector<std::string> {
|
RemoteCall::exportAs("GMLIB_API", "getAllObjectives", []() -> std::vector<std::string> {
|
||||||
auto objs = GMLIB_Scoreboard::getInstance()->getObjectives();
|
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
for (auto& obj : objs) {
|
for (auto& obj : GMLIB_Scoreboard::getInstance()->getObjectives()) {
|
||||||
result.push_back(obj->getName());
|
result.push_back(obj->getName());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardPlayers", []() -> std::vector<std::string> {
|
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardPlayers", []() -> std::vector<std::string> {
|
||||||
auto uuids = GMLIB_Scoreboard::getInstance()->getAllPlayerUuids();
|
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
for (auto& uuid : uuids) {
|
for (auto& uuid : GMLIB_Scoreboard::getInstance()->getAllPlayerUuids()) {
|
||||||
result.push_back(uuid.asString());
|
result.push_back(uuid.asString());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardFakePlayers", []() -> std::vector<std::string> {
|
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardFakePlayers", []() -> std::vector<std::string> {
|
||||||
auto names = GMLIB_Scoreboard::getInstance()->getAllFakePlayers();
|
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
for (auto& name : names) {
|
for (auto& name : GMLIB_Scoreboard::getInstance()->getAllFakePlayers()) {
|
||||||
result.push_back(name);
|
result.push_back(name);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardEntities", []() -> std::vector<std::string> {
|
RemoteCall::exportAs("GMLIB_API", "getAllScoreboardEntities", []() -> std::vector<std::string> {
|
||||||
auto uniqueIds = GMLIB_Scoreboard::getInstance()->getAllEntities();
|
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
for (auto& uniqueId : uniqueIds) {
|
for (auto& uniqueId : GMLIB_Scoreboard::getInstance()->getAllEntities()) {
|
||||||
result.push_back(std::to_string(uniqueId.id));
|
result.push_back(std::to_string(uniqueId.rawID));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
@@ -486,26 +404,23 @@ void Export_Compatibility_API() {
|
|||||||
"getAllTrackedTargets",
|
"getAllTrackedTargets",
|
||||||
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
||||||
std::vector<std::unordered_map<std::string, std::string>> result;
|
std::vector<std::unordered_map<std::string, std::string>> result;
|
||||||
auto uuids = GMLIB_Scoreboard::getInstance()->getAllPlayerUuids();
|
for (auto& uuid : GMLIB_Scoreboard::getInstance()->getAllPlayerUuids()) {
|
||||||
for (auto& uuid : uuids) {
|
result.push_back({
|
||||||
std::unordered_map<std::string, std::string> data;
|
{"Type", "Player" },
|
||||||
data["Type"] = "Player";
|
{"Uuid", uuid.asString()}
|
||||||
data["Uuid"] = uuid.asString();
|
});
|
||||||
result.push_back(data);
|
|
||||||
}
|
}
|
||||||
auto names = GMLIB_Scoreboard::getInstance()->getAllFakePlayers();
|
for (auto& name : GMLIB_Scoreboard::getInstance()->getAllFakePlayers()) {
|
||||||
for (auto& name : names) {
|
result.push_back({
|
||||||
std::unordered_map<std::string, std::string> data;
|
{"Type", "FakePlayer"},
|
||||||
data["Type"] = "FakePlayer";
|
{"Name", name }
|
||||||
data["Name"] = name;
|
});
|
||||||
result.push_back(data);
|
|
||||||
}
|
}
|
||||||
auto uniqueIds = GMLIB_Scoreboard::getInstance()->getAllEntities();
|
for (auto& uniqueId : GMLIB_Scoreboard::getInstance()->getAllEntities()) {
|
||||||
for (auto& uniqueId : uniqueIds) {
|
result.push_back({
|
||||||
std::unordered_map<std::string, std::string> data;
|
{"Type", "Entity" },
|
||||||
data["Type"] = "Entity";
|
{"UniqueId", std::to_string(uniqueId.rawID)}
|
||||||
data["UniqueId"] = std::to_string(uniqueId.id);
|
});
|
||||||
result.push_back(data);
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -514,35 +429,28 @@ void Export_Compatibility_API() {
|
|||||||
return ll::service::getLevel()->getPlayer(mce::UUID::fromString(uuid));
|
return ll::service::getLevel()->getPlayer(mce::UUID::fromString(uuid));
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerFromUniqueId", [](std::string const& uniqueId) -> Actor* {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerFromUniqueId", [](std::string const& uniqueId) -> Actor* {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
return ll::service::getLevel()->getPlayer(parseScriptUniqueID(uniqueId));
|
||||||
return ll::service::getLevel()->getPlayer(auid);
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityFromUniqueId", [](std::string const& uniqueId) -> Actor* {
|
RemoteCall::exportAs("GMLIB_API", "getEntityFromUniqueId", [](std::string const& uniqueId) -> Actor* {
|
||||||
auto auid = parseScriptUniqueID(uniqueId);
|
return ll::service::getLevel()->fetchEntity(parseScriptUniqueID(uniqueId), false);
|
||||||
return ll::service::getLevel()->fetchEntity(auid);
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getWorldSpawn", []() -> std::pair<BlockPos, int> {
|
RemoteCall::exportAs("GMLIB_API", "getWorldSpawn", []() -> std::pair<BlockPos, int> {
|
||||||
return {GMLIB_Level::getInstance()->getWorldSpawn(), 0};
|
return {GMLIB_Level::getInstance()->getWorldSpawn(), 0};
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "setWorldSpawn", [](std::pair<BlockPos, int> pos) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "setWorldSpawn", [](std::pair<BlockPos, int> pos) -> bool {
|
||||||
if (pos.second != 0) {
|
if (pos.second != 0) return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
GMLIB_Level::getInstance()->setWorldSpawn(pos.first);
|
GMLIB_Level::getInstance()->setWorldSpawn(pos.first);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerSpawnPoint", [](Player* pl) -> std::pair<BlockPos, int> {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerSpawnPoint", [](Player* pl) -> std::pair<BlockPos, int> {
|
||||||
auto player = (GMLIB_Player*)pl;
|
auto res = ((GMLIB_Player*)pl)->getSpawnPoint();
|
||||||
auto res = player->getSpawnPoint();
|
|
||||||
return {res.first, res.second};
|
return {res.first, res.second};
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "setPlayerSpawnPoint", [](Player* pl, std::pair<BlockPos, int> pos) -> void {
|
RemoteCall::exportAs("GMLIB_API", "setPlayerSpawnPoint", [](Player* pl, std::pair<BlockPos, int> pos) -> void {
|
||||||
auto player = (GMLIB_Player*)pl;
|
((GMLIB_Player*)pl)->setSpawnPoint(pos.first, pos.second);
|
||||||
player->setSpawnPoint(pos.first, pos.second);
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "clearPlayerSpawnPoint", [](Player* pl) -> void {
|
RemoteCall::exportAs("GMLIB_API", "clearPlayerSpawnPoint", [](Player* pl) -> void {
|
||||||
auto player = (GMLIB_Player*)pl;
|
((GMLIB_Player*)pl)->clearSpawnPoint();
|
||||||
player->clearSpawnPoint();
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
@@ -555,55 +463,46 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getXuidByUuid", [](std::string const& uuid) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getXuidByUuid", [](std::string const& uuid) -> std::string {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
return GMLIB::UserCache::getXuidByUuid(mce::UUID::fromString(uuid)).value_or("");
|
||||||
auto result = UserCache::getXuidByUuid(uid);
|
|
||||||
return result ? result.value() : "";
|
|
||||||
});
|
|
||||||
RemoteCall::exportAs("GMLIB_API", "getNameByUuid", [](std::string const& uuid) -> std::string {
|
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
|
||||||
auto result = UserCache::getNameByUuid(uid);
|
|
||||||
return result ? result.value() : "";
|
|
||||||
});
|
|
||||||
RemoteCall::exportAs("GMLIB_API", "getUuidByXuid", [](std::string const& xuid) -> std::string {
|
|
||||||
auto result = UserCache::getUuidByXuid(xuid);
|
|
||||||
return result ? result.value().asString() : "";
|
|
||||||
});
|
|
||||||
RemoteCall::exportAs("GMLIB_API", "getNameByXuid", [](std::string const& xuid) -> std::string {
|
|
||||||
auto result = UserCache::getNameByXuid(xuid);
|
|
||||||
return result ? result.value() : "";
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getXuidByName", [](std::string const& name) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getXuidByName", [](std::string const& name) -> std::string {
|
||||||
auto result = UserCache::getXuidByName(name);
|
return GMLIB::UserCache::getXuidByName(name).value_or("");
|
||||||
return result ? result.value() : "";
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getNameByUuid", [](std::string const& uuid) -> std::string {
|
||||||
|
return GMLIB::UserCache::getNameByUuid(mce::UUID::fromString(uuid)).value_or("");
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getNameByXuid", [](std::string const& xuid) -> std::string {
|
||||||
|
return GMLIB::UserCache::getNameByXuid(xuid).value_or("");
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getUuidByXuid", [](std::string const& xuid) -> std::string {
|
||||||
|
return GMLIB::UserCache::getUuidByXuid(xuid)
|
||||||
|
.transform([](mce::UUID&& uuid) -> std::string { return uuid.asString(); })
|
||||||
|
.value_or("");
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getUuidByName", [](std::string const& name) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getUuidByName", [](std::string const& name) -> std::string {
|
||||||
auto result = UserCache::getUuidByName(name);
|
return GMLIB::UserCache::getUuidByName(name)
|
||||||
return result ? result.value().asString() : "";
|
.transform([](mce::UUID&& uuid) -> std::string { return uuid.asString(); })
|
||||||
});
|
.value_or("");
|
||||||
RemoteCall::exportAs("GMLIB_API", "getUuidByName", [](std::string const& name) -> std::string {
|
|
||||||
auto result = UserCache::getUuidByName(name);
|
|
||||||
return result ? result.value().asString() : "";
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"getAllPlayerInfo",
|
"getAllPlayerInfo",
|
||||||
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
||||||
std::vector<std::unordered_map<std::string, std::string>> result;
|
std::vector<std::unordered_map<std::string, std::string>> result;
|
||||||
UserCache::forEach([&result](const UserCache::UserCacheEntry& entry) {
|
GMLIB::UserCache::forEach([&result](const GMLIB::UserCache::UserCacheEntry& entry) -> void {
|
||||||
std::unordered_map<std::string, std::string> info;
|
result.push_back({
|
||||||
info["Name"] = entry.mName;
|
{"Name", entry.mName },
|
||||||
info["Xuid"] = entry.mXuid;
|
{"Xuid", entry.mXuid },
|
||||||
info["Uuid"] = entry.mUuid.asString();
|
{"Uuid", entry.mUuid.asString()}
|
||||||
result.push_back(info);
|
});
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getBlockRuntimeId", [](std::string const& blockName, short legacyData) -> uint {
|
RemoteCall::exportAs("GMLIB_API", "getBlockRuntimeId", [](std::string const& blockName, short legacyData) -> uint {
|
||||||
if (auto block = Block::tryGetFromRegistry(blockName, legacyData)) {
|
return Block::tryGetFromRegistry(blockName, legacyData)
|
||||||
return block->getRuntimeId();
|
.transform([](const Block& block) -> uint { return block.getRuntimeId(); })
|
||||||
}
|
.value_or(0);
|
||||||
return 0;
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKey", [](Block const* block) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKey", [](Block const* block) -> std::string {
|
||||||
return block->buildDescriptionId();
|
return block->buildDescriptionId();
|
||||||
@@ -657,10 +556,7 @@ void Export_Compatibility_API() {
|
|||||||
return item->canDestroySpecial(*block);
|
return item->canDestroySpecial(*block);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "blockCanDropWithAnyTool", [](Block const* block) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "blockCanDropWithAnyTool", [](Block const* block) -> bool {
|
||||||
return block->canDropWithAnyTool();
|
return !block->requiresCorrectToolForDrops();
|
||||||
});
|
|
||||||
RemoteCall::exportAs("GMLIB_API", "blockIsAlwaysDestroyable", [](Block const* block) -> bool {
|
|
||||||
return block->getMaterial().isAlwaysDestroyable();
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
@@ -676,59 +572,54 @@ void Export_Compatibility_API() {
|
|||||||
return player->pullInEntity(*entity);
|
return player->pullInEntity(*entity);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKeyFromName", [](std::string const& blockName) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getBlockTranslateKeyFromName", [](std::string const& blockName) -> std::string {
|
||||||
if (auto block = Block::tryGetFromRegistry(blockName)) {
|
return Block::tryGetFromRegistry(blockName)
|
||||||
return block->buildDescriptionId();
|
.transform([](const Block& block) -> std::string { return block.buildDescriptionId(); })
|
||||||
}
|
.value_or("tile.unknown.name");
|
||||||
return "tile.unknown.name";
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"getBlockLightEmission",
|
"getBlockLightEmission",
|
||||||
[](std::string const& blockName, short legacyData) -> char {
|
[](std::string const& blockName, short legacyData) -> char {
|
||||||
if (auto block = Block::tryGetFromRegistry(blockName, legacyData)) {
|
return Block::tryGetFromRegistry(blockName)
|
||||||
return (char)block->getLightEmission().value;
|
.transform([](const Block& block) -> char { return (char)block.getLightEmission().mValue; })
|
||||||
}
|
.value_or(-1);
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"getGameRules",
|
"getGameRules",
|
||||||
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
[]() -> std::vector<std::unordered_map<std::string, std::string>> {
|
||||||
auto gameRules = ll::service::getLevel()->getGameRules().getRules();
|
|
||||||
std::vector<std::unordered_map<std::string, std::string>> result;
|
std::vector<std::unordered_map<std::string, std::string>> result;
|
||||||
for (auto& gameRule : gameRules) {
|
for (auto& gameRule : ll::service::getLevel()->getGameRules().getRules()) {
|
||||||
std::unordered_map<std::string, std::string> data;
|
|
||||||
data["Name"] = gameRule.getName();
|
|
||||||
switch (gameRule.getType()) {
|
switch (gameRule.getType()) {
|
||||||
case GameRule::Type::Bool:
|
case GameRule::Type::Bool:
|
||||||
data["Type"] = "Bool";
|
result.push_back({
|
||||||
data["Value"] = std::to_string(gameRule.getBool());
|
{"Name", gameRule.getName() },
|
||||||
|
{"Type", "Bool" },
|
||||||
|
{"Value", std::to_string(gameRule.getBool())}
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
case GameRule::Type::Float:
|
case GameRule::Type::Float:
|
||||||
data["Type"] = "Float";
|
result.push_back({
|
||||||
data["Value"] = std::to_string(gameRule.getFloat());
|
{"Name", gameRule.getName() },
|
||||||
|
{"Type", "Float" },
|
||||||
|
{"Value", std::to_string(gameRule.getFloat())}
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
case GameRule::Type::Int:
|
case GameRule::Type::Int:
|
||||||
data["Type"] = "Int";
|
result.push_back({
|
||||||
data["Value"] = std::to_string(gameRule.getInt());
|
{"Name", gameRule.getName() },
|
||||||
|
{"Type", "Int" },
|
||||||
|
{"Value", std::to_string(gameRule.getInt())}
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
case GameRule::Type::Invalid:
|
case GameRule::Type::Invalid:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
result.push_back(data);
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getLegalEnchants", [](ItemStack const* item) -> std::vector<std::string> {
|
|
||||||
std::vector<int> enchants = EnchantUtils::getLegalEnchants(item->getItem());
|
|
||||||
std::vector<std::string> result;
|
|
||||||
for (auto& enchant : enchants) {
|
|
||||||
result.push_back(Enchant::getEnchant((Enchant::Type)enchant)->getStringId());
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
});
|
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEnchantTypeNameFromId", [](int id) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getEnchantTypeNameFromId", [](int id) -> std::string {
|
||||||
if (auto enchant = Enchant::getEnchant((Enchant::Type)id)) {
|
if (auto enchant = Enchant::getEnchant((Enchant::Type)id)) {
|
||||||
return std::string(enchant->getStringId());
|
return std::string(enchant->getStringId());
|
||||||
@@ -738,29 +629,23 @@ void Export_Compatibility_API() {
|
|||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
"applyEnchant",
|
"applyEnchant",
|
||||||
[](ItemStack const* item, std::string const& typeName, int level, bool allowNonVanilla) -> bool {
|
[](ItemStack* item, std::string const& typeName, int level, bool allowNonVanilla) -> bool {
|
||||||
return EnchantUtils::applyEnchant(
|
return EnchantUtils::applyEnchant(
|
||||||
*(const_cast<ItemStack*>(item)),
|
*item,
|
||||||
Enchant::getEnchantTypeFromName(HashedString(typeName)),
|
Enchant::getEnchantTypeFromName(HashedString(typeName)),
|
||||||
level,
|
level,
|
||||||
allowNonVanilla
|
allowNonVanilla
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "removeEnchants", [](ItemStack const* item) -> void {
|
RemoteCall::exportAs("GMLIB_API", "removeEnchants", [](ItemStack* item) -> void {
|
||||||
EnchantUtils::removeEnchants((ItemStack&)*item);
|
EnchantUtils::removeEnchants(*item);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "hasEnchant", [](ItemStack const* item, std::string const& typeName) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "hasEnchant", [](ItemStack* item, std::string const& typeName) -> bool {
|
||||||
return EnchantUtils::hasEnchant(
|
return EnchantUtils::hasEnchant(Enchant::getEnchantTypeFromName(HashedString(typeName)), *item);
|
||||||
Enchant::getEnchantTypeFromName(HashedString(typeName)),
|
|
||||||
*(const_cast<ItemStack*>(item))
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEnchantLevel", [](ItemStack const* item, std::string const& typeName) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getEnchantLevel", [](ItemStack* item, std::string const& typeName) -> int {
|
||||||
return EnchantUtils::getEnchantLevel(
|
return EnchantUtils::getEnchantLevel(Enchant::getEnchantTypeFromName(HashedString(typeName)), *item);
|
||||||
Enchant::getEnchantTypeFromName(HashedString(typeName)),
|
|
||||||
*(const_cast<ItemStack*>(item))
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_API",
|
||||||
@@ -775,10 +660,10 @@ void Export_Compatibility_API() {
|
|||||||
[](Player* player, ItemStack const* item, bool randomly) -> bool { return player->drop(*item, randomly); }
|
[](Player* player, ItemStack const* item, bool randomly) -> bool { return player->drop(*item, randomly); }
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerRuntimeId", [](Player* player) -> uint64 {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerRuntimeId", [](Player* player) -> uint64 {
|
||||||
return player->getRuntimeID().id;
|
return player->getRuntimeID().rawID;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityRuntimeId", [](Actor* entity) -> uint64 {
|
RemoteCall::exportAs("GMLIB_API", "getEntityRuntimeId", [](Actor* entity) -> uint64 {
|
||||||
return entity->getRuntimeID().id;
|
return entity->getRuntimeID().rawID;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityNameTag", [](Actor* entity) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getEntityNameTag", [](Actor* entity) -> std::string {
|
||||||
return entity->getNameTag();
|
return entity->getNameTag();
|
||||||
@@ -804,8 +689,8 @@ void Export_Compatibility_API() {
|
|||||||
RemoteCall::exportAs("GMLIB_API", "getItemRepairCost", [](ItemStack const* item) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getItemRepairCost", [](ItemStack const* item) -> int {
|
||||||
return item->getBaseRepairCost();
|
return item->getBaseRepairCost();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "setItemRepairCost", [](ItemStack const* item, int cost) -> void {
|
RemoteCall::exportAs("GMLIB_API", "setItemRepairCost", [](ItemStack* item, int cost) -> void {
|
||||||
(*(const_cast<ItemStack*>(item))).setRepairCost(cost);
|
(*item).setRepairCost(cost);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getItemCanDestroy", [](ItemStack const* item) -> std::vector<std::string> {
|
RemoteCall::exportAs("GMLIB_API", "getItemCanDestroy", [](ItemStack const* item) -> std::vector<std::string> {
|
||||||
std::vector<std::string> result = {};
|
std::vector<std::string> result = {};
|
||||||
@@ -836,7 +721,7 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerHungry", [](Player* player) -> float {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerHungry", [](Player* player) -> float {
|
||||||
return player->getMutableAttribute(Player::HUNGER)->getCurrentValue();
|
return player->getMutableAttribute(Player::HUNGER())->getCurrentValue();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerArmorCoverPercentage", [](Player* player) -> float {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerArmorCoverPercentage", [](Player* player) -> float {
|
||||||
return player->getArmorCoverPercentage();
|
return player->getArmorCoverPercentage();
|
||||||
@@ -845,7 +730,7 @@ void Export_Compatibility_API() {
|
|||||||
return player->getArmorValue();
|
return player->getArmorValue();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityOwnerUniqueId", [](Actor* entity) -> int64 {
|
RemoteCall::exportAs("GMLIB_API", "getEntityOwnerUniqueId", [](Actor* entity) -> int64 {
|
||||||
return entity->getOwnerId().id;
|
return entity->getOwnerId().rawID;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getItemCategoryName", [](ItemStack const* item) -> std::string {
|
RemoteCall::exportAs("GMLIB_API", "getItemCategoryName", [](ItemStack const* item) -> std::string {
|
||||||
return item->getCategoryName();
|
return item->getCategoryName();
|
||||||
@@ -863,7 +748,7 @@ void Export_Compatibility_API() {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "setPlayerUIItem", [](Player* player, int slot, ItemStack const* item) -> void {
|
RemoteCall::exportAs("GMLIB_API", "setPlayerUIItem", [](Player* player, int slot, ItemStack const* item) -> void {
|
||||||
player->setPlayerUIItem((PlayerUISlot)slot, *item);
|
player->setPlayerUIItem((PlayerUISlot)slot, *item, false);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getPlayerUIItem", [](Player* player, int slot) -> ItemStack* {
|
RemoteCall::exportAs("GMLIB_API", "getPlayerUIItem", [](Player* player, int slot) -> ItemStack* {
|
||||||
return const_cast<ItemStack*>(&player->getPlayerUIItem((PlayerUISlot)slot));
|
return const_cast<ItemStack*>(&player->getPlayerUIItem((PlayerUISlot)slot));
|
||||||
@@ -879,8 +764,7 @@ void Export_Compatibility_API() {
|
|||||||
return magic_enum::enum_name(container->getContainerType()).data();
|
return magic_enum::enum_name(container->getContainerType()).data();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "hasPlayerNbt", [](std::string const& uuid) -> bool {
|
RemoteCall::exportAs("GMLIB_API", "hasPlayerNbt", [](std::string const& uuid) -> bool {
|
||||||
auto uid = mce::UUID::fromString(uuid);
|
return GMLIB_Player::getPlayerNbt(mce::UUID::fromString(uuid)) != nullptr;
|
||||||
return GMLIB_Player::getPlayerNbt(uid) ? true : false;
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getItemMaxCount", [](ItemStack const* item) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getItemMaxCount", [](ItemStack const* item) -> int {
|
||||||
return item->getMaxStackSize();
|
return item->getMaxStackSize();
|
||||||
@@ -899,25 +783,25 @@ void Export_Compatibility_API() {
|
|||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDuration", [](Actor* entity, int effectId) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDuration", [](Actor* entity, int effectId) -> int {
|
||||||
if (auto effect = entity->getEffect(effectId)) {
|
if (auto effect = entity->getEffect(effectId)) {
|
||||||
return effect->mDuration;
|
return effect->mDuration->mValue;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDurationEasy", [](Actor* entity, int effectId) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDurationEasy", [](Actor* entity, int effectId) -> int {
|
||||||
if (auto effect = entity->getEffect(effectId)) {
|
if (auto effect = entity->getEffect(effectId)) {
|
||||||
return effect->mDurationEasy;
|
return effect->mDurationEasy->transform([](auto&& duration) -> int { return duration.mValue; }).value_or(0);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDurationHard", [](Actor* entity, int effectId) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDurationHard", [](Actor* entity, int effectId) -> int {
|
||||||
if (auto effect = entity->getEffect(effectId)) {
|
if (auto effect = entity->getEffect(effectId)) {
|
||||||
return effect->mDurationHard;
|
return effect->mDurationHard->transform([](auto&& duration) -> int { return duration.mValue; }).value_or(0);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDurationNormal", [](Actor* entity, int effectId) -> int {
|
RemoteCall::exportAs("GMLIB_API", "getEntityEffectDurationNormal", [](Actor* entity, int effectId) -> int {
|
||||||
if (auto effect = entity->getEffect(effectId)) {
|
if (auto effect = entity->getEffect(effectId)) {
|
||||||
return effect->mDurationNormal;
|
return effect->mDurationNormal->transform([](auto&& duration) -> int { return duration.mValue; }).value_or(0);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
@@ -937,10 +821,9 @@ void Export_Compatibility_API() {
|
|||||||
return entity->hasEffect(*MobEffect::getById(effectId));
|
return entity->hasEffect(*MobEffect::getById(effectId));
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getGameDifficulty", []() -> int {
|
RemoteCall::exportAs("GMLIB_API", "getGameDifficulty", []() -> int {
|
||||||
if (auto level = ll::service::getLevel()) {
|
return ll::service::getLevel().transform(
|
||||||
return (int)level->getDifficulty();
|
[](Level& level) -> int { return (int)level.getDifficulty(); }
|
||||||
}
|
).value_or(-1);
|
||||||
return -1;
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "setGameDifficulty", [](int difficulty) -> void {
|
RemoteCall::exportAs("GMLIB_API", "setGameDifficulty", [](int difficulty) -> void {
|
||||||
if (auto level = ll::service::getLevel()) {
|
if (auto level = ll::service::getLevel()) {
|
||||||
@@ -948,14 +831,71 @@ void Export_Compatibility_API() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "getDefaultGameMode", []() -> int {
|
RemoteCall::exportAs("GMLIB_API", "getDefaultGameMode", []() -> int {
|
||||||
if (auto level = ll::service::getLevel()) {
|
return ll::service::getLevel().transform(
|
||||||
return (int)level->getDefaultGameType();
|
[](Level& level) -> int { return (int)level.getDefaultGameType(); }
|
||||||
}
|
).value_or(-1);
|
||||||
return -1;
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLIB_API", "setDefaultGameMode", [](int gameMode) -> void {
|
RemoteCall::exportAs("GMLIB_API", "setDefaultGameMode", [](int gameMode) -> void {
|
||||||
if (auto level = ll::service::getLevel()) {
|
if (auto level = ll::service::getLevel()) {
|
||||||
level->setDefaultGameType((GameType)gameMode);
|
level->setDefaultGameType((GameType)gameMode);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"registerCustomShapelessRecipe",
|
||||||
|
[](std::string const& recipe_id, std::vector<std::string> ingredients, ItemStack* result) -> void {
|
||||||
|
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||||
|
std::vector<Recipes::Type> types;
|
||||||
|
char rt = 'A';
|
||||||
|
for (auto& ing : ingredients) {
|
||||||
|
auto ingredient = RecipeIngredient{ing, 0,1};
|
||||||
|
types.push_back(Recipes::Type{
|
||||||
|
(Item*)ingredient.getItem(),
|
||||||
|
ingredient.getBlock(),
|
||||||
|
ingredient,
|
||||||
|
rt++
|
||||||
|
});
|
||||||
|
}
|
||||||
|
GMLIB::Mod::CustomRecipe::registerShapelessCraftingTableRecipe(recipe_id, types, *result);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs(
|
||||||
|
"GMLIB_API",
|
||||||
|
"registerCustomShapedRecipe",
|
||||||
|
[](std::string const& recipe_id,
|
||||||
|
std::vector<std::string> shape,
|
||||||
|
std::vector<std::string> ingredients,
|
||||||
|
ItemStack* result) -> void {
|
||||||
|
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||||
|
std::vector<Recipes::Type> types;
|
||||||
|
char rt = 'A';
|
||||||
|
for (auto& ing : ingredients) {
|
||||||
|
auto ingredient = RecipeIngredient{ing, 0, 1};
|
||||||
|
types.push_back(Recipes::Type{(Item*)ingredient.getItem(), ingredient.getBlock(), ingredient, rt++});
|
||||||
|
}
|
||||||
|
auto tmp = RecipeUnlockingRequirement();
|
||||||
|
tmp.mContext = RecipeUnlockingRequirement::UnlockingContext::AlwaysUnlocked;
|
||||||
|
ll::service::bedrock::getLevel()->getRecipes().addShapedRecipe(
|
||||||
|
recipe_id,
|
||||||
|
ItemInstance(*result),
|
||||||
|
shape,
|
||||||
|
types,
|
||||||
|
{"crafting_table"},
|
||||||
|
50,
|
||||||
|
nullptr,
|
||||||
|
tmp,
|
||||||
|
SemVersion(1, 20, 80, "", ""),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "entityIsType", [](Actor* entity, int type) -> bool {
|
||||||
|
return entity->isType((ActorType)type);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "entityHasType", [](Actor* entity, int type) -> bool {
|
||||||
|
return entity->hasType((ActorType)type);
|
||||||
|
});
|
||||||
|
RemoteCall::exportAs("GMLIB_API", "getEntityTypeId", [](Actor* entity) -> int {
|
||||||
|
return (int)entity->getEntityTypeId();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
+13
-12
@@ -1,12 +1,10 @@
|
|||||||
#include "Entry.h"
|
#include "Entry.h"
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
ll::Logger logger(PLUGIN_NAME);
|
namespace gmlib {
|
||||||
|
|
||||||
namespace GMLIB {
|
LegacyRemoteCallApi& LegacyRemoteCallApi::getInstance() {
|
||||||
|
static LegacyRemoteCallApi instance;
|
||||||
std::unique_ptr<LegacyRemoteCallApi>& LegacyRemoteCallApi::getInstance() {
|
|
||||||
static std::unique_ptr<LegacyRemoteCallApi> instance;
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -16,14 +14,17 @@ bool LegacyRemoteCallApi::load() {
|
|||||||
Export_Compatibility_API();
|
Export_Compatibility_API();
|
||||||
ExportPAPI();
|
ExportPAPI();
|
||||||
Export_Event_API();
|
Export_Event_API();
|
||||||
logger.info("GMLIB-LegacyRemoteCallApi Loaded!");
|
Export_BinaryStream_API();
|
||||||
logger.info(
|
// Export_Form_API();
|
||||||
|
auto logger = ll::io::LoggerRegistry::getInstance().getOrCreate(PLUGIN_NAME);
|
||||||
|
logger->info("GMLIB-LegacyRemoteCallApi Loaded!");
|
||||||
|
logger->info(
|
||||||
"Loaded Version: {} with {}",
|
"Loaded Version: {} with {}",
|
||||||
fmt::format(fg(fmt::color::pink), "GMLIB-" + Version::getLibVersionString()),
|
fmt::format(fg(fmt::color::pink), "GMLIB-" + GMLIB::Version::getLibVersionString()),
|
||||||
fmt::format(fg(fmt::color::light_green), "GMLIB-LegacyRemoteCallApi-" + LIB_VERSION.asString())
|
fmt::format(fg(fmt::color::light_green), "GMLIB-LegacyRemoteCallApi-" + LIB_VERSION.asString())
|
||||||
);
|
);
|
||||||
logger.info("Author: GroupMountain");
|
logger->info("Author: GroupMountain");
|
||||||
logger.info("Repository: https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi");
|
logger->info("Repository: https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,6 +32,6 @@ bool LegacyRemoteCallApi::enable() { return true; }
|
|||||||
|
|
||||||
bool LegacyRemoteCallApi::disable() { return true; }
|
bool LegacyRemoteCallApi::disable() { return true; }
|
||||||
|
|
||||||
} // namespace GMLIB
|
} // namespace gmlib
|
||||||
|
|
||||||
LL_REGISTER_MOD(LegacyRemoteCallApi, LegacyRemoteCallApi::getInstance());
|
LL_REGISTER_MOD(gmlib::LegacyRemoteCallApi, gmlib::LegacyRemoteCallApi::getInstance());
|
||||||
|
|||||||
+4
-4
@@ -2,14 +2,14 @@
|
|||||||
#include <ll/api/mod/NativeMod.h>
|
#include <ll/api/mod/NativeMod.h>
|
||||||
#include <ll/api/mod/RegisterHelper.h>
|
#include <ll/api/mod/RegisterHelper.h>
|
||||||
|
|
||||||
namespace GMLIB {
|
namespace gmlib {
|
||||||
|
|
||||||
class LegacyRemoteCallApi {
|
class LegacyRemoteCallApi {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static std::unique_ptr<LegacyRemoteCallApi>& getInstance();
|
static LegacyRemoteCallApi& getInstance();
|
||||||
|
|
||||||
LegacyRemoteCallApi(ll::mod::NativeMod& self) : mSelf(self) {}
|
LegacyRemoteCallApi() : mSelf(*ll::mod::NativeMod::current()) {}
|
||||||
|
|
||||||
[[nodiscard]] ll::mod::NativeMod& getSelf() const { return mSelf; }
|
[[nodiscard]] ll::mod::NativeMod& getSelf() const { return mSelf; }
|
||||||
|
|
||||||
@@ -30,4 +30,4 @@ private:
|
|||||||
ll::mod::NativeMod& mSelf;
|
ll::mod::NativeMod& mSelf;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace GMLIB
|
} // namespace gmlib
|
||||||
|
|||||||
+288
-265
@@ -1,271 +1,320 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
using namespace ll::hash_utils;
|
using namespace ll::hash_utils;
|
||||||
|
|
||||||
|
class EventManager {
|
||||||
|
private:
|
||||||
|
std::unordered_map<ullong, ll::event::ListenerPtr> mEventIds;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static EventManager& getInstance() {
|
||||||
|
static std::unique_ptr<EventManager> instance;
|
||||||
|
if (!instance) instance = std::make_unique<EventManager>();
|
||||||
|
return *instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
ullong getNextId() {
|
||||||
|
auto id = mEventIds.size();
|
||||||
|
mEventIds.emplace(id, nullptr);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool addListener(ullong id, ll::event::ListenerPtr const& listener) {
|
||||||
|
if (mEventIds.contains(id) && mEventIds[id]) return false;
|
||||||
|
mEventIds[id] = listener;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool removeListener(ullong id) {
|
||||||
|
if (ll::event::EventBus::getInstance().removeListener(mEventIds[id])) {
|
||||||
|
mEventIds[id] = nullptr;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasListener(ullong id) { return mEventIds.contains(id) && mEventIds[id]; }
|
||||||
|
|
||||||
|
ll::event::ListenerPtr getListener(ullong id) { return mEventIds.contains(id) ? mEventIds[id] : nullptr; }
|
||||||
|
};
|
||||||
|
|
||||||
|
#define REGISTER_EVENT_LISTEN(eventType, paramType, params, cancelFun, ...) \
|
||||||
|
auto eventPtr = ll::event::EventBus::getInstance().emplaceListener<eventType>( \
|
||||||
|
[pluginName, eventName, eventId](eventType& event) -> void { \
|
||||||
|
if (!RemoteCall::hasFunc(pluginName, eventName + "_" + std::to_string(eventId))) { \
|
||||||
|
EventManager::getInstance().removeListener(eventId); \
|
||||||
|
return; \
|
||||||
|
} \
|
||||||
|
try { \
|
||||||
|
__VA_ARGS__ \
|
||||||
|
auto result = \
|
||||||
|
RemoteCall::importAs<bool paramType>(pluginName, eventName + "_" + std::to_string(eventId)) \
|
||||||
|
params; \
|
||||||
|
cancelFun \
|
||||||
|
} catch (...) {} \
|
||||||
|
}, \
|
||||||
|
ll::event::EventPriority(priority) \
|
||||||
|
); \
|
||||||
|
return eventId
|
||||||
|
|
||||||
void Export_Event_API() {
|
void Export_Event_API() {
|
||||||
auto eventBus = &ll::event::EventBus::getInstance();
|
RemoteCall::exportAs("GMLIB_Event_API", "removeListener", [](ll::event::ListenerId eventId) -> bool {
|
||||||
|
return EventManager::getInstance().removeListener(eventId);
|
||||||
|
});
|
||||||
|
|
||||||
|
RemoteCall::exportAs("GMLIB_Event_API", "hasListener", [](ll::event::ListenerId eventId) -> bool {
|
||||||
|
return EventManager::getInstance().hasListener(eventId);
|
||||||
|
});
|
||||||
|
|
||||||
|
RemoteCall::exportAs("GMLIB_Event_API", "getListenerPriority", [](ll::event::ListenerId eventId) -> int {
|
||||||
|
if (auto event = EventManager::getInstance().getListener(eventId); event != nullptr) {
|
||||||
|
return (int)event->getPriority();
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
});
|
||||||
|
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
"GMLIB_API",
|
"GMLIB_Event_API",
|
||||||
"callCustomEvent",
|
"emplaceListener",
|
||||||
[eventBus](std::string const& eventName, std::string const& eventId) -> bool {
|
[](std::string const& pluginName, std::string const& eventName, int priority) -> llong {
|
||||||
if (!RemoteCall::hasFunc(eventName, eventId)) return false;
|
auto eventId = EventManager::getInstance().getNextId();
|
||||||
switch (doHash(eventName)) {
|
switch (doHash(eventName)) {
|
||||||
case doHash("onClientLogin"): {
|
case doHash("ll::ServerStoppingEvent"): {
|
||||||
auto Call = RemoteCall::importAs<bool(
|
REGISTER_EVENT_LISTEN(ll::event::ServerStoppingEvent, (), (), , );
|
||||||
std::string const& realName,
|
}
|
||||||
|
case doHash("gmlib::ClientLoginAfterEvent"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::PacketEvent::ClientLoginAfterEvent,
|
||||||
|
(std::string const& realName,
|
||||||
std::string const& uuid,
|
std::string const& uuid,
|
||||||
std::string const& serverXuid,
|
std::string const& serverXuid,
|
||||||
std::string const& clientXuid
|
std::string const& clientXuid),
|
||||||
)>(eventName, eventId);
|
(event.getRealName(),
|
||||||
eventBus->emplaceListener<Event::PacketEvent::ClientLoginAfterEvent>(
|
event.getUuid().asString(),
|
||||||
[Call](Event::PacketEvent::ClientLoginAfterEvent& ev) {
|
event.getServerAuthXuid(),
|
||||||
try {
|
event.getClientAuthXuid()),
|
||||||
Call(
|
if (result) event.disConnectClient();
|
||||||
ev.getRealName(),
|
|
||||||
ev.getUuid().asString(),
|
|
||||||
ev.getServerAuthXuid(),
|
|
||||||
ev.getClientAuthXuid()
|
|
||||||
);
|
);
|
||||||
} catch (...) {}
|
|
||||||
}
|
}
|
||||||
|
case doHash("gmlib::WeatherUpdateBeforeEvent"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::LevelEvent::WeatherUpdateBeforeEvent,
|
||||||
|
(float rainLevel, int rainTime, float lightningLevel, int lightningTime, bool isCancelled),
|
||||||
|
(event.getRainLevel(),
|
||||||
|
event.getRainingLastTick(),
|
||||||
|
event.getLightningLevel(),
|
||||||
|
event.getLightningLastTick(),
|
||||||
|
event.isCancelled()),
|
||||||
|
event.setCancelled(result);
|
||||||
);
|
);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
case doHash("onWeatherChange"): {
|
case doHash("gmlib::WeatherUpdateAfterEvent"): {
|
||||||
auto Call =
|
REGISTER_EVENT_LISTEN(
|
||||||
RemoteCall::importAs<bool(int lightningLevel, int rainLevel, int lightningLast, int rainLast)>(
|
GMLIB::Event::LevelEvent::WeatherUpdateAfterEvent,
|
||||||
eventName,
|
(float rainLevel, int rainTime, float lightningLevel, int lightningTime),
|
||||||
eventId
|
(event.getRainLevel(),
|
||||||
|
event.getRainingLastTick(),
|
||||||
|
event.getLightningLevel(),
|
||||||
|
event.getLightningLastTick()),
|
||||||
|
,
|
||||||
);
|
);
|
||||||
eventBus->emplaceListener<Event::LevelEvent::WeatherUpdateBeforeEvent>(
|
}
|
||||||
[Call](Event::LevelEvent::WeatherUpdateBeforeEvent& ev) {
|
case doHash("gmlib::MobPickupItemBeforeEvent"): {
|
||||||
bool result = true;
|
REGISTER_EVENT_LISTEN(
|
||||||
try {
|
GMLIB::Event::EntityEvent::MobPickupItemBeforeEvent,
|
||||||
result = Call(
|
(Actor * mob, Actor * item, bool isCancelled),
|
||||||
ev.getLightningLevel(),
|
(&event.self(), (Actor*)&event.getItemActor(), event.isCancelled()),
|
||||||
ev.getRainLevel(),
|
event.setCancelled(result);
|
||||||
ev.getLightningLastTick(),
|
|
||||||
ev.getRainingLastTick()
|
|
||||||
);
|
);
|
||||||
} catch (...) {}
|
|
||||||
if (!result) {
|
|
||||||
ev.cancel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
case doHash("gmlib::MobPickupItemAfterEvent"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::EntityEvent::MobPickupItemAfterEvent,
|
||||||
|
(Actor * mob, Actor * item),
|
||||||
|
(&event.self(), (Actor*)&event.getItemActor()),
|
||||||
|
,
|
||||||
);
|
);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case doHash("onMobPick"): {
|
|
||||||
auto Call = RemoteCall::importAs<bool(Actor * mob, Actor * item)>(eventName, eventId);
|
|
||||||
eventBus->emplaceListener<Event::EntityEvent::MobPickupItemBeforeEvent>(
|
|
||||||
[Call](Event::EntityEvent::MobPickupItemBeforeEvent& ev) {
|
|
||||||
bool result = true;
|
|
||||||
try {
|
|
||||||
result = Call(&ev.self(), (Actor*)&ev.getItemActor());
|
|
||||||
} catch (...) {}
|
|
||||||
if (!result) {
|
|
||||||
ev.cancel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
case doHash("gmlib::ItemActorSpawnBeforeEvent"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::EntityEvent::ItemActorSpawnBeforeEvent,
|
||||||
|
(ItemStack * item, std::pair<Vec3, int> position, int64 spawnerUniqueId, bool isCancelled),
|
||||||
|
(&event.getItem(),
|
||||||
|
{event.getPosition(), event.getBlockSource().getDimensionId().id},
|
||||||
|
event.getSpawner().has_value() ? event.getSpawner()->getOrCreateUniqueID().rawID : -1,
|
||||||
|
event.isCancelled()),
|
||||||
|
event.setCancelled(result);
|
||||||
);
|
);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
case doHash("onItemTrySpawn"): {
|
case doHash("gmlib::ItemActorSpawnAfterEvent"): {
|
||||||
auto Call =
|
REGISTER_EVENT_LISTEN(
|
||||||
RemoteCall::importAs<bool(const ItemStack* item, std::pair<Vec3, int> position, Actor* spawner)>(
|
GMLIB::Event::EntityEvent::ItemActorSpawnAfterEvent,
|
||||||
eventName,
|
(Actor * item, std::pair<Vec3, int> position, int64 spawnerUniqueId),
|
||||||
eventId
|
(&event.self(),
|
||||||
|
{event.getPosition(), event.getBlockSource().getDimensionId().id},
|
||||||
|
event.getSpawner().has_value() ? event.getSpawner()->getOrCreateUniqueID().rawID : -1),
|
||||||
|
,
|
||||||
);
|
);
|
||||||
eventBus->emplaceListener<Event::EntityEvent::ItemActorSpawnBeforeEvent>(
|
|
||||||
[Call](Event::EntityEvent::ItemActorSpawnBeforeEvent& ev) {
|
|
||||||
auto pos = ev.getPosition();
|
|
||||||
auto dimid = ev.getBlockSource().getDimensionId().id;
|
|
||||||
std::pair<Vec3, int> lsePos = {pos, dimid};
|
|
||||||
bool result = true;
|
|
||||||
try {
|
|
||||||
result = Call(&ev.getItem(), lsePos, ev.getSpawner());
|
|
||||||
} catch (...) {}
|
|
||||||
if (!result) {
|
|
||||||
ev.cancel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
case doHash("gmlib::ActorChangeDimensionBeforeEvent"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::EntityEvent::ActorChangeDimensionBeforeEvent,
|
||||||
|
(Actor * entity, int toDimId, bool isCancelled),
|
||||||
|
(&event.self(), event.getToDimensionId(), event.isCancelled()),
|
||||||
|
event.setCancelled(result);
|
||||||
);
|
);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
case doHash("onItemSpawned"): {
|
case doHash("gmlib::ActorChangeDimensionAfterEvent"): {
|
||||||
auto Call = RemoteCall::importAs<
|
REGISTER_EVENT_LISTEN(
|
||||||
bool(const ItemStack* item, Actor* itemActor, std::pair<Vec3, int> position, Actor* spawner)>(
|
GMLIB::Event::EntityEvent::ActorChangeDimensionAfterEvent,
|
||||||
eventName,
|
(Actor * entity, int fromDimId, int toDimId),
|
||||||
eventId
|
(&event.self(), event.getFromDimensionId(), event.getToDimensionId()),
|
||||||
|
,
|
||||||
);
|
);
|
||||||
eventBus->emplaceListener<Event::EntityEvent::ItemActorSpawnAfterEvent>(
|
|
||||||
[Call](Event::EntityEvent::ItemActorSpawnAfterEvent& ev) {
|
|
||||||
auto pos = ev.getPosition();
|
|
||||||
auto dimid = ev.getBlockSource().getDimensionId().id;
|
|
||||||
std::pair<Vec3, int> lsePos = {pos, dimid};
|
|
||||||
try {
|
|
||||||
Call(&ev.getItem(), (Actor*)&ev.getItemActor(), lsePos, ev.getSpawner());
|
|
||||||
} catch (...) {}
|
|
||||||
}
|
}
|
||||||
|
case doHash("gmlib::PlayerStartSleepBeforeEvent"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::PlayerEvent::PlayerStartSleepBeforeEvent,
|
||||||
|
(Player * entity, BlockPos pos, bool isCancelled),
|
||||||
|
(&event.self(), event.getPosition(), event.isCancelled()),
|
||||||
|
event.setCancelled(result);
|
||||||
);
|
);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case doHash("onEntityChangeDim"): {
|
|
||||||
auto Call = RemoteCall::importAs<bool(Actor * entity, int toDimId)>(eventName, eventId);
|
|
||||||
eventBus->emplaceListener<Event::EntityEvent::ActorChangeDimensionBeforeEvent>(
|
|
||||||
[Call](Event::EntityEvent::ActorChangeDimensionBeforeEvent& ev) {
|
|
||||||
bool result = true;
|
|
||||||
try {
|
|
||||||
result = Call(&ev.self(), ev.getToDimensionId());
|
|
||||||
} catch (...) {}
|
|
||||||
if (!result) {
|
|
||||||
ev.cancel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
case doHash("gmlib::PlayerStartSleepAfterEvent"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::PlayerEvent::PlayerStartSleepAfterEvent,
|
||||||
|
(Player * entity, BlockPos pos, int result),
|
||||||
|
(&event.self(), event.getPosition(), (int)event.getResult()),
|
||||||
|
,
|
||||||
);
|
);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case doHash("onLeaveBed"): {
|
|
||||||
auto Call = RemoteCall::importAs<bool(Player * pl)>(eventName, eventId);
|
|
||||||
eventBus->emplaceListener<Event::PlayerEvent::PlayerStopSleepBeforeEvent>(
|
|
||||||
[Call](Event::PlayerEvent::PlayerStopSleepBeforeEvent& ev) {
|
|
||||||
bool result = true;
|
|
||||||
try {
|
|
||||||
result = Call(&ev.self());
|
|
||||||
} catch (...) {}
|
|
||||||
if (!result) {
|
|
||||||
ev.cancel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
case doHash("gmlib::PlayerStopSleepBeforeEvent"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::PlayerEvent::PlayerStopSleepBeforeEvent,
|
||||||
|
(Player * entity, bool forcefulWakeUp, bool updateLevelList, bool isCancelled),
|
||||||
|
(&event.self(), event.isForcefulWakeUp(), event.isUpdateLevelList(), event.isCancelled()),
|
||||||
|
event.setCancelled(result);
|
||||||
);
|
);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
case doHash("onDeathMessage"): {
|
case doHash("gmlib::PlayerStopSleepAfterEvent"): {
|
||||||
auto Call =
|
REGISTER_EVENT_LISTEN(
|
||||||
RemoteCall::importAs<bool(std::string const& message, std::vector<std::string>, Actor* dead)>(
|
GMLIB::Event::PlayerEvent::PlayerStopSleepAfterEvent,
|
||||||
eventName,
|
(Player * entity, bool forcefulWakeUp, bool updateLevelList, bool),
|
||||||
eventId
|
(&event.self(), event.isForcefulWakeUp(), event.isUpdateLevelList(), false),
|
||||||
|
,
|
||||||
);
|
);
|
||||||
eventBus->emplaceListener<Event::EntityEvent::DeathMessageAfterEvent>(
|
|
||||||
[Call](Event::EntityEvent::DeathMessageAfterEvent& ev) {
|
|
||||||
auto msg = ev.getDeathMessage();
|
|
||||||
auto source = ev.getDamageSource();
|
|
||||||
try {
|
|
||||||
Call(msg.first, msg.second, &ev.self());
|
|
||||||
} catch (...) {}
|
|
||||||
}
|
}
|
||||||
|
case doHash("gmlib::DeathMessageAfterEvent"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::EntityEvent::DeathMessageAfterEvent,
|
||||||
|
(std::string const& message, std::vector<std::string>, Actor* dead),
|
||||||
|
(event.getDeathMessage().first, event.getDeathMessage().second, &event.self()),
|
||||||
|
,
|
||||||
);
|
);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
case doHash("onMobHurted"): {
|
case doHash("gmlib::MobHurtAfterEvent"): {
|
||||||
auto Call = RemoteCall::importAs<bool(Actor * mob, Actor * source, float damage, int cause)>(
|
REGISTER_EVENT_LISTEN(
|
||||||
eventName,
|
GMLIB::Event::EntityEvent::MobHurtAfterEvent,
|
||||||
eventId
|
(Actor * mob, Actor * source, float damage, int cause),
|
||||||
);
|
(&event.self(), source, -event.getDamage(), (int)damageSource.getCause()),
|
||||||
eventBus->emplaceListener<Event::EntityEvent::MobHurtAfterEvent>(
|
,
|
||||||
[Call](Event::EntityEvent::MobHurtAfterEvent& ev) {
|
auto& damageSource = event.getSource();
|
||||||
auto& damageSource = ev.getSource();
|
|
||||||
Actor* source = nullptr;
|
Actor* source = nullptr;
|
||||||
if (damageSource.isEntitySource()) {
|
if (damageSource.isEntitySource()) {
|
||||||
auto uniqueId = damageSource.getDamagingEntityUniqueID();
|
auto uniqueId = damageSource.getDamagingEntityUniqueID();
|
||||||
source = ll::service::getLevel()->fetchEntity(uniqueId);
|
source = ll::service::getLevel()->fetchEntity(uniqueId, false);
|
||||||
if (source->getOwner()) {
|
if (source->getOwner()) source = source->getOwner();
|
||||||
source = source->getOwner();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Call(&ev.self(), source, ev.getDamage(), (int)damageSource.getCause());
|
|
||||||
} catch (...) {}
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case doHash("onEndermanTake"): {
|
|
||||||
auto Call = RemoteCall::importAs<bool(Actor * mob)>(eventName, eventId);
|
|
||||||
eventBus->emplaceListener<Event::EntityEvent::EndermanTakeBlockBeforeEvent>(
|
|
||||||
[Call](Event::EntityEvent::EndermanTakeBlockBeforeEvent& ev) {
|
|
||||||
bool result = true;
|
|
||||||
try {
|
|
||||||
result = Call(&ev.self());
|
|
||||||
} catch (...) {}
|
|
||||||
if (!result) {
|
|
||||||
ev.cancel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
case doHash("gmlib::EndermanTakeBlockBeforeEvent"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::EntityEvent::EndermanTakeBlockBeforeEvent,
|
||||||
|
(Actor * mob, bool isCancelled),
|
||||||
|
(&event.self(), event.isCancelled()),
|
||||||
|
event.setCancelled(result);
|
||||||
);
|
);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case doHash("onEntityChangeDimAfter"): {
|
|
||||||
auto Call = RemoteCall::importAs<bool(Actor * mob, int fromDimId)>(eventName, eventId);
|
|
||||||
eventBus->emplaceListener<Event::EntityEvent::ActorChangeDimensionAfterEvent>(
|
|
||||||
[Call](Event::EntityEvent::ActorChangeDimensionAfterEvent& ev) {
|
|
||||||
bool result = true;
|
|
||||||
try {
|
|
||||||
result = Call(&ev.self(), ev.getFromDimensionId());
|
|
||||||
} catch (...) {}
|
|
||||||
}
|
}
|
||||||
|
case doHash("gmlib::DragonRespawnBeforeEvent"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::EntityEvent::DragonRespawnBeforeEvent,
|
||||||
|
(bool isCancelled),
|
||||||
|
(event.isCancelled()),
|
||||||
|
event.setCancelled(result);
|
||||||
);
|
);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case doHash("onDragonRespawn"): {
|
|
||||||
auto Call = RemoteCall::importAs<bool(int64 enderDragonUniqueID)>(eventName, eventId);
|
|
||||||
eventBus->emplaceListener<Event::EntityEvent::DragonRespawnBeforeEvent>(
|
|
||||||
[Call](Event::EntityEvent::DragonRespawnBeforeEvent& ev) {
|
|
||||||
bool result = true;
|
|
||||||
try {
|
|
||||||
result = Call(ev.getEnderDragon().id);
|
|
||||||
} catch (...) {}
|
|
||||||
if (!result) {
|
|
||||||
ev.cancel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
case doHash("gmlib::DragonRespawnAfterEvent"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::EntityEvent::DragonRespawnAfterEvent,
|
||||||
|
(Actor * mob),
|
||||||
|
(event.getEnderDragon()),
|
||||||
);
|
);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case doHash("onProjectileTryCreate"): {
|
|
||||||
auto Call = RemoteCall::importAs<bool(Actor * mob, int64 uniqueId)>(eventName, eventId);
|
|
||||||
eventBus->emplaceListener<Event::EntityEvent::ProjectileCreateBeforeEvent>(
|
|
||||||
[Call](Event::EntityEvent::ProjectileCreateBeforeEvent& ev) {
|
|
||||||
bool result = true;
|
|
||||||
try {
|
|
||||||
auto uid = ev.getShooter() ? ev.getShooter()->getOrCreateUniqueID().id : -1;
|
|
||||||
result = Call(&ev.self(), uid);
|
|
||||||
} catch (...) {}
|
|
||||||
if (!result) {
|
|
||||||
ev.cancel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
case doHash("gmlib::ProjectileCreateBeforeEvent"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::EntityEvent::ProjectileCreateBeforeEvent,
|
||||||
|
(Actor * mob, int64 uniqueId, bool isCancelled),
|
||||||
|
(&event.self(),
|
||||||
|
event.getShooter() ? event.getShooter()->getOrCreateUniqueID().rawID : -1,
|
||||||
|
event.isCancelled()),
|
||||||
|
event.setCancelled(result);
|
||||||
);
|
);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case doHash("onProjectileCreate"): {
|
|
||||||
auto Call = RemoteCall::importAs<bool(Actor * mob, int64 uniqueId)>(eventName, eventId);
|
|
||||||
eventBus->emplaceListener<Event::EntityEvent::ProjectileCreateAfterEvent>(
|
|
||||||
[Call](Event::EntityEvent::ProjectileCreateAfterEvent& ev) {
|
|
||||||
try {
|
|
||||||
auto uid = ev.getShooter() ? ev.getShooter()->getOrCreateUniqueID().id : -1;
|
|
||||||
Call(&ev.self(), uid);
|
|
||||||
} catch (...) {}
|
|
||||||
}
|
}
|
||||||
|
case doHash("gmlib::ProjectileCreateAfterEvent"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::EntityEvent::ProjectileCreateAfterEvent,
|
||||||
|
(Actor * mob, int64 uniqueId),
|
||||||
|
(&event.self(), event.getShooter() ? event.getShooter()->getOrCreateUniqueID().rawID : -1),
|
||||||
);
|
);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case doHash("onSpawnWanderingTrader"): {
|
|
||||||
auto Call = RemoteCall::importAs<bool(std::pair<BlockPos, int> pos)>(eventName, eventId);
|
|
||||||
eventBus->emplaceListener<Event::EntityEvent::SpawnWanderingTraderBeforeEvent>(
|
|
||||||
[Call](Event::EntityEvent::SpawnWanderingTraderBeforeEvent& ev) {
|
|
||||||
bool result = true;
|
|
||||||
try {
|
|
||||||
result = Call({ev.getPos(), ev.getRegion().getDimensionId()});
|
|
||||||
} catch (...) {}
|
|
||||||
if (!result) {
|
|
||||||
ev.cancel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
case doHash("gmlib::SpawnWanderingTraderBeforeEvent"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::EntityEvent::SpawnWanderingTraderBeforeEvent,
|
||||||
|
(std::pair<BlockPos, int> pos, bool isCancelled),
|
||||||
|
({event.getPos(), event.getRegion().getDimensionId()}, event.isCancelled()),
|
||||||
|
event.setCancelled(result);
|
||||||
);
|
);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
case doHash("onHandleRequestAction"): {
|
case doHash("gmlib::SpawnWanderingTraderAfterEvent"): {
|
||||||
auto Call = RemoteCall::importAs<bool(
|
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(
|
||||||
|
GMLIB::Event::PlayerEvent::HandleRequestActionBeforeEvent,
|
||||||
|
(
|
||||||
|
Player * player,
|
||||||
|
std::string const& actionType,
|
||||||
|
int count,
|
||||||
|
std::string const& sourceContainerNetId,
|
||||||
|
int sourceSlot,
|
||||||
|
std::string const& destinationContainerNetId,
|
||||||
|
int destinationSlot,
|
||||||
|
bool isCancelled
|
||||||
|
),
|
||||||
|
(
|
||||||
|
(Player*)&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(
|
||||||
|
GMLIB::Event::PlayerEvent::HandleRequestActionAfterEvent,
|
||||||
|
(
|
||||||
Player * player,
|
Player * player,
|
||||||
std::string const& actionType,
|
std::string const& actionType,
|
||||||
int count,
|
int count,
|
||||||
@@ -273,61 +322,35 @@ void Export_Event_API() {
|
|||||||
int sourceSlot,
|
int sourceSlot,
|
||||||
std::string const& destinationContainerNetId,
|
std::string const& destinationContainerNetId,
|
||||||
int destinationSlot
|
int destinationSlot
|
||||||
)>(eventName, eventId);
|
),
|
||||||
eventBus->emplaceListener<Event::PlayerEvent::HandleRequestActionBeforeEvent>(
|
(
|
||||||
[Call](Event::PlayerEvent::HandleRequestActionBeforeEvent& ev) {
|
(Player*)&event.self(),
|
||||||
bool result = true;
|
magic_enum::enum_name(requestAction.mActionType).data(),
|
||||||
try {
|
(int)requestAction.mAmount,
|
||||||
auto requestAction = (ItemStackRequestActionTransferBase*)&ev.getRequestAction();
|
magic_enum::enum_name(requestAction.mSrc->mFullContainerName.mName).data(),
|
||||||
auto source = requestAction->getSrc();
|
(int)requestAction.mSrc->mSlot,
|
||||||
// TODO: The next version of LeviLamina changes to a member function
|
magic_enum::enum_name(requestAction.mDst->mFullContainerName.mName).data(),
|
||||||
auto destination = ll::memory::dAccess<ItemStackRequestSlotInfo>(requestAction, 56);
|
(int)requestAction.mDst->mSlot
|
||||||
result = Call(
|
),
|
||||||
&ev.self(),
|
,
|
||||||
magic_enum::enum_name(requestAction->mActionType).data(),
|
auto& requestAction = (ItemStackRequestActionTransferBase&)event.getRequestAction();
|
||||||
ll::memory::dAccess<uchar>(requestAction, 18),
|
|
||||||
magic_enum::enum_name(source.mOpenContainerNetId).data(),
|
|
||||||
source.mSlot,
|
|
||||||
magic_enum::enum_name(destination.mOpenContainerNetId).data(),
|
|
||||||
destination.mSlot
|
|
||||||
);
|
);
|
||||||
} catch (...) {}
|
// clang-format on
|
||||||
if (!result) {
|
|
||||||
ev.cancel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
case doHash("gmlib::ContainerClosePacketSendAfterEvent"): {
|
||||||
|
REGISTER_EVENT_LISTEN(
|
||||||
|
GMLIB::Event::PacketEvent::ContainerClosePacketSendAfterEvent,
|
||||||
|
(Player * player, int containerId, bool serverInitiatedClose, bool),
|
||||||
|
(event.getServerNetworkHandler()
|
||||||
|
._getServerPlayer(event.getNetworkIdentifier(), event.getPacket().mClientSubId),
|
||||||
|
(int)event.getPacket().mContainerId,
|
||||||
|
event.getPacket().mServerInitiatedClose,
|
||||||
|
false),
|
||||||
|
,
|
||||||
);
|
);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
case doHash("onSendContainerClosePacket"): {
|
|
||||||
auto Call = RemoteCall::importAs<bool(Player * player, int ContainerNetId)>(eventName, eventId);
|
|
||||||
eventBus->emplaceListener<Event::PacketEvent::ContainerClosePacketSendAfterEvent>(
|
|
||||||
[Call](Event::PacketEvent::ContainerClosePacketSendAfterEvent& ev) {
|
|
||||||
try {
|
|
||||||
Call(
|
|
||||||
ev.getServerNetworkHandler()
|
|
||||||
.getServerPlayer(ev.getNetworkIdentifier(), ev.getPacket().mClientSubId),
|
|
||||||
(int)ev.getPacket().mContainerId
|
|
||||||
);
|
|
||||||
} catch (...) {}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case doHash("onServerStopping"): {
|
|
||||||
auto Call = RemoteCall::importAs<bool()>(eventName, eventId);
|
|
||||||
eventBus->emplaceListener<ll::event::server::ServerStoppingEvent>(
|
|
||||||
[Call](ll::event::server::ServerStoppingEvent& ev) {
|
|
||||||
try {
|
|
||||||
Call();
|
|
||||||
} catch (...) {}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
+288
@@ -0,0 +1,288 @@
|
|||||||
|
// #include "Global.h"
|
||||||
|
|
||||||
|
// using namespace ll::hash_utils;
|
||||||
|
|
||||||
|
// class LegacyScriptFormManager {
|
||||||
|
// private:
|
||||||
|
// int64 mNextFormCallbackId = 0;
|
||||||
|
// int64 mNextFormId = 0;
|
||||||
|
// std::unordered_map<int64, std::unique_ptr<gmlib::form::NpcDialogueForm>> mNpcDialogueForms;
|
||||||
|
// // std::unordered_map<int64, std::unique_ptr<ChestForm>> mChestForms;
|
||||||
|
|
||||||
|
// public:
|
||||||
|
// // std::string getNextFormCallbackId() {
|
||||||
|
// // return "GMLIB_FormApi_" + std::to_string(mNextFormCallbackId++);
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// int64 getNextFormId() {
|
||||||
|
// mNextFormId++;
|
||||||
|
// return mNextFormId;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// int64 createNpcDialogueForm(std::string const& npcName, std::string const& sceneName, std::string const& dialogue) {
|
||||||
|
// auto formId = LegacyScriptFormManager::getInstance().getNextFormId();
|
||||||
|
// auto formPtr = std::make_unique<gmlib::form::NpcDialogueForm>(npcName, sceneName, dialogue);
|
||||||
|
// mNpcDialogueForms[formId] = std::move(formPtr);
|
||||||
|
// return formId;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// bool destroyNpcDialogueForm(int64 formId) {
|
||||||
|
// if (mNpcDialogueForms.contains(formId)) {
|
||||||
|
// mNpcDialogueForms.erase(formId);
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// optional_ref<gmlib::form::NpcDialogueForm> getNpcDialogueForm(int64 formId) {
|
||||||
|
// if (mNpcDialogueForms.contains(formId)) {
|
||||||
|
// return mNpcDialogueForms[formId].get();
|
||||||
|
// }
|
||||||
|
// return {};
|
||||||
|
// }
|
||||||
|
|
||||||
|
// /*
|
||||||
|
// int64 createChestForm(std::string const& npcName, std::string const& sceneName, std::string const& dialogue) {
|
||||||
|
// auto formId = LegacyScriptFormManager::getInstance().getNextFormId();
|
||||||
|
// auto formPtr = std::make_unique<ChestForm>(npcName, sceneName, dialogue);
|
||||||
|
// mChestForms[formId] = std::move(formPtr);
|
||||||
|
// return formId;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// bool destroyChestForm(int64 formId) {
|
||||||
|
// if (mChestForms.contains(formId)) {
|
||||||
|
// mChestForms.erase(formId);
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// optional_ref<ChestForm> getChestForm(int64 formId) {
|
||||||
|
// if (mChestForms.contains(formId)) {
|
||||||
|
// return mChestForms[formId].get();
|
||||||
|
// }
|
||||||
|
// return {};
|
||||||
|
// }
|
||||||
|
|
||||||
|
// */
|
||||||
|
// public:
|
||||||
|
// static LegacyScriptFormManager& getInstance() {
|
||||||
|
// static std::unique_ptr<LegacyScriptFormManager> instance;
|
||||||
|
// if (!instance) {
|
||||||
|
// instance = std::make_unique<LegacyScriptFormManager>();
|
||||||
|
// }
|
||||||
|
// return *instance;
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
|
||||||
|
// #define PLAYER_DETECROR \
|
||||||
|
// [detectorId, result](::Player& pl) -> bool { \
|
||||||
|
// try { \
|
||||||
|
// if (RemoteCall::hasFunc("GMLIB_FORM_CALLBACK", detectorId)) { \
|
||||||
|
// auto const& detector = RemoteCall::importAs<bool(::Player*)>("GMLIB_FORM_CALLBACK", detectorId); \
|
||||||
|
// return detector(&pl); \
|
||||||
|
// } else { \
|
||||||
|
// gmlib::form::ServerSettingForm::removeElement(result); \
|
||||||
|
// } \
|
||||||
|
// } catch (...) {} \
|
||||||
|
// return false; \
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #define CALLBACK_TYPE(type) \
|
||||||
|
// [callbackId, result](Player& pl, type data) { \
|
||||||
|
// try { \
|
||||||
|
// if (RemoteCall::hasFunc("GMLIB_FORM_CALLBACK", callbackId)) { \
|
||||||
|
// auto const& callback = RemoteCall::importAs<void(Player*, type)>("GMLIB_FORM_CALLBACK", callbackId); \
|
||||||
|
// callback(&pl, data); \
|
||||||
|
// } else { \
|
||||||
|
// gmlib::form::ServerSettingForm::removeElement(result); \
|
||||||
|
// } \
|
||||||
|
// } catch (...) {} \
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #define CALLBACK_TYPE_NORMAL \
|
||||||
|
// [callbackId](::Player& pl) { \
|
||||||
|
// try { \
|
||||||
|
// if (RemoteCall::hasFunc("GMLIB_FORM_CALLBACK", callbackId)) { \
|
||||||
|
// auto const& callback = RemoteCall::importAs<void(::Player*)>("GMLIB_FORM_CALLBACK", callbackId); \
|
||||||
|
// callback(&pl); \
|
||||||
|
// } \
|
||||||
|
// } catch (...) {} \
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// void Export_Form_API() {
|
||||||
|
// //////////////////////////////// Form Manager /////////////////////////////////
|
||||||
|
// // RemoteCall::exportAs("GMLIB_FormAPI", "getNextFormCallbackId", []() -> std::string {
|
||||||
|
// // return LegacyScriptFormManager::getInstance().getNextFormCallbackId();
|
||||||
|
// // });
|
||||||
|
// ////////////////////////////// ServerSettingForm //////////////////////////////
|
||||||
|
// RemoteCall::exportAs("GMLIB_ServerSettingForm", "getDefaultPriority", []() -> int {
|
||||||
|
// return gmlib::form::ServerSettingForm::getDefaultPriority();
|
||||||
|
// });
|
||||||
|
// RemoteCall::exportAs("GMLIB_ServerSettingForm", "hasTitle", []() -> bool { return gmlib::form::ServerSettingForm::hasTitle(); });
|
||||||
|
// RemoteCall::exportAs("GMLIB_ServerSettingForm", "getTitle", []() -> std::string {
|
||||||
|
// return gmlib::form::ServerSettingForm::getTitle();
|
||||||
|
// });
|
||||||
|
// RemoteCall::exportAs("GMLIB_gmlib::form::ServerSettingForm", "setTitle", [](std::string const& title, bool forceModify) -> bool {
|
||||||
|
// return gmlib::form::ServerSettingForm::setTitle(title, forceModify);
|
||||||
|
// });
|
||||||
|
// RemoteCall::exportAs("GMLIB_gmlib::form::ServerSettingForm", "hasIcon", []() -> bool { return gmlib::form::ServerSettingForm::hasIcon(); });
|
||||||
|
// RemoteCall::exportAs("GMLIB_gmlib::form::ServerSettingForm", "getIconData", []() -> std::string {
|
||||||
|
// return gmlib::form::ServerSettingForm::getIconData().value_or("");
|
||||||
|
// });
|
||||||
|
// RemoteCall::exportAs("GMLIB_gmlib::form::ServerSettingForm", "getIconType", []() -> int {
|
||||||
|
// return gmlib::form::ServerSettingForm::getIconType()
|
||||||
|
// .transform([](gmlib::form::IconType&& type) -> int { return (int)type; })
|
||||||
|
// .value_or(-1);
|
||||||
|
// });
|
||||||
|
// RemoteCall::exportAs(
|
||||||
|
// "GMLIB_gmlib::form::ServerSettingForm",
|
||||||
|
// "setIcon",
|
||||||
|
// [](std::string const& title, uchar type, bool forceModify) -> bool {
|
||||||
|
// return gmlib::form::ServerSettingForm::setIcon(title, gmlib::form::IconType(type), forceModify);
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// RemoteCall::exportAs(
|
||||||
|
// "GMLIB_gmlib::form::ServerSettingForm",
|
||||||
|
// "addLabel",
|
||||||
|
// [](std::string const& text, std::string const& detectorId, int priority) -> uint {
|
||||||
|
// uint result = gmlib::form::ServerSettingForm::addLabel(text, PLAYER_DETECROR, priority);
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// RemoteCall::exportAs(
|
||||||
|
// "GMLIB_gmlib::form::ServerSettingForm",
|
||||||
|
// "addInput",
|
||||||
|
// [](std::string const& text,
|
||||||
|
// std::string const& placeholder,
|
||||||
|
// std::string const& defaultVal,
|
||||||
|
// std::string const& callbackId,
|
||||||
|
// std::string const& detectorId,
|
||||||
|
// int priority) -> uint {
|
||||||
|
// uint result = gmlib::form::ServerSettingForm::addInput(
|
||||||
|
// text,
|
||||||
|
// placeholder,
|
||||||
|
// defaultVal,
|
||||||
|
// CALLBACK_TYPE(std::string const&),
|
||||||
|
// PLAYER_DETECROR,
|
||||||
|
// priority
|
||||||
|
// );
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// RemoteCall::exportAs(
|
||||||
|
// "GMLIB_gmlib::form::ServerSettingForm",
|
||||||
|
// "addToggle",
|
||||||
|
// [](std::string const& text,
|
||||||
|
// bool defaultVal,
|
||||||
|
// std::string const& callbackId,
|
||||||
|
// std::string const& detectorId,
|
||||||
|
// int priority) -> uint {
|
||||||
|
// uint result = gmlib::form::ServerSettingForm::addToggle(text, defaultVal, CALLBACK_TYPE(bool), PLAYER_DETECROR, priority);
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// RemoteCall::exportAs(
|
||||||
|
// "GMLIB_gmlib::form::ServerSettingForm",
|
||||||
|
// "addDropdown",
|
||||||
|
// [](std::string const& text,
|
||||||
|
// std::vector<std::string> options,
|
||||||
|
// int64 defaultVal,
|
||||||
|
// std::string const& callbackId,
|
||||||
|
// std::string const& detectorId,
|
||||||
|
// int priority) -> uint {
|
||||||
|
// uint result = gmlib::form::ServerSettingForm::addDropdown(
|
||||||
|
// text,
|
||||||
|
// options,
|
||||||
|
// defaultVal,
|
||||||
|
// CALLBACK_TYPE(int64),
|
||||||
|
// PLAYER_DETECROR,
|
||||||
|
// priority
|
||||||
|
// );
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// RemoteCall::exportAs(
|
||||||
|
// "GMLIB_gmlib::form::ServerSettingForm",
|
||||||
|
// "addSlider",
|
||||||
|
// [](std::string const& text,
|
||||||
|
// double min,
|
||||||
|
// double max,
|
||||||
|
// double step,
|
||||||
|
// double defaultVal,
|
||||||
|
// std::string const& callbackId,
|
||||||
|
// std::string const& detectorId,
|
||||||
|
// int priority) -> uint {
|
||||||
|
// uint result = gmlib::form::ServerSettingForm::addSlider(
|
||||||
|
// text,
|
||||||
|
// min,
|
||||||
|
// max,
|
||||||
|
// step,
|
||||||
|
// defaultVal,
|
||||||
|
// CALLBACK_TYPE(double),
|
||||||
|
// PLAYER_DETECROR,
|
||||||
|
// priority
|
||||||
|
// );
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// RemoteCall::exportAs(
|
||||||
|
// "GMLIB_gmlib::form::ServerSettingForm",
|
||||||
|
// "addStepSlider",
|
||||||
|
// [](std::string const& text,
|
||||||
|
// std::vector<std::string> steps,
|
||||||
|
// int64 defaultVal,
|
||||||
|
// std::string const& callbackId,
|
||||||
|
// std::string const& detectorId,
|
||||||
|
// int priority) -> uint {
|
||||||
|
// uint result = gmlib::form::ServerSettingForm::addStepSlider(
|
||||||
|
// text,
|
||||||
|
// steps,
|
||||||
|
// defaultVal,
|
||||||
|
// CALLBACK_TYPE(int64),
|
||||||
|
// PLAYER_DETECROR,
|
||||||
|
// priority
|
||||||
|
// );
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// RemoteCall::exportAs("GMLIB_gmlib::form::ServerSettingForm", "removeElement", [](uint id) -> bool {
|
||||||
|
// return gmlib::form::ServerSettingForm::removeElement(id);
|
||||||
|
// });
|
||||||
|
// ////////////////////////////// NpcDialogueForm //////////////////////////////
|
||||||
|
// RemoteCall::exportAs(
|
||||||
|
// "GMLIB_NpcDialogueForm",
|
||||||
|
// "createForm",
|
||||||
|
// [](std::string const& npcName, std::string const& sceneName, std::string const& dialogue) -> int64 {
|
||||||
|
// return LegacyScriptFormManager::getInstance().createNpcDialogueForm(npcName, sceneName, dialogue);
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// RemoteCall::exportAs("GMLIB_NpcDialogueForm", "destroyForm", [](int64 formId) -> bool {
|
||||||
|
// return LegacyScriptFormManager::getInstance().destroyNpcDialogueForm(formId);
|
||||||
|
// });
|
||||||
|
// RemoteCall::exportAs(
|
||||||
|
// "GMLIB_NpcDialogueForm",
|
||||||
|
// "addButton",
|
||||||
|
// [](int64 formId, std::string const& button, std::string const& callbackId) -> void {
|
||||||
|
// if (auto formPtr = LegacyScriptFormManager::getInstance().getNpcDialogueForm(formId)) {
|
||||||
|
// formPtr->addButton(button, CALLBACK_TYPE_NORMAL);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// RemoteCall::exportAs(
|
||||||
|
// "GMLIB_NpcDialogueForm",
|
||||||
|
// "onPlayerClose",
|
||||||
|
// [](int64 formId, std::string const& callbackId) -> void {
|
||||||
|
// if (auto formPtr = LegacyScriptFormManager::getInstance().getNpcDialogueForm(formId)) {
|
||||||
|
// formPtr->onPlayerClose(CALLBACK_TYPE_NORMAL);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// RemoteCall::exportAs("GMLIB_NpcDialogueForm", "sendTo", [](int64 formId, ::Player* pl) -> void {
|
||||||
|
// if (auto formPtr = LegacyScriptFormManager::getInstance().getNpcDialogueForm(formId)) {
|
||||||
|
// formPtr->sendTo(*pl);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// ////////////////////////////// ChestForm //////////////////////////////
|
||||||
|
// }
|
||||||
+4
-8
@@ -3,22 +3,18 @@
|
|||||||
|
|
||||||
#include <RemoteCallAPI.h>
|
#include <RemoteCallAPI.h>
|
||||||
|
|
||||||
using namespace GMLIB;
|
|
||||||
using namespace Server;
|
|
||||||
using namespace Mod;
|
|
||||||
|
|
||||||
#define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA")
|
#define PLUGIN_NAME fmt::format(fg(fmt::color::light_green), "GMLIB-LRCA")
|
||||||
|
|
||||||
#define LIB_VERSION_MAJOR 0
|
#define LIB_VERSION_MAJOR 0
|
||||||
#define LIB_VERSION_MINOR 13
|
#define LIB_VERSION_MINOR 13
|
||||||
#define LIB_VERSION_PATCH 2
|
#define LIB_VERSION_PATCH 6
|
||||||
|
|
||||||
#define LIB_VERSION Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH)
|
#define LIB_VERSION GMLIB::Version(LIB_VERSION_MAJOR, LIB_VERSION_MINOR, LIB_VERSION_PATCH)
|
||||||
|
|
||||||
extern ll::Logger logger;
|
|
||||||
|
|
||||||
extern void Export_Legacy_GMLib_ModAPI();
|
extern void Export_Legacy_GMLib_ModAPI();
|
||||||
extern void Export_Legacy_GMLib_ServerAPI();
|
extern void Export_Legacy_GMLib_ServerAPI();
|
||||||
extern void Export_Compatibility_API();
|
extern void Export_Compatibility_API();
|
||||||
extern void ExportPAPI();
|
extern void ExportPAPI();
|
||||||
extern void Export_Event_API();
|
extern void Export_Event_API();
|
||||||
|
extern void Export_BinaryStream_API();
|
||||||
|
// extern void Export_Form_API();
|
||||||
|
|||||||
+50
-70
@@ -3,13 +3,8 @@
|
|||||||
std::unordered_set<std::string> HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"};
|
std::unordered_set<std::string> HardCodedKeys = {"AlwaysUnlocked", "PlayerHasManyItems", "PlayerInWater", "None"};
|
||||||
|
|
||||||
std::variant<std::string, std::vector<RecipeIngredient>> makeRecipeUnlockingKey(std::string const& key) {
|
std::variant<std::string, std::vector<RecipeIngredient>> makeRecipeUnlockingKey(std::string const& key) {
|
||||||
if (HardCodedKeys.count(key)) {
|
if (HardCodedKeys.count(key)) return key;
|
||||||
return key;
|
return std::vector<RecipeIngredient>({RecipeIngredient(key, 0, 1)});
|
||||||
}
|
|
||||||
std::vector<RecipeIngredient> result;
|
|
||||||
auto item = RecipeIngredient(key, 0, 1);
|
|
||||||
result.emplace_back(item);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Export_Legacy_GMLib_ModAPI() {
|
void Export_Legacy_GMLib_ModAPI() {
|
||||||
@@ -22,18 +17,17 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::string const& result,
|
std::string const& result,
|
||||||
int count,
|
int count,
|
||||||
std::string const& unlock) -> void {
|
std::string const& unlock) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||||
if (!level) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
std::vector<RecipeIngredient> types;
|
std::vector<RecipeIngredient> types;
|
||||||
for (auto ing : ingredients) {
|
for (auto ing : ingredients) {
|
||||||
auto key = RecipeIngredient(ing, 0, 1);
|
types.emplace_back(ing, 0, 1);
|
||||||
types.push_back(key);
|
|
||||||
}
|
}
|
||||||
auto res = RecipeIngredient(result, 0, count);
|
GMLIB::Mod::JsonRecipe::registerShapelessCraftingTableRecipe(
|
||||||
auto unl = makeRecipeUnlockingKey(unlock);
|
recipe_id,
|
||||||
JsonRecipe::registerShapelessCraftingTableRecipe(recipe_id, types, res, unl);
|
types,
|
||||||
|
RecipeIngredient(result, 0, count),
|
||||||
|
makeRecipeUnlockingKey(unlock)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -45,18 +39,18 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::string const& result,
|
std::string const& result,
|
||||||
int count,
|
int count,
|
||||||
std::string const& unlock) -> void {
|
std::string const& unlock) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||||
if (!level) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
std::vector<RecipeIngredient> types;
|
std::vector<RecipeIngredient> types;
|
||||||
for (auto ing : ingredients) {
|
for (auto ing : ingredients) {
|
||||||
auto key = RecipeIngredient(ing, 0, 1);
|
types.push_back(RecipeIngredient(ing, 0, 1));
|
||||||
types.push_back(key);
|
|
||||||
}
|
}
|
||||||
auto res = RecipeIngredient(result, 0, count);
|
GMLIB::Mod::JsonRecipe::registerShapedCraftingTableRecipe(
|
||||||
auto unl = makeRecipeUnlockingKey(unlock);
|
recipe_id,
|
||||||
JsonRecipe::registerShapedCraftingTableRecipe(recipe_id, shape, types, res, unl);
|
shape,
|
||||||
|
types,
|
||||||
|
RecipeIngredient(result, 0, count),
|
||||||
|
makeRecipeUnlockingKey(unlock)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -66,13 +60,13 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::string const& input,
|
std::string const& input,
|
||||||
std::string const& output,
|
std::string const& output,
|
||||||
std::vector<std::string> tags) -> void {
|
std::vector<std::string> tags) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||||
if (!level) {
|
GMLIB::Mod::JsonRecipe::registerFurnaceRecipe(
|
||||||
return;
|
recipe_id,
|
||||||
}
|
RecipeIngredient(input, 0, 1),
|
||||||
auto inp = RecipeIngredient(input, 0, 1);
|
RecipeIngredient(output, 0, 1),
|
||||||
auto outp = RecipeIngredient(output, 0, 1);
|
tags
|
||||||
JsonRecipe::registerFurnaceRecipe(recipe_id, inp, outp, tags);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -80,12 +74,8 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
"registerBrewingMixRecipe",
|
"registerBrewingMixRecipe",
|
||||||
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
||||||
) -> void {
|
) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||||
if (!level) {
|
GMLIB::Mod::JsonRecipe::registerBrewingMixRecipe(recipe_id, input, output, RecipeIngredient(reagent, 0, 1));
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto rea = RecipeIngredient(reagent, 0, 1);
|
|
||||||
JsonRecipe::registerBrewingMixRecipe(recipe_id, input, output, rea);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -93,14 +83,13 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
"registerBrewingContainerRecipe",
|
"registerBrewingContainerRecipe",
|
||||||
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
[](std::string const& recipe_id, std::string const& input, std::string const& output, std::string const& reagent
|
||||||
) -> void {
|
) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||||
if (!level) {
|
GMLIB::Mod::JsonRecipe::registerBrewingContainerRecipe(
|
||||||
return;
|
recipe_id,
|
||||||
}
|
RecipeIngredient(input, 0, 1),
|
||||||
auto inp = RecipeIngredient(input, 0, 1);
|
RecipeIngredient(output, 0, 1),
|
||||||
auto outp = RecipeIngredient(output, 0, 1);
|
RecipeIngredient(reagent, 0, 1)
|
||||||
auto rea = RecipeIngredient(reagent, 0, 1);
|
);
|
||||||
JsonRecipe::registerBrewingContainerRecipe(recipe_id, inp, outp, rea);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -111,11 +100,8 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::string const& base,
|
std::string const& base,
|
||||||
std::string const& addition,
|
std::string const& addition,
|
||||||
std::string const& result) -> void {
|
std::string const& result) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||||
if (!level) {
|
GMLIB::Mod::JsonRecipe::registerSmithingTransformRecipe(
|
||||||
return;
|
|
||||||
}
|
|
||||||
JsonRecipe::registerSmithingTransformRecipe(
|
|
||||||
recipe_id,
|
recipe_id,
|
||||||
smithing_template,
|
smithing_template,
|
||||||
base,
|
base,
|
||||||
@@ -131,11 +117,8 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::string const& smithing_template,
|
std::string const& smithing_template,
|
||||||
std::string const& base,
|
std::string const& base,
|
||||||
std::string const& addition) -> void {
|
std::string const& addition) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||||
if (!level) {
|
GMLIB::Mod::JsonRecipe::registerSmithingTrimRecipe(recipe_id, smithing_template, base, addition);
|
||||||
return;
|
|
||||||
}
|
|
||||||
JsonRecipe::registerSmithingTrimRecipe(recipe_id, smithing_template, base, addition);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs(
|
RemoteCall::exportAs(
|
||||||
@@ -147,18 +130,17 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::string const& output,
|
std::string const& output,
|
||||||
int output_data,
|
int output_data,
|
||||||
int output_count) -> void {
|
int output_count) -> void {
|
||||||
auto level = GMLIB_Level::getInstance();
|
if (!GMLIB_Level::getInstance().has_value()) return;
|
||||||
if (!level) {
|
GMLIB::Mod::JsonRecipe::registerStoneCutterRecipe(
|
||||||
return;
|
recipe_id,
|
||||||
}
|
RecipeIngredient(input, 0, 1),
|
||||||
auto inp = RecipeIngredient(input, 0, 1);
|
RecipeIngredient(output, 0, 1)
|
||||||
auto outp = RecipeIngredient(output, 0, 1);
|
);
|
||||||
JsonRecipe::registerStoneCutterRecipe(recipe_id, inp, outp);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
// 错误方块清理
|
// 错误方块清理
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "setUnknownBlockCleaner", []() -> void {
|
RemoteCall::exportAs("GMLib_ModAPI", "setUnknownBlockCleaner", []() -> void {
|
||||||
VanillaFix::setAutoCleanUnknownBlockEnabled();
|
GMLIB::Mod::VanillaFix::setAutoCleanUnknownBlockEnabled();
|
||||||
});
|
});
|
||||||
// 实验性
|
// 实验性
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void {
|
RemoteCall::exportAs("GMLib_ModAPI", "registerExperimentsRequire", [](int experiment_id) -> void {
|
||||||
@@ -167,7 +149,7 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
if (set.contains((AllExperiments)experiment_id)) {
|
if (set.contains((AllExperiments)experiment_id)) {
|
||||||
GMLIB_Level::addExperimentsRequire((AllExperiments)experiment_id);
|
GMLIB_Level::addExperimentsRequire((AllExperiments)experiment_id);
|
||||||
} else {
|
} else {
|
||||||
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
ll::io::LoggerRegistry::getInstance().getOrCreate("Server")->error("Experiment ID '{}' does not exist!", experiment_id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "setExperimentEnabled", [](int experiment_id, bool value) -> void {
|
RemoteCall::exportAs("GMLib_ModAPI", "setExperimentEnabled", [](int experiment_id, bool value) -> void {
|
||||||
@@ -176,7 +158,7 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||||
if (set.contains((AllExperiments)experiment_id)) {
|
if (set.contains((AllExperiments)experiment_id)) {
|
||||||
GMLIB_Level::getInstance()->setExperimentEnabled(((AllExperiments)experiment_id), value);
|
GMLIB_Level::getInstance()->setExperimentEnabled(((AllExperiments)experiment_id), value);
|
||||||
} else ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
} else ll::io::LoggerRegistry::getInstance().getOrCreate("Server")->error("Experiment ID '{}' does not exist!", experiment_id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "getExperimentEnabled", [](int experiment_id) -> bool {
|
RemoteCall::exportAs("GMLib_ModAPI", "getExperimentEnabled", [](int experiment_id) -> bool {
|
||||||
@@ -185,14 +167,12 @@ void Export_Legacy_GMLib_ModAPI() {
|
|||||||
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
std::unordered_set<AllExperiments> set(list.begin(), list.end());
|
||||||
if (set.contains((AllExperiments)experiment_id)) {
|
if (set.contains((AllExperiments)experiment_id)) {
|
||||||
return GMLIB_Level::getInstance()->getExperimentEnabled(((AllExperiments)experiment_id));
|
return GMLIB_Level::getInstance()->getExperimentEnabled(((AllExperiments)experiment_id));
|
||||||
} else {
|
|
||||||
ll::Logger("Server").error("Experiment ID '{}' does not exist!", experiment_id);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
ll::io::LoggerRegistry::getInstance().getOrCreate("Server")->error("Experiment ID '{}' does not exist!", experiment_id);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ModAPI", "setFixI18nEnabled", []() -> void {
|
RemoteCall::exportAs("GMLib_ModAPI", "setFixI18nEnabled", []() -> void {
|
||||||
VanillaFix::setFixI18nEnabled();
|
GMLIB::Mod::VanillaFix::setFixI18nEnabled();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
+12
-15
@@ -15,10 +15,9 @@ void Export_Legacy_GMLib_ServerAPI() {
|
|||||||
GMLIB_Level::requireServerResourcePackAndAllowClientResourcePack();
|
GMLIB_Level::requireServerResourcePackAndAllowClientResourcePack();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelName", []() -> std::string {
|
||||||
if (auto level = GMLIB_Level::getInstance()) {
|
return GMLIB_Level::getInstance()
|
||||||
return level->getLevelName();
|
.transform([](GMLIB_Level& level) -> std::string { return level.getLevelName(); })
|
||||||
}
|
.value_or("");
|
||||||
return {};
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setLevelName", [](std::string const& name) -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setLevelName", [](std::string const& name) -> void {
|
||||||
if (auto level = GMLIB_Level::getInstance()) {
|
if (auto level = GMLIB_Level::getInstance()) {
|
||||||
@@ -26,10 +25,9 @@ void Export_Legacy_GMLib_ServerAPI() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelSeed", []() -> std::string {
|
RemoteCall::exportAs("GMLib_ServerAPI", "getLevelSeed", []() -> std::string {
|
||||||
if (auto level = GMLIB_Level::getInstance()) {
|
return GMLIB_Level::getInstance()
|
||||||
return std::to_string(level->getSeed());
|
.transform([](GMLIB_Level& level) -> std::string { return std::to_string(level.getSeed()); })
|
||||||
}
|
.value_or("");
|
||||||
return {};
|
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "setFakeSeed", [](int64_t seed) -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "setFakeSeed", [](int64_t seed) -> void {
|
||||||
return GMLIB_Level::setFakeSeed(seed);
|
return GMLIB_Level::setFakeSeed(seed);
|
||||||
@@ -62,19 +60,18 @@ void Export_Legacy_GMLib_ServerAPI() {
|
|||||||
"GMLib_ServerAPI",
|
"GMLib_ServerAPI",
|
||||||
"addFakeList",
|
"addFakeList",
|
||||||
[](const std::string& name, const std::string& xuid) -> bool {
|
[](const std::string& name, const std::string& xuid) -> bool {
|
||||||
return FakeList::addFakeList(name, xuid, ActorUniqueID(-1));
|
return GMLIB::Server::FakeList::addFakeList(name, xuid, ActorUniqueID(-1));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "removeFakeList", [](const std::string& nameOrXuid) -> bool {
|
RemoteCall::exportAs("GMLib_ServerAPI", "removeFakeList", [](const std::string& nameOrXuid) -> bool {
|
||||||
return FakeList::removeFakeList(nameOrXuid);
|
return GMLIB::Server::FakeList::removeFakeList(nameOrXuid);
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "removeAllFakeList", []() -> void {
|
RemoteCall::exportAs("GMLib_ServerAPI", "removeAllFakeList", []() -> void {
|
||||||
return FakeList::removeAllFakeLists();
|
return GMLIB::Server::FakeList::removeAllFakeLists();
|
||||||
});
|
});
|
||||||
RemoteCall::exportAs("GMLib_ServerAPI", "getMaxPlayers", []() -> int {
|
RemoteCall::exportAs("GMLib_ServerAPI", "getMaxPlayers", []() -> int {
|
||||||
if (auto level = GMLIB_Level::getInstance()) {
|
return GMLIB_Level::getInstance().transform(
|
||||||
return level->getMaxPlayerCount();
|
[](GMLIB_Level& level) -> int { return level.getMaxPlayerCount(); }
|
||||||
}
|
).value_or(0);
|
||||||
return {};
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-16
@@ -13,10 +13,10 @@ bool isParameters(std::string const& str) {
|
|||||||
return std::regex_search(removeBrackets(str), reg);
|
return std::regex_search(removeBrackets(str), reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetValue(std::string const& from) { return PlaceholderAPI::getValue(from); }
|
std::string GetValue(std::string const& from) { return GMLIB::Server::PlaceholderAPI::getValue(from); }
|
||||||
|
|
||||||
std::string GetValueWithPlayer(std::string const& a1, std::string const& a2) {
|
std::string GetValueWithPlayer(std::string const& key, Player* player) {
|
||||||
return PlaceholderAPI::getValue(a1, ll::service::bedrock::getLevel()->getPlayer(a2));
|
return GMLIB::Server::PlaceholderAPI::getValue(key, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool registerPlayerPlaceholder(
|
bool registerPlayerPlaceholder(
|
||||||
@@ -25,20 +25,20 @@ bool registerPlayerPlaceholder(
|
|||||||
std::string const& PAPIName
|
std::string const& PAPIName
|
||||||
) {
|
) {
|
||||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||||
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
GMLIB::Server::PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||||
if (isParameters(PAPIName)) {
|
if (isParameters(PAPIName)) {
|
||||||
auto Call = RemoteCall::importAs<std::string(Player * pl, std::unordered_map<std::string, std::string>)>(
|
auto Call = RemoteCall::importAs<std::string(Player * pl, std::unordered_map<std::string, std::string>)>(
|
||||||
PluginName,
|
PluginName,
|
||||||
FuncName
|
FuncName
|
||||||
);
|
);
|
||||||
PlaceholderAPI::registerPlayerPlaceholder(
|
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
|
||||||
PAPIName,
|
PAPIName,
|
||||||
[Call](Player* sp, std::unordered_map<std::string, std::string> map) { return Call(sp, map); },
|
[Call](Player* sp, std::unordered_map<std::string, std::string> map) { return Call(sp, map); },
|
||||||
PluginName
|
PluginName
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
auto Call = RemoteCall::importAs<std::string(Player * pl)>(PluginName, FuncName);
|
auto Call = RemoteCall::importAs<std::string(Player * pl)>(PluginName, FuncName);
|
||||||
PlaceholderAPI::registerPlayerPlaceholder(
|
GMLIB::Server::PlaceholderAPI::registerPlayerPlaceholder(
|
||||||
PAPIName,
|
PAPIName,
|
||||||
[Call](Player* sp) { return Call(sp); },
|
[Call](Player* sp) { return Call(sp); },
|
||||||
PluginName
|
PluginName
|
||||||
@@ -55,18 +55,18 @@ bool registerServerPlaceholder(
|
|||||||
std::string const& PAPIName
|
std::string const& PAPIName
|
||||||
) {
|
) {
|
||||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||||
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
GMLIB::Server::PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||||
if (isParameters(PAPIName)) {
|
if (isParameters(PAPIName)) {
|
||||||
auto Call =
|
auto Call =
|
||||||
RemoteCall::importAs<std::string(std::unordered_map<std::string, std::string>)>(PluginName, FuncName);
|
RemoteCall::importAs<std::string(std::unordered_map<std::string, std::string>)>(PluginName, FuncName);
|
||||||
PlaceholderAPI::registerServerPlaceholder(
|
GMLIB::Server::PlaceholderAPI::registerServerPlaceholder(
|
||||||
PAPIName,
|
PAPIName,
|
||||||
[Call](std::unordered_map<std::string, std::string> map) { return Call(map); },
|
[Call](std::unordered_map<std::string, std::string> map) { return Call(map); },
|
||||||
PluginName
|
PluginName
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
||||||
PlaceholderAPI::registerServerPlaceholder(PAPIName, [Call]() { return Call(); }, PluginName);
|
GMLIB::Server::PlaceholderAPI::registerServerPlaceholder(PAPIName, [Call]() { return Call(); }, PluginName);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -80,17 +80,17 @@ bool registerStaticPlaceholder(
|
|||||||
int num
|
int num
|
||||||
) {
|
) {
|
||||||
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
if (RemoteCall::hasFunc(PluginName, FuncName)) {
|
||||||
PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
GMLIB::Server::PlaceholderAPI::unregisterPlaceholder(PAPIName);
|
||||||
if (isParameters(PAPIName)) {
|
if (isParameters(PAPIName)) {
|
||||||
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
auto Call = RemoteCall::importAs<std::string()>(PluginName, FuncName);
|
||||||
if (num == -1) {
|
if (num == -1) {
|
||||||
PlaceholderAPI::registerStaticPlaceholder(
|
GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder(
|
||||||
PAPIName,
|
PAPIName,
|
||||||
[Call] { return Call(); },
|
[Call] { return Call(); },
|
||||||
PluginName
|
PluginName
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
PlaceholderAPI::registerStaticPlaceholder(
|
GMLIB::Server::PlaceholderAPI::registerStaticPlaceholder(
|
||||||
PAPIName,
|
PAPIName,
|
||||||
num,
|
num,
|
||||||
[Call] { return Call(); },
|
[Call] { return Call(); },
|
||||||
@@ -104,14 +104,14 @@ bool registerStaticPlaceholder(
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string translateStringWithPlayer(std::string const& str, Player* pl) {
|
std::string translateStringWithPlayer(std::string const& str, Player* pl) {
|
||||||
return PlaceholderAPI::translateString(str, pl);
|
return GMLIB::Server::PlaceholderAPI::translateString(str, pl);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string translateString(std::string const& str) { return PlaceholderAPI::translateString(str); }
|
std::string translateString(std::string const& str) { return GMLIB::Server::PlaceholderAPI::translateString(str); }
|
||||||
|
|
||||||
bool unRegisterPlaceholder(std::string const& str) { return PlaceholderAPI::unregisterPlaceholder(str); }
|
bool unRegisterPlaceholder(std::string const& str) { return GMLIB::Server::PlaceholderAPI::unregisterPlaceholder(str); }
|
||||||
|
|
||||||
std::vector<std::string> getAllPAPI() { return PlaceholderAPI::getAllPAPI(); }
|
std::vector<std::string> getAllPAPI() { return GMLIB::Server::PlaceholderAPI::getAllPAPI(); }
|
||||||
|
|
||||||
} // namespace PAPIRemoteCall
|
} // namespace PAPIRemoteCall
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"format_version": 2,
|
"format_version": 2,
|
||||||
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
"tooth": "github.com/GroupMountain/GMLIB-LegacyRemoteCallApi",
|
||||||
"version": "0.13.2",
|
"version": "0.13.6",
|
||||||
"info": {
|
"info": {
|
||||||
"name": "GMLIB-LegacyRemoteCallApi",
|
"name": "GMLIB-LegacyRemoteCallApi",
|
||||||
"description": "Legacy RemoteCall API for GMLIB",
|
"description": "Legacy RemoteCall API for GMLIB",
|
||||||
@@ -14,9 +14,9 @@
|
|||||||
"library"
|
"library"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.13.2/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
|
"asset_url": "https://github.com/GroupMountain/GMLIB-LegacyRemoteCallApi/releases/download/v0.13.6/GMLIB-LegacyRemoteCallApi-windows-x64.zip",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"github.com/GroupMountain/GMLIB": ">=0.13.0"
|
"github.com/GroupMountain/GMLIB": ">=0.13.9"
|
||||||
},
|
},
|
||||||
"files": {
|
"files": {
|
||||||
"place": [
|
"place": [
|
||||||
|
|||||||
@@ -7,43 +7,12 @@ if not has_config("vs_runtime") then
|
|||||||
set_runtimes("MD")
|
set_runtimes("MD")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Option 1: Use the latest version of LeviLamina released on GitHub.
|
add_requires("levilamina", {configs = {target_type = "server"}})
|
||||||
add_requires("levilaminalibrary")
|
|
||||||
add_requires("legacyremotecall")
|
add_requires("legacyremotecall")
|
||||||
add_requires("gmlib")
|
add_requires("gmlib")
|
||||||
|
add_requires("levibuildscript")
|
||||||
|
|
||||||
-- Option 2: Use a specific version of LeviLamina released on GitHub.
|
target("GMLIB-LegacyRemoteCallApi")
|
||||||
-- add_requires("levilamina x.x.x")
|
|
||||||
|
|
||||||
-- Option 3: Use the latest commit of LeviLamina on GitHub.
|
|
||||||
-- -- Here, "develop" is the branch name. You can change it to any branch name you want.
|
|
||||||
-- add_requires("levilamina develop")
|
|
||||||
-- -- You can also use debug build of LeviLamina.
|
|
||||||
-- -- add_requires("levilamina develop", {debug = true})
|
|
||||||
-- package("levilamina")
|
|
||||||
-- add_urls("https://github.com/LiteLDev/LeviLamina.git")
|
|
||||||
|
|
||||||
-- add_deps("ctre 3.8.1")
|
|
||||||
-- add_deps("entt 3.12.2")
|
|
||||||
-- add_deps("fmt 10.1.1")
|
|
||||||
-- add_deps("gsl 4.0.0")
|
|
||||||
-- add_deps("leveldb 1.23")
|
|
||||||
-- add_deps("magic_enum 0.9.0")
|
|
||||||
-- add_deps("nlohmann_json 3.11.2")
|
|
||||||
-- add_deps("rapidjson 1.1.0")
|
|
||||||
-- add_deps("pcg_cpp 1.0.0")
|
|
||||||
-- add_deps("pfr 2.1.1")
|
|
||||||
-- add_deps("preloader 1.4.0")
|
|
||||||
-- add_deps("symbolprovider 1.1.0")
|
|
||||||
|
|
||||||
-- -- You may need to change this to the target BDS version of your choice.
|
|
||||||
-- add_deps("bdslibrary 1.20.50.03")
|
|
||||||
|
|
||||||
-- on_install(function (package)
|
|
||||||
-- import("package.tools.xmake").install(package)
|
|
||||||
-- end)
|
|
||||||
|
|
||||||
target("GMLIB-LegacyRemoteCallApi") -- Change this to your plugin name.
|
|
||||||
add_cxflags(
|
add_cxflags(
|
||||||
"/EHa",
|
"/EHa",
|
||||||
"/utf-8"
|
"/utf-8"
|
||||||
@@ -59,14 +28,12 @@ target("GMLIB-LegacyRemoteCallApi") -- Change this to your plugin name.
|
|||||||
"src"
|
"src"
|
||||||
)
|
)
|
||||||
add_packages(
|
add_packages(
|
||||||
"levilaminalibrary",
|
"levilamina",
|
||||||
"legacyremotecall",
|
"legacyremotecall",
|
||||||
"gmlib"
|
"gmlib"
|
||||||
)
|
)
|
||||||
add_shflags(
|
add_rules("@levibuildscript/linkrule")
|
||||||
"/DELAYLOAD:bedrock_server.dll" -- Magic to import symbols from BDS
|
set_exceptions("none")
|
||||||
)
|
|
||||||
set_exceptions("none") -- To avoid conflicts with /EHa
|
|
||||||
set_kind("shared")
|
set_kind("shared")
|
||||||
set_languages("c++23")
|
set_languages("c++23")
|
||||||
set_symbols("debug")
|
set_symbols("debug")
|
||||||
|
|||||||
Reference in New Issue
Block a user