Add MysteryBoxKeysEvent

This commit is contained in:
Bill 2021-07-12 00:48:44 -04:00
parent ec85047bd3
commit 3f025a030e
10 changed files with 78 additions and 5 deletions

View File

@ -1,5 +1,5 @@
import { IMessageConfiguration } from '../../core/communication/messages/IMessageConfiguration'; 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 { AvailabilityStatusMessageEvent } from './messages/incoming/availability/AvailabilityStatusMessageEvent';
import { CatalogClubEvent } from './messages/incoming/catalog/CatalogClubEvent'; import { CatalogClubEvent } from './messages/incoming/catalog/CatalogClubEvent';
import { CatalogClubGiftsEvent } from './messages/incoming/catalog/CatalogClubGiftsEvent'; 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_USER_CHATLOG, ModtoolUserChatlogEvent);
this._events.set(IncomingHeader.MODTOOL_ROOM_CHATLOG, ModtoolRoomChatlogEvent); this._events.set(IncomingHeader.MODTOOL_ROOM_CHATLOG, ModtoolRoomChatlogEvent);
// MYSTERY BOX
this._events.set(IncomingHeader.MYSTERY_BOX_KEYS, MysteryBoxKeysEvent);
// NAVIGATOR // NAVIGATOR
this._events.set(IncomingHeader.NAVIGATOR_CATEGORIES, NavigatorCategoriesEvent); this._events.set(IncomingHeader.NAVIGATOR_CATEGORIES, NavigatorCategoriesEvent);
this._events.set(IncomingHeader.NAVIGATOR_COLLAPSED, NavigatorCollapsedEvent); this._events.set(IncomingHeader.NAVIGATOR_COLLAPSED, NavigatorCollapsedEvent);

View File

@ -141,7 +141,7 @@ export class IncomingHeader
public static ROOM_THICKNESS = 3547; public static ROOM_THICKNESS = 3547;
public static SECURITY_DEBUG = 3284; public static SECURITY_DEBUG = 3284;
public static SECURITY_MACHINE = 1488; public static SECURITY_MACHINE = 1488;
public static SECURITY_UNKNOWN2 = 2833; public static MYSTERY_BOX_KEYS = 2833;
public static TRADE_ACCEPTED = 2568; public static TRADE_ACCEPTED = 2568;
public static TRADE_CLOSED = 1373; public static TRADE_CLOSED = 1373;
public static TRADE_COMPLETED = 1001; public static TRADE_COMPLETED = 1001;

View File

@ -24,6 +24,7 @@ export * from './inventory/pets';
export * from './inventory/trading'; export * from './inventory/trading';
export * from './moderation'; export * from './moderation';
export * from './modtool'; export * from './modtool';
export * from './mysterybox';
export * from './navigator'; export * from './navigator';
export * from './notifications'; export * from './notifications';
export * from './room'; export * from './room';

View File

@ -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;
}
}

View File

@ -0,0 +1 @@
export * from './MysteryBoxKeysEvent';

View File

@ -11,6 +11,7 @@ export * from './help';
export * from './inventory'; export * from './inventory';
export * from './moderation'; export * from './moderation';
export * from './modtool'; export * from './modtool';
export * from './mysterybox';
export * from './navigator'; export * from './navigator';
export * from './notifications'; export * from './notifications';
export * from './room'; export * from './room';

View File

@ -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;
}
}

View File

@ -0,0 +1 @@
export * from './MysteryBoxKeysParser';

View File

@ -2,6 +2,7 @@ import { Texture } from 'pixi.js';
import { NitroManager } from '../../core/common/NitroManager'; import { NitroManager } from '../../core/common/NitroManager';
import { IMessageComposer } from '../../core/communication/messages/IMessageComposer'; import { IMessageComposer } from '../../core/communication/messages/IMessageComposer';
import { NitroEvent } from '../../core/events/NitroEvent'; import { NitroEvent } from '../../core/events/NitroEvent';
import { MysteryBoxKeysEvent } from '../communication';
import { INitroCommunicationManager } from '../communication/INitroCommunicationManager'; import { INitroCommunicationManager } from '../communication/INitroCommunicationManager';
import { AvailabilityStatusMessageEvent } from '../communication/messages/incoming/availability/AvailabilityStatusMessageEvent'; import { AvailabilityStatusMessageEvent } from '../communication/messages/incoming/availability/AvailabilityStatusMessageEvent';
import { ChangeUserNameResultMessageEvent } from '../communication/messages/incoming/avatar/ChangeUserNameResultMessageEvent'; import { ChangeUserNameResultMessageEvent } from '../communication/messages/incoming/avatar/ChangeUserNameResultMessageEvent';
@ -20,6 +21,7 @@ import { Nitro } from '../Nitro';
import { HabboWebTools } from '../utils/HabboWebTools'; import { HabboWebTools } from '../utils/HabboWebTools';
import { BadgeImageManager } from './BadgeImageManager'; import { BadgeImageManager } from './BadgeImageManager';
import { SecurityLevel } from './enum/SecurityLevel'; import { SecurityLevel } from './enum/SecurityLevel';
import { MysteryBoxKeysUpdateEvent } from './events';
import { SessionDataPreferencesEvent } from './events/SessionDataPreferencesEvent'; import { SessionDataPreferencesEvent } from './events/SessionDataPreferencesEvent';
import { UserNameUpdateEvent } from './events/UserNameUpdateEvent'; import { UserNameUpdateEvent } from './events/UserNameUpdateEvent';
import { FurnitureDataLoader } from './furniture/FurnitureDataLoader'; 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 UserNameChangeMessageEvent(this.onUserNameChangeMessageEvent.bind(this)));
this._communication.registerMessageEvent(new RoomModelNameEvent(this.onRoomModelNameEvent.bind(this))); this._communication.registerMessageEvent(new RoomModelNameEvent(this.onRoomModelNameEvent.bind(this)));
this._communication.registerMessageEvent(new InClientLinkEvent(this.onInClientLinkEvent.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); 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); 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 private onNitroSettingsEvent(event: NitroSettingsEvent): void
{ {
this._isRoomCameraFollowDisabled = event.cameraFollow; this._isRoomCameraFollowDisabled = event.cameraFollow;

View File

@ -7,12 +7,12 @@ export class MysteryBoxKeysUpdateEvent extends NitroEvent
private _boxColor: string; private _boxColor: string;
private _keyColor: string; private _keyColor: string;
constructor(k: string, _arg_2: string) constructor(boxColor: string, keyColor: string)
{ {
super(MysteryBoxKeysUpdateEvent.MYSTERY_BOX_KEYS_UPDATE); super(MysteryBoxKeysUpdateEvent.MYSTERY_BOX_KEYS_UPDATE);
this._boxColor = k; this._boxColor = boxColor;
this._keyColor = _arg_2; this._keyColor = keyColor;
} }
public get boxColor(): string public get boxColor(): string