New Group packets

This commit is contained in:
MyNameIsBatman 2021-09-03 16:01:49 -03:00
parent 4e46c15107
commit 49f934b820
13 changed files with 198 additions and 2 deletions

View File

@ -1,5 +1,5 @@
import { IMessageConfiguration } from '../../core/communication/messages/IMessageConfiguration';
import { AchievementNotificationMessageEvent, ActivityPointNotificationMessageEvent, AddJukeboxDiskComposer, ApproveNameMessageComposer, ApproveNameMessageEvent, AvailabilityTimeMessageEvent, BadgeReceivedEvent, BonusRareInfoMessageEvent, BuildersClubFurniCountMessageEvent, BuildersClubSubscriptionStatusMessageEvent, BundleDiscountRulesetMessageEvent, ChangeUserNameMessageComposer, ChangeUserNameResultMessageEvent, CheckUserNameMessageComposer, CheckUserNameResultMessageEvent, ClubGiftNotificationEvent, DirectSMSClubBuyAvailableMessageEvent, FigureUpdateEvent, FurnitureGroupInfoComposer, GetBonusRareInfoMessageComposer, GetCatalogPageExpirationComposer, GetCatalogPageWithEarliestExpiryComposer, GetDirectClubBuyAvailableComposer, GetHabboBasicMembershipExtendOfferComposer, GetHabboClubExtendOfferMessageComposer, GetInterstitialMessageComposer, GetJukeboxPlayListMessageComposer, GetLimitedOfferAppearingNextComposer, GetNextTargetedOfferComposer, GetNowPlayingMessageComposer, GetOfficialSongIdMessageComposer, GetRoomAdPurchaseInfoComposer, GetSeasonalCalendarDailyOfferComposer, GetSongInfoMessageComposer, GetSoundMachinePlayListMessageComposer, GetUserSongDisksMessageComposer, HabboClubExtendOfferMessageEvent, HotelClosedAndOpensEvent, HotelClosesAndWillOpenAtEvent, HotelWillCloseInMinutesEvent, InfoFeedEnableMessageEvent, InterstitialMessageEvent, InterstitialShownMessageComposer, IsOfferGiftableMessageEvent, JukeboxPlayListFullMessageEvent, JukeboxSongDisksMessageEvent, LimitedOfferAppearingNextMessageEvent, MaintenanceStatusMessageEvent, MarkCatalogNewAdditionsPageOpenedComposer, MarketplaceBuyOfferComposer, MarketplaceRedeemCreditsComposer, MarketplaceRequesstItemStatsComposer, MarketplaceRequestComposer, MarketplaceRequestOffersComposer, MarketplaceRequestOwnItemsComposer, MarketplaceTakeItemBackComposer, MysteryBoxKeysEvent, NotEnoughBalanceMessageEvent, NowPlayingMessageEvent, OfficialSongIdMessageEvent, OpenCampaignCalendarDoorAsStaffComposer, OpenCampaignCalendarDoorComposer, PetExperienceEvent, PetMountComposer, PetSupplementComposer, PlayListMessageEvent, PlayListSongAddedMessageEvent, PurchaseBasicMembershipExtensionComposer, PurchaseRoomAdMessageComposer, PurchaseTargetedOfferComposer, PurchaseVipMembershipExtensionComposer, RemoveAllRightsMessageComposer, RemoveJukeboxDiskComposer, RemoveOwnRoomRightsRoomMessageComposer, RemovePetSaddleComposer, RoomAdErrorEvent, RoomAdPurchaseInfoEvent, RoomUnitGiveHandItemPetComposer, SeasonalCalendarDailyOfferMessageEvent, SellablePetPalettesMessageEvent, SetTargetedOfferStateComposer, ShopTargetedOfferViewedComposer, TargetedOfferEvent, TargetedOfferNotFoundEvent, TogglePetBreedingComposer, TogglePetRidingComposer, TraxSongInfoMessageEvent, UnseenResetCategoryComposer, UnseenResetItemsComposer, UsePetProductComposer, UserSongDisksInventoryMessageEvent, WardrobeMessageEvent } from './messages';
import { AchievementNotificationMessageEvent, ActivityPointNotificationMessageEvent, AddJukeboxDiskComposer, ApproveNameMessageComposer, ApproveNameMessageEvent, AvailabilityTimeMessageEvent, BadgeReceivedEvent, BonusRareInfoMessageEvent, BuildersClubFurniCountMessageEvent, BuildersClubSubscriptionStatusMessageEvent, BundleDiscountRulesetMessageEvent, ChangeUserNameMessageComposer, ChangeUserNameResultMessageEvent, CheckUserNameMessageComposer, CheckUserNameResultMessageEvent, ClubGiftNotificationEvent, DirectSMSClubBuyAvailableMessageEvent, FigureUpdateEvent, FurnitureGroupInfoComposer, GetBonusRareInfoMessageComposer, GetCatalogPageExpirationComposer, GetCatalogPageWithEarliestExpiryComposer, GetDirectClubBuyAvailableComposer, GetHabboBasicMembershipExtendOfferComposer, GetHabboClubExtendOfferMessageComposer, GetInterstitialMessageComposer, GetJukeboxPlayListMessageComposer, GetLimitedOfferAppearingNextComposer, GetNextTargetedOfferComposer, GetNowPlayingMessageComposer, GetOfficialSongIdMessageComposer, GetRoomAdPurchaseInfoComposer, GetSeasonalCalendarDailyOfferComposer, GetSongInfoMessageComposer, GetSoundMachinePlayListMessageComposer, GetUserSongDisksMessageComposer, GroupBadgesComposer, GroupBadgesEvent, HabboClubExtendOfferMessageEvent, HotelClosedAndOpensEvent, HotelClosesAndWillOpenAtEvent, HotelWillCloseInMinutesEvent, InfoFeedEnableMessageEvent, InterstitialMessageEvent, InterstitialShownMessageComposer, IsOfferGiftableMessageEvent, JukeboxPlayListFullMessageEvent, JukeboxSongDisksMessageEvent, LimitedOfferAppearingNextMessageEvent, MaintenanceStatusMessageEvent, MarkCatalogNewAdditionsPageOpenedComposer, MarketplaceBuyOfferComposer, MarketplaceRedeemCreditsComposer, MarketplaceRequesstItemStatsComposer, MarketplaceRequestComposer, MarketplaceRequestOffersComposer, MarketplaceRequestOwnItemsComposer, MarketplaceTakeItemBackComposer, MysteryBoxKeysEvent, NotEnoughBalanceMessageEvent, NowPlayingMessageEvent, OfficialSongIdMessageEvent, OpenCampaignCalendarDoorAsStaffComposer, OpenCampaignCalendarDoorComposer, PetExperienceEvent, PetMountComposer, PetSupplementComposer, PlayListMessageEvent, PlayListSongAddedMessageEvent, PurchaseBasicMembershipExtensionComposer, PurchaseRoomAdMessageComposer, PurchaseTargetedOfferComposer, PurchaseVipMembershipExtensionComposer, RemoveAllRightsMessageComposer, RemoveJukeboxDiskComposer, RemoveOwnRoomRightsRoomMessageComposer, RemovePetSaddleComposer, RoomAdErrorEvent, RoomAdPurchaseInfoEvent, RoomUnitGiveHandItemPetComposer, SeasonalCalendarDailyOfferMessageEvent, SellablePetPalettesMessageEvent, SetTargetedOfferStateComposer, ShopTargetedOfferViewedComposer, TargetedOfferEvent, TargetedOfferNotFoundEvent, TogglePetBreedingComposer, TogglePetRidingComposer, TraxSongInfoMessageEvent, UnseenResetCategoryComposer, UnseenResetItemsComposer, UsePetProductComposer, UserSongDisksInventoryMessageEvent, WardrobeMessageEvent } from './messages';
import { AvailabilityStatusMessageEvent } from './messages/incoming/availability/AvailabilityStatusMessageEvent';
import { CfhSanctionMessageEvent, CfhTopicsInitEvent, SanctionStatusEvent } from './messages/incoming/callforhelp';
import { CameraPublishStatusMessageEvent } from './messages/incoming/camera/CameraPublishStatusMessageEvent';
@ -278,6 +278,7 @@ import { GroupBuyComposer } from './messages/outgoing/group/GroupBuyComposer';
import { GroupBuyDataComposer } from './messages/outgoing/group/GroupBuyDataComposer';
import { GroupConfirmRemoveMemberComposer } from './messages/outgoing/group/GroupConfirmRemoveMemberComposer';
import { GroupDeleteComposer } from './messages/outgoing/group/GroupDeleteComposer';
import { GroupFavoriteComposer } from './messages/outgoing/group/GroupFavoriteComposer';
import { GroupInformationComposer } from './messages/outgoing/group/GroupInformationComposer';
import { GroupJoinComposer } from './messages/outgoing/group/GroupJoinComposer';
import { GroupMembersComposer } from './messages/outgoing/group/GroupMembersComposer';
@ -584,6 +585,7 @@ export class NitroMessages implements IMessageConfiguration
this._events.set(IncomingHeader.GROUP_BADGE_PARTS, GroupBadgePartsEvent);
this._events.set(IncomingHeader.GROUP_SETTINGS, GroupSettingsEvent);
this._events.set(IncomingHeader.GROUP_PURCHASED, GroupPurchasedEvent);
this._events.set(IncomingHeader.GROUP_BADGES, GroupBadgesEvent);
// HELP
this._events.set(IncomingHeader.CFH_RESULT_MESSAGE, CallForHelpResultMessageEvent);
@ -971,6 +973,8 @@ export class NitroMessages implements IMessageConfiguration
this._composers.set(OutgoingHeader.GROUP_SAVE_COLORS, GroupSaveColorsComposer);
this._composers.set(OutgoingHeader.GROUP_SAVE_INFORMATION, GroupSaveInformationComposer);
this._composers.set(OutgoingHeader.GROUP_SAVE_PREFERENCES, GroupSavePreferencesComposer);
this._composers.set(OutgoingHeader.GROUP_FAVORITE, GroupFavoriteComposer);
this._composers.set(OutgoingHeader.GROUP_BADGES, GroupBadgesComposer);
// SECURITY
this._composers.set(OutgoingHeader.SECURITY_TICKET, SecurityTicketComposer);

