mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-20 01:46:19 +00:00
File Renames
This commit is contained in:
1 parent
efc9555a00
commit
ef8d9dc0fd
8 files changed
+340
-340
No files matched your search
+26
-26
@@ -41,11 +41,11 @@ class AntiCheat
|
||||
if (reader.BytesRemaining == 0 && !flag)
|
||||
{
|
||||
AmongUsClient.Instance.ReportPlayer(player.GetClientId(), ReportReasons.Cheating_Hacking);
|
||||
BAUNotificationManager.NotifyCheat(player, $"Sicko Menu", newText: "Has been detected with a cheat client");
|
||||
BetterNotificationManager.NotifyCheat(player, $"Sicko Menu", newText: "Has been detected with a cheat client");
|
||||
PlayerData[Utils.GetHashPuid(player)] = player.FriendCode;
|
||||
SickoData[Utils.GetHashPuid(player)] = player.FriendCode;
|
||||
BAUDataManager.SaveCheatData(Utils.GetHashPuid(player), player.Data.FriendCode, player.Data.PlayerName, "cheatData", "Sicko Menu RPC");
|
||||
BAUDataManager.SaveCheatData(Utils.GetHashPuid(player), player.Data.FriendCode, player.Data.PlayerName, "sickoData", "Sicko Menu RPC");
|
||||
BetterDataManager.SaveCheatData(Utils.GetHashPuid(player), player.Data.FriendCode, player.Data.PlayerName, "cheatData", "Sicko Menu RPC");
|
||||
BetterDataManager.SaveCheatData(Utils.GetHashPuid(player), player.Data.FriendCode, player.Data.PlayerName, "sickoData", "Sicko Menu RPC");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,11 +65,11 @@ class AntiCheat
|
||||
if (!flag)
|
||||
{
|
||||
AmongUsClient.Instance.ReportPlayer(player.GetClientId(), ReportReasons.Cheating_Hacking);
|
||||
BAUNotificationManager.NotifyCheat(player, $"AUM", newText: "Has been detected with a cheat client");
|
||||
BetterNotificationManager.NotifyCheat(player, $"AUM", newText: "Has been detected with a cheat client");
|
||||
PlayerData[Utils.GetHashPuid(player)] = player.FriendCode;
|
||||
AUMData[Utils.GetHashPuid(player)] = player.FriendCode;
|
||||
BAUDataManager.SaveCheatData(Utils.GetHashPuid(player), player.Data.FriendCode, player.Data.PlayerName, "cheatData", "AUM RPC");
|
||||
BAUDataManager.SaveCheatData(Utils.GetHashPuid(player), player.Data.FriendCode, player.Data.PlayerName, "aumData", "AUM RPC");
|
||||
BetterDataManager.SaveCheatData(Utils.GetHashPuid(player), player.Data.FriendCode, player.Data.PlayerName, "cheatData", "AUM RPC");
|
||||
BetterDataManager.SaveCheatData(Utils.GetHashPuid(player), player.Data.FriendCode, player.Data.PlayerName, "aumData", "AUM RPC");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,11 +98,11 @@ class AntiCheat
|
||||
if (!flag && !flag2)
|
||||
{
|
||||
AmongUsClient.Instance.ReportPlayer(player.GetClientId(), ReportReasons.Cheating_Hacking);
|
||||
BAUNotificationManager.NotifyCheat(AUMPlayer, $"AUM", newText: "Has been detected with a cheat client");
|
||||
BetterNotificationManager.NotifyCheat(AUMPlayer, $"AUM", newText: "Has been detected with a cheat client");
|
||||
PlayerData[Utils.GetHashPuid(AUMPlayer)] = AUMPlayer.FriendCode;
|
||||
AUMData[Utils.GetHashPuid(AUMPlayer)] = AUMPlayer.FriendCode;
|
||||
BAUDataManager.SaveCheatData(Utils.GetHashPuid(player), player.Data.FriendCode, player.Data.PlayerName, "cheatData", "AUM Chat RPC");
|
||||
BAUDataManager.SaveCheatData(Utils.GetHashPuid(player), player.Data.FriendCode, player.Data.PlayerName, "aumData", "AUM Chat RPC");
|
||||
BetterDataManager.SaveCheatData(Utils.GetHashPuid(player), player.Data.FriendCode, player.Data.PlayerName, "cheatData", "AUM Chat RPC");
|
||||
BetterDataManager.SaveCheatData(Utils.GetHashPuid(player), player.Data.FriendCode, player.Data.PlayerName, "aumData", "AUM Chat RPC");
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
@@ -128,7 +128,7 @@ class AntiCheat
|
||||
if (callId is (byte)RpcCalls.EnterVent or (byte)RpcCalls.ExitVent)
|
||||
{
|
||||
if ((IsCrewmate && Role != RoleTypes.Engineer) || player.Data.IsDead)
|
||||
BAUNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -136,7 +136,7 @@ class AntiCheat
|
||||
if (callId is (byte)RpcCalls.ProtectPlayer)
|
||||
{
|
||||
if (Role is not RoleTypes.GuardianAngel)
|
||||
BAUNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -150,7 +150,7 @@ class AntiCheat
|
||||
if (target != null)
|
||||
{
|
||||
if (IsCrewmate || !player.IsAlive() || player.IsInVanish() || !target.IsAlive() || target.IsImpostorTeam())
|
||||
BAUNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ class AntiCheat
|
||||
if (callId is (byte)RpcCalls.SendChat or (byte)RpcCalls.SendQuickChat)
|
||||
{
|
||||
if (player.IsAlive() && GameStates.IsInGamePlay && !GameStates.IsMeeting && !GameStates.IsExilling)
|
||||
BAUNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -172,7 +172,7 @@ class AntiCheat
|
||||
uint level = reader.ReadPackedUInt32();
|
||||
if (level >= 200)
|
||||
{
|
||||
BAUNotificationManager.NotifyCheat(player, $"Invalid Level: {level}");
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Level: {level}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ class AntiCheat
|
||||
if (callId is (byte)RpcCalls.CloseDoorsOfType)
|
||||
{
|
||||
byte Type = reader.ReadByte();
|
||||
BAUNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)} - {Enum.GetName((SystemTypes)callId)}");
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)} - {Enum.GetName((SystemTypes)callId)}");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -200,7 +200,7 @@ class AntiCheat
|
||||
or (byte)SystemTypes.MushroomMixupSabotage
|
||||
or (byte)SystemTypes.HeliSabotage)
|
||||
{
|
||||
BAUNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)} - {Enum.GetName((SystemTypes)callId)}");
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)} - {Enum.GetName((SystemTypes)callId)}");
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -212,7 +212,7 @@ class AntiCheat
|
||||
{
|
||||
if (callId is (byte)RpcCalls.CompleteTask or (byte)RpcCalls.BootFromVent)
|
||||
{
|
||||
BAUNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -222,7 +222,7 @@ class AntiCheat
|
||||
{
|
||||
if (player?.CurrentOutfit?.PetId == "pet_EmptyPet")
|
||||
{
|
||||
BAUNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -248,7 +248,7 @@ class AntiCheat
|
||||
|
||||
if (TrustedRPCs(callId) != true)
|
||||
{
|
||||
BAUNotificationManager.NotifyCheat(player, $"Untrusted RPC received: {callId}");
|
||||
BetterNotificationManager.NotifyCheat(player, $"Untrusted RPC received: {callId}");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -258,13 +258,13 @@ class AntiCheat
|
||||
|
||||
if (Role is not RoleTypes.Shapeshifter || !player.IsAlive())
|
||||
{
|
||||
BAUNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!flag && !player.IsInVent())
|
||||
{
|
||||
BAUNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -273,7 +273,7 @@ class AntiCheat
|
||||
{
|
||||
if (Role is not RoleTypes.Phantom || player.Data.IsDead)
|
||||
{
|
||||
BAUNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Action RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -284,7 +284,7 @@ class AntiCheat
|
||||
or (byte)RpcCalls.ExtendLobbyTimer
|
||||
or (byte)RpcCalls.CloseMeeting)
|
||||
{
|
||||
BAUNotificationManager.NotifyCheat(player, $"Invalid Host RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Host RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -293,7 +293,7 @@ class AntiCheat
|
||||
{
|
||||
if (callId is (byte)RpcCalls.SetName or (byte)RpcCalls.CheckName or (byte)RpcCalls.SetLevel)
|
||||
{
|
||||
BAUNotificationManager.NotifyCheat(player, $"Invalid Set RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Set RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -307,7 +307,7 @@ class AntiCheat
|
||||
or (byte)RpcCalls.SetPet
|
||||
or (byte)RpcCalls.SetNamePlate)
|
||||
{
|
||||
BAUNotificationManager.NotifyCheat(player, $"Invalid Set RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Set RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -341,7 +341,7 @@ class AntiCheat
|
||||
or (byte)RpcCalls.CheckAppear
|
||||
or (byte)RpcCalls.CheckVanish)
|
||||
{
|
||||
BAUNotificationManager.NotifyCheat(player, $"Invalid Lobby RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
BetterNotificationManager.NotifyCheat(player, $"Invalid Lobby RPC: {Enum.GetName((RpcCalls)callId)}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,202 +1,202 @@
|
||||
using System.Text.Json;
|
||||
|
||||
namespace BetterAmongUs;
|
||||
|
||||
class BAUDataManager
|
||||
{
|
||||
public static string GetFilePath(string name)
|
||||
{
|
||||
return Path.Combine(Main.GetDataPathToAmongUs(), $"{name}.json");
|
||||
}
|
||||
|
||||
public static void SetUp()
|
||||
{
|
||||
string filePath = GetFilePath("BetterData");
|
||||
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
// Initialize with predefined categories
|
||||
var initialData = new Dictionary<string, Dictionary<string, Dictionary<string, string>>>
|
||||
{
|
||||
{ "Data", new Dictionary<string, Dictionary<string, string>>() }, // Default category
|
||||
{ "cheatData", new Dictionary<string, Dictionary<string, string>>() },
|
||||
{ "sickoData", new Dictionary<string, Dictionary<string, string>>() },
|
||||
{ "aumData", new Dictionary<string, Dictionary<string, string>>() }
|
||||
};
|
||||
|
||||
string json = JsonSerializer.Serialize(initialData, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(filePath, json);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Load the existing JSON data
|
||||
string json = File.ReadAllText(filePath);
|
||||
var jsonData = JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, Dictionary<string, string>>>>(json) ?? new Dictionary<string, Dictionary<string, Dictionary<string, string>>>();
|
||||
|
||||
// Check and add missing categories
|
||||
if (!jsonData.ContainsKey("Data"))
|
||||
{
|
||||
jsonData["Data"] = new Dictionary<string, Dictionary<string, string>>();
|
||||
}
|
||||
if (!jsonData.ContainsKey("cheatData"))
|
||||
{
|
||||
jsonData["cheatData"] = new Dictionary<string, Dictionary<string, string>>();
|
||||
}
|
||||
if (!jsonData.ContainsKey("sickoData"))
|
||||
{
|
||||
jsonData["sickoData"] = new Dictionary<string, Dictionary<string, string>>();
|
||||
}
|
||||
if (!jsonData.ContainsKey("aumData"))
|
||||
{
|
||||
jsonData["aumData"] = new Dictionary<string, Dictionary<string, string>>();
|
||||
}
|
||||
|
||||
// Write the updated JSON data back to the file
|
||||
json = JsonSerializer.Serialize(jsonData, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(filePath, json);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Save(string name, string dataToSave, string category = "Data")
|
||||
{
|
||||
string filePath = GetFilePath("BetterData");
|
||||
|
||||
string json = File.ReadAllText(filePath);
|
||||
var jsonData = JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, string>>>(json) ?? new Dictionary<string, Dictionary<string, string>>();
|
||||
|
||||
if (!jsonData.ContainsKey(category))
|
||||
{
|
||||
jsonData[category] = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
jsonData[category][name] = dataToSave;
|
||||
|
||||
json = JsonSerializer.Serialize(jsonData, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(filePath, json);
|
||||
}
|
||||
|
||||
public static string Load(string name, string category = "Data")
|
||||
{
|
||||
try
|
||||
{
|
||||
string filePath = GetFilePath("BetterData");
|
||||
|
||||
string json = File.ReadAllText(filePath);
|
||||
var jsonData = JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, string>>>(json);
|
||||
|
||||
if (jsonData != null && jsonData.ContainsKey(category) && jsonData[category].ContainsKey(name))
|
||||
{
|
||||
return jsonData[category][name];
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error(ex.ToString());
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public static void SaveCheatData(string puid, string friendCode, string name, string category = "cheatData", string reason = "None")
|
||||
{
|
||||
string filePath = GetFilePath("BetterData");
|
||||
|
||||
string json = File.ReadAllText(filePath);
|
||||
var jsonData = JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, Dictionary<string, string>>>>(json) ?? new Dictionary<string, Dictionary<string, Dictionary<string, string>>>();
|
||||
|
||||
if (!jsonData.ContainsKey(category))
|
||||
{
|
||||
jsonData[category] = new Dictionary<string, Dictionary<string, string>>();
|
||||
}
|
||||
|
||||
if (!jsonData[category].ContainsKey(name))
|
||||
{
|
||||
jsonData[category][name] = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
jsonData[category][name]["FriendCode"] = friendCode;
|
||||
jsonData[category][name]["HashPUID"] = puid;
|
||||
jsonData[category][name]["Reason"] = reason;
|
||||
|
||||
json = JsonSerializer.Serialize(jsonData, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(filePath, json);
|
||||
}
|
||||
|
||||
public static void ClearCheatData()
|
||||
{
|
||||
string filePath = GetFilePath("BetterData");
|
||||
string json = File.ReadAllText(filePath);
|
||||
var jsonData = JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, Dictionary<string, string>>>>(json)
|
||||
?? new Dictionary<string, Dictionary<string, Dictionary<string, string>>>();
|
||||
|
||||
// Clear in-save data
|
||||
if (jsonData != null)
|
||||
{
|
||||
if (jsonData.ContainsKey("cheatData"))
|
||||
{
|
||||
jsonData["cheatData"].Clear();
|
||||
}
|
||||
|
||||
if (jsonData.ContainsKey("sickoData"))
|
||||
{
|
||||
jsonData["sickoData"].Clear();
|
||||
}
|
||||
|
||||
if (jsonData.ContainsKey("aumData"))
|
||||
{
|
||||
jsonData["aumData"].Clear();
|
||||
}
|
||||
|
||||
json = JsonSerializer.Serialize(jsonData, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(filePath, json);
|
||||
}
|
||||
|
||||
// Clear in-memory data
|
||||
AntiCheat.PlayerData.Clear();
|
||||
AntiCheat.SickoData.Clear();
|
||||
AntiCheat.AUMData.Clear();
|
||||
|
||||
Logger.LogCheat("Cleared cheat memory and data");
|
||||
}
|
||||
|
||||
public static void LoadCheatData()
|
||||
{
|
||||
try
|
||||
{
|
||||
string filePath = GetFilePath("BetterData");
|
||||
string json = File.ReadAllText(filePath);
|
||||
var jsonData = JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, Dictionary<string, string>>>>(json);
|
||||
|
||||
if (jsonData != null)
|
||||
{
|
||||
if (jsonData.ContainsKey("cheatData"))
|
||||
{
|
||||
foreach (var item in jsonData["cheatData"])
|
||||
{
|
||||
AntiCheat.PlayerData[item.Value["HashPUID"]] = item.Value["FriendCode"];
|
||||
}
|
||||
}
|
||||
|
||||
if (jsonData.ContainsKey("sickoData"))
|
||||
{
|
||||
foreach (var item in jsonData["sickoData"])
|
||||
{
|
||||
AntiCheat.SickoData[item.Value["HashPUID"]] = item.Value["FriendCode"];
|
||||
}
|
||||
}
|
||||
|
||||
if (jsonData.ContainsKey("aumData"))
|
||||
{
|
||||
foreach (var item in jsonData["aumData"])
|
||||
{
|
||||
AntiCheat.AUMData[item.Value["HashPUID"]] = item.Value["FriendCode"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error(ex.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Text.Json;
|
||||
|
||||
namespace BetterAmongUs;
|
||||
|
||||
class BetterDataManager
|
||||
{
|
||||
public static string GetFilePath(string name)
|
||||
{
|
||||
return Path.Combine(Main.GetDataPathToAmongUs(), $"{name}.json");
|
||||
}
|
||||
|
||||
public static void SetUp()
|
||||
{
|
||||
string filePath = GetFilePath("BetterData");
|
||||
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
// Initialize with predefined categories
|
||||
var initialData = new Dictionary<string, Dictionary<string, Dictionary<string, string>>>
|
||||
{
|
||||
{ "Data", new Dictionary<string, Dictionary<string, string>>() }, // Default category
|
||||
{ "cheatData", new Dictionary<string, Dictionary<string, string>>() },
|
||||
{ "sickoData", new Dictionary<string, Dictionary<string, string>>() },
|
||||
{ "aumData", new Dictionary<string, Dictionary<string, string>>() }
|
||||
};
|
||||
|
||||
string json = JsonSerializer.Serialize(initialData, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(filePath, json);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Load the existing JSON data
|
||||
string json = File.ReadAllText(filePath);
|
||||
var jsonData = JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, Dictionary<string, string>>>>(json) ?? new Dictionary<string, Dictionary<string, Dictionary<string, string>>>();
|
||||
|
||||
// Check and add missing categories
|
||||
if (!jsonData.ContainsKey("Data"))
|
||||
{
|
||||
jsonData["Data"] = new Dictionary<string, Dictionary<string, string>>();
|
||||
}
|
||||
if (!jsonData.ContainsKey("cheatData"))
|
||||
{
|
||||
jsonData["cheatData"] = new Dictionary<string, Dictionary<string, string>>();
|
||||
}
|
||||
if (!jsonData.ContainsKey("sickoData"))
|
||||
{
|
||||
jsonData["sickoData"] = new Dictionary<string, Dictionary<string, string>>();
|
||||
}
|
||||
if (!jsonData.ContainsKey("aumData"))
|
||||
{
|
||||
jsonData["aumData"] = new Dictionary<string, Dictionary<string, string>>();
|
||||
}
|
||||
|
||||
// Write the updated JSON data back to the file
|
||||
json = JsonSerializer.Serialize(jsonData, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(filePath, json);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Save(string name, string dataToSave, string category = "Data")
|
||||
{
|
||||
string filePath = GetFilePath("BetterData");
|
||||
|
||||
string json = File.ReadAllText(filePath);
|
||||
var jsonData = JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, string>>>(json) ?? new Dictionary<string, Dictionary<string, string>>();
|
||||
|
||||
if (!jsonData.ContainsKey(category))
|
||||
{
|
||||
jsonData[category] = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
jsonData[category][name] = dataToSave;
|
||||
|
||||
json = JsonSerializer.Serialize(jsonData, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(filePath, json);
|
||||
}
|
||||
|
||||
public static string Load(string name, string category = "Data")
|
||||
{
|
||||
try
|
||||
{
|
||||
string filePath = GetFilePath("BetterData");
|
||||
|
||||
string json = File.ReadAllText(filePath);
|
||||
var jsonData = JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, string>>>(json);
|
||||
|
||||
if (jsonData != null && jsonData.ContainsKey(category) && jsonData[category].ContainsKey(name))
|
||||
{
|
||||
return jsonData[category][name];
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error(ex.ToString());
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public static void SaveCheatData(string puid, string friendCode, string name, string category = "cheatData", string reason = "None")
|
||||
{
|
||||
string filePath = GetFilePath("BetterData");
|
||||
|
||||
string json = File.ReadAllText(filePath);
|
||||
var jsonData = JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, Dictionary<string, string>>>>(json) ?? new Dictionary<string, Dictionary<string, Dictionary<string, string>>>();
|
||||
|
||||
if (!jsonData.ContainsKey(category))
|
||||
{
|
||||
jsonData[category] = new Dictionary<string, Dictionary<string, string>>();
|
||||
}
|
||||
|
||||
if (!jsonData[category].ContainsKey(name))
|
||||
{
|
||||
jsonData[category][name] = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
jsonData[category][name]["FriendCode"] = friendCode;
|
||||
jsonData[category][name]["HashPUID"] = puid;
|
||||
jsonData[category][name]["Reason"] = reason;
|
||||
|
||||
json = JsonSerializer.Serialize(jsonData, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(filePath, json);
|
||||
}
|
||||
|
||||
public static void ClearCheatData()
|
||||
{
|
||||
string filePath = GetFilePath("BetterData");
|
||||
string json = File.ReadAllText(filePath);
|
||||
var jsonData = JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, Dictionary<string, string>>>>(json)
|
||||
?? new Dictionary<string, Dictionary<string, Dictionary<string, string>>>();
|
||||
|
||||
// Clear in-save data
|
||||
if (jsonData != null)
|
||||
{
|
||||
if (jsonData.ContainsKey("cheatData"))
|
||||
{
|
||||
jsonData["cheatData"].Clear();
|
||||
}
|
||||
|
||||
if (jsonData.ContainsKey("sickoData"))
|
||||
{
|
||||
jsonData["sickoData"].Clear();
|
||||
}
|
||||
|
||||
if (jsonData.ContainsKey("aumData"))
|
||||
{
|
||||
jsonData["aumData"].Clear();
|
||||
}
|
||||
|
||||
json = JsonSerializer.Serialize(jsonData, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(filePath, json);
|
||||
}
|
||||
|
||||
// Clear in-memory data
|
||||
AntiCheat.PlayerData.Clear();
|
||||
AntiCheat.SickoData.Clear();
|
||||
AntiCheat.AUMData.Clear();
|
||||
|
||||
Logger.LogCheat("Cleared cheat memory and data");
|
||||
}
|
||||
|
||||
public static void LoadCheatData()
|
||||
{
|
||||
try
|
||||
{
|
||||
string filePath = GetFilePath("BetterData");
|
||||
string json = File.ReadAllText(filePath);
|
||||
var jsonData = JsonSerializer.Deserialize<Dictionary<string, Dictionary<string, Dictionary<string, string>>>>(json);
|
||||
|
||||
if (jsonData != null)
|
||||
{
|
||||
if (jsonData.ContainsKey("cheatData"))
|
||||
{
|
||||
foreach (var item in jsonData["cheatData"])
|
||||
{
|
||||
AntiCheat.PlayerData[item.Value["HashPUID"]] = item.Value["FriendCode"];
|
||||
}
|
||||
}
|
||||
|
||||
if (jsonData.ContainsKey("sickoData"))
|
||||
{
|
||||
foreach (var item in jsonData["sickoData"])
|
||||
{
|
||||
AntiCheat.SickoData[item.Value["HashPUID"]] = item.Value["FriendCode"];
|
||||
}
|
||||
}
|
||||
|
||||
if (jsonData.ContainsKey("aumData"))
|
||||
{
|
||||
foreach (var item in jsonData["aumData"])
|
||||
{
|
||||
AntiCheat.AUMData[item.Value["HashPUID"]] = item.Value["FriendCode"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error(ex.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,102 +1,102 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BetterAmongUs;
|
||||
|
||||
class BAUNotificationManager
|
||||
{
|
||||
public static GameObject BAUNotificationManagerObj;
|
||||
private static Dictionary<string, float> NotifyQueue = [];
|
||||
private static float showTime = 0f;
|
||||
private static Camera localCamera;
|
||||
private static bool Notifying = false;
|
||||
|
||||
public static void Notify(string text, float Time = 5f)
|
||||
{
|
||||
if (BAUNotificationManagerObj != null)
|
||||
{
|
||||
if (Notifying)
|
||||
{
|
||||
if (text == BAUNotificationManagerObj.transform.Find("Sizer/ChatText (TMP)").GetComponent<TextMeshPro>().text)
|
||||
return;
|
||||
NotifyQueue[text] = Time;
|
||||
return;
|
||||
}
|
||||
|
||||
showTime = Time;
|
||||
BAUNotificationManagerObj.SetActive(true);
|
||||
BAUNotificationManagerObj.transform.Find("Sizer/ChatText (TMP)").GetComponent<TextMeshPro>().text = text;
|
||||
SoundManager.Instance.PlaySound(DestroyableSingleton<HudManager>.Instance.TaskCompleteSound, false, 1f);
|
||||
Notifying = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void NotifyCheat(PlayerControl player, string reason, string newText = "", bool kickPlayer = true)
|
||||
{
|
||||
string text = $"Player: <color=#0097b5>{player?.CurrentOutfit.PlayerName}</color> Has been detected doing an unauthorized action: <b><color=#fc0000>{reason}</color></b>";
|
||||
if (newText != "")
|
||||
text = $"Player: <color=#0097b5>{player?.CurrentOutfit.PlayerName}</color> " + newText + $": <b><color=#fc0000>{reason}</color></b>";
|
||||
|
||||
if (!AntiCheat.PlayerData.ContainsKey(Utils.GetHashPuid(player)))
|
||||
{
|
||||
AntiCheat.PlayerData[Utils.GetHashPuid(player)] = player.Data.FriendCode;
|
||||
BAUDataManager.SaveCheatData(Utils.GetHashPuid(player), player.Data.FriendCode, player.Data.PlayerName, "cheatData", reason);
|
||||
Notify(text, Time: 8f);
|
||||
}
|
||||
|
||||
if (GameStates.IsHost && kickPlayer)
|
||||
{
|
||||
player.RpcSetName($"<color=#ffea00>{player.Data.PlayerName}</color> Has been banned by <color=#4f92ff>Anti-Cheat</color>, Reason: {reason}<size=0%>");
|
||||
AmongUsClient.Instance.KickPlayer(player.GetClientId(), true);
|
||||
}
|
||||
|
||||
Logger.LogCheat(Utils.GetRawText(text));
|
||||
}
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
if (BAUNotificationManagerObj != null)
|
||||
{
|
||||
if (!localCamera)
|
||||
{
|
||||
if (DestroyableSingleton<HudManager>.InstanceExists)
|
||||
{
|
||||
localCamera = DestroyableSingleton<HudManager>.Instance.GetComponentInChildren<Camera>();
|
||||
}
|
||||
else
|
||||
{
|
||||
localCamera = Camera.main;
|
||||
}
|
||||
}
|
||||
|
||||
BAUNotificationManagerObj.transform.position = AspectPosition.ComputeWorldPosition(localCamera, AspectPosition.EdgeAlignments.Bottom, new Vector3(-1.3f, 0.7f, localCamera.nearClipPlane + 0.1f));
|
||||
|
||||
showTime -= Time.deltaTime;
|
||||
if (showTime <= 0f)
|
||||
{
|
||||
BAUNotificationManagerObj.transform.Find("Sizer/ChatText (TMP)").GetComponent<TextMeshPro>().text = "";
|
||||
BAUNotificationManagerObj.SetActive(false);
|
||||
Notifying = false;
|
||||
|
||||
CheckNotifyQueue();
|
||||
}
|
||||
|
||||
if (!GameStates.IsInGame)
|
||||
{
|
||||
BAUNotificationManagerObj.SetActive(false);
|
||||
showTime = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void CheckNotifyQueue()
|
||||
{
|
||||
if (NotifyQueue.Any())
|
||||
{
|
||||
var key = NotifyQueue.Keys.First();
|
||||
var value = NotifyQueue[key];
|
||||
Notify(key, value);
|
||||
NotifyQueue.Remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BetterAmongUs;
|
||||
|
||||
class BetterNotificationManager
|
||||
{
|
||||
public static GameObject BAUNotificationManagerObj;
|
||||
private static Dictionary<string, float> NotifyQueue = [];
|
||||
private static float showTime = 0f;
|
||||
private static Camera localCamera;
|
||||
private static bool Notifying = false;
|
||||
|
||||
public static void Notify(string text, float Time = 5f)
|
||||
{
|
||||
if (BAUNotificationManagerObj != null)
|
||||
{
|
||||
if (Notifying)
|
||||
{
|
||||
if (text == BAUNotificationManagerObj.transform.Find("Sizer/ChatText (TMP)").GetComponent<TextMeshPro>().text)
|
||||
return;
|
||||
NotifyQueue[text] = Time;
|
||||
return;
|
||||
}
|
||||
|
||||
showTime = Time;
|
||||
BAUNotificationManagerObj.SetActive(true);
|
||||
BAUNotificationManagerObj.transform.Find("Sizer/ChatText (TMP)").GetComponent<TextMeshPro>().text = text;
|
||||
SoundManager.Instance.PlaySound(DestroyableSingleton<HudManager>.Instance.TaskCompleteSound, false, 1f);
|
||||
Notifying = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void NotifyCheat(PlayerControl player, string reason, string newText = "", bool kickPlayer = true)
|
||||
{
|
||||
string text = $"Player: <color=#0097b5>{player?.CurrentOutfit.PlayerName}</color> Has been detected doing an unauthorized action: <b><color=#fc0000>{reason}</color></b>";
|
||||
if (newText != "")
|
||||
text = $"Player: <color=#0097b5>{player?.CurrentOutfit.PlayerName}</color> " + newText + $": <b><color=#fc0000>{reason}</color></b>";
|
||||
|
||||
if (!AntiCheat.PlayerData.ContainsKey(Utils.GetHashPuid(player)))
|
||||
{
|
||||
AntiCheat.PlayerData[Utils.GetHashPuid(player)] = player.Data.FriendCode;
|
||||
BetterDataManager.SaveCheatData(Utils.GetHashPuid(player), player.Data.FriendCode, player.Data.PlayerName, "cheatData", reason);
|
||||
Notify(text, Time: 8f);
|
||||
}
|
||||
|
||||
if (GameStates.IsHost && kickPlayer)
|
||||
{
|
||||
player.RpcSetName($"<color=#ffea00>{player.Data.PlayerName}</color> Has been banned by <color=#4f92ff>Anti-Cheat</color>, Reason: {reason}<size=0%>");
|
||||
AmongUsClient.Instance.KickPlayer(player.GetClientId(), true);
|
||||
}
|
||||
|
||||
Logger.LogCheat(Utils.GetRawText(text));
|
||||
}
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
if (BAUNotificationManagerObj != null)
|
||||
{
|
||||
if (!localCamera)
|
||||
{
|
||||
if (DestroyableSingleton<HudManager>.InstanceExists)
|
||||
{
|
||||
localCamera = DestroyableSingleton<HudManager>.Instance.GetComponentInChildren<Camera>();
|
||||
}
|
||||
else
|
||||
{
|
||||
localCamera = Camera.main;
|
||||
}
|
||||
}
|
||||
|
||||
BAUNotificationManagerObj.transform.position = AspectPosition.ComputeWorldPosition(localCamera, AspectPosition.EdgeAlignments.Bottom, new Vector3(-1.3f, 0.7f, localCamera.nearClipPlane + 0.1f));
|
||||
|
||||
showTime -= Time.deltaTime;
|
||||
if (showTime <= 0f)
|
||||
{
|
||||
BAUNotificationManagerObj.transform.Find("Sizer/ChatText (TMP)").GetComponent<TextMeshPro>().text = "";
|
||||
BAUNotificationManagerObj.SetActive(false);
|
||||
Notifying = false;
|
||||
|
||||
CheckNotifyQueue();
|
||||
}
|
||||
|
||||
if (!GameStates.IsInGame)
|
||||
{
|
||||
BAUNotificationManagerObj.SetActive(false);
|
||||
showTime = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void CheckNotifyQueue()
|
||||
{
|
||||
if (NotifyQueue.Any())
|
||||
{
|
||||
var key = NotifyQueue.Keys.First();
|
||||
var value = NotifyQueue[key];
|
||||
Notify(key, value);
|
||||
NotifyQueue.Remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,13 +44,13 @@ public class DebugMenu : MonoBehaviour
|
||||
{
|
||||
if (GameStates.IsInGame || GameStates.IsLobby || GameStates.IsFreePlay)
|
||||
{
|
||||
BAUNotificationManager.NotifyCheat(PlayerControl.LocalPlayer, "Debug Test", kickPlayer: false);
|
||||
BetterNotificationManager.NotifyCheat(PlayerControl.LocalPlayer, "Debug Test", kickPlayer: false);
|
||||
}
|
||||
}, true);
|
||||
|
||||
AddButtonToTab(Main, "Clear Anti-Cheat Data", () =>
|
||||
{
|
||||
BAUDataManager.ClearCheatData();
|
||||
BetterDataManager.ClearCheatData();
|
||||
});
|
||||
|
||||
AddButtonToTab(HostOnly, "Sync All Names", () =>
|
||||
|
||||
@@ -11,7 +11,7 @@ public class ChatNotificationPatch
|
||||
[HarmonyPostfix]
|
||||
public static void Awake_Postfix(ChatNotification __instance)
|
||||
{
|
||||
if (__instance.gameObject.name == "ChatNotification" && BAUNotificationManager.BAUNotificationManagerObj == null)
|
||||
if (__instance.gameObject.name == "ChatNotification" && BetterNotificationManager.BAUNotificationManagerObj == null)
|
||||
{
|
||||
GameObject ChatNotifications = __instance.gameObject;
|
||||
if (ChatNotifications != null)
|
||||
@@ -25,7 +25,7 @@ public class ChatNotificationPatch
|
||||
GameObject.Find($"{BAUNotification.name}/Sizer/NameText").transform.localPosition = new Vector3(-3.3192f, -0.0105f);
|
||||
GameObject.Find($"{BAUNotification.name}/Sizer/NameText").GetComponent<TextMeshPro>().text = "<color=#00ff44>System Notification</color>";
|
||||
UnityEngine.Object.DontDestroyOnLoad(BAUNotification);
|
||||
BAUNotificationManager.BAUNotificationManagerObj = BAUNotification;
|
||||
BetterNotificationManager.BAUNotificationManagerObj = BAUNotification;
|
||||
BAUNotification.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public static class OptionsMenuBehaviourPatch
|
||||
{
|
||||
bool flag = GameStates.IsInGame && !GameStates.IsLobby || GameStates.IsFreePlay;
|
||||
if (flag)
|
||||
BAUNotificationManager.Notify($"Unable to toggle {buttonName} while in game!", 2.5f);
|
||||
BetterNotificationManager.Notify($"Unable to toggle {buttonName} while in game!", 2.5f);
|
||||
|
||||
return flag;
|
||||
}
|
||||
@@ -84,11 +84,11 @@ public static class OptionsMenuBehaviourPatch
|
||||
DisableLobbyTheme = ClientOptionItem.Create("Open Save Data", null, __instance, OpenSaveDataButtonToggle, IsToggle: false);
|
||||
static void OpenSaveDataButtonToggle()
|
||||
{
|
||||
if (File.Exists(BAUDataManager.GetFilePath("BetterData")))
|
||||
if (File.Exists(BetterDataManager.GetFilePath("BetterData")))
|
||||
{
|
||||
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo()
|
||||
{
|
||||
FileName = BAUDataManager.GetFilePath("BetterData"),
|
||||
FileName = BetterDataManager.GetFilePath("BetterData"),
|
||||
UseShellExecute = true,
|
||||
Verb = "open"
|
||||
});
|
||||
|
||||
@@ -21,7 +21,7 @@ public class HudManagerPatch
|
||||
{
|
||||
try
|
||||
{
|
||||
if (BAUNotificationManager.BAUNotificationManagerObj == null)
|
||||
if (BetterNotificationManager.BAUNotificationManagerObj == null)
|
||||
{
|
||||
bool ChatState = GameObject.Find("ChatUi");
|
||||
__instance.Chat.gameObject.SetActive(true);
|
||||
@@ -34,7 +34,7 @@ public class HudManagerPatch
|
||||
|
||||
if (!HasBeenWelcomed && GameStates.IsInGame && GameStates.IsLobby && !GameStates.IsFreePlay)
|
||||
{
|
||||
BAUNotificationManager.Notify("<b><color=#00751f>Welcome To Better Among Us!</color></b>", 8f);
|
||||
BetterNotificationManager.Notify("<b><color=#00751f>Welcome To Better Among Us!</color></b>", 8f);
|
||||
|
||||
Utils.AddChatPrivate(WelcomeMessage, overrideName: " ");
|
||||
HasBeenWelcomed = true;
|
||||
|
||||
@@ -17,6 +17,6 @@ public class ModManagerPatch
|
||||
|
||||
FileChecker.UpdateUnauthorizedFiles();
|
||||
LateTask.Update(Time.deltaTime);
|
||||
BAUNotificationManager.Update();
|
||||
BetterNotificationManager.Update();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user