Interface IPlayerConfigAPI


public interface IPlayerConfigAPI
API for a player config on the server side
  • Method Details

    • getPlayerId

      @Nullable UUID 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 null
      value - the value to set the option to, can be null but won't be accepted
      Returns:
      the result type of this action
    • getEffective

      @Nonnull <T extends Comparable<T>> T getEffective(@Nonnull IPlayerConfigOptionSpecAPI<T> option)
      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

      @Nullable <T extends Comparable<T>> T getRaw(@Nonnull IPlayerConfigOptionSpecAPI<T> o)
      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 in getDefaultRawValue(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

      @Nonnull PlayerConfigType getType()
      Gets the type PlayerConfigType of this config.
      Returns:
      the type of this config, not null
    • getSubConfig

      @Nullable IPlayerConfigAPI getSubConfig(@Nonnull String id)
      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

      @Nonnull IPlayerConfigAPI getEffectiveSubConfig(@Nonnull String id)
      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

      @Nonnull IPlayerConfigAPI getEffectiveSubConfig(int subIndex)
      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

      boolean subConfigExists(@Nonnull String id)
      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

      @Nonnull IPlayerConfigAPI getUsedSubConfig()
      Gets the sub-config currently used for new claims.
      Returns:
      the sub-config, not null
    • getUsedServerSubConfig

      @Nonnull IPlayerConfigAPI getUsedServerSubConfig()
      Gets the server sub-config currently used for new claims.
      Returns:
      the server sub-config, not null
    • createSubConfig

      @Nullable IPlayerConfigAPI createSubConfig(@Nonnull String id)
      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

      @Nullable String 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

      @Nonnull List<String> 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

      @Nonnull Stream<IPlayerConfigAPI> 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

      boolean isOptionAllowed(@Nonnull IPlayerConfigOptionSpecAPI<?> option)
      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