11using System ;
2+ using System . Collections . Generic ;
23using System . IO ;
4+ using System . Linq ;
35using System . Threading . Tasks ;
46using Nitrox . Launcher . Models . Services ;
57using Nitrox . Launcher . ViewModels ;
68using Nitrox . Model . Core ;
7- using Nitrox . Model . Helper ;
89using Nitrox . Model . Logger ;
910using Nitrox . Model . Platforms . OS . Shared ;
1011
@@ -20,7 +21,7 @@ public static async Task<bool> IsOutdatedGameAndNotify(string gameInstallDir, Di
2021 try
2122 {
2223 ArgumentException . ThrowIfNullOrWhiteSpace ( gameInstallDir ) ;
23-
24+
2425 string gameVersionFile = Path . Combine ( gameInstallDir , GameInfo . Subnautica . DataFolder , "StreamingAssets" , "SNUnmanagedData" , "plastic_status.ignore" ) ;
2526 if ( int . TryParse ( await File . ReadAllTextAsync ( gameVersionFile ) , out int gameVersion ) && gameVersion < NitroxEnvironment . GameMinimumVersion )
2627 {
@@ -57,8 +58,40 @@ public static bool WarnIfGameProcessExists(GameInfo game)
5758 {
5859 return false ;
5960 }
60-
6161 LauncherNotifier . Warning ( $ "An instance of { game . FullName } is already running") ;
6262 return true ;
6363 }
64+
65+ public static void WarnIfBepInExMods ( string gameDir )
66+ {
67+ if ( string . IsNullOrWhiteSpace ( gameDir ) || ! Directory . Exists ( gameDir ) )
68+ {
69+ return ;
70+ }
71+ string bepRoot = Path . Combine ( gameDir , "BepInEx" ) ;
72+ if ( ! Directory . Exists ( bepRoot ) )
73+ {
74+ return ;
75+ }
76+
77+ int modDllCount = GetDllPaths ( Path . Combine ( bepRoot , "plugins" ) ) . Count ( ) ;
78+ modDllCount += GetDllPaths ( Path . Combine ( bepRoot , "patchers" ) ) . Count ( ) ;
79+ if ( modDllCount > 0 )
80+ {
81+ Log . Warn ( $ "BepInEx plugins detected: { modDllCount } ") ;
82+ LauncherNotifier . Warning ( $ "BepInEx mod(s) were detected ({ modDllCount } ). Nitrox multiplayer does not support mods and they may cause instability.") ;
83+ }
84+
85+ static IEnumerable < string > GetDllPaths ( string path )
86+ {
87+ try
88+ {
89+ return Directory . EnumerateFiles ( path , "*.dll" , SearchOption . AllDirectories ) ;
90+ }
91+ catch ( IOException )
92+ {
93+ return [ ] ;
94+ }
95+ }
96+ }
6497}
0 commit comments