commit 75df742452091392ade980179df65dde8da7dbe7 Author: Nb1X Date: Fri Jul 31 11:59:11 2026 +0200 Added other regions support diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f28da86 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,47 @@ +name: Build Plugin + +on: + push: + branches: + - main + - master + tags: + - 'v*' + pull_request: + branches: + - main + - master + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '6.0.x' + + - name: Restore Dependencies + run: dotnet restore + + - name: Build Project (Development) + run: dotnet build --configuration Development --no-restore + + - name: Upload Build Artifact + uses: actions/upload-artifact@v4 + with: + name: AUModdedRegions + path: bin/Development/net6.0/AUModdedRegions.dll + + - name: Upload Release Asset + if: startsWith(github.ref, 'refs/tags/') + uses: softprops/action-gh-release@v2 + with: + files: bin/Development/net6.0/AUModdedRegions.dll + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a06d8cb --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +bin/ +obj/ +Libs/ diff --git a/AUModdedRegions.cs b/AUModdedRegions.cs new file mode 100644 index 0000000..5c2d44d --- /dev/null +++ b/AUModdedRegions.cs @@ -0,0 +1,163 @@ +using BepInEx; +using BepInEx.Unity.IL2CPP; +using HarmonyLib; +using UnityEngine; +using System; +using System.IO; +using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Nodes; + +namespace AUModdedRegions +{ + [BepInPlugin("com.aumoddedregions", "AUModdedRegions", "1.0.0")] + public class AUModdedRegionsPlugin : BasePlugin + { + private static readonly string[] OfficialDomains = new string[] + { + "innersloth.com", + "among.us", + "matchmaker.among.us", + "matchmaker-as.among.us", + "matchmaker-eu.among.us" + }; + + // La liste des 8 régions moddées à garantir dans le fichier + private static readonly List<(string Name, string Host)> DefaultModdedRegions = new() + { + ("Niko233 (EU)", "https://au-eu.niko233.top"), + ("Niko233 (AS)", "https://au-as.niko233.top"), + ("Niko233 (NA)", "https://au-us.niko233.top"), + ("Niko233 (CN)", "https://au-cn.niko233.top"), + ("Modded NA", "https://aumods.org"), + ("Modded EU", "https://au-eu.duikbo.at"), + ("Modded AS", "https://au-as.duikbo.at"), + ("Skeld.net", "https://play.skeld.net") + }; + + public override void Load() + { + ProcessAndMergeRegions(); + + // Bloque le CleanAndMerge natif d'Among Us pour pas qu'il remette Innersloth + Harmony.CreateAndPatchAll(typeof(PatchCleanAndMerge)); + Log.LogInfo("AUModdedRegions chargé avec succès !"); + } + + private void ProcessAndMergeRegions() + { + string regionFilePath = Path.Combine(Application.persistentDataPath, "regionInfo.json"); + + try + { + JsonNode rootNode; + + // 1. Lire le fichier s'il existe, sinon créer une structure JSON vide + if (File.Exists(regionFilePath) && new FileInfo(regionFilePath).Length > 0) + { + string content = File.ReadAllText(regionFilePath); + rootNode = JsonNode.Parse(content) ?? CreateEmptyRegionStructure(); + } + else + { + rootNode = CreateEmptyRegionStructure(); + } + + JsonArray regionsArray = rootNode["Regions"]?.AsArray() ?? new JsonArray(); + + // 2. Filtrer et supprimer uniquement les régions Innersloth + for (int i = regionsArray.Count - 1; i >= 0; i--) + { + string regionJson = regionsArray[i]?.ToJsonString() ?? ""; + if (IsOfficialInnersloth(regionJson)) + { + regionsArray.RemoveAt(i); + } + } + + // 3. Ajouter les 8 régions moddées si elles ne sont pas déjà présentes + foreach (var (name, host) in DefaultModdedRegions) + { + if (!HasRegion(regionsArray, host)) + { + regionsArray.Add(BuildRegionNode(name, host)); + } + } + + // 4. Mettre à jour et sauvegarder le fichier + rootNode["Regions"] = regionsArray; + + var options = new JsonSerializerOptions { WriteIndented = true }; + File.WriteAllText(regionFilePath, rootNode.ToJsonString(options)); + + Log.LogInfo("[AUModdedRegions] Fichier regionInfo.json mis à jour ! (Innersloth viré, tes régions custom + régions moddées conservées/ajoutées)."); + } + catch (Exception ex) + { + Log.LogError($"[AUModdedRegions] Erreur lors du traitement du fichier regionInfo.json : {ex.Message}"); + } + } + + private bool IsOfficialInnersloth(string json) + { + foreach (var domain in OfficialDomains) + { + if (json.Contains(domain, StringComparison.OrdinalIgnoreCase)) + return true; + } + return false; + } + + private bool HasRegion(JsonArray regionsArray, string host) + { + foreach (var node in regionsArray) + { + if (node != null && node.ToJsonString().Contains(host, StringComparison.OrdinalIgnoreCase)) + { + return true; + } + } + return false; + } + + private JsonNode CreateEmptyRegionStructure() + { + return new JsonObject + { + ["CurrentRegionIdx"] = 0, + ["Regions"] = new JsonArray() + }; + } + + private JsonNode BuildRegionNode(string name, string host) + { + return new JsonObject + { + ["$type"] = "StaticHttpRegionInfo, Assembly-CSharp", + ["Name"] = name, + ["PingServer"] = host, + ["Servers"] = new JsonArray + { + new JsonObject + { + ["Name"] = "Http-1", + ["Ip"] = host, + ["Port"] = 443, + ["UseDtls"] = false, + ["Players"] = 0, + ["ConnectionFailures"] = 0 + } + }, + ["TargetServer"] = null, + ["TranslateName"] = 1003 + }; + } + } + + [HarmonyPatch("ServerManager+JsonServerData", "CleanAndMerge")] + public static class PatchCleanAndMerge + { + [HarmonyPrefix] + public static bool Prefix() => false; + } +} \ No newline at end of file diff --git a/AUModdedRegions.csproj b/AUModdedRegions.csproj new file mode 100644 index 0000000..ff773f1 --- /dev/null +++ b/AUModdedRegions.csproj @@ -0,0 +1,29 @@ + + + + net6.0 + AUModdedRegions + AUModdedRegions + 1.0.0 + latest + true + enable + embedded + Auto-manages and injects custom modded regions into Among Us while filtering out official servers. + Nb1X + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..7a3706d --- /dev/null +++ b/README.md @@ -0,0 +1,54 @@ +> This mod is not affiliated with Among Us or Innersloth LLC, and the content contained therein is not endorsed or otherwise sponsored by Innersloth LLC. Portions of the materials contained herein are property of Innersloth LLC. © Innersloth LLC. + +> In the releases, there are BepInEx builds with AUModdedRegions included. BepInEx's [source code is available here](https://github.com/BepInEx/BepInEx) and it is not under MIT License like this project. It is under LGPL-v2.1 + +# AUModdedRegions + +

+ + Logo +
+
+ Status + Version + Dotnet + GitHub + Windows + Badges Are Awesome + Licence + Gemini + GitHub Stars +

+ +AUModdedRegions is a BepInEx plugin that removes Innersloth regions from Among Us and adds other regions that supports [modded handshake](https://github.com/NuclearPowered/Reactor.Impostor). + +It adds the following regions (If there is another region other than the modded regions listed below in your regionInfo.json file, they will stay on the regions list but the modded regions listed will all be added): + +- Niko233 (NA) +- Niko233 (EU) +- Niko233 (AS) +- Niko233 (CN) +- Modded EU +- Modded NA +- Modded AS + +and removes these regions: +- North America +- Europe +- Asia + +The modded regions are not managed by me. If you have a problem, contact the regions' owner. + +Niko233 regions website: https://au.niko233.top + +Modded EU, Modded AS and Modded NA regions doesn't have a website yet. + +For more information, see [Informations](INFO.md). + +For mod developers that want to integrate this plugin to their mods, you can. See [license here](LICENSE). + +All of the listed regions use a custom, open-source server called [Impostor](https://github.com/Impostor/Impostor). You can host it yourself on a VPS, a [Raspberry Pi](https://raspberrypi.com) or an old laptop. + +(Niko233 servers are using a custom build of Impostor available [here](https://github.com/NikoCat233/Impostor)) + +To use BETA builds of this plugin, go to the [Actions](https://github.com/BetterUsProject/AUModdedRegions/actions) of this repository (sometimes, normal versions are also on Actions). diff --git a/nuget.config b/nuget.config new file mode 100644 index 0000000..f322c73 --- /dev/null +++ b/nuget.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/static/logo.png b/static/logo.png new file mode 100644 index 0000000..ff85cd3 Binary files /dev/null and b/static/logo.png differ