Show error when trader id can't be found in Traders enum
Exit early when sending messages from trader if no trader supplied
This commit is contained in:
parent
177a01439b
commit
cda89084d3
@ -396,6 +396,13 @@ export class TraderHelper
|
|||||||
{
|
{
|
||||||
const keys = Object.keys(Traders).filter(x => Traders[x] === traderId);
|
const keys = Object.keys(Traders).filter(x => Traders[x] === traderId);
|
||||||
|
|
||||||
return keys.length > 0 ? keys[0] as Traders : null;
|
if (keys.length === 0)
|
||||||
|
{
|
||||||
|
this.logger.error(`Unable to find trader: ${traderId} in Traders enum`);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return keys[0] as Traders;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -43,6 +43,13 @@ export class MailSendService
|
|||||||
*/
|
*/
|
||||||
public sendDirectNpcMessageToPlayer(playerId: string, sender: Traders, messageType: MessageType, message: string, items: Item[] = [], maxStorageTimeSeconds = null): void
|
public sendDirectNpcMessageToPlayer(playerId: string, sender: Traders, messageType: MessageType, message: string, items: Item[] = [], maxStorageTimeSeconds = null): void
|
||||||
{
|
{
|
||||||
|
if (!sender)
|
||||||
|
{
|
||||||
|
this.logger.error(`Unable to send message type: ${messageType} to player: ${playerId}, provided trader enum was null`);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const details: ISendMessageDetails = {
|
const details: ISendMessageDetails = {
|
||||||
recipientId: playerId,
|
recipientId: playerId,
|
||||||
sender: messageType,
|
sender: messageType,
|
||||||
@ -72,6 +79,13 @@ export class MailSendService
|
|||||||
*/
|
*/
|
||||||
public sendLocalisedNpcMessageToPlayer(playerId: string, sender: Traders, messageType: MessageType, messageLocaleId: string, items: Item[] = [], maxStorageTimeSeconds = null): void
|
public sendLocalisedNpcMessageToPlayer(playerId: string, sender: Traders, messageType: MessageType, messageLocaleId: string, items: Item[] = [], maxStorageTimeSeconds = null): void
|
||||||
{
|
{
|
||||||
|
if (!sender)
|
||||||
|
{
|
||||||
|
this.logger.error(`Unable to send message type: ${messageType} to player: ${playerId}, provided trader enum was null`);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const details: ISendMessageDetails = {
|
const details: ISendMessageDetails = {
|
||||||
recipientId: playerId,
|
recipientId: playerId,
|
||||||
sender: messageType,
|
sender: messageType,
|
||||||
|
Loading…
Reference in New Issue
Block a user