Cleanup, code review, comments.

This commit is contained in:
Pieter-Jan Briers
2020-11-10 21:30:20 +01:00
parent 7bc93bd2a9
commit 736f9958cc
12 changed files with 136 additions and 47 deletions

View File

@@ -21,8 +21,6 @@ namespace Content.Client.Administration
public event Action? AdminStatusUpdated;
public AdminFlags? Flags => _adminData?.Flags;
public bool HasFlag(AdminFlags flag)
{
return _adminData?.HasFlag(flag) ?? false;
@@ -67,12 +65,12 @@ namespace Content.Client.Administration
_adminData = message.Admin;
if (_adminData != null)
{
var flagsText = string.Join("|", AdminFlagsExt.FlagsToNames(_adminData.Flags));
var flagsText = string.Join("|", AdminFlagsHelper.FlagsToNames(_adminData.Flags));
Logger.InfoS("admin", $"Updated admin status: {_adminData.Active}/{_adminData.Title}/{flagsText}");
}
else
{
Logger.InfoS("admin", $"Updated admin status: Not admin");
Logger.InfoS("admin", "Updated admin status: Not admin");
}
AdminStatusUpdated?.Invoke();

View File

@@ -1,19 +1,50 @@
using System;
using Content.Shared.Administration;
#nullable enable
namespace Content.Client.Administration
{
/// <summary>
/// Manages server admin permissions for the local player.
/// </summary>
public interface IClientAdminManager
{
public event Action AdminStatusUpdated;
/// <summary>
/// Fired when the admin status of the local player changes, such as losing admin privileges.
/// </summary>
event Action AdminStatusUpdated;
AdminFlags? Flags { get; }
/// <summary>
/// Checks whether the local player has an admin flag.
/// </summary>
/// <param name="flag">The flags to check. Multiple flags can be specified, they must all be held.</param>
/// <returns>False if the local player is not an admin, inactive, or does not have all the flags specified.</returns>
bool HasFlag(AdminFlags flag);
/// <summary>
/// Check if a player can execute a specified console command.
/// </summary>
bool CanCommand(string cmdName);
/// <summary>
/// Check if the local player can open the VV menu.
/// </summary>
bool CanViewVar();
/// <summary>
/// Check if the local player can spawn stuff in with the entity/tile spawn panel.
/// </summary>
bool CanAdminPlace();
/// <summary>
/// Check if the local player can execute server-side C# scripts.
/// </summary>
bool CanScript();
/// <summary>
/// Check if the local player can open the admin menu.
/// </summary>
bool CanAdminMenu();
void Initialize();