Skip to content

Commit

Permalink
Fix events
Browse files Browse the repository at this point in the history
  • Loading branch information
AnyBananaGAME committed Sep 21, 2024
1 parent d378f32 commit 374f8ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 12 additions & 6 deletions src/client/Listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,27 @@ class Listener extends EventEmitter {
emit<K extends keyof ListenerEvents>(
eventName: K,
...args: Parameters<ListenerEvents[K]>
): boolean {
): boolean;
emit(eventName: string, ...args: unknown[]): boolean;
emit(eventName: string, ...args: unknown[]): boolean {
return super.emit(eventName, ...args);
}

on<K extends keyof ListenerEvents>(
eventName: K,
listener: ListenerEvents[K],
): this {
listener: ListenerEvents[K]
): this;
on(eventName: string, listener: (...args: unknown[]) => void): this;
on(eventName: string, listener: (...args: unknown[]) => void): this {
return super.on(eventName, listener);
}

once<K extends keyof ListenerEvents>(
eventName: K,
listener: ListenerEvents[K],
): this {
listener: ListenerEvents[K]
): this;
once(eventName: string, listener: (...args: unknown[]) => void): this;
once(eventName: string, listener: (...args: unknown[]) => void): this {
return super.once(eventName, listener);
}
}
Expand All @@ -30,7 +36,7 @@ type PacketNames = {
}[keyof typeof Protocol];

type ListenerEvents = {
// @ts-ignore rararara
// @ts-expect-error does not matter
[K in PacketNames]: (packet: InstanceType<(typeof Protocol)[K]>) => void;
} & {
session: () => void;
Expand Down
2 changes: 0 additions & 2 deletions src/vendor/PacketSorter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ export class PacketSorter {
const id = getPacketId(frame);
if (id === SetScorePacket.id) continue;

/** @ts-ignore */
const PacketClass = Packets[id];

if (!PacketClass) {
Expand All @@ -142,7 +141,6 @@ export class PacketSorter {
}
try {
const instance = new PacketClass(frame).deserialize();
// @ts-ignore why tsc.... why!
this.client.emit(PacketClass.name, instance);
} catch (error) {
Logger.warn(
Expand Down

0 comments on commit 374f8ac

Please sign in to comment.