mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-20 01:46:19 +00:00
Add support to ModdedProtocol
This commit is contained in:
1 parent
c863c34678
commit
8107cd4462
6 files changed
+33
-39
No files matched your search
@@ -85,10 +85,11 @@ internal static class BetterNotificationManager
|
||||
/// Displays a notification message in-game.
|
||||
/// </summary>
|
||||
/// <param name="text">The text to display in the notification.</param>
|
||||
/// <param name="Time">The duration in seconds to show the notification.</param>
|
||||
internal static void Notify(string text, float Time = 5f)
|
||||
/// <param name="time">The duration in seconds to show the notification.</param>
|
||||
/// /// <param name="force">If notification should be forced even if better notifications is disabled.</param>
|
||||
internal static void Notify(string text, float time = 5f, bool force = false)
|
||||
{
|
||||
if (!BAUConfigs.BetterNotifications.Value)
|
||||
if (!BAUConfigs.BetterNotifications.Value && !force)
|
||||
return;
|
||||
|
||||
if (BAUNotificationManagerObj == null)
|
||||
@@ -99,11 +100,11 @@ internal static class BetterNotificationManager
|
||||
if (text == TextArea.text)
|
||||
return;
|
||||
|
||||
NotifyQueue[text] = Time;
|
||||
NotifyQueue[text] = time;
|
||||
return;
|
||||
}
|
||||
|
||||
showTime = Time;
|
||||
showTime = time;
|
||||
BAUNotificationManagerObj.SetActive(true);
|
||||
NameText.text = $"<color=#00ff44>{Translator.GetString("SystemNotification")}</color>";
|
||||
TextArea.text = text;
|
||||
@@ -167,7 +168,7 @@ internal static class BetterNotificationManager
|
||||
{
|
||||
BetterDataManager.Files.BetterDataFile.CheatData.Add(new(player?.ExtendedData().RealName ?? player.Data.PlayerName, player.GetHashPuid(), player.Data.FriendCode, reason));
|
||||
BetterDataManager.Files.BetterDataFile.Save();
|
||||
Notify(text, Time: 8f);
|
||||
Notify(text, time: 8f);
|
||||
}
|
||||
|
||||
Logger_.LogCheat($"{player.cosmetics.nameText.text} Info: {player.Data.PlayerName} - {player.Data.FriendCode} - {player.GetHashPuid()}");
|
||||
|
||||
@@ -18,12 +18,15 @@ namespace BetterAmongUs.Modules.AntiCheat;
|
||||
internal static class BetterAntiCheat
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets whether anti-cheat is enabled for the current player.
|
||||
/// Gets whether anti-cheat is enabled.
|
||||
/// </summary>
|
||||
internal static bool IsEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
if (GameState.IsModdedProtocol)
|
||||
return false;
|
||||
|
||||
if (PlayerControl.LocalPlayer == null)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -246,7 +246,7 @@ internal static class GameState
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsVanillaServer)
|
||||
if (IsFreePlay || IsLocalGame)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -261,7 +261,7 @@ internal static class GameState
|
||||
return false;
|
||||
}
|
||||
|
||||
if (PlayerControl.LocalPlayer.Data.AmOwner)
|
||||
if (PlayerControl.LocalPlayer.Data.OwnerId == -2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using BetterAmongUs.Enums;
|
||||
using BetterAmongUs.Helpers;
|
||||
using BetterAmongUs.Modules;
|
||||
using BetterAmongUs.Mono.Extended;
|
||||
using Hazel;
|
||||
|
||||
@@ -105,22 +104,6 @@ internal static class RPC
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (!Enum.IsDefined(typeof(CustomRPC), (int)unchecked(callId)))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!GameState.IsHost)
|
||||
{
|
||||
if (player.IsHost())
|
||||
{
|
||||
var Icon = Translator.GetString("BAUMark");
|
||||
var BAU = $"<color=#278720>{Icon}</color><color=#0ed400><b>{Translator.GetString("BAU")}</b></color><color=#278720>{Icon}</color>";
|
||||
Utils.DisconnectSelf(string.Format(Translator.GetString("ModdedLobbyMsg"), BAU));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using BepInEx.Unity.IL2CPP.Utils.Collections;
|
||||
using BetterAmongUs.Data.Config;
|
||||
using BetterAmongUs.Helpers;
|
||||
using BetterAmongUs.Managers;
|
||||
using BetterAmongUs.Modules;
|
||||
using BetterAmongUs.Modules.OptionItems;
|
||||
using BetterAmongUs.Modules.Support;
|
||||
@@ -27,24 +28,29 @@ internal static class PlayerControlPatch
|
||||
OptionPlayerItem.UpdateAllValues();
|
||||
|
||||
// Append favorite color setting to player initialization coroutine
|
||||
__result = Effects.Sequence(__result, CoSetFavoriteColor(__instance).WrapToIl2Cpp());
|
||||
__result = Effects.Sequence(__result, CoStartPostfix(__instance).WrapToIl2Cpp());
|
||||
}
|
||||
|
||||
private static IEnumerator CoSetFavoriteColor(PlayerControl player)
|
||||
private static IEnumerator CoStartPostfix(PlayerControl player)
|
||||
{
|
||||
if (BAUModdedSupportFlags.HasFlag(BAUModdedSupportFlags.Disable_FavoriteColor))
|
||||
yield break;
|
||||
|
||||
if (!GameState.IsLobby)
|
||||
yield break;
|
||||
|
||||
// Apply player's favorite color setting if they own this character
|
||||
if (player.AmOwner)
|
||||
if (GameState.IsLobby)
|
||||
{
|
||||
if (BAUConfigs.FavoriteColor.Value >= 0 && player.cosmetics.ColorId != (byte)BAUConfigs.FavoriteColor.Value)
|
||||
if (player.AmOwner)
|
||||
{
|
||||
// Send command to server to change color
|
||||
player.CmdCheckColor((byte)BAUConfigs.FavoriteColor.Value);
|
||||
// Apply player's favorite color setting if they own this character
|
||||
if (!BAUModdedSupportFlags.HasFlag(BAUModdedSupportFlags.Disable_FavoriteColor))
|
||||
{
|
||||
if (BAUConfigs.FavoriteColor.Value >= 0 && player.cosmetics.ColorId != (byte)BAUConfigs.FavoriteColor.Value)
|
||||
{
|
||||
// Send command to server to change color
|
||||
player.CmdCheckColor((byte)BAUConfigs.FavoriteColor.Value);
|
||||
}
|
||||
}
|
||||
|
||||
if (GameState.IsModdedProtocol)
|
||||
{
|
||||
BetterNotificationManager.Notify(Translator.GetString("AntiCheat.DisabledModdedProtocol"), 6f, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -112,6 +112,7 @@
|
||||
"AntiCheat.Ban": "Banned",
|
||||
"AntiCheat.Kick": "Kicked",
|
||||
"AntiCheat.PlayerDetected": "Player",
|
||||
"AntiCheat.DisabledModdedProtocol": "Anti-Cheat has been temporarily disabled on modded protocol!",
|
||||
"AntiCheat.UnauthorizedAction": "Has been detected doing an unauthorized action",
|
||||
"AntiCheat.ByAntiCheat": "{0} by <color=#4f92ff>Anti-Cheat</color>",
|
||||
"AntiCheat.KickMessage": "{0}! Reason: <color=#fc0000>{1}</color>",
|
||||
|
||||
Reference in new issue
Block a user