diff --git a/packages/communication/src/NitroMessages.ts b/packages/communication/src/NitroMessages.ts index 3caca87..c91d3f7 100644 --- a/packages/communication/src/NitroMessages.ts +++ b/packages/communication/src/NitroMessages.ts @@ -7,6 +7,7 @@ import { ConfInvisStateMessageEvent } from './messages'; import { HanditemBlockStateMessageEvent } from './messages'; import { TranslationLanguagesEvent, TranslationLanguagesRequestComposer, TranslationResultEvent, TranslationTextRequestComposer } from './messages'; import { YouTubeRoomBroadcastEvent, YouTubeRoomPlayComposer, YouTubeRoomSettingsComposer, YouTubeRoomSettingsEvent, YouTubeRoomWatchersEvent, YouTubeRoomWatchingComposer } from './messages'; +import { HousekeepingFindUserByNameComposer, HousekeepingUserDetailEvent } from './messages'; export class NitroMessages implements IMessageConfiguration { private _events: Map; @@ -505,6 +506,9 @@ export class NitroMessages implements IMessageConfiguration this._events.set(IncomingHeader.YOUTUBE_ROOM_BROADCAST, YouTubeRoomBroadcastEvent); this._events.set(IncomingHeader.YOUTUBE_ROOM_SETTINGS, YouTubeRoomSettingsEvent); this._events.set(IncomingHeader.YOUTUBE_ROOM_WATCHERS, YouTubeRoomWatchersEvent); + + // Housekeeping (in-client admin panel) + this._events.set(IncomingHeader.HOUSEKEEPING_USER_DETAIL, HousekeepingUserDetailEvent); this._events.set(IncomingHeader.WIRED_REWARD, WiredRewardResultMessageEvent); this._events.set(IncomingHeader.WIRED_SAVE, WiredSaveSuccessEvent); this._events.set(IncomingHeader.WIRED_ERROR, WiredValidationErrorEvent); @@ -1255,6 +1259,9 @@ export class NitroMessages implements IMessageConfiguration this._composers.set(OutgoingHeader.YOUTUBE_ROOM_PLAY, YouTubeRoomPlayComposer); this._composers.set(OutgoingHeader.YOUTUBE_ROOM_SETTINGS, YouTubeRoomSettingsComposer); this._composers.set(OutgoingHeader.YOUTUBE_ROOM_WATCHING, YouTubeRoomWatchingComposer); + + // Housekeeping (in-client admin panel) + this._composers.set(OutgoingHeader.HOUSEKEEPING_FIND_USER_BY_NAME, HousekeepingFindUserByNameComposer); } public get events(): Map diff --git a/packages/communication/src/messages/incoming/IncomingHeader.ts b/packages/communication/src/messages/incoming/IncomingHeader.ts index 70dbad3..5433111 100644 --- a/packages/communication/src/messages/incoming/IncomingHeader.ts +++ b/packages/communication/src/messages/incoming/IncomingHeader.ts @@ -503,4 +503,7 @@ export class IncomingHeader public static YOUTUBE_ROOM_BROADCAST = 8001; public static YOUTUBE_ROOM_WATCHERS = 8002; public static YOUTUBE_ROOM_SETTINGS = 8003; + + // Housekeeping (in-client admin panel) — IDs 9200..9299 reserved + public static HOUSEKEEPING_USER_DETAIL = 9200; } diff --git a/packages/communication/src/messages/incoming/housekeeping/HousekeepingUserDetailEvent.ts b/packages/communication/src/messages/incoming/housekeeping/HousekeepingUserDetailEvent.ts new file mode 100644 index 0000000..2db1e82 --- /dev/null +++ b/packages/communication/src/messages/incoming/housekeeping/HousekeepingUserDetailEvent.ts @@ -0,0 +1,16 @@ +import { IMessageEvent } from '@nitrots/api'; +import { MessageEvent } from '@nitrots/events'; +import { HousekeepingUserDetailParser } from '../../parser'; + +export class HousekeepingUserDetailEvent extends MessageEvent implements IMessageEvent +{ + constructor(callBack: Function) + { + super(callBack, HousekeepingUserDetailParser); + } + + public getParser(): HousekeepingUserDetailParser + { + return this.parser as HousekeepingUserDetailParser; + } +} diff --git a/packages/communication/src/messages/incoming/housekeeping/index.ts b/packages/communication/src/messages/incoming/housekeeping/index.ts new file mode 100644 index 0000000..1b31bba --- /dev/null +++ b/packages/communication/src/messages/incoming/housekeeping/index.ts @@ -0,0 +1 @@ +export * from './HousekeepingUserDetailEvent'; diff --git a/packages/communication/src/messages/incoming/index.ts b/packages/communication/src/messages/incoming/index.ts index 5584383..8620b9e 100644 --- a/packages/communication/src/messages/incoming/index.ts +++ b/packages/communication/src/messages/incoming/index.ts @@ -24,6 +24,7 @@ export * from './group'; export * from './groupforums'; export * from './handshake'; export * from './help'; +export * from './housekeeping'; export * from './inventory'; export * from './inventory/achievements'; export * from './inventory/avatareffect'; diff --git a/packages/communication/src/messages/outgoing/OutgoingHeader.ts b/packages/communication/src/messages/outgoing/OutgoingHeader.ts index 80dc117..58e5471 100644 --- a/packages/communication/src/messages/outgoing/OutgoingHeader.ts +++ b/packages/communication/src/messages/outgoing/OutgoingHeader.ts @@ -522,4 +522,7 @@ export class OutgoingHeader public static YOUTUBE_ROOM_PLAY = 8001; public static YOUTUBE_ROOM_WATCHING = 8002; public static YOUTUBE_ROOM_SETTINGS = 8003; + + // Housekeeping (in-client admin panel) — IDs 9100..9199 reserved + public static HOUSEKEEPING_FIND_USER_BY_NAME = 9100; } diff --git a/packages/communication/src/messages/outgoing/housekeeping/HousekeepingFindUserByNameComposer.ts b/packages/communication/src/messages/outgoing/housekeeping/HousekeepingFindUserByNameComposer.ts new file mode 100644 index 0000000..82bcfd6 --- /dev/null +++ b/packages/communication/src/messages/outgoing/housekeeping/HousekeepingFindUserByNameComposer.ts @@ -0,0 +1,21 @@ +import { IMessageComposer } from '@nitrots/api'; + +export class HousekeepingFindUserByNameComposer implements IMessageComposer> +{ + private _data: ConstructorParameters; + + constructor(username: string) + { + this._data = [username]; + } + + public getMessageArray() + { + return this._data; + } + + public dispose(): void + { + return; + } +} diff --git a/packages/communication/src/messages/outgoing/housekeeping/index.ts b/packages/communication/src/messages/outgoing/housekeeping/index.ts new file mode 100644 index 0000000..c38ee13 --- /dev/null +++ b/packages/communication/src/messages/outgoing/housekeeping/index.ts @@ -0,0 +1 @@ +export * from './HousekeepingFindUserByNameComposer'; diff --git a/packages/communication/src/messages/outgoing/index.ts b/packages/communication/src/messages/outgoing/index.ts index 10e3549..131d0dd 100644 --- a/packages/communication/src/messages/outgoing/index.ts +++ b/packages/communication/src/messages/outgoing/index.ts @@ -21,6 +21,7 @@ export * from './group'; export * from './groupforums'; export * from './handshake'; export * from './help'; +export * from './housekeeping'; export * from './inventory'; export * from './inventory/avatareffect'; export * from './inventory/badges'; diff --git a/packages/communication/src/messages/parser/housekeeping/HousekeepingUserDetailData.ts b/packages/communication/src/messages/parser/housekeeping/HousekeepingUserDetailData.ts new file mode 100644 index 0000000..f387dd2 --- /dev/null +++ b/packages/communication/src/messages/parser/housekeeping/HousekeepingUserDetailData.ts @@ -0,0 +1,61 @@ +import { IMessageDataWrapper } from '@nitrots/api'; + +export class HousekeepingUserDetailData +{ + private _id: number = 0; + private _username: string = ''; + private _motto: string = ''; + private _figure: string = ''; + private _rank: number = 0; + private _rankName: string = ''; + private _online: boolean = false; + private _lastOnlineAt: number = 0; + private _creditsBalance: number = 0; + private _ducketsBalance: number = 0; + private _diamondsBalance: number = 0; + private _email: string = ''; + private _ipLast: string = ''; + private _isBanned: boolean = false; + private _isMuted: boolean = false; + private _isTradeLocked: boolean = false; + + constructor(wrapper: IMessageDataWrapper) + { + if(!wrapper) throw new Error('invalid_wrapper'); + + this._id = wrapper.readInt(); + this._username = wrapper.readString(); + this._motto = wrapper.readString(); + this._figure = wrapper.readString(); + this._rank = wrapper.readInt(); + this._rankName = wrapper.readString(); + this._online = wrapper.readBoolean(); + this._lastOnlineAt = wrapper.readInt(); + this._creditsBalance = wrapper.readInt(); + this._ducketsBalance = wrapper.readInt(); + this._diamondsBalance = wrapper.readInt(); + this._email = wrapper.readString(); + this._ipLast = wrapper.readString(); + this._isBanned = wrapper.readBoolean(); + + if(wrapper.bytesAvailable) this._isMuted = wrapper.readBoolean(); + if(wrapper.bytesAvailable) this._isTradeLocked = wrapper.readBoolean(); + } + + public get id(): number { return this._id; } + public get username(): string { return this._username; } + public get motto(): string { return this._motto; } + public get figure(): string { return this._figure; } + public get rank(): number { return this._rank; } + public get rankName(): string { return this._rankName; } + public get online(): boolean { return this._online; } + public get lastOnlineAt(): number { return this._lastOnlineAt; } + public get creditsBalance(): number { return this._creditsBalance; } + public get ducketsBalance(): number { return this._ducketsBalance; } + public get diamondsBalance(): number { return this._diamondsBalance; } + public get email(): string { return this._email; } + public get ipLast(): string { return this._ipLast; } + public get isBanned(): boolean { return this._isBanned; } + public get isMuted(): boolean { return this._isMuted; } + public get isTradeLocked(): boolean { return this._isTradeLocked; } +} diff --git a/packages/communication/src/messages/parser/housekeeping/HousekeepingUserDetailParser.ts b/packages/communication/src/messages/parser/housekeeping/HousekeepingUserDetailParser.ts new file mode 100644 index 0000000..d20e5fd --- /dev/null +++ b/packages/communication/src/messages/parser/housekeeping/HousekeepingUserDetailParser.ts @@ -0,0 +1,30 @@ +import { IMessageDataWrapper, IMessageParser } from '@nitrots/api'; +import { HousekeepingUserDetailData } from './HousekeepingUserDetailData'; + +export class HousekeepingUserDetailParser implements IMessageParser +{ + private _found: boolean = false; + private _user: HousekeepingUserDetailData | null = null; + + public flush(): boolean + { + this._found = false; + this._user = null; + + return true; + } + + public parse(wrapper: IMessageDataWrapper): boolean + { + if(!wrapper) return false; + + this._found = wrapper.readBoolean(); + + if(this._found) this._user = new HousekeepingUserDetailData(wrapper); + + return true; + } + + public get found(): boolean { return this._found; } + public get user(): HousekeepingUserDetailData | null { return this._user; } +} diff --git a/packages/communication/src/messages/parser/housekeeping/index.ts b/packages/communication/src/messages/parser/housekeeping/index.ts new file mode 100644 index 0000000..571cbe2 --- /dev/null +++ b/packages/communication/src/messages/parser/housekeeping/index.ts @@ -0,0 +1,2 @@ +export * from './HousekeepingUserDetailData'; +export * from './HousekeepingUserDetailParser'; diff --git a/packages/communication/src/messages/parser/index.ts b/packages/communication/src/messages/parser/index.ts index 7a7fc3b..d695022 100644 --- a/packages/communication/src/messages/parser/index.ts +++ b/packages/communication/src/messages/parser/index.ts @@ -24,6 +24,7 @@ export * from './group/utils'; export * from './groupforums'; export * from './handshake'; export * from './help'; +export * from './housekeeping'; export * from './inventory'; export * from './inventory/achievements'; export * from './inventory/avatareffect';