refactor: wip

This commit is contained in:
anavoi 2025-07-13 16:16:41 +02:00
commit 0cb7131435
5 changed files with 69 additions and 45 deletions

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Reflection;
using BepInEx;
using BepInEx.Logging;
@ -54,6 +54,16 @@ public class Plugin : BaseUnityPlugin
Helper.CreateRotationFolder();
Log.LogDebug("Server game config should be found at " + Helper.GameConfigPath);
// Parse CLI arguments
if (CommandLineParser.Instance.KeyExists("-ip"))
{
Helper.serverip = CommandLineParser.Instance.GetValueForKey("-ip", true);
}
if (CommandLineParser.Instance.KeyExists("-port"))
{
int.TryParse(CommandLineParser.Instance.GetValueForKey("-port", true), out Helper.serverport);
}
}
private static void GBSUCompInit()
@ -66,6 +76,13 @@ public class Plugin : BaseUnityPlugin
}
public static void AddServerComp()
{
DestroyServerComp();
Log.LogDebug("Adding GBSUServer component");
GBSUCompContainer.AddComponent<GBSUServer>();
}
public static void DestroyServerComp()
{
Component[] comps = GBSUCompContainer.GetComponents(typeof(Component));
foreach (var comp in comps)
@ -77,8 +94,5 @@ public class Plugin : BaseUnityPlugin
Destroy(comp);
}
}
Log.LogDebug("Adding GBSUServer component");
GBSUCompContainer.AddComponent<GBSUServer>();
}
}