View File

@ -37,7 +37,7 @@ export class IncomingHeader
public static GENERIC_ALERT = 3801;
public static MODERATOR_MESSAGE = 2030;
public static GENERIC_ERROR = 1600;
public static GIFT_WRAPPER_CONFIG = 2234;
public static GIFT_WRAPPER_CONFIG = 2234;
public static GROUP_BADGES = 2402;
public static GROUP_CREATE_OPTIONS = 2159;
public static GROUP_FORUM_INFO = 3011;

View File

@ -0,0 +1,16 @@
import { IMessageEvent } from '../../../../../core/communication/messages/IMessageEvent';
import { MessageEvent } from '../../../../../core/communication/messages/MessageEvent';
import { GroupBadgesParser } from '../../parser/group/GroupBadgesParser';
export class GroupBadgesEvent extends MessageEvent implements IMessageEvent
{
constructor(callBack: Function)
{
super(callBack, GroupBadgesParser);
}
public getParser(): GroupBadgesParser
{
return this.parser as GroupBadgesParser;
}
}

View File

@ -1,4 +1,5 @@
export * from './GroupBadgePartsEvent';
export * from './GroupBadgesEvent';
export * from './GroupBuyDataEvent';
export * from './GroupConfirmMemberRemoveEvent';
export * from './GroupInformationEvent';

