Removed unused variable.. Added some more docs.

This commit is contained in:
Zack Piispanen 2012-06-01 13:34:15 -04:00
parent 896a8272c9
commit 99185c8c37

View file

@ -25,16 +25,52 @@ namespace TShockAPI
{ {
// NOTE: Using a const still suffers from needing to recompile to change the default // 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 :( // ideally we would use a static but this means it can't be used for the default parameter :(
/// <summary>
/// Default chat color.
/// </summary>
public const string defaultChatColor = "255.255.255"; public const string defaultChatColor = "255.255.255";
/// <summary>
/// List of permissions available to the group.
/// </summary>
public readonly List<string> permissions = new List<string>(); public readonly List<string> permissions = new List<string>();
/// <summary>
/// List of permissions that the group is explicitly barred from.
/// </summary>
public readonly List<string> negatedpermissions = new List<string>(); public readonly List<string> negatedpermissions = new List<string>();
/// <summary>
/// The group's name.
/// </summary>
public string Name { get; set; } public string Name { get; set; }
/// <summary>
/// The group that this group inherits permissions from.
/// </summary>
public Group Parent { get; set; } public Group Parent { get; set; }
public int Order { get; set; }
/// <summary>
/// The chat prefix for this group.
/// </summary>
public string Prefix { get; set; } public string Prefix { get; set; }
/// <summary>
/// The chat suffix for this group.
/// </summary>
public string Suffix { get; set; } public string Suffix { get; set; }
/// <summary>
/// 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.
/// </summary>
public string ParentName { get { return (null == Parent) ? "" : Parent.Name; } } public string ParentName { get { return (null == Parent) ? "" : Parent.Name; } }
/// <summary>
/// The chat color of the group.
/// Returns "255255255", sets "255,255,255"
/// </summary>
public string ChatColor public string ChatColor
{ {
get { return string.Format("{0}{1}{2}", R.ToString("X2"), G.ToString("X2"), B.ToString("X2")); } get { return string.Format("{0}{1}{2}", R.ToString("X2"), G.ToString("X2"), B.ToString("X2")); }
@ -58,6 +94,9 @@ namespace TShockAPI
} }
} }
/// <summary>
/// The permissions of the user in string form.
/// </summary>
public string Permissions public string Permissions
{ {
get get
@ -75,6 +114,9 @@ namespace TShockAPI
} }
} }
/// <summary>
/// The permissions of this group and all that it inherits from.
/// </summary>
public List<string> TotalPermissions public List<string> TotalPermissions
{ {
get get
@ -125,6 +167,11 @@ namespace TShockAPI
Permissions = permissions; Permissions = permissions;
} }
/// <summary>
/// Checks to see if a group has a specified permission.
/// </summary>
/// <param name="permission">The permission to check.</param>
/// <returns>Returns true if the user has that permission.</returns>
public virtual bool HasPermission(string permission) public virtual bool HasPermission(string permission)
{ {
if (string.IsNullOrEmpty(permission)) if (string.IsNullOrEmpty(permission))
@ -148,6 +195,10 @@ namespace TShockAPI
return false; return false;
} }
/// <summary>
/// Adds a permission to the list of negated permissions.
/// </summary>
/// <param name="permission">The permission to negate.</param>
public void NegatePermission(string permission) public void NegatePermission(string permission)
{ {
// Avoid duplicates // Avoid duplicates
@ -158,6 +209,10 @@ namespace TShockAPI
} }
} }
/// <summary>
/// Adds a permission to the list of permissions.
/// </summary>
/// <param name="permission">The permission to add.</param>
public void AddPermission(string permission) public void AddPermission(string permission)
{ {
if (permission.StartsWith("!")) if (permission.StartsWith("!"))
@ -173,6 +228,11 @@ namespace TShockAPI
} }
} }
/// <summary>
/// Clears the permission list and sets it to the list provided,
/// will parse "!permssion" and add it to the negated permissions.
/// </summary>
/// <param name="permission"></param>
public void SetPermission(List<string> permission) public void SetPermission(List<string> permission)
{ {
permissions.Clear(); permissions.Clear();
@ -180,6 +240,11 @@ namespace TShockAPI
permission.ForEach(p => AddPermission(p)); permission.ForEach(p => AddPermission(p));
} }
/// <summary>
/// Will remove a permission from the respective list,
/// where "!permission" will remove a negated permission.
/// </summary>
/// <param name="permission"></param>
public void RemovePermission(string permission) public void RemovePermission(string permission)
{ {
if (permission.StartsWith("!")) if (permission.StartsWith("!"))
@ -191,6 +256,9 @@ namespace TShockAPI
} }
} }
/// <summary>
/// This class is the SuperAdminGroup, which has access to everything.
/// </summary>
public class SuperAdminGroup : Group public class SuperAdminGroup : Group
{ {
public SuperAdminGroup() public SuperAdminGroup()
@ -203,6 +271,11 @@ namespace TShockAPI
Suffix = TShock.Config.SuperAdminChatSuffix; Suffix = TShock.Config.SuperAdminChatSuffix;
} }
/// <summary>
/// Override to allow access to everything.
/// </summary>
/// <param name="permission">The permission</param>
/// <returns>True</returns>
public override bool HasPermission(string permission) public override bool HasPermission(string permission)
{ {
return true; return true;