using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Mango.Players.Permissions { /// /// Permissions for a specific Player. /// sealed class PermissionComponent { /// /// Permission rights are stored here. /// private readonly List _permissions; public PermissionComponent() { this._permissions = new List(); } /// /// Initialize the PermissionComponent. /// /// public bool Init(Player Player) { if (_permissions.Count > 0) { throw new InvalidOperationException("Permissions cannot be re-initialized, use the reload method"); } List PermissionSet = Mango.GetServer().GetPermissionManager().GetPermissionsForPlayer(Player); this._permissions.AddRange(PermissionSet); return true; } /// /// Reloads the permissions. /// /// public void Reload(Player Player) { // Clear the permissions first. this._permissions.Clear(); // Reload the permissions. List PermissionSet = Mango.GetServer().GetPermissionManager().GetPermissionsForPlayer(Player); this._permissions.AddRange(PermissionSet); } /// /// Checks if the user has the specified right. /// /// /// public bool HasRight(string Right) { return this._permissions.Contains(Right); } } }