mirror of
https://github.com/ApeMV/AmongUsRevamped.git
synced 2026-10-20 01:46:28 +00:00
Starlight compatibility, small fixes
This commit is contained in:
1 parent
673386336a
commit
a6c3220892
11 files changed
+105
-60
No files matched your search
+29
-5
@@ -5,22 +5,30 @@ using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
// https://github.com/EnhancedNetwork/TownofHost-Enhanced/blob/main/Modules/BanManager.cs
|
||||
namespace AmongUsRevamped;
|
||||
|
||||
public static class BanManager
|
||||
{
|
||||
public static readonly string DataPath =
|
||||
#if ANDROID
|
||||
Application.persistentDataPath;
|
||||
#else
|
||||
".";
|
||||
#endif
|
||||
|
||||
public static string RemoveHtmlTags(this string str) => Regex.Replace(str, "<[^>]*?>", "");
|
||||
private static readonly string DenyNameListPath = "./AUR-DATA/DenyNameList.txt";
|
||||
private static string BanListPath = "./AUR-DATA/BanList.txt";
|
||||
private static string ModeratorListPath = "./AUR-DATA/ModeratorList.txt";
|
||||
private static readonly string DenyNameListPath = $"{DataPath}/AUR-DATA/DenyNameList.txt";
|
||||
private static string BanListPath = $"{DataPath}/AUR-DATA/BanList.txt";
|
||||
private static string ModeratorListPath = $"{DataPath}/AUR-DATA/ModeratorList.txt";
|
||||
public static List<string> TempBanWhiteList = [];
|
||||
public static void Init()
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory("AUR-DATA");
|
||||
if (!Directory.Exists($"{DataPath}/AUR-DATA")) Directory.CreateDirectory($"{DataPath}/AUR-DATA");
|
||||
|
||||
if (!File.Exists(DenyNameListPath))
|
||||
{
|
||||
@@ -120,8 +128,9 @@ public static class BanManager
|
||||
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory("AUR-DATA");
|
||||
if (!Directory.Exists($"{DataPath}/AUR-DATA")) Directory.CreateDirectory($"{DataPath}/AUR-DATA");
|
||||
if (!File.Exists(BanListPath)) File.Create(BanListPath).Close();
|
||||
|
||||
using StreamReader sr = new(BanListPath);
|
||||
string line;
|
||||
while ((line = sr.ReadLine()) != null)
|
||||
@@ -141,6 +150,21 @@ public static class BanManager
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static bool IsPlayerInDenyName(ClientData client, string name)
|
||||
{
|
||||
if (name == "" || !AmongUsClient.Instance.AmHost || !Options.ApplyDenyNameList.GetBool()) return false;
|
||||
|
||||
var deniedNames = File.ReadAllLines(DenyNameListPath);
|
||||
|
||||
if (deniedNames.Where(code => !string.IsNullOrWhiteSpace(code)).Any(code => name.Contains(code, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
AmongUsClient.Instance.KickPlayer(client.Id, false);
|
||||
Logger.Info($" {name} was kicked because their name was in DenyNameList.txt", "Kick");
|
||||
Logger.SendInGame($" {name} was kicked because their name was in DenyNameList.txt");
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
}
|
||||
[HarmonyPatch(typeof(BanMenu), nameof(BanMenu.Select))]
|
||||
|
||||
+11
-8
@@ -5,16 +5,23 @@ using UnityEngine;
|
||||
|
||||
namespace AmongUsRevamped;
|
||||
|
||||
#if !ANDROID
|
||||
[HarmonyPatch(typeof(ControllerManager), nameof(ControllerManager.Update))]
|
||||
internal class Hotkeys
|
||||
{
|
||||
public static void Postfix()
|
||||
{
|
||||
// I don't know which psychopath would use right keys, but I know someday, someone will complain
|
||||
bool Shift = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
|
||||
bool Ctrl = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
|
||||
bool Enter = Input.GetKeyDown(KeyCode.Return);
|
||||
|
||||
if ((!AmongUsClient.Instance.IsGameStarted || !Utils.IsOnlineGame) && Utils.CanMove && PlayerControl.LocalPlayer.Collider != null)
|
||||
{
|
||||
PlayerControl.LocalPlayer.Collider.enabled = !Ctrl;
|
||||
}
|
||||
|
||||
if (!AmongUsClient.Instance.AmHost) return;
|
||||
|
||||
if (Input.GetKey(KeyCode.L) && Shift && Enter)
|
||||
{
|
||||
MessageWriter writer = AmongUsClient.Instance.StartEndGame();
|
||||
@@ -34,16 +41,11 @@ internal class Hotkeys
|
||||
}
|
||||
}
|
||||
|
||||
if (Shift && GameStartManager.InstanceExists && GameStartManager.Instance.startState == GameStartManager.StartingStates.Countdown && !HudManager.Instance.Chat.IsOpenOrOpening)
|
||||
if (Shift && GameStartManager.InstanceExists && GameStartManager.Instance != null && GameStartManager.Instance.startState == GameStartManager.StartingStates.Countdown && !HudManager.Instance.Chat.IsOpenOrOpening)
|
||||
{
|
||||
GameStartManager.Instance.countDownTimer = 0;
|
||||
}
|
||||
|
||||
if ((!AmongUsClient.Instance.IsGameStarted || !Utils.IsOnlineGame) && Utils.CanMove && PlayerControl.LocalPlayer.Collider != null)
|
||||
{
|
||||
PlayerControl.LocalPlayer.Collider.enabled = !Ctrl;
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.C) && GameStartManager.InstanceExists && GameStartManager.Instance != null && GameStartManager.Instance.startState == GameStartManager.StartingStates.Countdown && !HudManager.Instance.Chat.IsOpenOrOpening && Utils.IsLobby)
|
||||
{
|
||||
Logger.Info("Resetted start countdown", "KeyCommand");
|
||||
@@ -51,4 +53,5 @@ internal class Hotkeys
|
||||
Logger.SendInGame("Starting countdown canceled");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+8
-19
@@ -52,28 +52,11 @@ public static class Utils
|
||||
{
|
||||
if (friendCode == "") return false;
|
||||
|
||||
var friendCodesFilePath = @"./AUR-DATA/ModeratorList.txt";
|
||||
var friendCodesFilePath = @$"{BanManager.DataPath}/AUR-DATA/ModeratorList.txt";
|
||||
var friendCodes = File.ReadAllLines(friendCodesFilePath);
|
||||
return friendCodes.Any(code => code.Contains(friendCode));
|
||||
}
|
||||
|
||||
public static bool IsPlayerInDenyName(ClientData client, string name)
|
||||
{
|
||||
if (name == "" || !AmongUsClient.Instance.AmHost || !Options.ApplyDenyNameList.GetBool()) return false;
|
||||
|
||||
var denyNameFilePath = @"./AUR-DATA/DenyNameList.txt";
|
||||
var deniedNames = File.ReadAllLines(denyNameFilePath);
|
||||
|
||||
if (deniedNames.Where(code => !string.IsNullOrWhiteSpace(code)).Any(code => name.Contains(code, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
AmongUsClient.Instance.KickPlayer(client.Id, false);
|
||||
Logger.Info($" {name} was kicked because their name was in DenyNameList.txt", "Kick");
|
||||
Logger.SendInGame($" {name} was kicked because their name was in DenyNameList.txt");
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
public static string GetTabName(TabGroup tab)
|
||||
{
|
||||
switch (tab)
|
||||
@@ -394,8 +377,12 @@ public static class Utils
|
||||
|
||||
public static void DumpLog()
|
||||
{
|
||||
string f = $"{Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)}/AUR-logs/";
|
||||
string t = DateTime.Now.ToString("yyyy-MM-dd_HH.mm.ss");
|
||||
#if ANDROID
|
||||
var f = $"{BanManager.DataPath}/AUR-Logs/{t}";
|
||||
#else
|
||||
string f = $"{Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)}/AUR-logs/";
|
||||
#endif
|
||||
string filename = $"{f}AUR-{Main.ModVersion}-{t}.log";
|
||||
if (!Directory.Exists(f)) Directory.CreateDirectory(f);
|
||||
FileInfo file = new(@$"{Environment.CurrentDirectory}/BepInEx/LogOutput.log");
|
||||
@@ -404,8 +391,10 @@ public static class Utils
|
||||
if (PlayerControl.LocalPlayer != null)
|
||||
{
|
||||
HudManager.Instance.Chat.AddChat(PlayerControl.LocalPlayer, $"/Dump command activated\n\nFile: AUR-{Main.ModVersion}-{t}");
|
||||
#if !ANDROID
|
||||
ProcessStartInfo psi = new("Explorer.exe") { Arguments = "/e,/select," + @filename.Replace("/", "\\") };
|
||||
Process.Start(psi);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -4,6 +4,7 @@ using UnityEngine;
|
||||
namespace AmongUsRevamped;
|
||||
|
||||
// https://github.com/Yumenopai/TownOfHost_Y
|
||||
#if !ANDROID
|
||||
[HarmonyPatch(typeof(HudManager), nameof(HudManager.Update))]
|
||||
public static class Zoom
|
||||
{
|
||||
@@ -16,9 +17,7 @@ public static class Zoom
|
||||
|
||||
public static void Postfix()
|
||||
{
|
||||
bool canZoom =
|
||||
(Utils.IsShip && !Utils.IsMeeting && Utils.CanMove && PlayerControl.LocalPlayer.Data.IsDead)
|
||||
|| (Utils.IsLobby && Utils.CanMove);
|
||||
bool canZoom = (Utils.IsShip && !Utils.IsMeeting && Utils.CanMove && PlayerControl.LocalPlayer.Data.IsDead) || (Utils.IsLobby && Utils.CanMove);
|
||||
|
||||
if (!canZoom)
|
||||
{
|
||||
@@ -100,4 +99,5 @@ public static class Flag
|
||||
{
|
||||
OneTimeList.Remove(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in new issue
Block a user