Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
Sirin3rd committed May 8, 2024
1 parent 7a30366 commit 49e0e5f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 2 additions & 6 deletions util/MainClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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("预留位踢出理由")]
Expand Down
8 changes: 7 additions & 1 deletion util/ReserveSlot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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;
}
}
}

0 comments on commit 49e0e5f

Please sign in to comment.