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

Updated CustomItems & CustomRoles give commands to use default RAUtils.ProcessPlayerIdOrNamesList #179

Merged
merged 9 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
2 changes: 1 addition & 1 deletion EXILED/EXILED.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<PropertyGroup>
<!-- This is the global version and is used for all projects that don't have a version -->
<Version Condition="$(Version) == ''">8.14.1</Version>
<Version Condition="$(Version) == ''">8.14.0</Version>
louis1706 marked this conversation as resolved.
Show resolved Hide resolved
<!-- Enables public beta warning via the PUBLIC_BETA constant -->
<PublicBeta>false</PublicBeta>

Expand Down
33 changes: 20 additions & 13 deletions EXILED/Exiled.CustomItems/Commands/Give.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ namespace Exiled.CustomItems.Commands
using Exiled.Permissions.Extensions;

using RemoteAdmin;
using UnityStandardAssets.Effects;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

using Utils;

/// <summary>
/// The command to give a player an item.
Expand Down Expand Up @@ -97,27 +99,32 @@ public bool Execute(ArraySegment<string> 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;
}
break;
}

if (!CheckEligible(player))
{
response = "Player cannot receive custom items!";
return false;
}
IEnumerable<Player> list = Player.GetProcessedData(arguments, 1);

if (list == null)
icedchai marked this conversation as resolved.
Show resolved Hide resolved
{
response = "Cannot find player! Try using the player ID!";
return false;
}

foreach (Player player in list)
{
if (CheckEligible(player))
{
item?.Give(player);
response = $"{item?.Name} given to {player.Nickname} ({player.UserId})";
return true;
}
}

response = $"{item?.Name} given to {list.Count()} players!";
return true;
}

/// <summary>
/// Checks if the player is eligible to receive custom items.
/// </summary>
private bool CheckEligible(Player player) => player.IsAlive && !player.IsCuffed && (player.Items.Count < 8);
}
}
}
27 changes: 18 additions & 9 deletions EXILED/Exiled.CustomRoles/Commands/Give.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace Exiled.CustomRoles.Commands
using Exiled.Permissions.Extensions;

using RemoteAdmin;
using Utils;

/// <summary>
/// The command to give a role to player(s).
Expand Down Expand Up @@ -96,16 +97,24 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
ListPool<Player>.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;
}

IEnumerable<Player> list = Player.GetProcessedData(arguments, 1);
if (list == null)
icedchai marked this conversation as resolved.
Show resolved Hide resolved
{
response = "Cannot find player! Try using the player ID!";
return false;
}

foreach (Player player in list)
{
role.AddRole(player);
}

response = $"Customrole {role.Name} given to {list.Count()} players!";

return true;
}
catch (Exception e)
{
Expand Down