Class NumProvider

java.lang.Object
wbs.utils.util.providers.NumProvider
All Implemented Interfaces:
Provider, Refreshable

public class NumProvider extends Object implements Provider
Represents a number (typically a double) that may either be static, or change over time
  • Constructor Summary

    Constructors
    Constructor
    Description
    NumProvider(double staticValue)
    Create this provider with a single static value
    NumProvider(@NotNull DoubleGenerator generator)
    Create this provider with a given, pre-configured DoubleGenerator
    NumProvider(org.bukkit.configuration.ConfigurationSection section, String field, WbsSettings settings, String directory)
    Create this provider from a configuration section, and log any errors against the given settings.
    NumProvider(org.bukkit.configuration.ConfigurationSection section, String field, WbsSettings settings, String directory, double defaultValue)
    Create this provider from a configuration section, and log any errors against the given settings.
    Clone constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Get the current value as an integer
    void
    Generate a new value
    double
    val()
    Get the current value this object represents
    void
    writeToConfig(org.bukkit.configuration.ConfigurationSection section, String path)
    Save this provider in a config that can be read by the constructor

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • NumProvider

      public NumProvider(NumProvider clone)
      Clone constructor.
      Parameters:
      clone - The object to clone from.
    • NumProvider

      public NumProvider(@NotNull @NotNull DoubleGenerator generator)
      Create this provider with a given, pre-configured DoubleGenerator
      Parameters:
      generator - The DoubleGenerator to generate numbers
    • NumProvider

      public NumProvider(double staticValue)
      Create this provider with a single static value
      Parameters:
      staticValue - The value to return from val()
    • NumProvider

      public NumProvider(org.bukkit.configuration.ConfigurationSection section, String field, WbsSettings settings, String directory)
      Create this provider from a configuration section, and log any errors against the given settings.
      Parameters:
      section - The parent section of the key-pair that contains this provider
      field - The key/field where this provider exists inside the given section
      settings - The WbsSettings to log errors against
      directory - The path taken through the section to reach this provider, for logging purposes
    • NumProvider

      public NumProvider(org.bukkit.configuration.ConfigurationSection section, String field, WbsSettings settings, String directory, double defaultValue)
      Create this provider from a configuration section, and log any errors against the given settings.
      Parameters:
      section - The parent section of the key-pair that contains this provider
      field - The key/field where this provider exists inside the given section
      settings - The WbsSettings to log errors against
      directory - The path taken through the section to reach this provider, for logging purposes
      defaultValue - The default double to use in case a double exists but is malformed
  • Method Details

    • refresh

      public void refresh()
      Generate a new value
      Specified by:
      refresh in interface Refreshable
    • val

      public double val()
      Get the current value this object represents
      Returns:
      The current value
    • intVal

      public int intVal()
      Get the current value as an integer
      Returns:
      The current integer value
    • writeToConfig

      public void writeToConfig(org.bukkit.configuration.ConfigurationSection section, String path)
      Save this provider in a config that can be read by the constructor
      Specified by:
      writeToConfig in interface Provider
      Parameters:
      section - The section to write to
      path - The field/path inside the given section