You've already forked Nitro_Render_V3
mirror of
https://github.com/duckietm/Nitro_Render_V3.git
synced 2026-06-19 15:06:20 +00:00
feat: custom prefix system protocol layer
Prefix parsers, composers and events: - UserPrefixesParser, PrefixReceivedParser, ActivePrefixUpdatedParser - PurchasePrefixComposer, SetActivePrefixComposer, DeletePrefixComposer, RequestPrefixesComposer - RoomUnitChatParser reads prefixText/Color/Icon/Effect from chat packets - RoomSessionChatEvent carries prefix data to client - RoomChatHandler passes prefix fields through event chain
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -37,6 +37,7 @@ export * from './messages/incoming/inventory/clothes';
|
||||
export * from './messages/incoming/inventory/furni';
|
||||
export * from './messages/incoming/inventory/furni/gifts';
|
||||
export * from './messages/incoming/inventory/pets';
|
||||
export * from './messages/incoming/inventory/prefixes';
|
||||
export * from './messages/incoming/inventory/trading';
|
||||
export * from './messages/incoming/landingview';
|
||||
export * from './messages/incoming/landingview/votes';
|
||||
@@ -109,6 +110,7 @@ export * from './messages/outgoing/inventory/badges';
|
||||
export * from './messages/outgoing/inventory/bots';
|
||||
export * from './messages/outgoing/inventory/furni';
|
||||
export * from './messages/outgoing/inventory/pets';
|
||||
export * from './messages/outgoing/inventory/prefixes';
|
||||
export * from './messages/outgoing/inventory/trading';
|
||||
export * from './messages/outgoing/inventory/unseen';
|
||||
export * from './messages/outgoing/landingview';
|
||||
@@ -187,6 +189,7 @@ export * from './messages/parser/inventory/badges';
|
||||
export * from './messages/parser/inventory/clothing';
|
||||
export * from './messages/parser/inventory/furniture';
|
||||
export * from './messages/parser/inventory/pets';
|
||||
export * from './messages/parser/inventory/prefixes';
|
||||
export * from './messages/parser/inventory/purse';
|
||||
export * from './messages/parser/inventory/trading';
|
||||
export * from './messages/parser/landingview';
|
||||
|
||||
@@ -474,4 +474,9 @@ export class IncomingHeader
|
||||
public static WEEKLY_GAME2_LEADERBOARD = 2196;
|
||||
public static RENTABLE_FURNI_RENT_OR_BUYOUT_OFFER = 35;
|
||||
public static HANDSHAKE_IDENTITY_ACCOUNT = 3523;
|
||||
|
||||
// Custom Prefixes
|
||||
public static USER_PREFIXES = 7001;
|
||||
public static PREFIX_RECEIVED = 7002;
|
||||
public static ACTIVE_PREFIX_UPDATED = 7003;
|
||||
}
|
||||
|
||||
@@ -5,4 +5,5 @@ export * from './clothes';
|
||||
export * from './furni';
|
||||
export * from './furni/gifts';
|
||||
export * from './pets';
|
||||
export * from './prefixes';
|
||||
export * from './trading';
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import { IMessageEvent } from '@nitrots/api';
|
||||
import { MessageEvent } from '@nitrots/events';
|
||||
import { ActivePrefixUpdatedParser } from '../../../parser';
|
||||
|
||||
export class ActivePrefixUpdatedEvent extends MessageEvent implements IMessageEvent
|
||||
{
|
||||
constructor(callBack: Function)
|
||||
{
|
||||
super(callBack, ActivePrefixUpdatedParser);
|
||||
}
|
||||
|
||||
public getParser(): ActivePrefixUpdatedParser
|
||||
{
|
||||
return this.parser as ActivePrefixUpdatedParser;
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import { IMessageEvent } from '@nitrots/api';
|
||||
import { MessageEvent } from '@nitrots/events';
|
||||
import { PrefixReceivedParser } from '../../../parser';
|
||||
|
||||
export class PrefixReceivedEvent extends MessageEvent implements IMessageEvent
|
||||
{
|
||||
constructor(callBack: Function)
|
||||
{
|
||||
super(callBack, PrefixReceivedParser);
|
||||
}
|
||||
|
||||
public getParser(): PrefixReceivedParser
|
||||
{
|
||||
return this.parser as PrefixReceivedParser;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { IMessageEvent } from '@nitrots/api';
|
||||
import { MessageEvent } from '@nitrots/events';
|
||||
import { UserPrefixesParser } from '../../../parser';
|
||||
|
||||
export class UserPrefixesEvent extends MessageEvent implements IMessageEvent
|
||||
{
|
||||
constructor(callBack: Function)
|
||||
{
|
||||
super(callBack, UserPrefixesParser);
|
||||
}
|
||||
|
||||
public getParser(): UserPrefixesParser
|
||||
{
|
||||
return this.parser as UserPrefixesParser;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export * from './ActivePrefixUpdatedEvent';
|
||||
export * from './PrefixReceivedEvent';
|
||||
export * from './UserPrefixesEvent';
|
||||
@@ -477,4 +477,10 @@ export class OutgoingHeader
|
||||
public static DELETE_ITEM = 10018;
|
||||
public static DELETE_PET = 10030;
|
||||
public static DELETE_BADGE = 10031;
|
||||
|
||||
// Custom Prefixes
|
||||
public static REQUEST_PREFIXES = 7011;
|
||||
public static SET_ACTIVE_PREFIX = 7012;
|
||||
public static DELETE_PREFIX = 7013;
|
||||
public static PURCHASE_PREFIX = 7014;
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@ export * from './badges';
|
||||
export * from './bots';
|
||||
export * from './furni';
|
||||
export * from './pets';
|
||||
export * from './prefixes';
|
||||
export * from './trading';
|
||||
export * from './unseen';
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
import { IMessageComposer } from '@nitrots/api';
|
||||
|
||||
export class DeletePrefixComposer implements IMessageComposer<ConstructorParameters<typeof DeletePrefixComposer>>
|
||||
{
|
||||
private _data: ConstructorParameters<typeof DeletePrefixComposer>;
|
||||
|
||||
constructor(prefixId: number)
|
||||
{
|
||||
this._data = [ prefixId ];
|
||||
}
|
||||
|
||||
public getMessageArray()
|
||||
{
|
||||
return this._data;
|
||||
}
|
||||
|
||||
public dispose(): void
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
import { IMessageComposer } from '@nitrots/api';
|
||||
|
||||
export class PurchasePrefixComposer implements IMessageComposer<ConstructorParameters<typeof PurchasePrefixComposer>>
|
||||
{
|
||||
private _data: ConstructorParameters<typeof PurchasePrefixComposer>;
|
||||
|
||||
constructor(text: string, color: string, icon: string = '', effect: string = '')
|
||||
{
|
||||
this._data = [ text, color, icon, effect ];
|
||||
}
|
||||
|
||||
public getMessageArray()
|
||||
{
|
||||
return this._data;
|
||||
}
|
||||
|
||||
public dispose(): void
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
import { IMessageComposer } from '@nitrots/api';
|
||||
|
||||
export class RequestPrefixesComposer implements IMessageComposer<ConstructorParameters<typeof RequestPrefixesComposer>>
|
||||
{
|
||||
private _data: ConstructorParameters<typeof RequestPrefixesComposer>;
|
||||
|
||||
constructor()
|
||||
{
|
||||
this._data = [];
|
||||
}
|
||||
|
||||
public getMessageArray()
|
||||
{
|
||||
return this._data;
|
||||
}
|
||||
|
||||
public dispose(): void
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
import { IMessageComposer } from '@nitrots/api';
|
||||
|
||||
export class SetActivePrefixComposer implements IMessageComposer<ConstructorParameters<typeof SetActivePrefixComposer>>
|
||||
{
|
||||
private _data: ConstructorParameters<typeof SetActivePrefixComposer>;
|
||||
|
||||
constructor(prefixId: number)
|
||||
{
|
||||
this._data = [ prefixId ];
|
||||
}
|
||||
|
||||
public getMessageArray()
|
||||
{
|
||||
return this._data;
|
||||
}
|
||||
|
||||
public dispose(): void
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export * from './DeletePrefixComposer';
|
||||
export * from './PurchasePrefixComposer';
|
||||
export * from './RequestPrefixesComposer';
|
||||
export * from './SetActivePrefixComposer';
|
||||
@@ -4,5 +4,6 @@ export * from './badges';
|
||||
export * from './clothing';
|
||||
export * from './furniture';
|
||||
export * from './pets';
|
||||
export * from './prefixes';
|
||||
export * from './purse';
|
||||
export * from './trading';
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
import { IMessageDataWrapper, IMessageParser } from '@nitrots/api';
|
||||
|
||||
export class ActivePrefixUpdatedParser implements IMessageParser
|
||||
{
|
||||
private _prefixId: number;
|
||||
private _text: string;
|
||||
private _color: string;
|
||||
private _icon: string;
|
||||
private _effect: string;
|
||||
|
||||
public flush(): boolean
|
||||
{
|
||||
this._prefixId = 0;
|
||||
this._text = '';
|
||||
this._color = '';
|
||||
this._icon = '';
|
||||
this._effect = '';
|
||||
return true;
|
||||
}
|
||||
|
||||
public parse(wrapper: IMessageDataWrapper): boolean
|
||||
{
|
||||
if(!wrapper) return false;
|
||||
|
||||
this._prefixId = wrapper.readInt();
|
||||
this._text = wrapper.readString();
|
||||
this._color = wrapper.readString();
|
||||
this._icon = wrapper.readString();
|
||||
this._effect = wrapper.readString();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public get prefixId(): number { return this._prefixId; }
|
||||
public get text(): string { return this._text; }
|
||||
public get color(): string { return this._color; }
|
||||
public get icon(): string { return this._icon; }
|
||||
public get effect(): string { return this._effect; }
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import { IMessageDataWrapper, IMessageParser } from '@nitrots/api';
|
||||
|
||||
export class PrefixReceivedParser implements IMessageParser
|
||||
{
|
||||
private _id: number;
|
||||
private _text: string;
|
||||
private _color: string;
|
||||
private _icon: string;
|
||||
private _effect: string;
|
||||
|
||||
public flush(): boolean
|
||||
{
|
||||
this._id = 0;
|
||||
this._text = '';
|
||||
this._color = '';
|
||||
this._icon = '';
|
||||
this._effect = '';
|
||||
return true;
|
||||
}
|
||||
|
||||
public parse(wrapper: IMessageDataWrapper): boolean
|
||||
{
|
||||
if(!wrapper) return false;
|
||||
|
||||
this._id = wrapper.readInt();
|
||||
this._text = wrapper.readString();
|
||||
this._color = wrapper.readString();
|
||||
this._icon = wrapper.readString();
|
||||
this._effect = wrapper.readString();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public get id(): number { return this._id; }
|
||||
public get text(): string { return this._text; }
|
||||
public get color(): string { return this._color; }
|
||||
public get icon(): string { return this._icon; }
|
||||
public get effect(): string { return this._effect; }
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import { IMessageDataWrapper, IMessageParser } from '@nitrots/api';
|
||||
|
||||
export interface IPrefixData
|
||||
{
|
||||
id: number;
|
||||
text: string;
|
||||
color: string;
|
||||
icon: string;
|
||||
effect: string;
|
||||
active: boolean;
|
||||
}
|
||||
|
||||
export class UserPrefixesParser implements IMessageParser
|
||||
{
|
||||
private _prefixes: IPrefixData[];
|
||||
|
||||
public flush(): boolean
|
||||
{
|
||||
this._prefixes = [];
|
||||
return true;
|
||||
}
|
||||
|
||||
public parse(wrapper: IMessageDataWrapper): boolean
|
||||
{
|
||||
if(!wrapper) return false;
|
||||
|
||||
this._prefixes = [];
|
||||
|
||||
let count = wrapper.readInt();
|
||||
|
||||
while(count > 0)
|
||||
{
|
||||
this._prefixes.push({
|
||||
id: wrapper.readInt(),
|
||||
text: wrapper.readString(),
|
||||
color: wrapper.readString(),
|
||||
icon: wrapper.readString(),
|
||||
effect: wrapper.readString(),
|
||||
active: wrapper.readInt() === 1
|
||||
});
|
||||
|
||||
count--;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public get prefixes(): IPrefixData[]
|
||||
{
|
||||
return this._prefixes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export * from './ActivePrefixUpdatedParser';
|
||||
export * from './PrefixReceivedParser';
|
||||
export * from './UserPrefixesParser';
|
||||
@@ -9,6 +9,10 @@ export class RoomUnitChatParser implements IMessageParser
|
||||
private _urls: string[];
|
||||
private _chatColours: string;
|
||||
private _messageLength: number;
|
||||
private _prefixText: string;
|
||||
private _prefixColor: string;
|
||||
private _prefixIcon: string;
|
||||
private _prefixEffect: string;
|
||||
|
||||
public flush(): boolean
|
||||
{
|
||||
@@ -19,6 +23,10 @@ export class RoomUnitChatParser implements IMessageParser
|
||||
this._urls = [];
|
||||
this._chatColours = null;
|
||||
this._messageLength = 0;
|
||||
this._prefixText = '';
|
||||
this._prefixColor = '';
|
||||
this._prefixIcon = '';
|
||||
this._prefixEffect = '';
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -33,9 +41,13 @@ export class RoomUnitChatParser implements IMessageParser
|
||||
this._bubble = wrapper.readInt();
|
||||
|
||||
this.parseUrls(wrapper);
|
||||
|
||||
|
||||
this._chatColours = wrapper.readString();
|
||||
this._messageLength = wrapper.readInt();
|
||||
this._prefixText = wrapper.readString();
|
||||
this._prefixColor = wrapper.readString();
|
||||
this._prefixIcon = wrapper.readString();
|
||||
this._prefixEffect = wrapper.readString();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -82,7 +94,7 @@ export class RoomUnitChatParser implements IMessageParser
|
||||
{
|
||||
return this._urls;
|
||||
}
|
||||
|
||||
|
||||
public get chatColours(): string
|
||||
{
|
||||
return this._chatColours;
|
||||
@@ -92,4 +104,24 @@ export class RoomUnitChatParser implements IMessageParser
|
||||
{
|
||||
return this._messageLength;
|
||||
}
|
||||
|
||||
public get prefixText(): string
|
||||
{
|
||||
return this._prefixText;
|
||||
}
|
||||
|
||||
public get prefixColor(): string
|
||||
{
|
||||
return this._prefixColor;
|
||||
}
|
||||
|
||||
public get prefixIcon(): string
|
||||
{
|
||||
return this._prefixIcon;
|
||||
}
|
||||
|
||||
public get prefixEffect(): string
|
||||
{
|
||||
return this._prefixEffect;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,12 @@ export class RoomSessionChatEvent extends RoomSessionEvent
|
||||
private _links: string[];
|
||||
private _extraParam: number;
|
||||
private _style: number;
|
||||
private _prefixText: string;
|
||||
private _prefixColor: string;
|
||||
private _prefixIcon: string;
|
||||
private _prefixEffect: string;
|
||||
|
||||
constructor(type: string, session: IRoomSession, objectId: number, message: string, chatType: number, style: number = 0, chatColours: string[], links: string[] = null, extraParam: number = -1)
|
||||
constructor(type: string, session: IRoomSession, objectId: number, message: string, chatType: number, style: number = 0, chatColours: string[], links: string[] = null, extraParam: number = -1, prefixText: string = '', prefixColor: string = '', prefixIcon: string = '', prefixEffect: string = '')
|
||||
{
|
||||
super(type, session);
|
||||
|
||||
@@ -36,6 +40,10 @@ export class RoomSessionChatEvent extends RoomSessionEvent
|
||||
this._links = links;
|
||||
this._extraParam = extraParam;
|
||||
this._style = style;
|
||||
this._prefixText = prefixText;
|
||||
this._prefixColor = prefixColor;
|
||||
this._prefixIcon = prefixIcon;
|
||||
this._prefixEffect = prefixEffect;
|
||||
}
|
||||
|
||||
public get objectId(): number
|
||||
@@ -67,9 +75,29 @@ export class RoomSessionChatEvent extends RoomSessionEvent
|
||||
{
|
||||
return this._style;
|
||||
}
|
||||
|
||||
|
||||
public get chatColours(): string[]
|
||||
{
|
||||
return this._chatColours;
|
||||
}
|
||||
|
||||
public get prefixText(): string
|
||||
{
|
||||
return this._prefixText;
|
||||
}
|
||||
|
||||
public get prefixColor(): string
|
||||
{
|
||||
return this._prefixColor;
|
||||
}
|
||||
|
||||
public get prefixIcon(): string
|
||||
{
|
||||
return this._prefixIcon;
|
||||
}
|
||||
|
||||
public get prefixEffect(): string
|
||||
{
|
||||
return this._prefixEffect;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ export class RoomChatHandler extends BaseHandler
|
||||
if(event instanceof RoomUnitChatShoutEvent) chatType = RoomSessionChatEvent.CHAT_TYPE_SHOUT;
|
||||
else if(event instanceof RoomUnitChatWhisperEvent) chatType = RoomSessionChatEvent.CHAT_TYPE_WHISPER;
|
||||
|
||||
const chatEvent = new RoomSessionChatEvent(RoomSessionChatEvent.CHAT_EVENT, session, parser.roomIndex, parser.message, chatType, parser.bubble, parser.chatColours);
|
||||
const chatEvent = new RoomSessionChatEvent(RoomSessionChatEvent.CHAT_EVENT, session, parser.roomIndex, parser.message, chatType, parser.bubble, parser.chatColours, null, -1, parser.prefixText, parser.prefixColor, parser.prefixIcon, parser.prefixEffect);
|
||||
|
||||
GetEventDispatcher().dispatchEvent(chatEvent);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user