Class SettingBase
- Namespace
- Exiled.API.Features.Core.UserSettings
- Assembly
- Exiled.API.dll
A base class for all Server Specific Settings.
public class SettingBase : TypeCastObject<SettingBase>, IWrapper<ServerSpecificSettingBase>
- Inheritance
-
SettingBase
- Implements
-
IWrapper<ServerSpecificSettingBase>
- Derived
- Inherited Members
- Extension Methods
Properties
Base
Gets the base UserSettings.ServerSpecific.ServerSpecificSettingBase that this class is wrapping.
public ServerSpecificSettingBase Base { get; }
Property Value
- ServerSpecificSettingBase
Header
Gets or sets the header of this setting.
public HeaderSetting Header { get; set; }
Property Value
Remarks
Can be null
.
HintDescription
Gets or sets the description of this setting.
public string HintDescription { get; set; }
Property Value
Id
Gets or sets the id of this setting.
public int Id { get; set; }
Property Value
Label
Gets or sets the label of this setting.
public string Label { get; set; }
Property Value
List
Gets the list of settings that were used as a prefabs.
public static IReadOnlyCollection<SettingBase> List { get; }
Property Value
OnChanged
Gets or sets the action to be executed when this setting is changed.
public Action<Player, SettingBase> OnChanged { get; set; }
Property Value
OriginalDefinition
Gets the setting that was sent to players.
public SettingBase OriginalDefinition { get; }
Property Value
Remarks
Can be null
if this SettingBase is a prefab.
ResponseMode
Gets the response mode of this setting.
public ServerSpecificSettingBase.UserResponseMode ResponseMode { get; }
Property Value
- ServerSpecificSettingBase.UserResponseMode
SyncOnJoin
Gets or sets the predicate for syncing this setting when a player joins.
public static Predicate<Player> SyncOnJoin { get; set; }
Property Value
SyncedList
Gets the list of all synced settings.
public static IReadOnlyDictionary<Player, ReadOnlyCollection<SettingBase>> SyncedList { get; }
Property Value
Methods
Create(ServerSpecificSettingBase)
Creates a new instance of this setting.
public static SettingBase Create(ServerSpecificSettingBase settingBase)
Parameters
settingBase
ServerSpecificSettingBaseA UserSettings.ServerSpecific.ServerSpecificSettingBase instance.
Returns
- SettingBase
A new instance of this setting.
Remarks
This method is used only to create a new instance of SettingBase from an existing UserSettings.ServerSpecific.ServerSpecificSettingBase instance. New setting won't be synced with players.
Create<T>(ServerSpecificSettingBase)
Creates a new instance of this setting.
public static T Create<T>(ServerSpecificSettingBase settingBase) where T : SettingBase
Parameters
settingBase
ServerSpecificSettingBaseAUserSettings.ServerSpecific.ServerSpecificSettingBase instance.
Returns
- T
A new instance of this setting.
Type Parameters
T
Type of the setting.
Remarks
This method is used only to create a new instance of SettingBase from an existing UserSettings.ServerSpecific.ServerSpecificSettingBase instance. New setting won't be synced with players.
Register(IEnumerable<SettingBase>, Func<Player, bool>)
Registers all settings from the specified collection.
public static IEnumerable<SettingBase> Register(IEnumerable<SettingBase> settings, Func<Player, bool> predicate = null)
Parameters
settings
IEnumerable<SettingBase>A collection of settings to register.
predicate
Func<Player, bool>A requirement to meet when sending settings to players.
Returns
- IEnumerable<SettingBase>
A IEnumerable<T> of SettingBase instances that were successfully registered.
Remarks
This method is used to sync new settings with players.
SendToAll()
Syncs setting with all players.
public static void SendToAll()
SendToAll(Func<Player, bool>)
Syncs setting with all players according to the specified predicate.
public static void SendToAll(Func<Player, bool> predicate)
Parameters
SendToPlayer(Player)
Syncs setting with the specified target.
public static void SendToPlayer(Player player)
Parameters
player
PlayerTarget player.
SendToPlayer(Player, IEnumerable<SettingBase>)
Syncs specific settings with the specified target.
public static void SendToPlayer(Player player, IEnumerable<SettingBase> settings)
Parameters
player
PlayerTarget player.
settings
IEnumerable<SettingBase>Settings to send to the player.
ToString()
Returns a string representation of this SettingBase.
public override string ToString()
Returns
- string
A string in human-readable format.
TryGetSetting(Player, int, out SettingBase)
Tries to get the setting with the specified id.
public static bool TryGetSetting(Player player, int id, out SettingBase setting)
Parameters
player
PlayerPlayer who has received the setting.
id
intId of the setting.
setting
SettingBaseA SettingBase instance if found. Otherwise,
null
.
Returns
- bool
true
if the setting was found,false
otherwise.
TryGetSetting<T>(Player, int, out T)
Tries to get the setting with the specified id.
public static bool TryGetSetting<T>(Player player, int id, out T setting) where T : SettingBase
Parameters
player
PlayerPlayer who has received the setting.
id
intId of the setting.
setting
TA SettingBase instance if found. Otherwise,
null
.
Returns
- bool
true
if the setting was found,false
otherwise.
Type Parameters
T
Type of the setting.
Unregister(Func<Player, bool>, IEnumerable<SettingBase>)
Removes settings from players.
public static IEnumerable<SettingBase> Unregister(Func<Player, bool> predicate = null, IEnumerable<SettingBase> settings = null)
Parameters
predicate
Func<Player, bool>Determines which players will receive this update.
settings
IEnumerable<SettingBase>Settings to remove. If
null
, all settings will be removed.
Returns
- IEnumerable<SettingBase>
A IEnumerable<T> of SettingBase instances that were successfully removed.
Remarks
This method is used to unsync settings from players. Using it with Register(IEnumerable<SettingBase>, Func<Player, bool>) provides an opportunity to update synced settings.