Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Griseo-bh3rd committed Jul 28, 2023
1 parent a745074 commit 6b553b5
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 13 deletions.
4 changes: 2 additions & 2 deletions util/MainClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class PluginConfig : IConfig
[Description("是否启用系统核弹")]
public bool SystemWarheadEnabled { get; set; } = true;
[Description("系统核弹触发时间")]
public float SysteamWarheadTime { get; set; } = 1200;
public float SystemWarheadTime { get; set; } = 1200;
[Description("系统核弹触发时公告")]
public string SystemWarheadBroadcast { get; set; } = "注意,系统核弹已经启动";
[Description("启用管理员预留位")]
Expand All @@ -44,7 +44,7 @@ public override void OnEnabled()
}
public override string Author => "Silver Wolf";
public override string Name => "UtilPlugin";
public override Version Version => new Version(1,2,1);
public override Version Version => new Version(1,2,2);
public static UtilPlugin Instance { get; private set; }
public UtilPlugin()
{
Expand Down
46 changes: 38 additions & 8 deletions util/ReserveSlot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static void Joining(JoinedEventArgs ev)

public static bool CheckPermission(Player player)
{
if ((player.Group.Permissions & (ulong)PlayerPermissions.AFKImmunity)!=0)
if (!(player.Group == null) && (player.Group.Permissions & (ulong)PlayerPermissions.AFKImmunity) != 0)
{
return true;
}
Expand All @@ -61,7 +61,7 @@ public static bool CheckPermission(Player player)

public static IEnumerator<float> Checkid(Player player)
{
yield return Timing.WaitForSeconds(7);
yield return Timing.WaitForSeconds(10);
if (Server.PlayerCount > Server.MaxPlayerCount - Remain)
{
if (!CheckPermission(player))
Expand All @@ -87,32 +87,62 @@ namespace CommandSystem
{
[CommandHandler(typeof(GameConsoleCommandHandler))]
[CommandHandler(typeof(RemoteAdminCommandHandler))]
public class Test : ICommand
public class Refresh : ICommand
{
public string Command => "test";
public string Command => "refresh";

public string[] Aliases => Array.Empty<string>();

public string Description => "";
public string Description => "刷新预留位剩余";

public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
UtilPlugin.ReserveSlot.RoundRestart();
foreach (Player player in Player.List)
{
if (UtilPlugin.ReserveSlot.CheckPermission(player))
{
UtilPlugin.ReserveSlot.Remain--;
}
}
response = $"Remain:{UtilPlugin.ReserveSlot.Remain}";
return true;
}
}
[CommandHandler(typeof(GameConsoleCommandHandler))]
[CommandHandler(typeof(RemoteAdminCommandHandler))]
public class Fetch : ICommand
{
public string Command => "FetchRemain";

public string[] Aliases => Array.Empty<string>();

public string Description => "查询预留位剩余";

public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
response = UtilPlugin.ReserveSlot.Remain.ToString() + " " + (Server.MaxPlayerCount - UtilPlugin.ReserveSlot.Remain).ToString();
response = $"Remain:{UtilPlugin.ReserveSlot.Remain},Total:{Server.PlayerCount}";
return true;
}
}
[CommandHandler(typeof(RemoteAdminCommandHandler))]
public class CheckPermission : ICommand
{
public string Command => "checkpermission";
public string Command => "setremain";

public string[] Aliases => Array.Empty<string>();

public string Description => "";

public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
response = UtilPlugin.ReserveSlot.CheckPermission(Player.Get((sender as CommandSender).SenderId)).ToString();
if (arguments.Count != 1)
{
response = "need 1 argument!Usage:setremain <newremain>";
return false;
}
UtilPlugin.ReserveSlot.Remain = int.Parse(arguments.At(0));
response = "Done!";
return true;
}
}
Expand Down
9 changes: 6 additions & 3 deletions util/SystemWarhead.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class SystemWarhead
public static CoroutineHandle _systemwarheadwaiter;
public static void OnRoundStarted()
{
_systemwarheadwaiter = Timing.RunCoroutine(SystemWarheadwaiter(UtilPlugin.Instance.Config.SysteamWarheadTime));
_systemwarheadwaiter = Timing.RunCoroutine(SystemWarheadwaiter(UtilPlugin.Instance.Config.SystemWarheadTime));
}
public static void OnRoundFinished()
{
Expand All @@ -24,7 +24,7 @@ public static IEnumerator<float> SystemWarheadwaiter(float time)
yield return Timing.WaitForSeconds(time);
Detonate();
}
public static void Detonate()
public static void Detonate(bool sendbroadcast = true)
{
Warhead.LeverStatus = true;
Warhead.IsKeycardActivated = true;
Expand All @@ -33,7 +33,10 @@ public static void Detonate()
Warhead.Start();
}
Warhead.IsLocked = true;
PluginAPI.Core.Server.SendBroadcast(UtilPlugin.Instance.Config.SystemWarheadBroadcast, 10, Broadcast.BroadcastFlags.Normal, true);
if (sendbroadcast)
{
PluginAPI.Core.Server.SendBroadcast(UtilPlugin.Instance.Config.SystemWarheadBroadcast, 10, Broadcast.BroadcastFlags.Normal, true);
}
}
}
}

0 comments on commit 6b553b5

Please sign in to comment.