From e08863b6d3a5faa11008d3cf8eb735ae1524c65c Mon Sep 17 00:00:00 2001 From: icedchai <70030002+icedchai@users.noreply.github.com> Date: Tue, 12 Nov 2024 21:58:22 -0600 Subject: [PATCH 1/8] Update Give.cs --- EXILED/Exiled.CustomItems/Commands/Give.cs | 44 ++++++++++++++-------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/EXILED/Exiled.CustomItems/Commands/Give.cs b/EXILED/Exiled.CustomItems/Commands/Give.cs index cf228ca56c..6901645366 100644 --- a/EXILED/Exiled.CustomItems/Commands/Give.cs +++ b/EXILED/Exiled.CustomItems/Commands/Give.cs @@ -18,6 +18,7 @@ namespace Exiled.CustomItems.Commands using Exiled.Permissions.Extensions; using RemoteAdmin; + using Utils; /// /// The command to give a player an item. @@ -83,7 +84,6 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s response = "Failed to provide a valid player, please follow the syntax."; return false; } - string identifier = string.Join(" ", arguments.Skip(1)); switch (identifier) @@ -97,22 +97,36 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s response = $"Custom item {item?.Name} given to all players who can receive them ({eligiblePlayers.Count} players)"; return true; default: - if (Player.Get(identifier) is not { } player) - { - response = $"Unable to find player: {identifier}."; - return false; - } - - if (!CheckEligible(player)) - { - response = "Player cannot receive custom items!"; - return false; - } + break; + } + string[] newargs; + List list = RAUtils.ProcessPlayerIdOrNamesList(arguments, 1, out newargs); + if (list == null) + { + response = "Cannot find player! Try using the player ID!"; + return false; + } + foreach (ReferenceHub hub in list) + { + Player player = Player.Get(hub); + if (!CheckEligible(player)) + { + list.Remove(hub); + } - item?.Give(player); - response = $"{item?.Name} given to {player.Nickname} ({player.UserId})"; - return true; + item?.Give(player); + } + if (list.Count == 1) + { + Player player = Player.Get(list[0]); + response = $"{item?.Name} given to {player.Nickname} ({player.UserId})"; } + else + { + response = $"{item?.Name} given to {list.Count} players!"; + } + return true; + } /// From fc074d7a83f2e8a43a69b36471cf5908b4495cb6 Mon Sep 17 00:00:00 2001 From: icedchai <70030002+icedchai@users.noreply.github.com> Date: Wed, 13 Nov 2024 20:52:53 -0600 Subject: [PATCH 2/8] Update Give.cs --- EXILED/Exiled.CustomRoles/Commands/Give.cs | 35 ++++++++++++++++------ 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/EXILED/Exiled.CustomRoles/Commands/Give.cs b/EXILED/Exiled.CustomRoles/Commands/Give.cs index f69ab08add..797f3a2d98 100644 --- a/EXILED/Exiled.CustomRoles/Commands/Give.cs +++ b/EXILED/Exiled.CustomRoles/Commands/Give.cs @@ -19,6 +19,8 @@ namespace Exiled.CustomRoles.Commands using Exiled.Permissions.Extensions; using RemoteAdmin; + using static HarmonyLib.Code; + using Utils; /// /// The command to give a role to player(s). @@ -96,16 +98,31 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s ListPool.Pool.Return(players); return true; default: - if (Player.Get(identifier) is not Player ply) - { - response = $"Unable to find a player: {identifier}"; - return false; - } - - role.AddRole(ply); - response = $"{role.Name} given to {ply.Nickname}."; - return true; + break; + } + string[] newargs; + List list = RAUtils.ProcessPlayerIdOrNamesList(arguments, 1, out newargs); + if (list == null) + { + response = "Cannot find player! Try using the player ID!"; + return false; + } + foreach (ReferenceHub hub in list) + { + Player player = Player.Get(hub); + role.AddRole(player); + } + if (list.Count == 1) + { + Player player = Player.Get(list[0]); + role.AddRole(player); + response = $"Customrole {role.Name} given to {player.Nickname} ({player.UserId})"; + } + else + { + response = $"Customrole {role.Name} given to {list.Count} players!"; } + return true; } catch (Exception e) { From 5eaf3ee0e6cecfe471068fb83edf327c7d4f8ae6 Mon Sep 17 00:00:00 2001 From: icedchai <70030002+icedchai@users.noreply.github.com> Date: Wed, 13 Nov 2024 21:46:25 -0600 Subject: [PATCH 3/8] fixed style violation --- EXILED/Exiled.CustomItems/Commands/Give.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/EXILED/Exiled.CustomItems/Commands/Give.cs b/EXILED/Exiled.CustomItems/Commands/Give.cs index 6901645366..6a31cfe451 100644 --- a/EXILED/Exiled.CustomItems/Commands/Give.cs +++ b/EXILED/Exiled.CustomItems/Commands/Give.cs @@ -84,6 +84,7 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s response = "Failed to provide a valid player, please follow the syntax."; return false; } + string identifier = string.Join(" ", arguments.Skip(1)); switch (identifier) @@ -99,6 +100,7 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s default: break; } + string[] newargs; List list = RAUtils.ProcessPlayerIdOrNamesList(arguments, 1, out newargs); if (list == null) @@ -106,6 +108,7 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s response = "Cannot find player! Try using the player ID!"; return false; } + foreach (ReferenceHub hub in list) { Player player = Player.Get(hub); @@ -116,15 +119,18 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s item?.Give(player); } + if (list.Count == 1) { Player player = Player.Get(list[0]); response = $"{item?.Name} given to {player.Nickname} ({player.UserId})"; } + else { response = $"{item?.Name} given to {list.Count} players!"; } + return true; } @@ -134,4 +140,4 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s /// private bool CheckEligible(Player player) => player.IsAlive && !player.IsCuffed && (player.Items.Count < 8); } -} \ No newline at end of file +} From 8a6d6b6e05f068990d28238f2c2e533cf1d3a882 Mon Sep 17 00:00:00 2001 From: icedchai <70030002+icedchai@users.noreply.github.com> Date: Thu, 14 Nov 2024 19:21:29 -0600 Subject: [PATCH 4/8] Fixed issue --- EXILED/Exiled.CustomItems/Commands/Give.cs | 12 +++++------- EXILED/Exiled.CustomRoles/Commands/Give.cs | 5 ++++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/EXILED/Exiled.CustomItems/Commands/Give.cs b/EXILED/Exiled.CustomItems/Commands/Give.cs index 6a31cfe451..8144388061 100644 --- a/EXILED/Exiled.CustomItems/Commands/Give.cs +++ b/EXILED/Exiled.CustomItems/Commands/Give.cs @@ -84,7 +84,7 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s response = "Failed to provide a valid player, please follow the syntax."; return false; } - + string identifier = string.Join(" ", arguments.Skip(1)); switch (identifier) @@ -100,7 +100,7 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s default: break; } - + string[] newargs; List list = RAUtils.ProcessPlayerIdOrNamesList(arguments, 1, out newargs); if (list == null) @@ -108,7 +108,7 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s response = "Cannot find player! Try using the player ID!"; return false; } - + foreach (ReferenceHub hub in list) { Player player = Player.Get(hub); @@ -119,20 +119,18 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s item?.Give(player); } - + if (list.Count == 1) { Player player = Player.Get(list[0]); response = $"{item?.Name} given to {player.Nickname} ({player.UserId})"; } - else { response = $"{item?.Name} given to {list.Count} players!"; } - - return true; + return true; } /// diff --git a/EXILED/Exiled.CustomRoles/Commands/Give.cs b/EXILED/Exiled.CustomRoles/Commands/Give.cs index 797f3a2d98..0e2d9a24e3 100644 --- a/EXILED/Exiled.CustomRoles/Commands/Give.cs +++ b/EXILED/Exiled.CustomRoles/Commands/Give.cs @@ -19,7 +19,6 @@ namespace Exiled.CustomRoles.Commands using Exiled.Permissions.Extensions; using RemoteAdmin; - using static HarmonyLib.Code; using Utils; /// @@ -100,6 +99,7 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s default: break; } + string[] newargs; List list = RAUtils.ProcessPlayerIdOrNamesList(arguments, 1, out newargs); if (list == null) @@ -107,11 +107,13 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s response = "Cannot find player! Try using the player ID!"; return false; } + foreach (ReferenceHub hub in list) { Player player = Player.Get(hub); role.AddRole(player); } + if (list.Count == 1) { Player player = Player.Get(list[0]); @@ -122,6 +124,7 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s { response = $"Customrole {role.Name} given to {list.Count} players!"; } + return true; } catch (Exception e) From 215906fba8b1b96895551b3f67035eb7db1f9297 Mon Sep 17 00:00:00 2001 From: icedchai <70030002+icedchai@users.noreply.github.com> Date: Sat, 16 Nov 2024 12:24:39 -0600 Subject: [PATCH 5/8] Player.GetProcessedData --- EXILED/Exiled.CustomItems/Commands/Give.cs | 25 ++++++---------------- EXILED/Exiled.CustomRoles/Commands/Give.cs | 17 +++------------ 2 files changed, 10 insertions(+), 32 deletions(-) diff --git a/EXILED/Exiled.CustomItems/Commands/Give.cs b/EXILED/Exiled.CustomItems/Commands/Give.cs index 8144388061..bc4d95db92 100644 --- a/EXILED/Exiled.CustomItems/Commands/Give.cs +++ b/EXILED/Exiled.CustomItems/Commands/Give.cs @@ -18,6 +18,7 @@ namespace Exiled.CustomItems.Commands using Exiled.Permissions.Extensions; using RemoteAdmin; + using UnityStandardAssets.Effects; using Utils; /// @@ -101,35 +102,23 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s break; } - string[] newargs; - List list = RAUtils.ProcessPlayerIdOrNamesList(arguments, 1, out newargs); + IEnumerable list = Player.GetProcessedData(arguments, 1); + if (list == null) { response = "Cannot find player! Try using the player ID!"; return false; } - foreach (ReferenceHub hub in list) + foreach (Player player in list) { - Player player = Player.Get(hub); - if (!CheckEligible(player)) + if (CheckEligible(player)) { - list.Remove(hub); + item?.Give(player); } - - item?.Give(player); - } - - if (list.Count == 1) - { - Player player = Player.Get(list[0]); - response = $"{item?.Name} given to {player.Nickname} ({player.UserId})"; - } - else - { - response = $"{item?.Name} given to {list.Count} players!"; } + response = $"{item?.Name} given to {list.Count()} players!"; return true; } diff --git a/EXILED/Exiled.CustomRoles/Commands/Give.cs b/EXILED/Exiled.CustomRoles/Commands/Give.cs index 0e2d9a24e3..082731d202 100644 --- a/EXILED/Exiled.CustomRoles/Commands/Give.cs +++ b/EXILED/Exiled.CustomRoles/Commands/Give.cs @@ -100,30 +100,19 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s break; } - string[] newargs; - List list = RAUtils.ProcessPlayerIdOrNamesList(arguments, 1, out newargs); + IEnumerable list = Player.GetProcessedData(arguments, 1); if (list == null) { response = "Cannot find player! Try using the player ID!"; return false; } - foreach (ReferenceHub hub in list) + foreach (Player player in list) { - Player player = Player.Get(hub); role.AddRole(player); } - if (list.Count == 1) - { - Player player = Player.Get(list[0]); - role.AddRole(player); - response = $"Customrole {role.Name} given to {player.Nickname} ({player.UserId})"; - } - else - { - response = $"Customrole {role.Name} given to {list.Count} players!"; - } + response = $"Customrole {role.Name} given to {list.Count()} players!"; return true; } From 410fb613ad4e1e08d86c534f53e3250d6e83f122 Mon Sep 17 00:00:00 2001 From: icedchai <70030002+icedchai@users.noreply.github.com> Date: Sun, 17 Nov 2024 18:46:16 -0600 Subject: [PATCH 6/8] Update EXILED.props --- EXILED/EXILED.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/EXILED.props b/EXILED/EXILED.props index 62d6e57cd7..b4aecc1f33 100644 --- a/EXILED/EXILED.props +++ b/EXILED/EXILED.props @@ -15,7 +15,7 @@ - 8.14.1 + 8.14.0 false From 2bd59191ca184d36c35065f25faa77110de89e61 Mon Sep 17 00:00:00 2001 From: icedchai <70030002+icedchai@users.noreply.github.com> Date: Mon, 18 Nov 2024 18:49:13 -0600 Subject: [PATCH 7/8] list.isempty --- EXILED/Exiled.CustomItems/Commands/Give.cs | 2 +- EXILED/Exiled.CustomRoles/Commands/Give.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/EXILED/Exiled.CustomItems/Commands/Give.cs b/EXILED/Exiled.CustomItems/Commands/Give.cs index bc4d95db92..0f02dace38 100644 --- a/EXILED/Exiled.CustomItems/Commands/Give.cs +++ b/EXILED/Exiled.CustomItems/Commands/Give.cs @@ -104,7 +104,7 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s IEnumerable list = Player.GetProcessedData(arguments, 1); - if (list == null) + if (list.IsEmpty()) { response = "Cannot find player! Try using the player ID!"; return false; diff --git a/EXILED/Exiled.CustomRoles/Commands/Give.cs b/EXILED/Exiled.CustomRoles/Commands/Give.cs index 082731d202..b61e6d56af 100644 --- a/EXILED/Exiled.CustomRoles/Commands/Give.cs +++ b/EXILED/Exiled.CustomRoles/Commands/Give.cs @@ -101,7 +101,7 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s } IEnumerable list = Player.GetProcessedData(arguments, 1); - if (list == null) + if (list.IsEmpty()) { response = "Cannot find player! Try using the player ID!"; return false; From 274067131cfcd8e3a913e8bb0095886d4bd806a7 Mon Sep 17 00:00:00 2001 From: icedchai <70030002+icedchai@users.noreply.github.com> Date: Mon, 18 Nov 2024 18:50:19 -0600 Subject: [PATCH 8/8] Revert "Update EXILED.props" This reverts commit 410fb613ad4e1e08d86c534f53e3250d6e83f122. --- EXILED/EXILED.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/EXILED.props b/EXILED/EXILED.props index b4aecc1f33..62d6e57cd7 100644 --- a/EXILED/EXILED.props +++ b/EXILED/EXILED.props @@ -15,7 +15,7 @@ - 8.14.0 + 8.14.1 false