diff --git a/CustomServersClient.sln b/CustomServersClient.sln index 8b34eda..ef8f21b 100644 --- a/CustomServersClient.sln +++ b/CustomServersClient.sln @@ -7,20 +7,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CustomServersClient", "Cust EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Itch-Debug|Any CPU = Itch-Debug|Any CPU - Itch-Release|Any CPU = Itch-Release|Any CPU - Steam-Debug|Any CPU = Steam-Debug|Any CPU - Steam-Release|Any CPU = Steam-Release|Any CPU + Release|Any CPU = Release|Any CPU + Debug|Any CPU = Debug|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {8424C5D8-334F-4CAB-B3C8-4D7635283B7F}.Itch-Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8424C5D8-334F-4CAB-B3C8-4D7635283B7F}.Itch-Debug|Any CPU.Build.0 = Debug|Any CPU - {8424C5D8-334F-4CAB-B3C8-4D7635283B7F}.Itch-Release|Any CPU.ActiveCfg = Itch-Release|Any CPU - {8424C5D8-334F-4CAB-B3C8-4D7635283B7F}.Itch-Release|Any CPU.Build.0 = Itch-Release|Any CPU - {8424C5D8-334F-4CAB-B3C8-4D7635283B7F}.Steam-Debug|Any CPU.ActiveCfg = Steam-Debug|Any CPU - {8424C5D8-334F-4CAB-B3C8-4D7635283B7F}.Steam-Debug|Any CPU.Build.0 = Steam-Debug|Any CPU - {8424C5D8-334F-4CAB-B3C8-4D7635283B7F}.Steam-Release|Any CPU.ActiveCfg = Debug|Any CPU - {8424C5D8-334F-4CAB-B3C8-4D7635283B7F}.Steam-Release|Any CPU.Build.0 = Debug|Any CPU + {8424C5D8-334F-4CAB-B3C8-4D7635283B7F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8424C5D8-334F-4CAB-B3C8-4D7635283B7F}.Release|Any CPU.Build.0 = Release|Any CPU + {8424C5D8-334F-4CAB-B3C8-4D7635283B7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8424C5D8-334F-4CAB-B3C8-4D7635283B7F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8424C5D8-334F-4CAB-B3C8-4D7635283B7F}.Release|Any CPU.Deploy.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/CustomServersClient/CustomServersClient.csproj b/CustomServersClient/CustomServersClient.csproj index ebb267b..ce54f8f 100644 --- a/CustomServersClient/CustomServersClient.csproj +++ b/CustomServersClient/CustomServersClient.csproj @@ -2,30 +2,21 @@ netstandard2.1 - 1.5.0 - 2021.3.5s - NuclearPowered/Mappings:0.2.0 - + 1.6.0 + 2021.3.31.3s + NuclearPowered/Mappings:0.3.0 + andruzzzhka - - 2021.3.5s - $(DefineConstants);STEAM - - - - 2021.3.5i - $(DefineConstants);ITCH - - + - $(AmongUs)\mono\Managed\System.Windows.Forms.dll + $(AmongUs)\BepInEx\plugins\CustomServersClient\System.Windows.Forms.dll diff --git a/CustomServersClient/CustomServersPatches.cs b/CustomServersClient/CustomServersPatches.cs index 764acb9..9eb85b7 100644 --- a/CustomServersClient/CustomServersPatches.cs +++ b/CustomServersClient/CustomServersPatches.cs @@ -1,14 +1,9 @@ using HarmonyLib; -using InnerNet; using Newtonsoft.Json; using System.Collections.Generic; using System.IO; -using System.Linq; -using System; using UnhollowerBaseLib; using CustomServersClient.UI; -using Il2CppSystem.Diagnostics.Tracing; -using Il2CppSystem.Globalization; namespace CustomServersClient { @@ -46,7 +41,7 @@ public static bool Prefix(ref RegionMenu __instance) var regions = new IRegionInfo[4 + customServers.Count]; regions[0] = new DnsRegionInfo("Manage servers...", "Manage servers...", StringNames.NoTranslation, - "Manage servers...").Cast(); + "Manage servers...", 0).Cast(); for (int i = 0; i < 3; i++) { @@ -55,7 +50,7 @@ public static bool Prefix(ref RegionMenu __instance) for (int i = 0; i < customServers.Count; i++) { - Il2CppReferenceArray servers = new ServerInfo[1] { new ServerInfo(customServers[i].name, customServers[i].ip, (ushort)customServers[i].port) }; + Il2CppReferenceArray servers = new [] { new ServerInfo(customServers[i].name, customServers[i].ip, (ushort)customServers[i].port) }; regions[i + 4] = new DnsRegionInfo(customServers[i].ip, customServers[i].name, StringNames.NoTranslation, servers).Cast(); } @@ -87,17 +82,17 @@ public static void ClearOnClickAction(ObjectPoolBehavior buttonPool) } - [HarmonyPatch(typeof(RegionMenu.c__DisplayClass2_0), "Method_Internal_Void_0")] + [HarmonyPatch(typeof(RegionMenu), nameof(RegionMenu.ChooseOption))] public static class RegionMenuChooseOptionPatch { - public static bool Prefix(ref RegionMenu.c__DisplayClass2_0 __instance) + public static bool Prefix(RegionMenu __instance, [HarmonyArgument(0)] IRegionInfo region) { - if (__instance.region.PingServer == "Manage servers...") + if (region.PingServer == "Manage servers...") { if (_managementForm == null || _managementForm.IsDisposed) _managementForm = new ServersManagementForm(); - _managementForm.regionMenu = __instance.__this; + _managementForm.regionMenu = __instance; if (_managementForm.Visible) _managementForm.Focus(); diff --git a/CustomServersClient/CustomServersPlugin.cs b/CustomServersClient/CustomServersPlugin.cs index 00f0539..0e3b470 100644 --- a/CustomServersClient/CustomServersPlugin.cs +++ b/CustomServersClient/CustomServersPlugin.cs @@ -6,7 +6,7 @@ namespace CustomServersClient { - [BepInPlugin("com.andruzzzhka.customserversclient")] + [BepInPlugin(Id)] [BepInProcess("Among Us.exe")] [BepInDependency(ReactorPlugin.Id)] [ReactorPluginSide(PluginSide.ClientOnly)] @@ -14,16 +14,17 @@ public class CustomServersPlugin : BasePlugin { public const string userDataPath = "UserData"; public const string customServersFilePath = "CustomServers.json"; + public const string Id = "com.andruzzzhka.customserversclient"; - static internal BepInEx.Logging.ManualLogSource Logger; + internal static BepInEx.Logging.ManualLogSource Logger; - static Harmony _harmony; + static Harmony _harmony = new Harmony(Id); public override void Load() { Logger = Log; - _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.andruzzzhka.customserversclient"); + _harmony.PatchAll(); Logger.LogDebug("Applied Harmony patches!"); } diff --git a/CustomServersClient/UI/EditServerForm.cs b/CustomServersClient/UI/EditServerForm.cs index e299803..34790f1 100644 --- a/CustomServersClient/UI/EditServerForm.cs +++ b/CustomServersClient/UI/EditServerForm.cs @@ -37,7 +37,7 @@ private void saveBtn_Click(object sender, EventArgs e) CustomServersPlugin.Logger.LogWarning($"Resolving IP address for domain \"{address}\"..."); var adresses = Dns.GetHostAddresses(address); - if (adresses != null && adresses.Length > 0) + if (adresses.Length > 0) { address = adresses[0].ToString(); } diff --git a/README.md b/README.md index ae8ec74..0d18ed4 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,30 @@ +[![Our Discord](https://img.shields.io/discord/787008412482797598?color=7289da&label=DISCORD&style=for-the-badge)](https://discord.gg/XEc7PdDTyn) # Custom Servers Client An in-game client for custom servers for Among Us. This works on both the Steam and Itch versions of the game. -Works on Steam as of **v2021.3.5s**. +Works (tested) on Steam as of **v2021.3.31.3s**. Works (tested) on Itch as of **v2020.11.17i**. ## Installation (on Steam) 1. Download latest [BepInEx (Reactor fork)](https://github.com/NuclearPowered/BepInEx/releases) -2. Extract all files from zipped archive and put them in Among Us directory (where Among Us.exe is) -3. Download [latest Reactor.dll for 2021.3.5s](https://nightly.link/NuclearPowered/Reactor/workflows/main/master) and put it in `YourAmongUsDirectory/BepInEx/plugins` +2. Extract all files from zipped archive and put them in `YourAmongUsDirectory` (where Among Us.exe is) +3. Download [latest Reactor.dll for 2021.3.31.3s](https://nightly.link/NuclearPowered/Reactor/workflows/main/master) and put it in `YourAmongUsDirectory/BepInEx/plugins` 4. Download latest CustomServersClient.zip from releases, unzip it. -5. Put unzipped content of `CustomServersClient_v.x.x.x_Steam.zip` in `YourAmongUsDirectory` +5. Put unzipped content of `CustomServersClient_vx.x.x_Steam.zip` in `YourAmongUsDirectory\BepInEx\plugins` (for versions v1.5.0 and lower, just put the content in `YourAmongUsDirectory`) *`YourAmongUsDirectory` is your Among Us root directory ## Versions | Mod version | Game version | BepInEx | Downloads | | ------------- | ------------- | ------- | --------- | +| v1.6.0 | v2021.3.31.3 | [Reactor BepInEx](https://github.com/NuclearPowered/BepInEx/releases/download/6.0.0-reactor.18%2Bstructfix/BepInEx-6.0.0-reactor.18+structfix.zip) | [Releases](https://github.com/CrowdedMods/CustomServersClient/releases/tag/1.6.0) | | v1.5.0 | v2021.3.5 | [Reactor BepInEx](https://github.com/NuclearPowered/BepInEx/releases/download/6.0.0-reactor.16/BepInEx-6.0.0-reactor.16.zip) | [Releases](https://github.com/CrowdedMods/CustomServersClient/releases/tag/1.5.0) | -| v1.4.0 | v2020.12.9s | [Reactor BepInEx](https://github.com/NuclearPowered/BepInEx/releases/download/6.0.0-reactor.16/BepInEx-6.0.0-reactor.16.zip) | [Releases](https://github.com/CrowdedMods/CustomServersClient/releases/tag/1.4.0) | +| v1.4.0 | v2020.12.9 | [Reactor BepInEx](https://github.com/NuclearPowered/BepInEx/releases/download/6.0.0-reactor.16/BepInEx-6.0.0-reactor.16.zip) | [Releases](https://github.com/CrowdedMods/CustomServersClient/releases/tag/1.4.0) | | v1.3.0 | v2020.12.9s | [BepInEx IL2CPP #325](https://builds.bepis.io/projects/bepinex_be/325/BepInEx_UnityIL2CPP_x86_3d75179_6.0.0-be.325.zip) | [Releases](https://github.com/CrowdedMods/CustomServersClient/releases/tag/1.3.0) | | v1.2.1 | v2020.11.11s and i | [BepInEx IL2CPP #297](https://builds.bepis.io/projects/bepinex_be/297/BepInEx_UnityIL2CPP_x86_7801f9e_6.0.0-be.297.zip) | [Releases](https://github.com/CrowdedMods/CustomServersClient/releases/tag/1.2.1) | | v1.1.0 | v2020.10.22s | [IL2CPP Public Preview](https://cdn.discordapp.com/attachments/754333645199900723/757332321169834134/BepInEx_IL2CPP_Preview_x86.7z) | [Releases](https://github.com/CrowdedMods/CustomServersClient/releases/tag/1.1.0) | | v1.0.0 | v2020.09.22s | [IL2CPP Public Preview](https://cdn.discordapp.com/attachments/754333645199900723/757332321169834134/BepInEx_IL2CPP_Preview_x86.7z) | [Releases](https://github.com/CrowdedMods/CustomServersClient/releases/tag/1.0.0) | -*Version v1.4.0 theoretically works with Itch, but wasn't tested. +*Versions v1.4.0+ theoretically work with Itch, but weren't tested. ## Building 1. Install [Reactor](https://docs.reactor.gg/docs/) (Quick Start guide) 2. Open `CustomServersClient.sln` in your favorite IDE