Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new feature #41

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
}
Loading