[Linux-only] basically bloxstap for sober
at dev 75 lines 1.7 kB view raw
1import { eventCollector } from "./EventCollector"; 2import type { 3 PlrJoinLeaveAction, 4 GameJoinAction, 5 BloxstrapRPCAction 6} from "./types"; 7 8/** 9 * Main EventEmitter class for emitting events to all registered plugins 10 * This replaces the old BloxstrapRPC API with a direct event system 11 */ 12export class EventEmitter { 13 /** 14 * Emit a game join event 15 */ 16 public static emitGameJoin(gameData: GameJoinAction): void { 17 eventCollector.emitGameJoin(gameData); 18 } 19 20 /** 21 * Emit a game leave event 22 */ 23 public static emitGameLeave(): void { 24 eventCollector.emitGameLeave(); 25 } 26 27 /** 28 * Emit a player join event 29 */ 30 public static emitPlayerJoin(playerData: PlrJoinLeaveAction): void { 31 eventCollector.emitPlayerJoin(playerData); 32 } 33 34 /** 35 * Emit a player leave event 36 */ 37 public static emitPlayerLeave(playerData: PlrJoinLeaveAction): void { 38 eventCollector.emitPlayerLeave(playerData); 39 } 40 41 /** 42 * Emit a Bloxstrap RPC event 43 */ 44 public static emitBloxstrapRPC(rpcData: BloxstrapRPCAction): void { 45 eventCollector.emitBloxstrapRPC(rpcData); 46 } 47 48 /** 49 * Get the number of listeners for a specific event type 50 */ 51 public static getListenerCount(eventType: string): number { 52 return eventCollector.getListenerCount(eventType as any); 53 } 54 55 /** 56 * Get all registered event types 57 */ 58 public static getRegisteredEvents(): string[] { 59 return eventCollector.getRegisteredEvents(); 60 } 61 62 /** 63 * Clear all listeners for a specific event type 64 */ 65 public static clearListeners(eventType: string): void { 66 eventCollector.clearListeners(eventType as any); 67 } 68 69 /** 70 * Clear all listeners for all event types 71 */ 72 public static clearAllListeners(): void { 73 eventCollector.clearAllListeners(); 74 } 75}