From d84f82e1b6314e2f65d34dcc89e6afcf47b00762 Mon Sep 17 00:00:00 2001 From: Sirin3rd <1532599172@qq.com> Date: Wed, 8 May 2024 12:14:15 +0800 Subject: [PATCH] ok --- util/MainClass.cs | 8 ++------ util/ReserveSlot.cs | 8 +++++++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/util/MainClass.cs b/util/MainClass.cs index e94a59a..2189e23 100644 --- a/util/MainClass.cs +++ b/util/MainClass.cs @@ -3,14 +3,8 @@ using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Exiled; -using Exiled.API; using Exiled.API.Features; using Exiled.API.Interfaces; -using Exiled.Events; using PlayerRoles; namespace UtilPlugin @@ -38,6 +32,8 @@ public class PluginConfig : IConfig public bool ReserveSlotEnabled { get; set; } = false; [Description("管理员预留位数量")] public int Slots { get; set; } = 5; + [Description("是否判断预留位占用")] + public bool WhetherOccupieSlots { get; set; } = false; [Description("系统核弹投票可发起时间(以秒为单位)")] public int SystemWarheadVoteTime { get; set; } = 720; [Description("预留位踢出理由")] diff --git a/util/ReserveSlot.cs b/util/ReserveSlot.cs index 4151c8f..9aa7adc 100644 --- a/util/ReserveSlot.cs +++ b/util/ReserveSlot.cs @@ -37,7 +37,7 @@ public static void Register(bool isEnabled) public static void OnJoining(PreAuthenticatingEventArgs ev) { Log.Debug($"Player {ev.UserId} joining, now remain {Server.MaxPlayerCount - LiteNetLib4MirrorCore.Host.ConnectedPeersCount}"); - if (Server.MaxPlayerCount - LiteNetLib4MirrorCore.Host.ConnectedPeersCount <= Remain) + if (Determine()) { Log.Debug($"Checking reservesolt of {ev.UserId}"); if (Check(ev.UserId)) @@ -49,5 +49,11 @@ public static void OnJoining(PreAuthenticatingEventArgs ev) ev.Reject(UtilPlugin.Instance.Config.ReserveSlotKickReason, true); } } + + private static bool Determine() + { + if (!UtilPlugin.Instance.Config.WhetherOccupieSlots) return Server.MaxPlayerCount - LiteNetLib4MirrorCore.Host.ConnectedPeersCount <= Remain; + else return Server.MaxPlayerCount - LiteNetLib4MirrorCore.Host.ConnectedPeersCount <= UtilPlugin.Instance.Config.Slots; + } } }