Table of Contents

Struct PermissionBranch

Namespace
Uncreated.Warfare.Players.Permissions
Assembly
Uncreated.Warfare.dll

Represents a relative permission with wildcards and additive/subtractive metadata.

[JsonConverter(typeof(PermissionBranchJsonConverter))]
public readonly struct PermissionBranch : IEquatable<PermissionBranch>, IEquatable<PermissionLeaf>, ITranslationArgument
Implements
Inherited Members
Extension Methods

Remarks

Stolen from DevkitServer.

Constructors

PermissionBranch(string)

Parse a permission branch with a prefix.

public PermissionBranch(string path)

Parameters

path string

Exceptions

FormatException

Parse failure.

Fields

Superuser

Additive superuser branch. Unlocks all permissions.

public static readonly PermissionBranch Superuser

Field Value

PermissionBranch

SuperuserSubtractive

Removes a superuser permission branch which would've unlocked all permissions. Doesn't necessarily remove all permissions.

public static readonly PermissionBranch SuperuserSubtractive

Field Value

PermissionBranch

Properties

IsAbsolute

If this branch doesn't contain a wildcard.

public bool IsAbsolute { get; }

Property Value

bool

IsSuperuser

Is this the superuser permission (unlocks all permissions).

public bool IsSuperuser { get; }

Property Value

bool

Mode

How this branch affects existing permissions. Additive gives the permission, subtractive removes it.

public PermissionMode Mode { get; }

Property Value

PermissionMode

Path

The path relative to the branch's domain. The domain is the permission prefix of the permission owner.

public string Path { get; }

Property Value

string

Remarks

Example: request.*.

Unturned

Is this permission relating to the base game?

public bool Unturned { get; }

Property Value

bool

Valid

Is this permission valid (has a path and a source definition)?

public bool Valid { get; }

Property Value

bool

Warfare

Is this permission relating to Uncreated Warfare?

public bool Warfare { get; }

Property Value

bool

WildcardLevel

Permission depth level (number of periods plus one) where the wildcard is at, or zero for absolute permissions.

public int WildcardLevel { get; }

Property Value

int

Remarks

Example: warfare::request.* would be 2.

Methods

Contains(PermissionBranch)

If branch (and any leaves it contains) would be included in this branch.

public bool Contains(PermissionBranch branch)

Parameters

branch PermissionBranch

Returns

bool

Remarks

Does not check Mode.

Contains(PermissionLeaf)

If leaf would be included in this branch.

public bool Contains(PermissionLeaf leaf)

Parameters

leaf PermissionLeaf

Returns

bool

Remarks

Does not check Mode.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

Equals(PermissionBranch)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(PermissionBranch branch)

Parameters

branch PermissionBranch

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(PermissionLeaf)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(PermissionLeaf leaf)

Parameters

leaf PermissionLeaf

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

EqualsWithoutMode(PermissionBranch)

public bool EqualsWithoutMode(PermissionBranch branch)

Parameters

branch PermissionBranch

Returns

bool

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

GetPrefix()

Get the permission prefix.

public string GetPrefix()

Returns

string

Remarks

Looks like this when placed in a full permission branch: warfare::request.*.

GetWildcardLevel(string)

Get the wildcard level in a path. Example: warfare::request.* would return 2. If there's no wildcard zero is returned.

public static int GetWildcardLevel(string path)

Parameters

path string

Returns

int

Remarks

Can optionally have a prefix.

Parse(string)

Parse a permission branch with a prefix.

public static PermissionBranch Parse(string path)

Parameters

path string

Returns

PermissionBranch

Exceptions

FormatException

Parse failure.

Read(ByteReader)

public static PermissionBranch Read(ByteReader reader)

Parameters

reader ByteReader

Returns

PermissionBranch

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.

Translate(ITranslationValueFormatter, in ValueFormatParameters)

Allows objects to define how they're translated in their own definition instead of creating a value converter.

public string Translate(ITranslationValueFormatter formatter, in ValueFormatParameters parameters)

Parameters

formatter ITranslationValueFormatter
parameters ValueFormatParameters

Returns

string

TryParse(string, out PermissionBranch)

Parse a permission branch with a prefix.

public static bool TryParse(string path, out PermissionBranch permissionBranch)

Parameters

path string
permissionBranch PermissionBranch

Returns

bool

true after a successful parse, otherwise false.

Write(ByteWriter, PermissionBranch)

public static void Write(ByteWriter writer, PermissionBranch branch)

Parameters

writer ByteWriter
branch PermissionBranch

Operators

operator ==(PermissionBranch, PermissionBranch)

public static bool operator ==(PermissionBranch left, PermissionBranch right)

Parameters

left PermissionBranch
right PermissionBranch

Returns

bool

explicit operator PermissionLeaf(PermissionBranch)

public static explicit operator PermissionLeaf(PermissionBranch branch)

Parameters

branch PermissionBranch

Returns

PermissionLeaf

operator !=(PermissionBranch, PermissionBranch)

public static bool operator !=(PermissionBranch left, PermissionBranch right)

Parameters

left PermissionBranch
right PermissionBranch

Returns

bool