View File

@ -40,6 +40,7 @@ export class OutgoingHeader
public static GROUP_ADMIN_ADD = 2894;
public static GROUP_ADMIN_REMOVE = 722;
public static GROUP_CREATE_OPTIONS = 798;
public static GROUP_FAVORITE = 3549;
public static GROUP_FORUM_INFO = 3149;
public static GROUP_FORUM_LIST = 873;
public static GROUP_FORUM_THREADS = 436;
@ -59,6 +60,7 @@ export class OutgoingHeader
public static GROUP_SAVE_BADGE = 1991;
public static GROUP_SAVE_COLORS = 1764;
public static GROUP_SAVE_PREFERENCES = 3435;
public static GROUP_BADGES = 21;
public static INVENTORY_UNKNOWN = 1371;
public static ITEM_CLOTHING_REDEEM = 3374;
public static ITEM_COLOR_WHEEL_CLICK = 2144;

View File

@ -0,0 +1,21 @@
import { IMessageComposer } from '../../../../../core/communication/messages/IMessageComposer';
export class GroupBadgesComposer implements IMessageComposer<ConstructorParameters<typeof GroupBadgesComposer>>
{
private _data: ConstructorParameters<typeof GroupBadgesComposer>;
constructor()
{
this._data = [];
}
public getMessageArray()
{
return this._data;
}
public dispose(): void
{
return;
}
}

