Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group changes #2951

Open
wants to merge 6 commits into
base: general-devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions TShockAPI/Group.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ You should have received a copy of the GNU General Public License
using System.Linq;
using System.Collections.Generic;

using Microsoft.Xna.Framework;

namespace TShockAPI
{
/// <summary>
Expand Down Expand Up @@ -52,17 +54,17 @@ public class Group
/// <summary>
/// The group that this group inherits permissions from.
/// </summary>
public Group Parent { get; set; }
public virtual Group Parent { get; set; }

/// <summary>
/// The chat prefix for this group.
/// </summary>
public string Prefix { get; set; }
public virtual string Prefix { get; set; }

/// <summary>
/// The chat suffix for this group.
/// </summary>
public string Suffix { get; set; }
public virtual string Suffix { get; set; }

/// <summary>
/// The name of the parent, not particularly sure why this is here.
Expand Down Expand Up @@ -164,6 +166,20 @@ public virtual List<string> TotalPermissions
/// </summary>
public byte B = 255;

/// <summary>
/// Simplifies work with the <see cref="R"/>, <see cref="G"/>, <see cref="B"/> properties.
/// </summary>
public virtual Color Color
{
get => new Color(R, G, B);
set
{
R = value.R;
G = value.G;
B = value.B;
}
}

/// <summary>
/// The default group attributed to unregistered users.
/// </summary>
Expand Down Expand Up @@ -242,7 +258,7 @@ private bool RealHasPermission(string permission, ref bool negated)
/// Adds a permission to the list of negated permissions.
/// </summary>
/// <param name="permission">The permission to negate.</param>
public void NegatePermission(string permission)
public virtual void NegatePermission(string permission)
{
// Avoid duplicates
if (!negatedpermissions.Contains(permission))
Expand All @@ -256,7 +272,7 @@ public void NegatePermission(string permission)
/// Adds a permission to the list of permissions.
/// </summary>
/// <param name="permission">The permission to add.</param>
public void AddPermission(string permission)
public virtual void AddPermission(string permission)
{
if (permission.StartsWith("!"))
{
Expand All @@ -276,7 +292,7 @@ public void AddPermission(string permission)
/// will parse "!permission" and add it to the negated permissions.
/// </summary>
/// <param name="permission">The new list of permissions to associate with the group.</param>
public void SetPermission(List<string> permission)
public virtual void SetPermission(List<string> permission)
{
permissions.Clear();
negatedpermissions.Clear();
Expand All @@ -288,7 +304,7 @@ public void SetPermission(List<string> permission)
/// where "!permission" will remove a negated permission.
/// </summary>
/// <param name="permission"></param>
public void RemovePermission(string permission)
public virtual void RemovePermission(string permission)
{
if (permission.StartsWith("!"))
{
Expand All @@ -302,7 +318,7 @@ public void RemovePermission(string permission)
/// Assigns all fields of this instance to another.
/// </summary>
/// <param name="otherGroup">The other instance.</param>
public void AssignTo(Group otherGroup)
public virtual void AssignTo(Group otherGroup)
{
otherGroup.Name = Name;
otherGroup.Parent = Parent;
Expand Down
2 changes: 1 addition & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Use past tense when adding new entries; sign your name off when you add or chang
* If there is no section called "Upcoming changes" below this line, please add one with `## Upcoming changes` as the first line, and then a bulleted item directly after with the first change. -->

## Upcoming changes
Your changes could be here!
* Added more modification options to `Group`. (@AgaSpace)

## TShock 5.2
* An additional option `pvpwithnoteam` is added at `PvPMode` to enable PVP with no team. (@CelestialAnarchy, #2617, @ATFGK)
Expand Down