Table of Contents

Class CustomAbility

Namespace
Exiled.CustomRoles.API.Features
Assembly
Exiled.CustomRoles.dll

The custom ability base class.

public abstract class CustomAbility
Inheritance
CustomAbility
Derived
Inherited Members
Extension Methods

Constructors

CustomAbility()

Initializes a new instance of the CustomAbility class.

public CustomAbility()

Properties

AbilityType

Gets the Type for this ability.

public string AbilityType { get; }

Property Value

string

Description

Gets or sets the description of the ability.

public abstract string Description { get; set; }

Property Value

string

Name

Gets or sets the name of the ability.

public abstract string Name { get; set; }

Property Value

string

Players

Gets all players who have this ability.

[YamlIgnore]
public HashSet<Player> Players { get; }

Property Value

HashSet<Player>

Registered

Gets a list of all registered custom abilities.

public static HashSet<CustomAbility> Registered { get; }

Property Value

HashSet<CustomAbility>

Methods

AbilityAdded(Player)

Called when the ability is first added to the player.

protected virtual void AbilityAdded(Player player)

Parameters

player Player

The Player using the ability.

AbilityRemoved(Player)

Called when the ability is being removed.

protected virtual void AbilityRemoved(Player player)

Parameters

player Player

The Player using the ability.

AddAbility(Player)

Adds this ability to the player.

public void AddAbility(Player player)

Parameters

player Player

The Player to give the ability to.

Check(Player)

Checks to see if the specified player has this ability.

public virtual bool Check(Player player)

Parameters

player Player

The Player to check.

Returns

bool

True if the player has this ability.

Destroy()

Destroys this ability.

public void Destroy()

Get(string)

Gets a CustomAbility by name.

public static CustomAbility? Get(string name)

Parameters

name string

The name of the ability to get.

Returns

CustomAbility

The ability, or null if it doesn't exist.

Get(Type)

Gets a CustomAbility by type.

public static CustomAbility? Get(Type type)

Parameters

type Type

The type of the ability to get.

Returns

CustomAbility

The type, or null if it doesn't exist.

Init()

Initializes this ability.

public void Init()

RegisterAbilities(bool, object?)

Registers all the CustomAbility's present in the current assembly.

public static IEnumerable<CustomAbility> RegisterAbilities(bool skipReflection = false, object? overrideClass = null)

Parameters

skipReflection bool

Whether reflection is skipped (more efficient if you are not using your custom item classes as config objects).

overrideClass object

The class to search properties for, if different from the plugin's config class.

Returns

IEnumerable<CustomAbility>

A IEnumerable<T> of CustomAbility which contains all registered CustomAbility's.

RegisterAbilities(IEnumerable<Type>, bool, bool, object?)

Registers all the CustomAbility's present in the current assembly.

public static IEnumerable<CustomAbility> RegisterAbilities(IEnumerable<Type> targetTypes, bool isIgnored = false, bool skipReflection = false, object? overrideClass = null)

Parameters

targetTypes IEnumerable<Type>

The IEnumerable<T> of Type containing the target types.

isIgnored bool

A value indicating whether the target types should be ignored.

skipReflection bool

Whether reflection is skipped (more efficient if you are not using your custom item classes as config objects).

overrideClass object

The class to search properties for, if different from the plugin's config class.

Returns

IEnumerable<CustomAbility>

A IEnumerable<T> of CustomAbility which contains all registered CustomAbility's.

RemoveAbility(Player)

Removes this ability from the player.

public void RemoveAbility(Player player)

Parameters

player Player

The Player to remove this ability from.

SubscribeEvents()

Loads the internal event handlers for the ability.

protected virtual void SubscribeEvents()

TryGet(string, out CustomAbility?)

Tries to get a CustomAbility by name.

public static bool TryGet(string name, out CustomAbility? customAbility)

Parameters

name string

The name of the ability to get.

customAbility CustomAbility

The custom ability.

Returns

bool

True if the ability exists.

Exceptions

ArgumentNullException

If the name is null or an empty string.

TryGet(Type, out CustomAbility?)

Tries to get a CustomAbility by type.

public static bool TryGet(Type type, out CustomAbility? customAbility)

Parameters

type Type

The type of the ability to get.

customAbility CustomAbility

The custom ability.

Returns

bool

True if the ability exists, otherwise false.

UnregisterAbilities()

Unregisters all the CustomAbility's present in the current assembly.

public static IEnumerable<CustomAbility> UnregisterAbilities()

Returns

IEnumerable<CustomAbility>

A IEnumerable<T> of CustomAbility which contains all unregistered CustomAbility's.

UnregisterAbilities(IEnumerable<CustomAbility>, bool)

Unregisters all the CustomAbility's present in the current assembly.

public static IEnumerable<CustomAbility> UnregisterAbilities(IEnumerable<CustomAbility> targetAbilities, bool isIgnored = false)

Parameters

targetAbilities IEnumerable<CustomAbility>

The IEnumerable<T> of CustomAbility containing the target roles.

isIgnored bool

A value indicating whether the target abilities should be ignored.

Returns

IEnumerable<CustomAbility>

A IEnumerable<T> of CustomAbility which contains all unregistered CustomAbility's.

UnregisterAbilities(IEnumerable<Type>, bool)

Unregisters all the CustomAbility's present in the current assembly.

public static IEnumerable<CustomAbility> UnregisterAbilities(IEnumerable<Type> targetTypes, bool isIgnored = false)

Parameters

targetTypes IEnumerable<Type>

The IEnumerable<T> of Type containing the target types.

isIgnored bool

A value indicating whether the target types should be ignored.

Returns

IEnumerable<CustomAbility>

A IEnumerable<T> of CustomAbility which contains all unregistered CustomAbility's.

UnsubscribeEvents()

Unloads the internal event handlers for the ability.

protected virtual void UnsubscribeEvents()