diff --git a/Fika.Core/FikaPlugin.cs b/Fika.Core/FikaPlugin.cs index e95da8a2..6f33c623 100644 --- a/Fika.Core/FikaPlugin.cs +++ b/Fika.Core/FikaPlugin.cs @@ -213,6 +213,7 @@ protected void Awake() new BotCacher_Patch().Enable(); new InventoryScroll_Patch().Enable(); new AbstractGame_InRaid_Patch().Enable(); + new DisconnectButton_Patch().Enable(); #if GOLDMASTER new TOS_Patch().Enable(); #endif diff --git a/Fika.Core/UI/Patches/DisconnectButton_Patch.cs b/Fika.Core/UI/Patches/DisconnectButton_Patch.cs new file mode 100644 index 00000000..61ffa0ba --- /dev/null +++ b/Fika.Core/UI/Patches/DisconnectButton_Patch.cs @@ -0,0 +1,32 @@ +using Comfort.Common; +using EFT.UI; +using Fika.Core.Coop.Matchmaker; +using Fika.Core.Networking; +using SPT.Reflection.Patching; +using System.Reflection; + +namespace Fika.Core.UI.Patches +{ + public class DisconnectButton_Patch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return typeof(MenuScreen).GetMethod(nameof(MenuScreen.method_11)); + } + + [PatchPrefix] + static bool Prefix() + { + if (MatchmakerAcceptPatches.IsServer) + { + FikaServer server = Singleton.Instance; + if (server != null && server.NetServer.ConnectedPeersCount > 0) + { + NotificationManagerClass.DisplayWarningNotification($"You cannot disconnect while there are still peers connected! Remaining: {server.NetServer.ConnectedPeersCount}"); + return false; + } + } + return true; + } + } +}