Package wbs.utils.util.providers
Class NumProvider
java.lang.Object
wbs.utils.util.providers.NumProvider
- All Implemented Interfaces:
Provider,Refreshable
Represents a number (typically a double) that may either be static, or change over time
-
Constructor Summary
ConstructorsConstructorDescriptionNumProvider(double staticValue) Create this provider with a single static valueNumProvider(@NotNull DoubleGenerator generator) Create this provider with a given, pre-configured DoubleGeneratorNumProvider(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.NumProvider(NumProvider clone) Clone constructor. -
Method Summary
Modifier and TypeMethodDescriptionintintVal()Get the current value as an integervoidrefresh()Generate a new valuedoubleval()Get the current value this object representsvoidwriteToConfig(org.bukkit.configuration.ConfigurationSection section, String path) Save this provider in a config that can be read by the constructor
-
Constructor Details
-
NumProvider
Clone constructor.- Parameters:
clone- The object to clone from.
-
NumProvider
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 fromval()
-
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 providerfield- The key/field where this provider exists inside the given sectionsettings- The WbsSettings to log errors againstdirectory- 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 providerfield- The key/field where this provider exists inside the given sectionsettings- The WbsSettings to log errors againstdirectory- The path taken through the section to reach this provider, for logging purposesdefaultValue- 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:
refreshin interfaceRefreshable
-
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
Save this provider in a config that can be read by the constructor- Specified by:
writeToConfigin interfaceProvider- Parameters:
section- The section to write topath- The field/path inside the given section
-