View File

@ -0,0 +1,21 @@
import { IMessageComposer } from '../../../../../core/communication/messages/IMessageComposer';
export class GroupFavoriteComposer implements IMessageComposer<ConstructorParameters<typeof GroupFavoriteComposer>>
{
private _data: ConstructorParameters<typeof GroupFavoriteComposer>;
constructor(groupId: number)
{
this._data = [ groupId ];
}
public getMessageArray()
{
return this._data;
}
public dispose(): void
{
return;
}
}

View File

@ -1,10 +1,12 @@
export * from './GroupAdminGiveComposer';
export * from './GroupAdminTakeComposer';
export * from './GroupBadgePartsComposer';
export * from './GroupBadgesComposer';
export * from './GroupBuyComposer';
export * from './GroupBuyDataComposer';
export * from './GroupConfirmRemoveMemberComposer';
export * from './GroupDeleteComposer';
export * from './GroupFavoriteComposer';
export * from './GroupInformationComposer';
export * from './GroupJoinComposer';
export * from './GroupMembersComposer';

View File

@ -0,0 +1,36 @@
import { IMessageDataWrapper, IMessageParser } from '../../../../../core';
export class GroupBadgesParser implements IMessageParser
{
private _badges: Map<number, string>;
flush(): boolean
{
this._badges = new Map();
return true;
}
parse(wrapper: IMessageDataWrapper): boolean
{
if(!wrapper) return false;
let badgesCount = wrapper.readInt();
while(badgesCount > 0)
{
const id = wrapper.readInt();
const badge = wrapper.readString();
this._badges.set(id, badge);
badgesCount--;
}
return true;
}
public get badges(): Map<number, string>
{
return this._badges;
}
}

View File

@ -1,4 +1,5 @@
export * from './GroupBadgePartsParser';
export * from './GroupBadgesParser';
export * from './GroupBuyDataParser';
export * from './GroupConfirmMemberRemoveParser';
export * from './GroupInformationParser';

View File

@ -0,0 +1,72 @@
import { IDisposable } from '../../core/common/disposable/IDisposable';
import { IMessageEvent } from '../../core/communication/messages/IMessageEvent';
import { GroupBadgesEvent } from '../communication/messages/incoming/group/GroupBadgesEvent';
import { GroupBadgesComposer } from '../communication/messages/outgoing/group/GroupBadgesComposer';
import { SessionDataManager } from './SessionDataManager';
export class GroupInformationManager implements IDisposable
{
private _sessionDataManager: SessionDataManager;
private _groupBadges: Map<number, string>;
private _messages: IMessageEvent[];
constructor(sessionDataManager: SessionDataManager)
{
this._sessionDataManager = sessionDataManager;
this._groupBadges = new Map();
}
public init(): void
{
if(this._sessionDataManager && this._sessionDataManager.communication)
{
this._messages = [
new GroupBadgesEvent(this.onGroupBadgesEvent.bind(this))
];
for(const message of this._messages) this._sessionDataManager.communication.registerMessageEvent(message);
}
}
public dispose(): void
{
if(this.disposed) return;
if(this._messages && this._messages.length)
{
for(const message of this._messages) this._sessionDataManager.communication.removeMessageEvent(message);
this._messages = null;
}
this._groupBadges = null;
this._sessionDataManager = null;
}
public requestGroupBadges(): void
{
this._sessionDataManager.send(new GroupBadgesComposer());
}
private onGroupBadgesEvent(event: GroupBadgesEvent): void
{
if(!event) return;
const parser = event.getParser();
if(!parser) return;
this._groupBadges = parser.badges;
}
public getGroupBadge(groupId: number): string
{
return this._groupBadges.get(groupId);
}
public get disposed(): boolean
{
return !!this._sessionDataManager;
}
}

