mirror of
https://github.com/SikongJueluo/kubejs-utils.git
synced 2026-01-29 08:17:49 +08:00
feature(areacontrol): more command and logout recover
feature(areacontrol): - merge setcenter and setradius into single command - add setAreaPos command to simplify the process of setting radius - recover gamemode when logout
This commit is contained in:
@@ -1,3 +1,17 @@
|
||||
/**
|
||||
* @typedef {(
|
||||
* "PlayerItemFishedEvent" |
|
||||
* "LivingEntityUseItemEvent$Finish"
|
||||
* )} EventName
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {(
|
||||
* ((event: Internal.ItemFishedEvent) => any) |
|
||||
* ((event: Internal.LivingEntityUseItemEvent$Finish) => any)
|
||||
* )} EventCallback
|
||||
*/
|
||||
|
||||
/**
|
||||
* A simple event bus for handling custom events in KubeJS environment.
|
||||
* @namespace
|
||||
@@ -9,6 +23,13 @@ const eventBus = {
|
||||
*/
|
||||
eventMap: {},
|
||||
|
||||
/**
|
||||
* Registers a callback function for a specific event.
|
||||
* @overload
|
||||
* @param {"PlayerItemFishedEvent"} eventName - The name of the event to listen for.
|
||||
* @param {(event: Internal.ItemFishedEvent) => any} callback - The callback function.
|
||||
* @returns {void}
|
||||
*/
|
||||
/**
|
||||
* Registers a callback function for a specific event.
|
||||
* @overload
|
||||
@@ -18,14 +39,21 @@ const eventBus = {
|
||||
*/
|
||||
/**
|
||||
* Registers a callback function for a specific event.
|
||||
* @param {string} eventName - The name of the event to listen for.
|
||||
* @param {Function} callback - The callback function to execute when the event is emitted.
|
||||
* @param {EventName} eventName - The name of the event to listen for.
|
||||
* @param {EventCallback} callback - The callback function to execute when the event is emitted.
|
||||
* @returns {void}
|
||||
*/
|
||||
register: function (eventName, callback) {
|
||||
this.eventMap[eventName] = callback;
|
||||
},
|
||||
|
||||
/**
|
||||
* Registers a callback function for a specific event.
|
||||
* @overload
|
||||
* @param {"PlayerItemFishedEvent"} eventName - The name of the event to listen for.
|
||||
* @param {(event: Internal.ItemFishedEvent) => any} callback - The callback function.
|
||||
* @returns {void}
|
||||
*/
|
||||
/**
|
||||
* Emits an event, calling the registered callback function if it exists.
|
||||
* @overload
|
||||
@@ -59,3 +87,17 @@ ForgeEvents.onEvent(
|
||||
eventBus.emit("LivingEntityUseItemEvent$Finish", event);
|
||||
},
|
||||
);
|
||||
|
||||
ForgeEvents.onEvent(
|
||||
"net.minecraftforge.event.entity.player.ItemFishedEvent",
|
||||
(event) => {
|
||||
eventBus.emit("PlayerItemFishedEvent", event);
|
||||
},
|
||||
);
|
||||
|
||||
ForgeEvents.onEvent(
|
||||
"net.minecraftforge.event.entity.player.ItemFishedEvent",
|
||||
(event) => {
|
||||
eventBus.emit("PlayerItemFishedEvent", event);
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user