From 82a22c8970a55048b5f53db5862526374951ee07 Mon Sep 17 00:00:00 2001 From: AdzZo3bi <73377149+AdzAhm@users.noreply.github.com> Date: Tue, 10 Feb 2026 19:42:50 +0200 Subject: [PATCH] Update Jail.cs Fixed console error on startup: [2026-02-10 17:21:43.985 +00:00] [ERROR] [Exiled.API] Command with same name has already registered! Command: jail that causes the jail command not to be registered at all --- AdminTools/Commands/Jail.cs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/AdminTools/Commands/Jail.cs b/AdminTools/Commands/Jail.cs index 15c712e..9575296 100644 --- a/AdminTools/Commands/Jail.cs +++ b/AdminTools/Commands/Jail.cs @@ -1,4 +1,4 @@ -using CommandSystem; +using CommandSystem; using Exiled.API.Enums; using Exiled.API.Extensions; using Exiled.API.Features; @@ -20,7 +20,18 @@ public class Jail : ICommand, IUsageProvider public string Description { get; } = "Jails or unjails a user"; - public string[] Usage { get; } = new string[] { "%player%", "[IsJail]"}; + public string[] Usage { get; } = new string[] { "%player%", "[IsJail]" }; + + public Jail() + { + // Check if the command already exists in the RemoteAdminCommandHandler + var existing = CommandHandler.Base.Commands.FirstOrDefault(x => x.Name.Equals(Command, StringComparison.OrdinalIgnoreCase)); + if (existing != null) + { + Log.Warn($"Jail command already exists as '{existing.Name}', skipping registration."); + throw new InvalidOperationException("Jail command already registered."); // prevents double registration + } + } public bool Execute(ArraySegment arguments, ICommandSender sender, out string response) { @@ -42,14 +53,13 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s response = $"Player not found: {arguments.At(0)}"; return false; } - + bool? isJail = null; if (bool.TryParse(arguments.ElementAtOrDefault(1), out bool result)) isJail = result; foreach (Player ply in players) { - if (isJail is true) DoJail(ply); else if (isJail is false) @@ -65,6 +75,7 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s response = $"Jail command has run successfully.\n{Extensions.LogPlayers(players)}"; return true; } + public static void DoJail(Player player, bool skipadd = false) { if (Main.JailedPlayers.ContainsKey(player.UserId))