View File

@ -3,6 +3,7 @@ import { INitroManager } from '../../core/common/INitroManager';
import { INitroCommunicationManager } from '../communication/INitroCommunicationManager';
import { IFurnitureData } from './furniture/IFurnitureData';
import { IFurnitureDataListener } from './furniture/IFurnitureDataListener';
import { GroupInformationManager } from './GroupInformationManager';
import { IgnoredUsersManager } from './IgnoredUsersManager';
import { IProductData } from './product/IProductData';
@ -29,6 +30,7 @@ export interface ISessionDataManager extends INitroManager
ignoreUser(name: string): void;
unignoreUser(name: string): void;
isUserIgnored(name: string): boolean;
getGroupBadge(groupId: number): string;
communication: INitroCommunicationManager;
userId: number;
userName: string;
@ -37,6 +39,7 @@ export interface ISessionDataManager extends INitroManager
isGodMode: boolean;
realName: string;
ignoredUsersManager: IgnoredUsersManager;
groupInformationManager: GroupInformationManager;
respectsReceived: number;
respectsLeft: number;
respectsPetLeft: number;

View File

@ -26,6 +26,7 @@ import { UserNameUpdateEvent } from './events/UserNameUpdateEvent';
import { FurnitureDataLoader } from './furniture/FurnitureDataLoader';
import { IFurnitureData } from './furniture/IFurnitureData';
import { IFurnitureDataListener } from './furniture/IFurnitureDataListener';
import { GroupInformationManager } from './GroupInformationManager';
import { IgnoredUsersManager } from './IgnoredUsersManager';
import { ISessionDataManager } from './ISessionDataManager';
import { IProductData } from './product/IProductData';
@ -47,6 +48,7 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
private _canChangeName: boolean;
private _ignoredUsersManager: IgnoredUsersManager;
private _groupInformationManager: GroupInformationManager;
private _clubLevel: number;
private _securityLevel: number;
@ -82,6 +84,7 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
this.resetUserInfo();
this._ignoredUsersManager = new IgnoredUsersManager(this);
this._groupInformationManager = new GroupInformationManager(this);
this._clubLevel = 0;
this._securityLevel = 0;
@ -111,6 +114,7 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
this.onProductDataReadyEvent = this.onProductDataReadyEvent.bind(this);
this.onNitroSettingsEvent = this.onNitroSettingsEvent.bind(this);
}
groupInformationManager: GroupInformationManager;
protected onInit(): void
{
@ -119,6 +123,7 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
this.loadBadgeImageManager();
(this._ignoredUsersManager && this._ignoredUsersManager.init());
(this._groupInformationManager && this._groupInformationManager.init());
this._communication.registerMessageEvent(new FigureUpdateEvent(this.onUserFigureEvent.bind(this)));
this._communication.registerMessageEvent(new UserInfoEvent(this.onUserInfoEvent.bind(this)));
@ -144,6 +149,13 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
this._ignoredUsersManager = null;
}
if(this._groupInformationManager)
{
this._groupInformationManager.dispose();
this._groupInformationManager = null;
}
Nitro.instance.events.removeEventListener(NitroSettingsEvent.SETTINGS_UPDATED, this.onNitroSettingsEvent);
super.onDispose();
@ -541,6 +553,11 @@ export class SessionDataManager extends NitroManager implements ISessionDataMana
return (this._ignoredUsersManager && this._ignoredUsersManager.isIgnored(name));
}
public getGroupBadge(groupId: number): string
{
return (this._groupInformationManager && this._groupInformationManager.getGroupBadge(groupId));
}
public send(composer: IMessageComposer<unknown[]>): void
{
this._communication.connection.send(composer);