Interface IPlayerConfigAPI
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enum
All possible result types when trying to set an option value -
Method Summary
Modifier and TypeMethodDescriptionCreates a new sub-config for a specified sub-config ID when possible.<T extends Comparable<T>>
TgetDefaultRawValue
(IPlayerConfigOptionSpecAPI<T> option) Gets the default raw value in this config for an option.<T extends Comparable<T>>
TgetEffective
(IPlayerConfigOptionSpecAPI<T> option) Gets the effective value of a config option.getEffectiveSubConfig
(int subIndex) Gets a sub-config of this config from a specified sub-config index.Gets a sub-config of this config from a specified sub-config ID.<T extends Comparable<T>>
TgetFromEffectiveConfig
(IPlayerConfigOptionSpecAPI<T> option) Gets the raw config value from the effective config of a config option, e.g.Gets the UUID of the player that this config is for.<T extends Comparable<T>>
TGets the raw config value from this config, which can be null in the case of sub-configs.getSubConfig
(String id) Gets a sub-config of this config from a specified sub-config ID.Gets a stream of all sub-configs of this player config.Gets an unmodifiable list of all string IDs of this config's sub-configs.int
Gets the maximum number of sub-configs that this player config is allowed to have.int
Gets the number of sub-configs that this config has.getSubId()
Gets the sub-config ID of this config.int
Gets the sub-config index of this config.getType()
Gets the typePlayerConfigType
of this config.Gets the server sub-config currently used for new claims.Gets the sub-config currently used for new claims.boolean
Checks whether this player (sub-)config is in the process of being deleted.boolean
isOptionAllowed
(IPlayerConfigOptionSpecAPI<?> option) Checks whether an option is allowed in this config.boolean
subConfigExists
(int subIndex) Checks whether a sub-config with a specified index exists.boolean
Checks whether a sub-config with a specified string ID exists.<T extends Comparable<T>>
IPlayerConfigAPI.SetResulttryToReset
(IPlayerConfigOptionSpecAPI<T> option) Tries to reset the value of a specified config option to the default raw value, as ingetDefaultRawValue(xaero.pac.common.server.player.config.api.IPlayerConfigOptionSpecAPI<T>)
.<T extends Comparable<T>>
IPlayerConfigAPI.SetResulttryToSet
(IPlayerConfigOptionSpecAPI<T> option, T value) Tries to set the value of a specified config option to a specified value.
-
Method Details
-
getPlayerId
Gets the UUID of the player that this config is for.- Returns:
- the UUID of the config owner, null if wilderness
-
tryToSet
@Nonnull <T extends Comparable<T>> IPlayerConfigAPI.SetResult tryToSet(@Nonnull IPlayerConfigOptionSpecAPI<T> option, @Nullable T value) Tries to set the value of a specified config option to a specified value.This won't succeed if the specified option is forced to the default config value (by the server mod config) or if the specified value isn't valid for the specified option. In any case, you will receive a
IPlayerConfigAPI.SetResult
.All player config option types are statically accessible in
PlayerConfigOptions
.- Type Parameters:
T
- the type of the option value- Parameters:
option
- the type of the option to set, not nullvalue
- the value to set the option to, can be null but won't be accepted- Returns:
- the result type of this action
-
getEffective
Gets the effective value of a config option.This method calculates the automatic option value if such is used, e.g. the claims color, while
getFromEffectiveConfig(xaero.pac.common.server.player.config.api.IPlayerConfigOptionSpecAPI<T>)
just gets the effective raw value.All player config option types are statically accessible in
PlayerConfigOptions
.- Type Parameters:
T
- the type of the option value- Parameters:
option
- the type of the option, not null- Returns:
- the effective value of the option, not null
-
getFromEffectiveConfig
@Nonnull <T extends Comparable<T>> T getFromEffectiveConfig(@Nonnull IPlayerConfigOptionSpecAPI<T> option) Gets the raw config value from the effective config of a config option, e.g. from the default player config for options that cannot be set per player.This method does not calculate the automatic option value if such is used, e.g. the claims color.
All player config option types are statically accessible in
PlayerConfigOptions
.- Type Parameters:
T
- the type of the option value- Parameters:
option
- the type of the option, not null- Returns:
- the raw effective value of the option, not null
-
getRaw
Gets the raw config value from this config, which can be null in the case of sub-configs.- Type Parameters:
T
- the type of the option value- Parameters:
o
- the type of the option, not null- Returns:
- the raw value of the option, can be null
-
tryToReset
@Nonnull <T extends Comparable<T>> IPlayerConfigAPI.SetResult tryToReset(@Nonnull IPlayerConfigOptionSpecAPI<T> option) Tries to reset the value of a specified config option to the default raw value, as ingetDefaultRawValue(xaero.pac.common.server.player.config.api.IPlayerConfigOptionSpecAPI<T>)
.You will receive a
IPlayerConfigAPI.SetResult
.All player config option types are statically accessible in
PlayerConfigOptions
.- Type Parameters:
T
- the type of the option value- Parameters:
option
- the type of the option to set, not null- Returns:
- the result type of this action
-
getType
Gets the typePlayerConfigType
of this config.- Returns:
- the type of this config, not null
-
getSubConfig
Gets a sub-config of this config from a specified sub-config ID.Gets this config, if the specified sub-config ID is "main".
- Parameters:
id
- the string ID of the sub-config, not null- Returns:
- the sub-config, null if it doesn't exist
-
getEffectiveSubConfig
Gets a sub-config of this config from a specified sub-config ID.Gets this config, if the specified sub-config ID is "main" or isn't used.
- Parameters:
id
- the string ID of the sub-config, not null- Returns:
- the effective sub-config, not null
-
getEffectiveSubConfig
Gets a sub-config of this config from a specified sub-config index.Gets this config, if the specified sub-config index is -1 or isn't used.
- Parameters:
subIndex
- the sub-config index- Returns:
- the effective sub-config, not null
-
subConfigExists
Checks whether a sub-config with a specified string ID exists.Does not consider "main" a sub-config.
- Parameters:
id
- the string ID of the sub-config, not null- Returns:
- true, if the sub-config exists, otherwise false
-
subConfigExists
boolean subConfigExists(int subIndex) Checks whether a sub-config with a specified index exists.Does not consider "main" a sub-config.
- Parameters:
subIndex
- the sub-config index- Returns:
- true, if the sub-config exists, otherwise false
-
getUsedSubConfig
Gets the sub-config currently used for new claims.- Returns:
- the sub-config, not null
-
getUsedServerSubConfig
Gets the server sub-config currently used for new claims.- Returns:
- the server sub-config, not null
-
createSubConfig
Creates a new sub-config for a specified sub-config ID when possible.The sub-config ID must be unique, at most 16 characters long and consist of A-Z, a-z, 0-9, '-', '_'.
- Parameters:
id
- the sub-config ID for the creates sub-config- Returns:
- the newly creates sub-config, null if wasn't successful
-
getSubId
Gets the sub-config ID of this config.- Returns:
- the string sub-config ID of this config, null when not a sub-config
-
getSubIndex
int getSubIndex()Gets the sub-config index of this config.- Returns:
- the sub-config index of this config, -1 when not a sub-config
-
getSubCount
int getSubCount()Gets the number of sub-configs that this config has.- Returns:
- the number of sub-configs
-
getSubConfigIds
Gets an unmodifiable list of all string IDs of this config's sub-configs.This must not be a sub-config in itself!
- Returns:
- an unmodifiable
List<String>
of sub-config IDs
-
getSubConfigAPIStream
Gets a stream of all sub-configs of this player config.- Returns:
- the stream of sub-configs, not null
-
getDefaultRawValue
@Nullable <T extends Comparable<T>> T getDefaultRawValue(@Nonnull IPlayerConfigOptionSpecAPI<T> option) Gets the default raw value in this config for an option.This does not redirect to the default player config. It gives you the actual default value for a config option. In the cause of sub-configs, the default raw value is always null.
All player config option types are statically accessible in
PlayerConfigOptions
.- Type Parameters:
T
- the type of the option value- Parameters:
option
- the type of the option, not null- Returns:
- the default raw option value in this config, always null for sub-configs
-
isOptionAllowed
Checks whether an option is allowed in this config.- Parameters:
option
- the option type, not null- Returns:
- true, if the option is allowed, otherwise false
-
isBeingDeleted
boolean isBeingDeleted()Checks whether this player (sub-)config is in the process of being deleted.This is typically only ever true for sub-configs.
- Returns:
- true if this player (sub-)config is in the process of being deleted, otherwise false
-
getSubConfigLimit
int getSubConfigLimit()Gets the maximum number of sub-configs that this player config is allowed to have.Returns 0 if this is a sub-config. Returns the maximum int value if this is a server claims config.
- Returns:
- the sub-config limit
-