mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
Add Discord RPC from TOHE (#20)
* Add Discord RPC from TOHE * Add Modded SA (MSA) Server
This commit is contained in:
1 parent
1cd7442b17
commit
644507aa3d
2 files changed
+67
-3
No files matched your search
@@ -13,8 +13,8 @@ public static class ServerAddManager
|
||||
private static readonly ServerManager serverManager = DestroyableSingleton<ServerManager>.Instance;
|
||||
public static void Init()
|
||||
{
|
||||
if (CultureInfo.CurrentCulture.Name.StartsWith("zh") && serverManager.AvailableRegions.Count == 7) return;
|
||||
if (!CultureInfo.CurrentCulture.Name.StartsWith("zh") && serverManager.AvailableRegions.Count == 6) return;
|
||||
if (CultureInfo.CurrentCulture.Name.StartsWith("zh") && serverManager.AvailableRegions.Count == 10) return;
|
||||
if (!CultureInfo.CurrentCulture.Name.StartsWith("zh") && serverManager.AvailableRegions.Count == 7) return;
|
||||
|
||||
serverManager.AvailableRegions = ServerManager.DefaultRegions;
|
||||
List<IRegionInfo> regionInfos =
|
||||
@@ -23,6 +23,7 @@ public static class ServerAddManager
|
||||
CreateHttp("au-as.duikbo.at", "Modded Asia (MAS)", 443, true),
|
||||
CreateHttp("www.aumods.xyz", "Modded NA (MNA)", 443, true),
|
||||
CreateHttp("au-eu.duikbo.at", "Modded EU (MEU)", 443, true),
|
||||
CreateHttp("35.247.251.253", "Modded SA (MSA)", 22023, false),
|
||||
];
|
||||
|
||||
regionInfos.Where(x => !serverManager.AvailableRegions.Contains(x)).Do(serverManager.AddOrUpdateRegion);
|
||||
@@ -55,4 +56,4 @@ public static class ServerAddManager
|
||||
return CastHelper<T>.Cast(obj.Pointer);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using AmongUs.Data;
|
||||
using Discord;
|
||||
using HarmonyLib;
|
||||
using System;
|
||||
|
||||
namespace TOHE.Patches
|
||||
{
|
||||
// Originally from Town of Us Rewritten, by Det
|
||||
[HarmonyPatch(typeof(ActivityManager), nameof(ActivityManager.UpdateActivity))]
|
||||
public class DiscordRPC
|
||||
{
|
||||
private static string lobbycode = "";
|
||||
private static string region = "";
|
||||
public static void Prefix([HarmonyArgument(0)] Activity activity)
|
||||
{
|
||||
var details = $"TOHE+ v{Main.PluginDisplayVersion}";
|
||||
activity.Details = details;
|
||||
|
||||
try
|
||||
{
|
||||
if (activity.State != "In Menus")
|
||||
{
|
||||
if (!DataManager.Settings.Gameplay.StreamerMode)
|
||||
{
|
||||
int maxSize = GameOptionsManager.Instance.currentNormalGameOptions.MaxPlayers;
|
||||
if (GameStates.IsLobby)
|
||||
{
|
||||
lobbycode = GameStartManager.Instance.GameRoomNameCode.text;
|
||||
region = ServerManager.Instance.CurrentRegion.Name;
|
||||
if (region == "North America") region = "NA";
|
||||
else if (region == "Europe") region = "EU";
|
||||
else if (region == "Asia") region = "AS";
|
||||
else if (region.Contains("MNA")) region = "MNA";
|
||||
else if (region.Contains("MEU")) region = "MEU";
|
||||
else if (region.Contains("MAS")) region = "MAS";
|
||||
}
|
||||
|
||||
if (lobbycode != "" && region != "")
|
||||
{
|
||||
details = $"TOHE+ - {lobbycode} ({region})";
|
||||
}
|
||||
|
||||
activity.Details = details;
|
||||
}
|
||||
else
|
||||
{
|
||||
details = $"TOHE+ v{Main.PluginDisplayVersion}";
|
||||
|
||||
activity.Details = details;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch (ArgumentException ex)
|
||||
{
|
||||
Logger.Error("Error in updating discord rpc", "DiscordPatch");
|
||||
Logger.Exception(ex, "DiscordPatch");
|
||||
details = $"TOHE+ v{Main.PluginDisplayVersion}";
|
||||
activity.Details = details;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user