diff --git a/Modules/AntiCheat.cs b/Modules/AntiCheat.cs index 6f09532..492ae49 100644 --- a/Modules/AntiCheat.cs +++ b/Modules/AntiCheat.cs @@ -258,16 +258,16 @@ class AntiCheat { uint level = reader.ReadPackedUInt32(); - if (level > BetterGameSettings.DetectedLevelAbove.GetInt()) + if (level + 1 > BetterGameSettings.DetectedLevelAbove.GetInt()) { BetterNotificationManager.NotifyCheat(player, $"Invalid Level: {level}"); Logger.LogCheat($"{player.BetterData().RealName} {Enum.GetName((RpcCalls)callId)}: {level > BetterGameSettings.DetectedLevelAbove.GetInt()}"); } - if (level <= 0) + if (level + 1 <= 0) { var betterData = player.BetterData(); - player.Kick(false, "{0}" + $" due to {level} being invalid level", bypassDataCheck: true); + player.Kick(false, "{0}" + $" due to {level + 1} being invalid level", bypassDataCheck: true); betterData.AntiCheatInfo.BannedByAntiCheat = true; } } diff --git a/Modules/BetterDataManager.cs b/Modules/BetterDataManager.cs index 8e53ecd..87b1efb 100644 --- a/Modules/BetterDataManager.cs +++ b/Modules/BetterDataManager.cs @@ -76,31 +76,38 @@ class BetterDataManager } else { - // Load the existing JSON data - string json = File.ReadAllText(filePath); - var jsonData = JsonSerializer.Deserialize>>>(json) ?? new Dictionary>>(); + try + { + // Load the existing JSON data + string json = File.ReadAllText(filePath); + var jsonData = JsonSerializer.Deserialize>>>(json) ?? new Dictionary>>(); - // Check and add missing categories - if (!jsonData.ContainsKey("Data")) - { - jsonData["Data"] = new Dictionary>(); - } - if (!jsonData.ContainsKey("cheatData")) - { - jsonData["cheatData"] = new Dictionary>(); - } - if (!jsonData.ContainsKey("sickoData")) - { - jsonData["sickoData"] = new Dictionary>(); - } - if (!jsonData.ContainsKey("aumData")) - { - jsonData["aumData"] = new Dictionary>(); - } + // Check and add missing categories + if (!jsonData.ContainsKey("Data")) + { + jsonData["Data"] = new Dictionary>(); + } + if (!jsonData.ContainsKey("cheatData")) + { + jsonData["cheatData"] = new Dictionary>(); + } + if (!jsonData.ContainsKey("sickoData")) + { + jsonData["sickoData"] = new Dictionary>(); + } + if (!jsonData.ContainsKey("aumData")) + { + jsonData["aumData"] = new Dictionary>(); + } - // Write the updated JSON data back to the file - json = JsonSerializer.Serialize(jsonData, new JsonSerializerOptions { WriteIndented = true }); - File.WriteAllText(filePath, json); + // Write the updated JSON data back to the file + json = JsonSerializer.Serialize(jsonData, new JsonSerializerOptions { WriteIndented = true }); + File.WriteAllText(filePath, json); + } + catch (Exception ex) + { + Logger.Error(ex); + } } }