From 99185c8c37c4cc1853f08a738a8baf7a12bf2a61 Mon Sep 17 00:00:00 2001 From: Zack Piispanen Date: Fri, 1 Jun 2012 13:34:15 -0400 Subject: [PATCH] Removed unused variable.. Added some more docs. --- TShockAPI/Group.cs | 75 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/TShockAPI/Group.cs b/TShockAPI/Group.cs index f6d41630..16e81345 100644 --- a/TShockAPI/Group.cs +++ b/TShockAPI/Group.cs @@ -25,16 +25,52 @@ namespace TShockAPI { // NOTE: Using a const still suffers from needing to recompile to change the default // ideally we would use a static but this means it can't be used for the default parameter :( + /// + /// Default chat color. + /// public const string defaultChatColor = "255.255.255"; + + /// + /// List of permissions available to the group. + /// public readonly List permissions = new List(); + + /// + /// List of permissions that the group is explicitly barred from. + /// public readonly List negatedpermissions = new List(); + /// + /// The group's name. + /// public string Name { get; set; } + + /// + /// The group that this group inherits permissions from. + /// public Group Parent { get; set; } - public int Order { get; set; } + + /// + /// The chat prefix for this group. + /// public string Prefix { get; set; } + + /// + /// The chat suffix for this group. + /// public string Suffix { get; set; } + + /// + /// The name of the parent, not particularly sure why this is here. + /// We can use group.Parent.Name and not have this second reference. + /// This was added for rest, so a discussion with Shank is necessary. + /// public string ParentName { get { return (null == Parent) ? "" : Parent.Name; } } + + /// + /// The chat color of the group. + /// Returns "255255255", sets "255,255,255" + /// public string ChatColor { get { return string.Format("{0}{1}{2}", R.ToString("X2"), G.ToString("X2"), B.ToString("X2")); } @@ -58,6 +94,9 @@ namespace TShockAPI } } + /// + /// The permissions of the user in string form. + /// public string Permissions { get @@ -75,6 +114,9 @@ namespace TShockAPI } } + /// + /// The permissions of this group and all that it inherits from. + /// public List TotalPermissions { get @@ -125,6 +167,11 @@ namespace TShockAPI Permissions = permissions; } + /// + /// Checks to see if a group has a specified permission. + /// + /// The permission to check. + /// Returns true if the user has that permission. public virtual bool HasPermission(string permission) { if (string.IsNullOrEmpty(permission)) @@ -148,6 +195,10 @@ namespace TShockAPI return false; } + /// + /// Adds a permission to the list of negated permissions. + /// + /// The permission to negate. public void NegatePermission(string permission) { // Avoid duplicates @@ -158,6 +209,10 @@ namespace TShockAPI } } + /// + /// Adds a permission to the list of permissions. + /// + /// The permission to add. public void AddPermission(string permission) { if (permission.StartsWith("!")) @@ -173,6 +228,11 @@ namespace TShockAPI } } + /// + /// Clears the permission list and sets it to the list provided, + /// will parse "!permssion" and add it to the negated permissions. + /// + /// public void SetPermission(List permission) { permissions.Clear(); @@ -180,6 +240,11 @@ namespace TShockAPI permission.ForEach(p => AddPermission(p)); } + /// + /// Will remove a permission from the respective list, + /// where "!permission" will remove a negated permission. + /// + /// public void RemovePermission(string permission) { if (permission.StartsWith("!")) @@ -191,6 +256,9 @@ namespace TShockAPI } } + /// + /// This class is the SuperAdminGroup, which has access to everything. + /// public class SuperAdminGroup : Group { public SuperAdminGroup() @@ -203,6 +271,11 @@ namespace TShockAPI Suffix = TShock.Config.SuperAdminChatSuffix; } + /// + /// Override to allow access to everything. + /// + /// The permission + /// True public override bool HasPermission(string permission) { return true;