Skip to content

Commit

Permalink
[API] IGamePermissionCommand (Exiled-Team#2586)
Browse files Browse the repository at this point in the history
  • Loading branch information
Misfiy authored Jun 1, 2024
1 parent c4bc839 commit 0f38e97
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Exiled.API/Interfaces/IGamePermissionCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// -----------------------------------------------------------------------
// <copyright file="IGamePermissionCommand.cs" company="Exiled Team">
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
// </copyright>
// -----------------------------------------------------------------------

namespace Exiled.API.Interfaces
{
using CommandSystem;

/// <summary>
/// Represents an interface for commands with game permissions.
/// </summary>
public interface IGamePermissionCommand : ICommand
{
/// <summary>
/// Gets the permissions of a command.
/// </summary>
public PlayerPermissions[] Permissions { get; }
}
}
5 changes: 5 additions & 0 deletions Exiled.Events/Patches/Generic/ProcessQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ private static bool CheckPermissions(ICommand command, CommandSender sender)
sender.RaReply($"{command.Command}#You do not have permissions to use this command. Required permission: {permissionCommand.Permission}", false, true, string.Empty);
return false;
}
else if (command is IGamePermissionCommand gamePermissionCommand && !sender.CheckPermission(gamePermissionCommand.Permissions))
{
sender.RaReply($"{command.Command}#You do not have permissions to use this command. Required permission: PlayerPermissions: [{string.Join(" ", gamePermissionCommand.Permissions)}]", false, true, string.Empty);
return false;
}

return true;
}
Expand Down

0 comments on commit 0f38e97

Please sign in to comment.