Make PlayerData.Apply -> public ApplyTo

This commit is contained in:
UnknownShadow200 2020-08-06 12:22:01 +10:00
parent 3e8764d141
commit 3165057336
2 changed files with 18 additions and 17 deletions

View File

@ -71,28 +71,29 @@ namespace MCGalaxy.DB {
} }
} }
internal static void Apply(PlayerData data, Player p) { /// <summary> Initialises the given player's stats from this instance. </summary>
p.TimesVisited = data.Logins + 1; public void ApplyTo(Player p) {
p.TotalTime = data.TotalTime; p.TimesVisited = Logins + 1;
p.DatabaseID = data.DatabaseID; p.TotalTime = TotalTime;
p.FirstLogin = data.FirstLogin; p.DatabaseID = DatabaseID;
p.FirstLogin = FirstLogin;
p.title = data.Title; p.title = Title;
p.titlecolor = data.TitleColor; p.titlecolor = TitleColor;
string col = data.Color; string col = Color;
if (col.Length == 0) col = p.group.Color; if (col.Length == 0) col = p.group.Color;
p.SetColor(col); p.SetColor(col);
p.TotalModified = data.TotalModified; p.TotalModified = TotalModified;
p.TotalDrawn = data.TotalDrawn; p.TotalDrawn = TotalDrawn;
p.TotalPlaced = data.TotalPlaced; p.TotalPlaced = TotalPlaced;
p.TotalDeleted = data.TotalDeleted; p.TotalDeleted = TotalDeleted;
p.TimesDied = data.Deaths; p.TimesDied = Deaths;
p.TotalMessagesSent = data.Messages; p.TotalMessagesSent = Messages;
p.money = data.Money; p.money = Money;
p.TimesBeenKicked = data.Kicks; p.TimesBeenKicked = Kicks;
} }
internal static PlayerData Parse(IDataRecord record) { internal static PlayerData Parse(IDataRecord record) {

View File

@ -217,7 +217,7 @@ namespace MCGalaxy {
Chat.MessageFrom(this, "λNICK %Shas connected for the first time!"); Chat.MessageFrom(this, "λNICK %Shas connected for the first time!");
Message("Welcome " + ColoredName + "%S! This is your first visit."); Message("Welcome " + ColoredName + "%S! This is your first visit.");
} else { } else {
PlayerData.Apply((PlayerData)raw, this); ((PlayerData)raw).ApplyTo(this);
Message("Welcome back " + FullName + "%S! You've been here " + TimesVisited + " times!"); Message("Welcome back " + FullName + "%S! You've been here " + TimesVisited + " times!");
} }
gotSQLData = true; gotSQLData = true;