Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 3 additions & 2 deletions LabApi/Features/Permissions/PermissionsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using CommandSystem;
using LabApi.Features.Wrappers;
using RemoteAdmin;

namespace LabApi.Features.Permissions;

Expand All @@ -20,11 +21,11 @@ public static string[] GetPermissions(this ICommandSender sender) =>

/// <inheritdoc cref="IPermissionsProvider.HasPermissions"/>
public static bool HasPermissions(this ICommandSender sender, params string[] permissions) =>
Player.Get(sender)?.HasPermissions(permissions) ?? false;
Player.Get(sender)?.HasPermissions(permissions) ?? sender is not PlayerCommandSender;

/// <inheritdoc cref="IPermissionsProvider.HasAnyPermission"/>
public static bool HasAnyPermission(this ICommandSender sender, params string[] permissions) =>
Player.Get(sender)?.HasAnyPermission(permissions) ?? false;
Player.Get(sender)?.HasAnyPermission(permissions) ?? sender is not PlayerCommandSender;

/// <inheritdoc cref="IPermissionsProvider.AddPermissions"/>
public static void AddPermissions(this ICommandSender sender, params string[] permissions) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,14 @@ private void ReloadPermissions()
permissionsGroup.SpecialPermissionsSuperset.Clear();
foreach (string permission in permissionsGroup.Permissions)
{
if (permission == "*")
if (permission == ".*")
{
permissionsGroup.IsRoot = true;
// We don't have to continue.
return;
break;
}

if (!permission.Contains("."))
if (!permission.Contains(".*"))
continue;

int index = permission.LastIndexOf(".", StringComparison.Ordinal);
Expand Down
6 changes: 3 additions & 3 deletions LabApi/Features/Wrappers/Players/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ public Item? CurrentItem
/// <summary>
/// Gets the <see cref="Item">items</see> in the player's inventory.
/// </summary>
public IEnumerable<Item?> Items => Inventory.UserInventory.Items.Values.Select(Item.Get);
public IEnumerable<Item> Items => Inventory.UserInventory.Items.Values.Select(Item.Get)!;

/// <summary>
/// Gets the player's Reserve Ammo.
Expand Down Expand Up @@ -1169,7 +1169,7 @@ public void RemoveItem(ItemType item, int maxAmount = 1)
public List<Pickup> DropAllItems()
{
List<Pickup> items = ListPool<Pickup>.Shared.Rent();
foreach (Item item in Items)
foreach (Item item in Items.ToArray())
Comment thread
ImBeryl marked this conversation as resolved.
items.Add(DropItem(item));

return items;
Expand Down Expand Up @@ -1221,7 +1221,7 @@ public List<AmmoPickup> DropAllAmmo()
/// </summary>
public void ClearItems()
{
foreach (Item item in Items)
foreach (Item item in Items.ToArray())
Comment thread
ImBeryl marked this conversation as resolved.
RemoveItem(item);
}

Expand Down