feat: Converts OnLogin to a coded generated event (#2070)

This commit is contained in:
Kamron Batman 2025-01-17 15:21:45 -08:00 committed by GitHub
parent 3b698de556
commit 66a257ece2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 127 additions and 122 deletions

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Net;
using System.Runtime.CompilerServices;
using System.Xml;
using ModernUO.CodeGeneratedEvents;
using ModernUO.Serialization;
using Server.Accounting.Security;
using Server.Misc;
@ -768,31 +769,24 @@ public partial class Account : IAccount, IComparable<Account>
acc.TotalGameTime += Core.Now - pm.SessionStart;
}
public static void OnLogin(Mobile m)
[OnEvent(nameof(PlayerMobile.PlayerLoginEvent))]
public static void OnLogin(PlayerMobile pm)
{
if (m is not PlayerMobile pm)
if (pm.Account is not Account acc || !pm.Young || !acc.Young)
{
return;
}
if (m.Account is not Account acc)
var ts = YoungDuration - acc.TotalGameTime;
var hours = Math.Max((int)ts.TotalHours, 0);
if (hours == 1)
{
return;
pm.SendAsciiMessage($"You will enjoy the benefits and relatively safe status of a young player for {hours} more hour.");
}
if (pm.Young && acc.Young)
else
{
var ts = YoungDuration - acc.TotalGameTime;
var hours = Math.Max((int)ts.TotalHours, 0);
if (hours == 1)
{
m.SendAsciiMessage($"You will enjoy the benefits and relatively safe status of a young player for {hours} more hour.");
}
else
{
m.SendAsciiMessage($"You will enjoy the benefits and relatively safe status of a young player for {hours} more hours.");
}
pm.SendAsciiMessage($"You will enjoy the benefits and relatively safe status of a young player for {hours} more hours.");
}
}