diff --git a/Si_BasicBanlist/Si_BasicBans.cs b/Si_BasicBanlist/Si_BasicBans.cs index 92b52f4..59daa32 100644 --- a/Si_BasicBanlist/Si_BasicBans.cs +++ b/Si_BasicBanlist/Si_BasicBans.cs @@ -28,7 +28,7 @@ You should have received a copy of the GNU General Public License using Si_BasicBanlist; using AdminExtension; -[assembly: MelonInfo(typeof(BasicBanlist), "[Si] Basic Banlist", "1.2.1", "databomb")] +[assembly: MelonInfo(typeof(BasicBanlist), "[Si] Basic Banlist", "1.2.2", "databomb")] [assembly: MelonGame("Bohemia Interactive", "Silica")] namespace Si_BasicBanlist @@ -63,6 +63,9 @@ public String? Comments static readonly String banListFile = System.IO.Path.Combine(MelonEnvironment.UserDataDirectory, "banned_users.json"); static bool AdminModAvailable = false; + static MelonPreferences_Category _modCategory; + static MelonPreferences_Entry Pref_Ban_KickButton_PermaBan; + public static void UpdateBanFile() { // convert back to json string @@ -74,6 +77,9 @@ public override void OnInitializeMelon() { try { + _modCategory ??= MelonPreferences.CreateCategory("Silica"); + Pref_Ban_KickButton_PermaBan ??= _modCategory.CreateEntry("Ban_HostKickButton_Permabans", false); + if (System.IO.File.Exists(banListFile)) { // Open the stream and read it back. @@ -245,13 +251,20 @@ public static BanEntry GenerateBanEntry(Il2Cpp.Player player, Il2Cpp.Player admi [HarmonyPatch(typeof(Il2Cpp.NetworkGameServer), nameof(Il2Cpp.NetworkGameServer.KickPlayer))] private static class ApplyPatchKickPlayer { - public static bool Prefix(Il2Cpp.Player __0, bool __1) + public static void Prefix(Il2Cpp.Player __0, bool __1) { try { if (MasterBanList == null) { - return true; + return; + } + + // if we just intended to kick, we can skip the rest + if (!Pref_Ban_KickButton_PermaBan.Value) + { + MelonLogger.Msg("Kicked player name (" + __0.PlayerName + ") SteamID (" + __0.ToString() + ")"); + return; } BanEntry thisBan = GenerateBanEntry(__0, Il2Cpp.NetworkGameServer.GetServerPlayer()); @@ -273,7 +286,7 @@ public static bool Prefix(Il2Cpp.Player __0, bool __1) HelperMethods.PrintError(error, "Failed to run NetworkGameServer::KickPlayer"); } - return true; + return; } } diff --git a/Si_BasicBanlist/bin/Si_BasicBanlist.dll b/Si_BasicBanlist/bin/Si_BasicBanlist.dll index f0cd4a9..03c2c15 100644 Binary files a/Si_BasicBanlist/bin/Si_BasicBanlist.dll and b/Si_BasicBanlist/bin/Si_BasicBanlist.dll differ