simplified-mojang-api 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/eventsManager.d.ts +2 -1
- package/dist/events/afterEventsSimplifiedManager.d.ts +8 -0
- package/dist/events/afterEventsSimplifiedManager.js +10 -0
- package/dist/events/beforeEventsSimplifiedManager.d.ts +25 -0
- package/dist/events/beforeEventsSimplifiedManager.js +34 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @template T
|
|
5
5
|
* @author HaJuegos - 11-03-2026
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
interface EventRegister<T> {
|
|
8
8
|
subscribe(callback: (args: T) => void): (args: T) => void;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
@@ -24,3 +24,4 @@ export declare class BaseEventManager<T> {
|
|
|
24
24
|
*/
|
|
25
25
|
register(callback: (args: T) => void): void;
|
|
26
26
|
}
|
|
27
|
+
export {};
|
|
@@ -7,6 +7,7 @@ import * as mc from "@minecraft/server";
|
|
|
7
7
|
declare class AfterEventsSimplified {
|
|
8
8
|
private entityDieManager;
|
|
9
9
|
private playerSpawnManager;
|
|
10
|
+
private worldLoadManager;
|
|
10
11
|
/**
|
|
11
12
|
* Eventos que se inicializan cuando la clase es llamada o inicializada.
|
|
12
13
|
* @constructor
|
|
@@ -26,6 +27,13 @@ declare class AfterEventsSimplified {
|
|
|
26
27
|
* @public
|
|
27
28
|
*/
|
|
28
29
|
onPlayerSpawns(callback: (args: mc.PlayerSpawnAfterEvent) => void): void;
|
|
30
|
+
/**
|
|
31
|
+
* Metodo auxiliar que ejecuta los eventos relacionados cuando un mundo se termino de cargar de forma simplificada.
|
|
32
|
+
* @param {(args: mc.WorldLoadAfterEvent) => void} callback Los argumentos del evento y su logica.
|
|
33
|
+
* @author HaJuegos - 11-03-2026
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
onWorldReady(callback: (args: mc.WorldLoadAfterEvent) => void): void;
|
|
29
37
|
}
|
|
30
38
|
export declare const afterEventsSimplified: AfterEventsSimplified;
|
|
31
39
|
export {};
|
|
@@ -13,6 +13,7 @@ class AfterEventsSimplified {
|
|
|
13
13
|
constructor() {
|
|
14
14
|
this.entityDieManager = new BaseEventManager(mc.world.afterEvents.entityDie, "AfterEntityDie");
|
|
15
15
|
this.playerSpawnManager = new BaseEventManager(mc.world.afterEvents.playerSpawn, "AfterPlayerSpawn");
|
|
16
|
+
this.worldLoadManager = new BaseEventManager(mc.world.afterEvents.worldLoad, "AfterWorldLoad");
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
19
|
* Metodo auxiliar que ejecuta los eventos relacionado cuando una entidad muere de forma simplificada.
|
|
@@ -32,5 +33,14 @@ class AfterEventsSimplified {
|
|
|
32
33
|
onPlayerSpawns(callback) {
|
|
33
34
|
this.playerSpawnManager.register(callback);
|
|
34
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Metodo auxiliar que ejecuta los eventos relacionados cuando un mundo se termino de cargar de forma simplificada.
|
|
38
|
+
* @param {(args: mc.WorldLoadAfterEvent) => void} callback Los argumentos del evento y su logica.
|
|
39
|
+
* @author HaJuegos - 11-03-2026
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
onWorldReady(callback) {
|
|
43
|
+
this.worldLoadManager.register(callback);
|
|
44
|
+
}
|
|
35
45
|
}
|
|
36
46
|
export const afterEventsSimplified = new AfterEventsSimplified();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as mc from "@minecraft/server";
|
|
1
2
|
/**
|
|
2
3
|
* Clase principal que maneja los eventos before de forma simplificada para mejor manejo de errores.
|
|
3
4
|
* @class BeforeEventsSimplified
|
|
@@ -5,11 +6,35 @@
|
|
|
5
6
|
* @export
|
|
6
7
|
*/
|
|
7
8
|
declare class BeforeEventsSimplified {
|
|
9
|
+
private startUpManager;
|
|
10
|
+
private shutDownManager;
|
|
11
|
+
private interactBlockManager;
|
|
8
12
|
/**
|
|
9
13
|
* Eventos que se inicializan cuando la clase es llamada o inicializada.
|
|
10
14
|
* @constructor
|
|
11
15
|
*/
|
|
12
16
|
constructor();
|
|
17
|
+
/**
|
|
18
|
+
* Metodo auxiliar que ejecuta los eventos relacionados cuando el add-on se carga por primera vez
|
|
19
|
+
* @param {(args: mc.StartupEvent) => void} callback Los argumentos del evento y su logica.
|
|
20
|
+
* @author HaJuegos - 11-03-2026
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
onAddonStarts(callback: (args: mc.StartupEvent) => void): void;
|
|
24
|
+
/**
|
|
25
|
+
* Metodo auxiliar que ejecuta los eventos relacionados cuando un mundo o servidor se cierra de forma simplificada.
|
|
26
|
+
* @param {(args: mc.ShutdownEvent) => void} callback Los argumentos del evento y su logica.
|
|
27
|
+
* @author HaJuegos - 11-03-2026
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
onAddonStops(callback: (args: mc.ShutdownEvent) => void): void;
|
|
31
|
+
/**
|
|
32
|
+
* Metodo auxiliar que ejecuta los eventos relacionados cuando se interactua con un bloque antes de que pase de forma simplificada.
|
|
33
|
+
* @param {(args: mc.PlayerInteractWithBlockBeforeEvent) => void} callback Los argumentos del evento y su logica.
|
|
34
|
+
* @author HaJuegos - 11-03-2026
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
onInteractBlock(callback: (args: mc.PlayerInteractWithBlockBeforeEvent) => void): void;
|
|
13
38
|
}
|
|
14
39
|
export declare const beforeEventsSimplified: BeforeEventsSimplified;
|
|
15
40
|
export {};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { BaseEventManager } from "../core/eventsManager";
|
|
2
|
+
import * as mc from "@minecraft/server";
|
|
1
3
|
/**
|
|
2
4
|
* Clase principal que maneja los eventos before de forma simplificada para mejor manejo de errores.
|
|
3
5
|
* @class BeforeEventsSimplified
|
|
@@ -9,6 +11,37 @@ class BeforeEventsSimplified {
|
|
|
9
11
|
* Eventos que se inicializan cuando la clase es llamada o inicializada.
|
|
10
12
|
* @constructor
|
|
11
13
|
*/
|
|
12
|
-
constructor() {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.startUpManager = new BaseEventManager(mc.system.beforeEvents.startup, "BeforeStartup");
|
|
16
|
+
this.shutDownManager = new BaseEventManager(mc.system.beforeEvents.shutdown, "BeforeShutdown");
|
|
17
|
+
this.interactBlockManager = new BaseEventManager(mc.world.beforeEvents.playerInteractWithBlock, "BeforeInteractBlock");
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Metodo auxiliar que ejecuta los eventos relacionados cuando el add-on se carga por primera vez
|
|
21
|
+
* @param {(args: mc.StartupEvent) => void} callback Los argumentos del evento y su logica.
|
|
22
|
+
* @author HaJuegos - 11-03-2026
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
onAddonStarts(callback) {
|
|
26
|
+
this.startUpManager.register(callback);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Metodo auxiliar que ejecuta los eventos relacionados cuando un mundo o servidor se cierra de forma simplificada.
|
|
30
|
+
* @param {(args: mc.ShutdownEvent) => void} callback Los argumentos del evento y su logica.
|
|
31
|
+
* @author HaJuegos - 11-03-2026
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
onAddonStops(callback) {
|
|
35
|
+
this.shutDownManager.register(callback);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Metodo auxiliar que ejecuta los eventos relacionados cuando se interactua con un bloque antes de que pase de forma simplificada.
|
|
39
|
+
* @param {(args: mc.PlayerInteractWithBlockBeforeEvent) => void} callback Los argumentos del evento y su logica.
|
|
40
|
+
* @author HaJuegos - 11-03-2026
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
onInteractBlock(callback) {
|
|
44
|
+
this.interactBlockManager.register(callback);
|
|
45
|
+
}
|
|
13
46
|
}
|
|
14
47
|
export const beforeEventsSimplified = new BeforeEventsSimplified();
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED