BugFix in loading stats files

master
Jan Beníček 2023-01-28 19:11:49 +01:00
parent a430b6a44c
commit 8922ec17d7
1 changed files with 3 additions and 3 deletions

View File

@ -23,7 +23,7 @@ namespace Lib_MCPlayerStats
return Task.FromResult(player); //If Deserialized object is null return empty stats object with ErrorMessage in Username return Task.FromResult(player); //If Deserialized object is null return empty stats object with ErrorMessage in Username
} }
Stats_Internal? loaded = JsonConvert.DeserializeObject<Stats_Internal>(File.ReadAllText(file)); //Desearialize Stats file to internal object Stats_Internal? loaded = JsonConvert.DeserializeObject<Stats_Internal>(File.ReadAllText(file).Replace("minecraft:", "")); //Desearialize Stats file to internal object
if (loaded == null) if (loaded == null)
{ {
@ -31,7 +31,7 @@ namespace Lib_MCPlayerStats
return Task.FromResult(player); //If Deserialized object is null return empty stats object with ErrorMessage in Username return Task.FromResult(player); //If Deserialized object is null return empty stats object with ErrorMessage in Username
} }
player.Username = GetNameByUUID(file.Split(@"/").Last().Replace("-", "").Replace(".json", "")); player.Username = GetNameByUUID(file.Split(@"/").Last().Replace("-", "").Replace(".json", "")); //Get Username by UUID
//Move data from loaded stats to object with username //Move data from loaded stats to object with username
player.picked_up = loaded.stats.picked_up; player.picked_up = loaded.stats.picked_up;
@ -56,7 +56,7 @@ namespace Lib_MCPlayerStats
{ {
List<Player_Stats> stats = new(); List<Player_Stats> stats = new();
foreach (string file in Directory.GetFiles(folder)) foreach (string file in Directory.GetFiles(folder)) //Search all .json files for load in selected directory
{ {
if (file.EndsWith(".json")) if (file.EndsWith(".json"))
{ {