mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-20 01:46:19 +00:00
Add support to dump command on android
This commit is contained in:
1 parent
f1307f4009
commit
d113919250
4 files changed
+87
-46
No files matched your search
+3
-3
@@ -160,10 +160,10 @@ internal class BAUPlugin : BasePlugin
|
||||
InstanceAttribute.RegisterAll();
|
||||
OutfitData.Initialize();
|
||||
|
||||
if (File.Exists(Path.Combine(BetterDataManager.Folders.fileFolderPath, "better-log.txt")))
|
||||
File.WriteAllText(Path.Combine(BetterDataManager.Folders.fileFolderPath, "better-previous-log.txt"), File.ReadAllText(Path.Combine(BetterDataManager.Folders.fileFolderPath, "better-log.txt")));
|
||||
if (File.Exists(BetterDataManager.Files.logFilePath))
|
||||
File.WriteAllText(BetterDataManager.Files.previousLogFilePath, File.ReadAllText(BetterDataManager.Files.logFilePath));
|
||||
|
||||
File.WriteAllText(Path.Combine(BetterDataManager.Folders.fileFolderPath, "better-log.txt"), "");
|
||||
File.WriteAllText(BetterDataManager.Files.logFilePath, "");
|
||||
Logger_.Log("Better Among Us successfully loaded!");
|
||||
|
||||
string SupportedVersions = string.Join(" ", ModInfo.SupportedAmongUsVersions);
|
||||
|
||||
+61
-30
@@ -9,8 +9,6 @@ internal sealed class DumpCommand : BaseCommand
|
||||
{
|
||||
internal override string Name => "dump";
|
||||
internal override string Description => "Dump the entire log to the user's desktop";
|
||||
internal override bool ShowCommand() =>
|
||||
!ModInfo.Starlight;
|
||||
|
||||
internal override bool CanRunCommand(out string reason)
|
||||
{
|
||||
@@ -23,10 +21,8 @@ internal sealed class DumpCommand : BaseCommand
|
||||
return base.CanRunCommand(out reason);
|
||||
}
|
||||
|
||||
internal override void Run()
|
||||
private static string DecryptLog(string log)
|
||||
{
|
||||
string logFilePath = Path.Combine(BetterDataManager.Folders.fileFolderPath, "better-log.txt");
|
||||
string log = File.ReadAllText(logFilePath);
|
||||
string newLog = string.Empty;
|
||||
string[] logArray = log.Split([Environment.NewLine], StringSplitOptions.None);
|
||||
foreach (string text in logArray)
|
||||
@@ -40,29 +36,64 @@ internal sealed class DumpCommand : BaseCommand
|
||||
newLog += text + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
|
||||
string logFolderPath = Path.Combine(desktopPath, "BetterLogs");
|
||||
if (!Directory.Exists(logFolderPath))
|
||||
{
|
||||
Directory.CreateDirectory(logFolderPath);
|
||||
}
|
||||
string logFileName = "log-" + BAUPlugin.GetVersionText().Replace(' ', '-').ToLower() + "-" + DateTime.Now.ToString("yyyy.MM.dd-HH.mm.ss") + ".log";
|
||||
string newLogFilePath = Path.Combine(logFolderPath, logFileName);
|
||||
File.WriteAllText(newLogFilePath, newLog);
|
||||
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo()
|
||||
{
|
||||
FileName = logFolderPath,
|
||||
UseShellExecute = true,
|
||||
Verb = "open"
|
||||
});
|
||||
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo()
|
||||
{
|
||||
FileName = newLogFilePath,
|
||||
UseShellExecute = true,
|
||||
Verb = "open"
|
||||
});
|
||||
|
||||
CommandResultText($"Dump logs at <color=#b1b1b1>'{newLogFilePath}'</color>");
|
||||
return newLog;
|
||||
}
|
||||
}
|
||||
|
||||
internal override void Run()
|
||||
{
|
||||
string logFilePath = BetterDataManager.Files.logFilePath;
|
||||
if (!File.Exists(logFilePath))
|
||||
{
|
||||
CommandErrorText("Log file not found!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ModInfo.Starlight)
|
||||
{
|
||||
string log = File.ReadAllText(logFilePath);
|
||||
string newLog = DecryptLog(log);
|
||||
|
||||
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
|
||||
string logFolderPath = Path.Combine(desktopPath, "BetterLogDumps");
|
||||
if (!Directory.Exists(logFolderPath))
|
||||
{
|
||||
Directory.CreateDirectory(logFolderPath);
|
||||
}
|
||||
string logFileName = "log-" + BAUPlugin.GetVersionText().Replace(' ', '-').ToLower() + "-" + DateTime.Now.ToString("yyyy.MM.dd-HH.mm.ss") + ".log";
|
||||
string newLogFilePath = Path.Combine(logFolderPath, logFileName);
|
||||
File.WriteAllText(newLogFilePath, newLog);
|
||||
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo()
|
||||
{
|
||||
FileName = logFolderPath,
|
||||
UseShellExecute = true,
|
||||
Verb = "open"
|
||||
});
|
||||
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo()
|
||||
{
|
||||
FileName = newLogFilePath,
|
||||
UseShellExecute = true,
|
||||
Verb = "open"
|
||||
});
|
||||
|
||||
CommandResultText($"Dump logs at <color=#b1b1b1>'{newLogFilePath}'</color>");
|
||||
}
|
||||
else
|
||||
{
|
||||
string dataPath = BetterDataManager.Folders.fileFolderPath;
|
||||
string logFolderPath = Path.Combine(dataPath, "BetterLogDumps");
|
||||
if (!Directory.Exists(logFolderPath))
|
||||
{
|
||||
Directory.CreateDirectory(logFolderPath);
|
||||
}
|
||||
|
||||
string androidLogContent = File.ReadAllText(logFilePath);
|
||||
string androidNewLog = DecryptLog(androidLogContent);
|
||||
|
||||
string androidLogFileName = "log-" + BAUPlugin.GetVersionText().Replace(' ', '-').ToLower() + "-" + DateTime.Now.ToString("yyyy.MM.dd-HH.mm.ss") + ".log";
|
||||
string androidNewLogFilePath = Path.Combine(logFolderPath, androidLogFileName);
|
||||
File.WriteAllText(androidNewLogFilePath, androidNewLog);
|
||||
|
||||
CommandResultText($"Dump logs at <color=#b1b1b1>'{androidNewLogFilePath}'</color>");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,27 +18,27 @@ internal static class BetterDataManager
|
||||
/// <summary>
|
||||
/// Root directory for BetterAmongUs data.
|
||||
/// </summary>
|
||||
internal static string fileFolderPath = Path.Combine(GetPathToAmongUs(), $"Better_Data");
|
||||
internal static readonly string fileFolderPath = Path.Combine(GetPathToAmongUs(), $"Better_Data");
|
||||
|
||||
/// <summary>
|
||||
/// Root directory for BetterAmongUs data.
|
||||
/// </summary>
|
||||
internal static string starLightDataFolderPath = Environment.GetEnvironmentVariable("STAR_DATA_PATH") ?? string.Empty;
|
||||
internal static readonly string starLightDataFolderPath = Environment.GetEnvironmentVariable("STAR_DATA_PATH") ?? string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Directory for save information files.
|
||||
/// </summary>
|
||||
internal static string saveInfoFolderPath = Path.Combine(fileFolderPath, $"SaveInfo");
|
||||
internal static readonly string saveInfoFolderPath = Path.Combine(fileFolderPath, $"SaveInfo");
|
||||
|
||||
/// <summary>
|
||||
/// Directory for settings files.
|
||||
/// </summary>
|
||||
internal static string settingsFolderPath = Path.Combine(fileFolderPath, $"Settings");
|
||||
internal static readonly string settingsFolderPath = Path.Combine(fileFolderPath, $"Settings");
|
||||
|
||||
/// <summary>
|
||||
/// Directory for game replay files.
|
||||
/// </summary>
|
||||
internal static string replaysFolderPath = Path.Combine(fileFolderPath, $"Replays");
|
||||
internal static readonly string replaysFolderPath = Path.Combine(fileFolderPath, $"Replays");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -56,20 +56,30 @@ internal static class BetterDataManager
|
||||
/// </summary>
|
||||
internal static BetterGameSettingsFile BetterGameSettingsFile = new();
|
||||
|
||||
/// <summary>
|
||||
/// The log file path.
|
||||
/// </summary>
|
||||
internal static readonly string logFilePath = Path.Combine(Folders.fileFolderPath, "better-log.txt");
|
||||
|
||||
/// <summary>
|
||||
/// The previous log file path.
|
||||
/// </summary>
|
||||
internal static readonly string previousLogFilePath = Path.Combine(Folders.fileFolderPath, "better-previous-log.txt");
|
||||
|
||||
/// <summary>
|
||||
/// Legacy data file path (BetterData.json).
|
||||
/// </summary>
|
||||
internal static string dataFilePath_Legacy = Path.Combine(GetPathToAmongUsData(), "BetterData.json");
|
||||
internal static readonly string dataFilePath_Legacy = Path.Combine(GetPathToAmongUsData(), "BetterData.json");
|
||||
|
||||
/// <summary>
|
||||
/// Current data file path (BetterDataV2.json).
|
||||
/// </summary>
|
||||
internal static string dataFilePath = Path.Combine(GetPathToAmongUsData(), "BetterDataV2.json");
|
||||
internal static readonly string dataFilePath = Path.Combine(GetPathToAmongUsData(), "BetterDataV2.json");
|
||||
|
||||
/// <summary>
|
||||
/// Legacy settings file path.
|
||||
/// </summary>
|
||||
internal static string settingsFilePath_Legacy = Path.Combine(Folders.settingsFolderPath, "Settings.dat");
|
||||
internal static readonly string settingsFilePath_Legacy = Path.Combine(Folders.settingsFolderPath, "Settings.dat");
|
||||
|
||||
/// <summary>
|
||||
/// Current compressed settings file path.
|
||||
@@ -79,17 +89,17 @@ internal static class BetterDataManager
|
||||
/// <summary>
|
||||
/// File containing banned player identifiers.
|
||||
/// </summary>
|
||||
internal static string banPlayerListFilePath = Path.Combine(Folders.saveInfoFolderPath, "BanPlayerList.txt");
|
||||
internal static readonly string banPlayerListFilePath = Path.Combine(Folders.saveInfoFolderPath, "BanPlayerList.txt");
|
||||
|
||||
/// <summary>
|
||||
/// File containing banned player names.
|
||||
/// </summary>
|
||||
internal static string banNameListFilePath = Path.Combine(Folders.saveInfoFolderPath, "BanNameList.txt");
|
||||
internal static readonly string banNameListFilePath = Path.Combine(Folders.saveInfoFolderPath, "BanNameList.txt");
|
||||
|
||||
/// <summary>
|
||||
/// File containing banned words/patterns.
|
||||
/// </summary>
|
||||
internal static string banWordListFilePath = Path.Combine(Folders.saveInfoFolderPath, "BanWordList.txt");
|
||||
internal static readonly string banWordListFilePath = Path.Combine(Folders.saveInfoFolderPath, "BanWordList.txt");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -28,7 +28,7 @@ internal static class Logger_
|
||||
return;
|
||||
|
||||
string mark = $"{DateTime.Now:HH:mm} [BetterLog][{tag}]";
|
||||
string logFilePath = Path.Combine(BetterDataManager.Folders.fileFolderPath, "better-log.txt");
|
||||
string logFilePath = BetterDataManager.Files.logFilePath;
|
||||
string newLine = $"{mark}: {Utils.RemoveHtmlText(info)}";
|
||||
File.AppendAllText(logFilePath, newLine + Environment.NewLine);
|
||||
BAUPlugin.Logger.LogInfo($"[{tag}] {info}");
|
||||
@@ -185,7 +185,7 @@ internal static class Logger_
|
||||
return;
|
||||
|
||||
string mark = $"{DateTime.Now:HH:mm} [BetterLog][PrivateLog][{tag}]";
|
||||
string logFilePath = Path.Combine(BetterDataManager.Folders.fileFolderPath, "better-log.txt");
|
||||
string logFilePath = BetterDataManager.Files.logFilePath;
|
||||
string newLine = $"{mark}: " + Encryptor.Encrypt($"{info}");
|
||||
File.AppendAllText(logFilePath, newLine + Environment.NewLine);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user