Merge pull request #20 from D1GQ/dev

v1.0.1
This commit is contained in:
D1GQ authored and GitHub committed 2024-08-13 22:37:09 -05:00
commit 1763a7afcf
14 files changed
+137 -33

No files matched your search

+1 -1
View File
@@ -10,7 +10,7 @@
<None Include="..\.editorconfig" Link=".editorconfig" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="AmongUs.GameLibs.Steam" Version="2024.6.18" />
<PackageReference Include="AmongUs.GameLibs.Steam" Version="2024.8.13" />
<PackageReference Include="BepInEx.IL2CPP.MSBuild" Version="2.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
+5 -5
View File
@@ -25,15 +25,15 @@ class AntiCheat
if (SickoData.ContainsKey(hashPuid))
{
player.Kick(true, $"<color=#ffea00>{player.Data.PlayerName}</color> Has been banned by <color=#4f92ff>Anti-Cheat</color>, Reason: Known Sicko Menu User<size=0%>");
player.Kick(true, $"<color=#ffea00>{player.Data.PlayerName}</color> Has been banned by <color=#4f92ff>Anti-Cheat</color>, Reason: <color=#00f583>Known Sicko Menu User</color>");
}
else if (AUMData.ContainsKey(hashPuid))
{
player.Kick(true, $"<color=#ffea00>{player.Data.PlayerName}</color> Has been banned by <color=#4f92ff>Anti-Cheat</color>, Reason: Known AUM User<size=0%>");
player.Kick(true, $"<color=#ffea00>{player.Data.PlayerName}</color> Has been banned by <color=#4f92ff>Anti-Cheat</color>, Reason: <color=#4f0000>Known AUM User</color>");
}
else if (PlayerData.ContainsKey(hashPuid))
{
player.Kick(true, $"<color=#ffea00>{player.Data.PlayerName}</color> Has been banned by <color=#4f92ff>Anti-Cheat</color>, Reason: Known Cheater<size=0%>");
player.Kick(true, $"<color=#ffea00>{player.Data.PlayerName}</color> Has been banned by <color=#4f92ff>Anti-Cheat</color>, Reason: <color=#fc0000>Known Cheater</color>");
}
}
}
@@ -72,7 +72,7 @@ class AntiCheat
{
player.ReportPlayer(ReportReasons.Cheating_Hacking);
BetterNotificationManager.NotifyCheat(player, $"Platform Spoofer", newText: "Has been detected with a cheat");
Logger.LogCheat($"{player.Data.PlayerName} Platform Spoofer: {__instance.XboxPlatformId} is not 10 to 16 characters");
Logger.LogCheat($"{player.Data.PlayerName} Platform Spoofer: {__instance.XboxPlatformId}");
}
}
@@ -82,7 +82,7 @@ class AntiCheat
{
player.ReportPlayer(ReportReasons.Cheating_Hacking);
BetterNotificationManager.NotifyCheat(player, $"Platform Spoofer", newText: "Has been detected with a cheat");
Logger.LogCheat($"{player.Data.PlayerName} Platform Spoofer: {__instance.PsnPlatformId} is not 14 to 19 characters");
Logger.LogCheat($"{player.Data.PlayerName} Platform Spoofer: {__instance.PsnPlatformId}");
}
}
}
+6 -5
View File
@@ -6,13 +6,15 @@ namespace BetterAmongUs;
class BetterNotificationManager
{
public static GameObject BAUNotificationManagerObj;
private static Dictionary<string, float> NotifyQueue = [];
private static float showTime = 0f;
public static Dictionary<string, float> NotifyQueue = [];
public static float showTime = 0f;
private static Camera localCamera;
private static bool Notifying = false;
public static bool Notifying = false;
public static void Notify(string text, float Time = 5f)
{
if (!Main.BetterNotifications.Value) return;
if (BAUNotificationManagerObj != null)
{
if (Notifying)
@@ -46,8 +48,7 @@ class BetterNotificationManager
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);
player.Kick(true, $"<color=#ffea00>{player.Data.PlayerName}</color> Has been banned by <color=#4f92ff>Anti-Cheat</color>, Reason: <color=#fc0000>{reason}</color>");
}
Logger.LogCheat(Utils.GetRawText(text));
+4 -2
View File
@@ -103,14 +103,16 @@ static class ExtendedPlayerControl
// Kick player
public static void Kick(this PlayerControl player, bool ban = false, string setReasonInfo = "")
{
if (!GameStates.IsHost || !player.DataIsCollected() || player.IsHost())
if (!GameStates.IsHost || !player.DataIsCollected() || player.IsHost() || player.BetterData().BannedByAntiCheat)
{
return;
}
player.BetterData().BannedByAntiCheat = true;
if (setReasonInfo != "")
{
player.RpcSetName(setReasonInfo);
player.RpcSetName(setReasonInfo + "<size=0%>");
}
AmongUsClient.Instance.KickPlayer(player.GetClientId(), ban);
+1
View File
@@ -6,6 +6,7 @@ public class ExtendedPlayerInfo
public bool IsBetterUser { get; set; } = false;
public bool IsBetterHost { get; set; } = false;
public bool IsTOHEHost { get; set; } = false;
public bool BannedByAntiCheat { get; set; } = false;
public bool HasNoisemakerNotify { get; set; } = false;
public int TimesCalledMeeting { get; set; } = 0;
+15 -7
View File
@@ -96,21 +96,29 @@ public static class Utils
public static string GetRoleName(RoleTypes role) => Main.GetRoleName[(int)role];
public static string Color32ToHex(Color32 color) => $"#{color.r:X2}{color.g:X2}{color.b:X2}{255:X2}";
// Disconnect client
public static void DisconnectSelf(string reason)
public static void DisconnectSelf(string reason, bool showReason = true)
{
AmongUsClient.Instance.ExitGame(0);
_ = new LateTask(() =>
{
SceneChanger.ChangeScene("MainMenu");
_ = new LateTask(() =>
if (showReason)
{
var lines = "<color=#ebbd34>----------------------------------------------------------------------------------------------</color>";
DisconnectPopup.Instance.gameObject.SetActive(true);
DisconnectPopup.Instance._textArea.enableWordWrapping = false;
DisconnectPopup.Instance._textArea.text = $"{lines}\n\n\n<size=150%>{reason}</size>\n\n\n{lines}";
}, 0.1f, "DisconnectSelf 2");
_ = new LateTask(() =>
{
var lines = "<color=#ebbd34>----------------------------------------------------------------------------------------------</color>";
ShowPopUp($"{lines}\n\n\n<size=150%>{reason}</size>\n\n\n{lines}");
}, 0.1f, "DisconnectSelf 2");
}
}, 0.2f, "DisconnectSelf 1");
}
// Show dc pop up with text
public static void ShowPopUp(string text, bool enableWordWrapping = false)
{
DisconnectPopup.Instance.gameObject.SetActive(true);
DisconnectPopup.Instance._textArea.enableWordWrapping = enableWordWrapping;
DisconnectPopup.Instance._textArea.text = text;
}
public static Dictionary<string, Sprite> CachedSprites = [];
+13
View File
@@ -12,6 +12,7 @@ public static class OptionsMenuBehaviourPatch
private static ClientOptionItem AntiCheat;
private static ClientOptionItem BetterHost;
private static ClientOptionItem BetterRoleAlgorithma;
private static ClientOptionItem BetterNotifications;
private static ClientOptionItem LobbyPlayerInfo;
private static ClientOptionItem DisableLobbyTheme;
private static ClientOptionItem UnlockFPS;
@@ -65,6 +66,18 @@ public static class OptionsMenuBehaviourPatch
if (BetterRoleAlgorithma == null || BetterRoleAlgorithma.ToggleButton == null)
{
BetterRoleAlgorithma = ClientOptionItem.Create("<color=#4f92ff>Better Role Algorithma</color>", Main.BetterRoleAlgorithma, __instance, toggleCheck: () => !toggleCheckInGamePlay("<color=#4f92ff>Better Role Algorithma</color>"));
}
if (BetterNotifications == null || BetterNotifications.ToggleButton == null)
{
BetterNotifications = ClientOptionItem.Create("<color=#4f92ff>Better Notifications</color>", Main.BetterNotifications, __instance, BetterNotificationsToggle);
static void BetterNotificationsToggle()
{
BetterNotificationManager.NotifyQueue.Clear();
BetterNotificationManager.showTime = 0f;
BetterNotificationManager.Notifying = false;
}
}
if (LobbyPlayerInfo == null || LobbyPlayerInfo.ToggleButton == null)
+39
View File
@@ -6,6 +6,45 @@ namespace BetterAmongUs.Patches;
public class ClientPatch
{
// Show warning message for newer and older versions of among us
[HarmonyPatch(typeof(EOSManager))]
public class EOSManagerPatch
{
[HarmonyPatch(nameof(EOSManager.EndFinalPartsOfLoginFlow))]
[HarmonyPostfix]
public static void EndFinalPartsOfLoginFlow_Postfix()
{
var varSupportedVersions = Main.SupportedAmongUsVersions;
Version currentVersion = new Version(Main.AmongUsVersion);
Version firstSupportedVersion = new Version(varSupportedVersions.First());
Version lastSupportedVersion = new Version(varSupportedVersions.Last());
if (currentVersion > firstSupportedVersion)
{
var verText = $"<b>{varSupportedVersions.First()}</b>";
if (firstSupportedVersion != lastSupportedVersion)
{
verText = $"<b>{varSupportedVersions.Last()}</b> - <b>{varSupportedVersions.First()}</b>";
}
Utils.ShowPopUp($"<size=200%>-= <color=#ff2200><b>Warning</b></color> =-</size>\n\n" +
$"<size=125%><color=#0dff00>Better Among Us {Main.GetVersionText()}</color>\nsupports <color=#4f92ff>Among Us {verText}</color>,\n" +
$"<color=#4f92ff>Among Us <b>{Main.AmongUsVersion}</b></color> is above the supported versions!\n" +
$"<color=#ae1700>You may encounter minor to game breaking bugs.</color></size>");
}
else if (currentVersion < lastSupportedVersion)
{
var verText = $"<b>{varSupportedVersions.First()}</b>";
if (firstSupportedVersion != lastSupportedVersion)
{
verText = $"<b>{varSupportedVersions.Last()}</b> - <b>{varSupportedVersions.First()}</b>";
}
Utils.ShowPopUp($"<size=200%>-= <color=#ff2200><b>Warning</b></color> =-</size>\n\n" +
$"<size=125%><color=#0dff00>Better Among Us {Main.GetVersionText()}</color>\nsupports <color=#4f92ff>Among Us {verText}</color>,\n" +
$"<color=#4f92ff>Among Us <b>{Main.AmongUsVersion}</b></color> is below the supported versions!\n" +
$"<color=#ae1700>You may encounter minor to game breaking bugs.</color></size>");
}
}
}
// Log game exit
[HarmonyPatch(typeof(AmongUsClient))]
public class AmongUsClientPatch
+7 -2
View File
@@ -21,7 +21,7 @@ class CommandsPatch
{
"help---Get help with commands",
"commands---Get a list of all available commands",
"dump---Dump at the entire log to the user's desktop",
"dump---Dump the entire log to the user's desktop",
"player {id}---Get a Players information---{player id}",
"players---Get all Player information",
"whisper {id} {msg}---Privately send an message to a player---{player id}",
@@ -32,10 +32,11 @@ class CommandsPatch
"ban {id}---Ban a player from the game - <color=red>Host Only</color>---{player id}",
"endgame {reason}---Force end the game - <color=red>Host Only</color>---{player id}",
"removeplayer {identifier}---Remove player from local <color=#4f92ff>Anti-Cheat</color> data---{FriendCode, HashPuid}",
"removeall---Remove all players from local <color=#4f92ff>Anti-Cheat</color> data",
};
public static string[] DebugCommandListHelper =
{
"getposition---Get current player position",
"getposition---Get current player position - <color=#ff00f7>DeBug</color>",
"role {role}---Set your role for the next game - <color=red>Host Only</color> - <color=#ff00f7>DeBug</color>",
"setrole {id} {role}---Set another players role for the next game - <color=red>Host Only</color> - <color=#ff00f7>DeBug</color>",
"syncallnames---Sync all players names for better host - <color=red>Host Only</color> - <color=#ff00f7>DeBug</color>",
@@ -272,6 +273,10 @@ class CommandsPatch
}
}
break;
case "removeall":
BetterDataManager.ClearCheatData();
Utils.AddChatPrivate($"All data successfully removed from local <color=#4f92ff>Anti-Cheat</color>!");
break;
default:
if (GameStates.IsDev && Main.ReleaseBuildType == ReleaseTypes.Dev)
{
+1 -3
View File
@@ -28,9 +28,7 @@ internal class MainMenuPatch
var icon = "<color=#278720>♻</color>";
var warning = "<color=#e60000>⚠</color>";
FileChecker.HasShownPopUp = true;
DisconnectPopup.Instance.gameObject.SetActive(true);
DisconnectPopup.Instance._textArea.enableWordWrapping = false;
DisconnectPopup.Instance._textArea.text = $"{lines}\n<b><size=200%>{icon}<color=#0ed400>Better Among Us</color>{icon}</size></b>\n<color=#757575><u><size=150%>{warning}<color=#8f0000>{FileChecker.UnauthorizedReason}</color>{warning}</size></u>\n\n<color=white>\n{OnlineMsg}\n{lines}";
Utils.ShowPopUp($"{lines}\n<b><size=200%>{icon}<color=#0ed400>Better Among Us</color>{icon}</size></b>\n<color=#757575><u><size=150%>{warning}<color=#8f0000>{FileChecker.UnauthorizedReason}</color>{warning}</size></u>\n\n<color=white>\n{OnlineMsg}\n{lines}");
}
}
}
+4 -1
View File
@@ -106,7 +106,10 @@ class PlayerControlPatch
string pattern = @"^[a-zA-Z0-9#]+$";
string hashtagPattern = @"^#[0-9]{4}$";
string friendCode = player.Data.FriendCode;
string friendCodeColor = (Regex.Replace(friendCode, hashtagPattern, string.Empty).Length is > 10 or < 5 || !Regex.IsMatch(friendCode, pattern) || !Regex.IsMatch(friendCode, hashtagPattern)) ? "#00f7ff" : "#ff0000";
string friendCodeColor = (Regex.Replace(friendCode, hashtagPattern, string.Empty).Length is > 10 or < 5
|| !Regex.IsMatch(friendCode, pattern)
|| !Regex.IsMatch(friendCode, hashtagPattern)
|| friendCode.Contains(' ')) ? "#00f7ff" : "#ff0000";
if (string.IsNullOrEmpty(friendCode) || friendCode == "")
{
friendCode = "???";
+2 -2
View File
@@ -78,10 +78,10 @@ class OnPlayerLeftPatch
if ((GameStates.IsInGame || GameStates.IsFreePlay) && !GameStates.IsLobby && !GameStates.IsHideNSeek && HudManager.Instance.CrewmatesKilled.isActiveAndEnabled)
HudManager.Instance?.NotifyOfDisconnect(data.Character);
}
}
}
[HarmonyPatch(typeof(GameData), nameof(GameData.ShowNotification))]
class GameDataPatch
class GameDataShowNotificationPatch
{
public static bool Prefix(AmongUsClient __instance, ref string playerName, ref DisconnectReasons reason)
{
+1 -1
View File
@@ -2,7 +2,7 @@
using HarmonyLib;
using Hazel;
namespace BetterAmongUs;
namespace BetterAmongUs.Patches;
[HarmonyPatch(typeof(RoleManager))]
public class RoleManagerPatch
+38 -4
View File
@@ -5,6 +5,8 @@ using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Innersloth.IO;
using System.Security.Cryptography;
using System.Text;
using UnityEngine;
namespace BetterAmongUs;
@@ -22,14 +24,43 @@ public class Main : BasePlugin
{
public const ReleaseTypes ReleaseBuildType = ReleaseTypes.Release;
public const string CanaryNum = "0";
public const string HotfixNum = "3";
public const bool IsHotFix = true;
public const string HotfixNum = "0";
public const bool IsHotFix = false;
public const string PluginGuid = "com.d1gq.betteramongus";
public const string PluginVersion = "1.0.0";
public const string ReleaseDate = "08.11.2024"; // mm/dd/yyyy
public const string PluginVersion = "1.0.1";
public const string ReleaseDate = "08.13.2024"; // mm/dd/yyyy
public const string Github = "https://github.com/D1GQ/BetterAmongUs-Public";
public const string Discord = "https://discord.gg/vjYrXpzNAn";
public static string modSignature
{
get
{
string GetHash(string puid)
{
using SHA256 sha256 = SHA256.Create();
byte[] sha256Bytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(puid));
string sha256Hash = BitConverter.ToString(sha256Bytes).Replace("-", "").ToLower();
return sha256Hash.Substring(0, 16) + sha256Hash.Substring(sha256Hash.Length - 8);
}
var versionData = new StringBuilder()
.Append(Enum.GetName(typeof(ReleaseTypes), ReleaseBuildType))
.Append(CanaryNum)
.Append(HotfixNum)
.Append(PluginGuid)
.Append(GetVersionText().Replace(" ", "."))
.Append(ReleaseDate)
.Append(Github)
.Append(Discord)
.Append(string.Join(",", Enum.GetNames(typeof(CustomRPC))))
.Append(string.Join(",", GetRoleName.Values))
.ToString();
return GetHash(versionData);
}
}
public static string GetVersionText(bool newLine = false)
{
string text = string.Empty;
@@ -55,6 +86,7 @@ public class Main : BasePlugin
public static List<string> SupportedAmongUsVersions =
[
"2024.8.13",
"2024.6.18",
];
@@ -128,6 +160,7 @@ public class Main : BasePlugin
public static ConfigEntry<bool> AntiCheat { get; private set; }
public static ConfigEntry<bool> BetterHost { get; private set; }
public static ConfigEntry<bool> BetterRoleAlgorithma { get; private set; }
public static ConfigEntry<bool> BetterNotifications { get; private set; }
public static ConfigEntry<bool> LobbyPlayerInfo { get; private set; }
public static ConfigEntry<bool> DisableLobbyTheme { get; private set; }
public static ConfigEntry<bool> UnlockFPS { get; private set; }
@@ -138,6 +171,7 @@ public class Main : BasePlugin
AntiCheat = Config.Bind("Better Options", "AntiCheat", true);
BetterHost = Config.Bind("Better Options", "BetterHost", false);
BetterRoleAlgorithma = Config.Bind("Better Options", "BetterRoleAlgorithma", true);
BetterNotifications = Config.Bind("Better Options", "BetterNotifications", true);
LobbyPlayerInfo = Config.Bind("Better Options", "LobbyPlayerInfo", true);
DisableLobbyTheme = Config.Bind("Better Options", "DisableLobbyTheme", true);
UnlockFPS = Config.Bind("Better Options", "UnlockFPS", false);