From 3f025a030e3aee41c0add0c565f3897c8f6695b7 Mon Sep 17 00:00:00 2001 From: Bill Date: Mon, 12 Jul 2021 00:48:44 -0400 Subject: [PATCH] Add MysteryBoxKeysEvent --- src/nitro/communication/NitroMessages.ts | 5 ++- .../messages/incoming/IncomingHeader.ts | 2 +- .../communication/messages/incoming/index.ts | 1 + .../mysterybox/MysteryBoxKeysEvent.ts | 16 +++++++++ .../messages/incoming/mysterybox/index.ts | 1 + .../communication/messages/parser/index.ts | 1 + .../parser/mysterybox/MysteryBoxKeysParser.ts | 36 +++++++++++++++++++ .../messages/parser/mysterybox/index.ts | 1 + src/nitro/session/SessionDataManager.ts | 14 ++++++++ .../events/MysteryBoxKeysUpdateEvent.ts | 6 ++-- 10 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 src/nitro/communication/messages/incoming/mysterybox/MysteryBoxKeysEvent.ts create mode 100644 src/nitro/communication/messages/incoming/mysterybox/index.ts create mode 100644 src/nitro/communication/messages/parser/mysterybox/MysteryBoxKeysParser.ts create mode 100644 src/nitro/communication/messages/parser/mysterybox/index.ts diff --git a/src/nitro/communication/NitroMessages.ts b/src/nitro/communication/NitroMessages.ts index c4d37cf4..2eb4cde2 100644 --- a/src/nitro/communication/NitroMessages.ts +++ b/src/nitro/communication/NitroMessages.ts @@ -1,5 +1,5 @@ import { IMessageConfiguration } from '../../core/communication/messages/IMessageConfiguration'; -import { ApproveNameMessageComposer, CatalogApproveNameResultEvent, FurnitureGuildInfoComposer, PetMountComposer, PetSupplementComposer, RemovePetSaddleComposer, RoomUnitGiveHandItemPetComposer, RoomWidgetCameraPublishedEvent, RoomWidgetCameraPurchaseComposer, SellablePetPalettesEvent, TogglePetBreedingComposer, TogglePetRidingComposer, UsePetProductComposer } from './messages'; +import { ApproveNameMessageComposer, CatalogApproveNameResultEvent, FurnitureGuildInfoComposer, MysteryBoxKeysEvent, PetMountComposer, PetSupplementComposer, RemovePetSaddleComposer, RoomUnitGiveHandItemPetComposer, RoomWidgetCameraPublishedEvent, RoomWidgetCameraPurchaseComposer, SellablePetPalettesEvent, TogglePetBreedingComposer, TogglePetRidingComposer, UsePetProductComposer } from './messages'; import { AvailabilityStatusMessageEvent } from './messages/incoming/availability/AvailabilityStatusMessageEvent'; import { CatalogClubEvent } from './messages/incoming/catalog/CatalogClubEvent'; import { CatalogClubGiftsEvent } from './messages/incoming/catalog/CatalogClubGiftsEvent'; @@ -541,6 +541,9 @@ export class NitroMessages implements IMessageConfiguration this._events.set(IncomingHeader.MODTOOL_USER_CHATLOG, ModtoolUserChatlogEvent); this._events.set(IncomingHeader.MODTOOL_ROOM_CHATLOG, ModtoolRoomChatlogEvent); + // MYSTERY BOX + this._events.set(IncomingHeader.MYSTERY_BOX_KEYS, MysteryBoxKeysEvent); + // NAVIGATOR this._events.set(IncomingHeader.NAVIGATOR_CATEGORIES, NavigatorCategoriesEvent); this._events.set(IncomingHeader.NAVIGATOR_COLLAPSED, NavigatorCollapsedEvent); diff --git a/src/nitro/communication/messages/incoming/IncomingHeader.ts b/src/nitro/communication/messages/incoming/IncomingHeader.ts index 1088c4f5..775f22f8 100644 --- a/src/nitro/communication/messages/incoming/IncomingHeader.ts +++ b/src/nitro/communication/messages/incoming/IncomingHeader.ts @@ -141,7 +141,7 @@ export class IncomingHeader public static ROOM_THICKNESS = 3547; public static SECURITY_DEBUG = 3284; public static SECURITY_MACHINE = 1488; - public static SECURITY_UNKNOWN2 = 2833; + public static MYSTERY_BOX_KEYS = 2833; public static TRADE_ACCEPTED = 2568; public static TRADE_CLOSED = 1373; public static TRADE_COMPLETED = 1001; diff --git a/src/nitro/communication/messages/incoming/index.ts b/src/nitro/communication/messages/incoming/index.ts index 3e838189..5b2529cb 100644 --- a/src/nitro/communication/messages/incoming/index.ts +++ b/src/nitro/communication/messages/incoming/index.ts @@ -24,6 +24,7 @@ export * from './inventory/pets'; export * from './inventory/trading'; export * from './moderation'; export * from './modtool'; +export * from './mysterybox'; export * from './navigator'; export * from './notifications'; export * from './room'; diff --git a/src/nitro/communication/messages/incoming/mysterybox/MysteryBoxKeysEvent.ts b/src/nitro/communication/messages/incoming/mysterybox/MysteryBoxKeysEvent.ts new file mode 100644 index 00000000..e14442bc --- /dev/null +++ b/src/nitro/communication/messages/incoming/mysterybox/MysteryBoxKeysEvent.ts @@ -0,0 +1,16 @@ +import { IMessageEvent } from '../../../../../core/communication/messages/IMessageEvent'; +import { MessageEvent } from '../../../../../core/communication/messages/MessageEvent'; +import { MysteryBoxKeysParser } from '../../parser'; + +export class MysteryBoxKeysEvent extends MessageEvent implements IMessageEvent +{ + constructor(callBack: Function) + { + super(callBack, MysteryBoxKeysParser); + } + + public getParser(): MysteryBoxKeysParser + { + return this.parser as MysteryBoxKeysParser; + } +} diff --git a/src/nitro/communication/messages/incoming/mysterybox/index.ts b/src/nitro/communication/messages/incoming/mysterybox/index.ts new file mode 100644 index 00000000..15a621fc --- /dev/null +++ b/src/nitro/communication/messages/incoming/mysterybox/index.ts @@ -0,0 +1 @@ +export * from './MysteryBoxKeysEvent'; diff --git a/src/nitro/communication/messages/parser/index.ts b/src/nitro/communication/messages/parser/index.ts index 6b2d0ec4..1614562a 100644 --- a/src/nitro/communication/messages/parser/index.ts +++ b/src/nitro/communication/messages/parser/index.ts @@ -11,6 +11,7 @@ export * from './help'; export * from './inventory'; export * from './moderation'; export * from './modtool'; +export * from './mysterybox'; export * from './navigator'; export * from './notifications'; export * from './room'; diff --git a/src/nitro/communication/messages/parser/mysterybox/MysteryBoxKeysParser.ts b/src/nitro/communication/messages/parser/mysterybox/MysteryBoxKeysParser.ts new file mode 100644 index 00000000..385a4fa2 --- /dev/null +++ b/src/nitro/communication/messages/parser/mysterybox/MysteryBoxKeysParser.ts @@ -0,0 +1,36 @@ +import { IMessageDataWrapper } from '../../../../../core/communication/messages/IMessageDataWrapper'; +import { IMessageParser } from '../../../../../core/communication/messages/IMessageParser'; + +export class MysteryBoxKeysParser implements IMessageParser +{ + private _boxColor: string; + private _keyColor: string; + + public flush(): boolean + { + this._boxColor = null; + this._keyColor = null; + + return true; + } + + public parse(wrapper: IMessageDataWrapper): boolean + { + if(!wrapper) return false; + + this._boxColor = wrapper.readString(); + this._keyColor = wrapper.readString(); + + return true; + } + + public get boxColor(): string + { + return this._boxColor; + } + + public get keyColor(): string + { + return this._keyColor; + } +} diff --git a/src/nitro/communication/messages/parser/mysterybox/index.ts b/src/nitro/communication/messages/parser/mysterybox/index.ts new file mode 100644 index 00000000..f9b3ed82 --- /dev/null +++ b/src/nitro/communication/messages/parser/mysterybox/index.ts @@ -0,0 +1 @@ +export * from './MysteryBoxKeysParser'; diff --git a/src/nitro/session/SessionDataManager.ts b/src/nitro/session/SessionDataManager.ts index 330af27f..ca7c6f53 100644 --- a/src/nitro/session/SessionDataManager.ts +++ b/src/nitro/session/SessionDataManager.ts @@ -2,6 +2,7 @@ import { Texture } from 'pixi.js'; import { NitroManager } from '../../core/common/NitroManager'; import { IMessageComposer } from '../../core/communication/messages/IMessageComposer'; import { NitroEvent } from '../../core/events/NitroEvent'; +import { MysteryBoxKeysEvent } from '../communication'; import { INitroCommunicationManager } from '../communication/INitroCommunicationManager'; import { AvailabilityStatusMessageEvent } from '../communication/messages/incoming/availability/AvailabilityStatusMessageEvent'; import { ChangeUserNameResultMessageEvent } from '../communication/messages/incoming/avatar/ChangeUserNameResultMessageEvent'; @@ -20,6 +21,7 @@ import { Nitro } from '../Nitro'; import { HabboWebTools } from '../utils/HabboWebTools'; import { BadgeImageManager } from './BadgeImageManager'; import { SecurityLevel } from './enum/SecurityLevel'; +import { MysteryBoxKeysUpdateEvent } from './events'; import { SessionDataPreferencesEvent } from './events/SessionDataPreferencesEvent'; import { UserNameUpdateEvent } from './events/UserNameUpdateEvent'; import { FurnitureDataLoader } from './furniture/FurnitureDataLoader'; @@ -127,6 +129,7 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana this._communication.registerMessageEvent(new UserNameChangeMessageEvent(this.onUserNameChangeMessageEvent.bind(this))); this._communication.registerMessageEvent(new RoomModelNameEvent(this.onRoomModelNameEvent.bind(this))); this._communication.registerMessageEvent(new InClientLinkEvent(this.onInClientLinkEvent.bind(this))); + this._communication.registerMessageEvent(new MysteryBoxKeysEvent(this.onMysteryBoxKeysEvent.bind(this))); Nitro.instance.events.addEventListener(NitroSettingsEvent.SETTINGS_UPDATED, this.onNitroSettingsEvent); } @@ -372,6 +375,17 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana Nitro.instance.createLinkEvent(parser.link); } + private onMysteryBoxKeysEvent(event: MysteryBoxKeysEvent): void + { + if(!event) return; + + const parser = event.getParser(); + + if(!parser) return; + + this.events.dispatchEvent(new MysteryBoxKeysUpdateEvent(parser.boxColor, parser.keyColor)); + } + private onNitroSettingsEvent(event: NitroSettingsEvent): void { this._isRoomCameraFollowDisabled = event.cameraFollow; diff --git a/src/nitro/session/events/MysteryBoxKeysUpdateEvent.ts b/src/nitro/session/events/MysteryBoxKeysUpdateEvent.ts index 459c946c..5ad409fe 100644 --- a/src/nitro/session/events/MysteryBoxKeysUpdateEvent.ts +++ b/src/nitro/session/events/MysteryBoxKeysUpdateEvent.ts @@ -7,12 +7,12 @@ export class MysteryBoxKeysUpdateEvent extends NitroEvent private _boxColor: string; private _keyColor: string; - constructor(k: string, _arg_2: string) + constructor(boxColor: string, keyColor: string) { super(MysteryBoxKeysUpdateEvent.MYSTERY_BOX_KEYS_UPDATE); - this._boxColor = k; - this._keyColor = _arg_2; + this._boxColor = boxColor; + this._keyColor = keyColor; } public get boxColor(): string