Table of Contents

Struct PermissionLeaf

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

Represents an absolute permission with no wildcards or additive/subtractive metadata.

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

Remarks

Stolen from DevkitServer.

Constructors

PermissionLeaf(string)

Parse a permission leaf with or without a prefix.

public PermissionLeaf(string path)

Parameters

path string

Remarks

Permission leafs without prefixes will be invalid.

Exceptions

FormatException

Parse failure.

Fields

InvalidPrefix

Prefix for invalid permissions.

public const string InvalidPrefix = "unknown"

Field Value

string

Nil

A permission that can never be met.

public static readonly PermissionLeaf Nil

Field Value

PermissionLeaf

UnturnedModulePrefix

Prefix for Core permissions.

public const string UnturnedModulePrefix = "unturned"

Field Value

string

WarfareModulePrefix

Prefix for Warfare module permissions.

public const string WarfareModulePrefix = "warfare"

Field Value

string

Properties

Level

Permission depth level (number of periods plus one).

public int Level { get; }

Property Value

int

Path

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

public string Path { get; }

Property Value

string

Remarks

Example: request.vehicle.

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

Methods

CountLevels(string)

Count the number of levels in a path. Example: warfare::request.vehicle would return 2.

public static int CountLevels(string path)

Parameters

path string

Returns

int

Remarks

Can optionally have a prefix.

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.

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 leaf: warfare::request.vehicle.

Parse(string)

Parse a permission leaf with a prefix.

public static PermissionLeaf Parse(string path)

Parameters

path string

Returns

PermissionLeaf

Exceptions

FormatException

Parse failure.

Read(ByteReader)

public static PermissionLeaf Read(ByteReader reader)

Parameters

reader ByteReader

Returns

PermissionLeaf

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 PermissionLeaf)

Parse a permission leaf with a prefix.

public static bool TryParse(string path, out PermissionLeaf permissionLeaf)

Parameters

path string
permissionLeaf PermissionLeaf

Returns

bool

true after a successful parse, otherwise false.

Write(ByteWriter, PermissionLeaf)

public static void Write(ByteWriter writer, PermissionLeaf leaf)

Parameters

writer ByteWriter
leaf PermissionLeaf

Operators

operator ==(PermissionLeaf, PermissionLeaf)

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

Parameters

left PermissionLeaf
right PermissionLeaf

Returns

bool

implicit operator PermissionBranch(PermissionLeaf)

public static implicit operator PermissionBranch(PermissionLeaf leaf)

Parameters

leaf PermissionLeaf

Returns

PermissionBranch

operator !=(PermissionLeaf, PermissionLeaf)

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

Parameters

left PermissionLeaf
right PermissionLeaf

Returns

bool