From 635e038af0637f3233570fabdeb2e8c6895f6f65 Mon Sep 17 00:00:00 2001 From: Andrew De palma Date: Sun, 19 Oct 2025 23:05:53 +0200 Subject: [PATCH 1/4] added customroles get command --- EXILED/Exiled.CustomRoles/Commands/Get.cs | 104 ++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 EXILED/Exiled.CustomRoles/Commands/Get.cs diff --git a/EXILED/Exiled.CustomRoles/Commands/Get.cs b/EXILED/Exiled.CustomRoles/Commands/Get.cs new file mode 100644 index 0000000000..2572e0c3c5 --- /dev/null +++ b/EXILED/Exiled.CustomRoles/Commands/Get.cs @@ -0,0 +1,104 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.CustomRoles.Commands +{ + using System; + using System.Linq; + using System.Text; + + using CommandSystem; + using Exiled.API.Features; + using Exiled.API.Features.Pools; + using Exiled.CustomRoles.API; + using Exiled.CustomRoles.API.Features; + using Exiled.Permissions.Extensions; + using RemoteAdmin; + + /// + /// The command to get player's current custom role. + /// + internal sealed class Get : ICommand + { + private Get() + { + } + + /// + /// Gets the command instance. + /// + public static Get Instance { get; } = new(); + + /// + public string Command { get; } = "get"; + + /// + public string[] Aliases { get; } = Array.Empty(); + + /// + public string Description { get; } = "Gets the specified player's current custom role."; + + /// + public bool Execute(ArraySegment arguments, ICommandSender sender, out string response) + { + try + { + if (!sender.CheckPermission("customroles.get")) + { + response = "Permission Denied, required: customroles.get"; + return false; + } + + if (sender is not PlayerCommandSender playerSender) + { + response = "Command can be used in game only."; + return false; + } + + Player target; + + if (arguments.Count == 0) + { + target = Player.Get(playerSender.ReferenceHub); + } + else + { + string identifier = string.Join(" ", arguments); + target = Player.List.FirstOrDefault(p => + p.Nickname.Equals(identifier, StringComparison.OrdinalIgnoreCase)); + + if (target is null) + { + response = $"No player found with nickname \"{identifier}\"."; + return false; + } + } + + CustomRole role = target.GetCustomRoles().FirstOrDefault(); + + if (role is null) + { + response = $"{target.Nickname} has no active custom role."; + return true; + } + + StringBuilder builder = StringBuilderPool.Pool.Get(); + builder.AppendLine($"{target.Nickname}'s custom role:"); + builder.Append("- ").Append(role.Name).Append(" [").Append(role.Id).Append(']'); + + response = StringBuilderPool.Pool.ToStringReturn(builder); + return true; + } + catch (Exception e) + { + Log.Error(e); + response = "An error occurred while executing the command."; + return false; + } + } + } +} \ No newline at end of file From c57e08bc3624fd5af211232b6ad4fff47d7914e2 Mon Sep 17 00:00:00 2001 From: Andrew De palma Date: Tue, 21 Oct 2025 23:42:17 +0200 Subject: [PATCH 2/4] added multiple players logic, registered the command, removed PlayerCommandSender check --- EXILED/Exiled.CustomRoles/Commands/Get.cs | 71 +++-- EXILED/Exiled.CustomRoles/Commands/Parent.cs | 1 + .../Exiled.CustomRoles.csproj | 279 +++++++++++++++++- 3 files changed, 314 insertions(+), 37 deletions(-) diff --git a/EXILED/Exiled.CustomRoles/Commands/Get.cs b/EXILED/Exiled.CustomRoles/Commands/Get.cs index 2572e0c3c5..c90cf96568 100644 --- a/EXILED/Exiled.CustomRoles/Commands/Get.cs +++ b/EXILED/Exiled.CustomRoles/Commands/Get.cs @@ -8,6 +8,7 @@ namespace Exiled.CustomRoles.Commands { using System; + using System.Collections.Generic; using System.Linq; using System.Text; @@ -17,10 +18,9 @@ namespace Exiled.CustomRoles.Commands using Exiled.CustomRoles.API; using Exiled.CustomRoles.API.Features; using Exiled.Permissions.Extensions; - using RemoteAdmin; /// - /// The command to get player's current custom role. + /// The command to get specified player(s) current custom roles. /// internal sealed class Get : ICommand { @@ -40,57 +40,78 @@ private Get() public string[] Aliases { get; } = Array.Empty(); /// - public string Description { get; } = "Gets the specified player's current custom role."; + public string Description { get; } = "Gets the specified player(s)' current custom role(s)."; /// public bool Execute(ArraySegment arguments, ICommandSender sender, out string response) { try { - if (!sender.CheckPermission("customroles.get")) + Player? playerSender = sender as Player; + if (!playerSender.CheckPermission("customroles.get")) { response = "Permission Denied, required: customroles.get"; return false; } - if (sender is not PlayerCommandSender playerSender) - { - response = "Command can be used in game only."; - return false; - } - - Player target; + List targets = new(); if (arguments.Count == 0) { - target = Player.Get(playerSender.ReferenceHub); + if (playerSender == null) + { + response = "You can't check your customroles if you're not connected to the server."; + return false; + } + + targets.Add(Player.Get(playerSender.ReferenceHub)); } else { string identifier = string.Join(" ", arguments); - target = Player.List.FirstOrDefault(p => - p.Nickname.Equals(identifier, StringComparison.OrdinalIgnoreCase)); - if (target is null) + switch (identifier.ToLower()) { - response = $"No player found with nickname \"{identifier}\"."; - return false; + case "*": + case "all": + targets.AddRange(Player.List); + break; + + default: + IEnumerable foundPlayers = Player.GetProcessedData(arguments, 0); + if (foundPlayers.IsEmpty()) + { + response = "No players found! Try using player ID or UserID."; + return false; + } + + targets.AddRange(foundPlayers); + break; } } - CustomRole role = target.GetCustomRoles().FirstOrDefault(); + StringBuilder builder = StringBuilderPool.Pool.Get(); - if (role is null) + foreach (Player target in targets) { - response = $"{target.Nickname} has no active custom role."; - return true; + CustomRole role = target.GetCustomRoles().FirstOrDefault(); + if (role is null) + { + builder.AppendLine($"{target.Nickname.PadRight(30)} | None"); + } + else + { + builder.AppendLine($"{target.Nickname.PadRight(30)} | {role.Name} [{role.Id}]"); + } } - StringBuilder builder = StringBuilderPool.Pool.Get(); - builder.AppendLine($"{target.Nickname}'s custom role:"); - builder.Append("- ").Append(role.Name).Append(" [").Append(role.Id).Append(']'); + string formattedList = new StringBuilder() + .AppendLine("===== Custom Roles =====") + .Append(builder.ToString()) + .AppendLine("========================") + .ToString(); - response = StringBuilderPool.Pool.ToStringReturn(builder); + response = formattedList; return true; } catch (Exception e) diff --git a/EXILED/Exiled.CustomRoles/Commands/Parent.cs b/EXILED/Exiled.CustomRoles/Commands/Parent.cs index f64facabec..13365edf0b 100644 --- a/EXILED/Exiled.CustomRoles/Commands/Parent.cs +++ b/EXILED/Exiled.CustomRoles/Commands/Parent.cs @@ -41,6 +41,7 @@ public override void LoadGeneratedCommands() RegisterCommand(Give.Instance); RegisterCommand(Info.Instance); RegisterCommand(List.List.Instance); + RegisterCommand(Get.Instance); } /// diff --git a/EXILED/Exiled.CustomRoles/Exiled.CustomRoles.csproj b/EXILED/Exiled.CustomRoles/Exiled.CustomRoles.csproj index 78b2030580..9604e8f0f9 100644 --- a/EXILED/Exiled.CustomRoles/Exiled.CustomRoles.csproj +++ b/EXILED/Exiled.CustomRoles/Exiled.CustomRoles.csproj @@ -26,19 +26,274 @@ - - - - - - - - - - - + + ..\..\..\BSCore\BSCore\bin\Release\Assembly-CSharp.dll + + + ..\..\..\BSCore\BSCore\bin\Release\Assembly-CSharp-firstpass.dll + + + ..\..\..\..\..\Downloads\CommandSystem.Core.dll + + + ..\..\..\..\..\Desktop\exileddo\Mirror.dll + - + + ..\..\..\..\..\Desktop\exileddo\Unity.Burst.dll + + + ..\..\..\..\..\Desktop\exileddo\Unity.Burst.Unsafe.dll + + + ..\..\..\..\..\Desktop\exileddo\Unity.Mathematics.dll + + + ..\..\..\..\..\Desktop\exileddo\Unity.ProBuilder.dll + + + ..\..\..\..\..\Desktop\exileddo\Unity.ProBuilder.Csg.dll + + + ..\..\..\..\..\Desktop\exileddo\Unity.ProBuilder.KdTree.dll + + + ..\..\..\..\..\Desktop\exileddo\Unity.ProBuilder.Poly2Tri.dll + + + ..\..\..\..\..\Desktop\exileddo\Unity.ProBuilder.Stl.dll + + + ..\..\..\..\..\Desktop\exileddo\Unity.RenderPipelines.Core.Runtime.dll + + + ..\..\..\..\..\Desktop\exileddo\Unity.RenderPipelines.Core.ShaderLibrary.dll + + + ..\..\..\..\..\Desktop\exileddo\Unity.RenderPipelines.HighDefinition.Config.Runtime.dll + + + ..\..\..\..\..\Desktop\exileddo\Unity.RenderPipelines.HighDefinition.Runtime.dll + + + ..\..\..\..\..\Desktop\exileddo\Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary.dll + + + ..\..\..\..\..\Desktop\exileddo\Unity.TextMeshPro.dll + + + ..\..\..\..\..\Desktop\exileddo\Unity.Timeline.dll + + + ..\..\..\..\..\Desktop\exileddo\Unity.VisualEffectGraph.Runtime.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.AccessibilityModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.AIModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.AndroidJNIModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.AnimationModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.ARModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.AssetBundleModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.AudioModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.ClothModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.ClusterInputModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.ClusterRendererModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.CoreModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.CrashReportingModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.DirectorModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.DSPGraphModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.GameCenterModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.GIModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.GridModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.HotReloadModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.ImageConversionModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.IMGUIModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.InputLegacyModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.InputModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.JSONSerializeModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.LocalizationModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.NVIDIAModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.ParticleSystemModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.PerformanceReportingModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.Physics2DModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.PhysicsModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.ProfilerModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.RuntimeInitializeOnLoadManagerInitializerModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.ScreenCaptureModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.SharedInternalsModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.SpriteMaskModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.SpriteShapeModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.StreamingModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.SubstanceModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.SubsystemsModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.TerrainModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.TerrainPhysicsModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.TextCoreFontEngineModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.TextCoreTextEngineModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.TextRenderingModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.TilemapModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.TLSModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.UI.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.UIElementsModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.UIElementsNativeModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.UIModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.UmbraModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.UNETModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.UnityAnalyticsCommonModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.UnityAnalyticsModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.UnityConnectModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.UnityCurlModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.UnityTestProtocolModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.UnityWebRequestAssetBundleModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.UnityWebRequestAudioModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.UnityWebRequestModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.UnityWebRequestTextureModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.UnityWebRequestWWWModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.VehiclesModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.VFXModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.VideoModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.VirtualTexturingModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.VRModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.WindModule.dll + + + ..\..\..\..\..\Desktop\exileddo\UnityEngine.XRModule.dll + From 7e47704e63cebb8853acf63932f7fe80431290c6 Mon Sep 17 00:00:00 2001 From: Andrew De palma Date: Thu, 23 Oct 2025 21:23:58 +0200 Subject: [PATCH 3/4] fixed everything requested --- EXILED/Exiled.CustomRoles/Commands/Get.cs | 16 +- .../Exiled.CustomRoles.csproj | 281 +----------------- 2 files changed, 20 insertions(+), 277 deletions(-) diff --git a/EXILED/Exiled.CustomRoles/Commands/Get.cs b/EXILED/Exiled.CustomRoles/Commands/Get.cs index c90cf96568..1134e76947 100644 --- a/EXILED/Exiled.CustomRoles/Commands/Get.cs +++ b/EXILED/Exiled.CustomRoles/Commands/Get.cs @@ -48,19 +48,19 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s try { Player? playerSender = sender as Player; - if (!playerSender.CheckPermission("customroles.get")) + if (playerSender is not null && !playerSender.CheckPermission("customroles.get")) { response = "Permission Denied, required: customroles.get"; return false; } - List targets = new(); + List targets = ListPool.Pool.Get(); if (arguments.Count == 0) { if (playerSender == null) { - response = "You can't check your customroles if you're not connected to the server."; + response = "You need to provide arguments (ID/Nickname) in order to use this command."; return false; } @@ -105,13 +105,11 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s } } - string formattedList = new StringBuilder() - .AppendLine("===== Custom Roles =====") - .Append(builder.ToString()) - .AppendLine("========================") - .ToString(); + builder.Insert(0, "===== Custom Roles =====\n"); + builder.AppendLine("========================"); - response = formattedList; + response = StringBuilderPool.Pool.ToStringReturn(builder); + ListPool.Pool.Return(targets); return true; } catch (Exception e) diff --git a/EXILED/Exiled.CustomRoles/Exiled.CustomRoles.csproj b/EXILED/Exiled.CustomRoles/Exiled.CustomRoles.csproj index 9604e8f0f9..cd1a8b4769 100644 --- a/EXILED/Exiled.CustomRoles/Exiled.CustomRoles.csproj +++ b/EXILED/Exiled.CustomRoles/Exiled.CustomRoles.csproj @@ -26,274 +26,19 @@ - - ..\..\..\BSCore\BSCore\bin\Release\Assembly-CSharp.dll - - - ..\..\..\BSCore\BSCore\bin\Release\Assembly-CSharp-firstpass.dll - - - ..\..\..\..\..\Downloads\CommandSystem.Core.dll - - - ..\..\..\..\..\Desktop\exileddo\Mirror.dll - + + + + + + + + + + + - - ..\..\..\..\..\Desktop\exileddo\Unity.Burst.dll - - - ..\..\..\..\..\Desktop\exileddo\Unity.Burst.Unsafe.dll - - - ..\..\..\..\..\Desktop\exileddo\Unity.Mathematics.dll - - - ..\..\..\..\..\Desktop\exileddo\Unity.ProBuilder.dll - - - ..\..\..\..\..\Desktop\exileddo\Unity.ProBuilder.Csg.dll - - - ..\..\..\..\..\Desktop\exileddo\Unity.ProBuilder.KdTree.dll - - - ..\..\..\..\..\Desktop\exileddo\Unity.ProBuilder.Poly2Tri.dll - - - ..\..\..\..\..\Desktop\exileddo\Unity.ProBuilder.Stl.dll - - - ..\..\..\..\..\Desktop\exileddo\Unity.RenderPipelines.Core.Runtime.dll - - - ..\..\..\..\..\Desktop\exileddo\Unity.RenderPipelines.Core.ShaderLibrary.dll - - - ..\..\..\..\..\Desktop\exileddo\Unity.RenderPipelines.HighDefinition.Config.Runtime.dll - - - ..\..\..\..\..\Desktop\exileddo\Unity.RenderPipelines.HighDefinition.Runtime.dll - - - ..\..\..\..\..\Desktop\exileddo\Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary.dll - - - ..\..\..\..\..\Desktop\exileddo\Unity.TextMeshPro.dll - - - ..\..\..\..\..\Desktop\exileddo\Unity.Timeline.dll - - - ..\..\..\..\..\Desktop\exileddo\Unity.VisualEffectGraph.Runtime.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.AccessibilityModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.AIModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.AndroidJNIModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.AnimationModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.ARModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.AssetBundleModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.AudioModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.ClothModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.ClusterInputModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.ClusterRendererModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.CoreModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.CrashReportingModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.DirectorModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.DSPGraphModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.GameCenterModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.GIModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.GridModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.HotReloadModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.ImageConversionModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.IMGUIModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.InputLegacyModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.InputModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.JSONSerializeModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.LocalizationModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.NVIDIAModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.ParticleSystemModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.PerformanceReportingModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.Physics2DModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.PhysicsModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.ProfilerModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.RuntimeInitializeOnLoadManagerInitializerModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.ScreenCaptureModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.SharedInternalsModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.SpriteMaskModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.SpriteShapeModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.StreamingModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.SubstanceModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.SubsystemsModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.TerrainModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.TerrainPhysicsModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.TextCoreFontEngineModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.TextCoreTextEngineModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.TextRenderingModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.TilemapModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.TLSModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.UI.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.UIElementsModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.UIElementsNativeModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.UIModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.UmbraModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.UNETModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.UnityAnalyticsCommonModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.UnityAnalyticsModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.UnityConnectModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.UnityCurlModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.UnityTestProtocolModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.UnityWebRequestAssetBundleModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.UnityWebRequestAudioModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.UnityWebRequestModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.UnityWebRequestTextureModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.UnityWebRequestWWWModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.VehiclesModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.VFXModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.VideoModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.VirtualTexturingModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.VRModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.WindModule.dll - - - ..\..\..\..\..\Desktop\exileddo\UnityEngine.XRModule.dll - + @@ -304,4 +49,4 @@ if [[ ! -z "$EXILED_DEV_REFERENCES" ]]; then cp "$(OutputPath)$(AssemblyName).dll" "$EXILED_DEV_REFERENCES/Plugins/"; fi - + \ No newline at end of file From 816f714410930ed216b1b58ce8a07a5d0211ee2a Mon Sep 17 00:00:00 2001 From: Yamato <66829532+louis1706@users.noreply.github.com> Date: Wed, 5 Nov 2025 13:43:06 +0100 Subject: [PATCH 4/4] simplify --- .../API/Features/CustomRole.cs | 6 ++ EXILED/Exiled.CustomRoles/Commands/Get.cs | 88 ++++++------------- 2 files changed, 34 insertions(+), 60 deletions(-) diff --git a/EXILED/Exiled.CustomRoles/API/Features/CustomRole.cs b/EXILED/Exiled.CustomRoles/API/Features/CustomRole.cs index f29e2d525c..afce01ccdf 100644 --- a/EXILED/Exiled.CustomRoles/API/Features/CustomRole.cs +++ b/EXILED/Exiled.CustomRoles/API/Features/CustomRole.cs @@ -790,6 +790,12 @@ public bool TryAddFriendlyFire(Dictionary ffRules, bool overw return true; } + /// + /// Returns the CustomRole in a human-readable format. + /// + /// A string containing CustomRole-related data. + public override string ToString() => $"{Name} ({Id})"; + /// /// Tries to register this role. /// diff --git a/EXILED/Exiled.CustomRoles/Commands/Get.cs b/EXILED/Exiled.CustomRoles/Commands/Get.cs index 1134e76947..e0e29d7759 100644 --- a/EXILED/Exiled.CustomRoles/Commands/Get.cs +++ b/EXILED/Exiled.CustomRoles/Commands/Get.cs @@ -9,6 +9,7 @@ namespace Exiled.CustomRoles.Commands { using System; using System.Collections.Generic; + using System.Collections.ObjectModel; using System.Linq; using System.Text; @@ -18,6 +19,7 @@ namespace Exiled.CustomRoles.Commands using Exiled.CustomRoles.API; using Exiled.CustomRoles.API.Features; using Exiled.Permissions.Extensions; + using HarmonyLib; /// /// The command to get specified player(s) current custom roles. @@ -45,79 +47,45 @@ private Get() /// public bool Execute(ArraySegment arguments, ICommandSender sender, out string response) { - try + if (!sender.CheckPermission("customroles.get")) { - Player? playerSender = sender as Player; - if (playerSender is not null && !playerSender.CheckPermission("customroles.get")) + response = "Permission Denied, required: customroles.get"; + return false; + } + + IEnumerable players = Player.GetProcessedData(arguments); + if (players.IsEmpty()) + { + if (arguments.Count > 0 || !Player.TryGet(sender, out Player player)) { - response = "Permission Denied, required: customroles.get"; + response = $"Player not found: {arguments.ElementAtOrDefault(0)}"; return false; } - List targets = ListPool.Pool.Get(); - - if (arguments.Count == 0) - { - if (playerSender == null) - { - response = "You need to provide arguments (ID/Nickname) in order to use this command."; - return false; - } - - targets.Add(Player.Get(playerSender.ReferenceHub)); - } - else - { - string identifier = string.Join(" ", arguments); + players.AddItem(player); + } - switch (identifier.ToLower()) - { - case "*": - case "all": - targets.AddRange(Player.List); - break; + StringBuilder builder = StringBuilderPool.Pool.Get(); - default: - IEnumerable foundPlayers = Player.GetProcessedData(arguments, 0); - if (foundPlayers.IsEmpty()) - { - response = "No players found! Try using player ID or UserID."; - return false; - } + builder.AppendLine("===== Custom Roles ====="); - targets.AddRange(foundPlayers); - break; - } + foreach (Player target in players) + { + ReadOnlyCollection role = target.GetCustomRoles(); + if (role.IsEmpty()) + { + builder.AppendLine($"{target.DisplayNickname.PadRight(30)} | None"); } - - StringBuilder builder = StringBuilderPool.Pool.Get(); - - foreach (Player target in targets) + else { - CustomRole role = target.GetCustomRoles().FirstOrDefault(); - if (role is null) - { - builder.AppendLine($"{target.Nickname.PadRight(30)} | None"); - } - else - { - builder.AppendLine($"{target.Nickname.PadRight(30)} | {role.Name} [{role.Id}]"); - } + builder.AppendLine($"{target.DisplayNickname.PadRight(30)} ({target.Id}) | {string.Join("-", role.ToString())}]"); } + } - builder.Insert(0, "===== Custom Roles =====\n"); - builder.AppendLine("========================"); + builder.AppendLine("========================"); - response = StringBuilderPool.Pool.ToStringReturn(builder); - ListPool.Pool.Return(targets); - return true; - } - catch (Exception e) - { - Log.Error(e); - response = "An error occurred while executing the command."; - return false; - } + response = StringBuilderPool.Pool.ToStringReturn(builder); + return true; } } } \ No newline at end of file