mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2025-02-17 04:41:21 +01:00
Created ValueGetter interface
This commit is contained in:
parent
8c2eddd2b2
commit
40f237317e
@ -17,7 +17,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public abstract class BaseConfig extends PluginDependent {
|
||||
public abstract class BaseConfig extends PluginDependent implements ValueGetter {
|
||||
/**
|
||||
* The linked {@link YamlConfiguration} where values are physically stored.
|
||||
*/
|
||||
@ -115,6 +115,7 @@ public abstract class BaseConfig extends PluginDependent {
|
||||
* @param path The key to fetch the value from.
|
||||
* @return The found value, or 0 if not found.
|
||||
*/
|
||||
@Override
|
||||
public int getInt(@NotNull final String path) {
|
||||
return config.getInt(path, 0);
|
||||
}
|
||||
@ -126,6 +127,7 @@ public abstract class BaseConfig extends PluginDependent {
|
||||
* @param def The value to default to if not found.
|
||||
* @return The found value, or the default.
|
||||
*/
|
||||
@Override
|
||||
public int getInt(@NotNull final String path,
|
||||
final int def) {
|
||||
return config.getInt(path, def);
|
||||
@ -137,6 +139,7 @@ public abstract class BaseConfig extends PluginDependent {
|
||||
* @param path The key to fetch the value from.
|
||||
* @return The found value, or a blank {@link java.util.ArrayList} if not found.
|
||||
*/
|
||||
@Override
|
||||
@NotNull
|
||||
public List<Integer> getInts(@NotNull final String path) {
|
||||
return config.getIntegerList(path);
|
||||
@ -148,6 +151,7 @@ public abstract class BaseConfig extends PluginDependent {
|
||||
* @param path The key to fetch the value from.
|
||||
* @return The found value, or false if not found.
|
||||
*/
|
||||
@Override
|
||||
public boolean getBool(@NotNull final String path) {
|
||||
return config.getBoolean(path, false);
|
||||
}
|
||||
@ -158,17 +162,19 @@ public abstract class BaseConfig extends PluginDependent {
|
||||
* @param path The key to fetch the value from.
|
||||
* @return The found value, or a blank {@link java.util.ArrayList} if not found.
|
||||
*/
|
||||
@Override
|
||||
@NotNull
|
||||
public List<Boolean> getBools(@NotNull final String path) {
|
||||
return config.getBooleanList(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a string from config.
|
||||
* Get a string from config.C
|
||||
*
|
||||
* @param path The key to fetch the value from.
|
||||
* @return The found value, or an empty string if not found.
|
||||
*/
|
||||
@Override
|
||||
@NotNull
|
||||
public String getString(@NotNull final String path) {
|
||||
return Objects.requireNonNull(config.getString(path, ""));
|
||||
@ -180,6 +186,7 @@ public abstract class BaseConfig extends PluginDependent {
|
||||
* @param path The key to fetch the value from.
|
||||
* @return The found value, or a blank {@link java.util.ArrayList} if not found.
|
||||
*/
|
||||
@Override
|
||||
@NotNull
|
||||
public List<String> getStrings(@NotNull final String path) {
|
||||
return config.getStringList(path);
|
||||
@ -191,6 +198,7 @@ public abstract class BaseConfig extends PluginDependent {
|
||||
* @param path The key to fetch the value from.
|
||||
* @return The found value, or 0 if not found.
|
||||
*/
|
||||
@Override
|
||||
public double getDouble(@NotNull final String path) {
|
||||
return config.getDouble(path, 0);
|
||||
}
|
||||
@ -201,6 +209,7 @@ public abstract class BaseConfig extends PluginDependent {
|
||||
* @param path The key to fetch the value from.
|
||||
* @return The found value, or a blank {@link java.util.ArrayList} if not found.
|
||||
*/
|
||||
@Override
|
||||
@NotNull
|
||||
public List<Double> getDoubles(@NotNull final String path) {
|
||||
return config.getDoubleList(path);
|
||||
|
@ -0,0 +1,87 @@
|
||||
package com.willfp.eco.util.config;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ValueGetter {
|
||||
|
||||
/**
|
||||
* Get an integer from config.
|
||||
*
|
||||
* @param path The key to fetch the value from.
|
||||
* @return The found value, or 0 if not found.
|
||||
*/
|
||||
int getInt(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Get an integer from config with a specified default (not found) value.
|
||||
*
|
||||
* @param path The key to fetch the value from.
|
||||
* @param def The value to default to if not found.
|
||||
* @return The found value, or the default.
|
||||
*/
|
||||
int getInt(@NotNull String path,
|
||||
int def);
|
||||
|
||||
/**
|
||||
* Get a list of integers from config.
|
||||
*
|
||||
* @param path The key to fetch the value from.
|
||||
* @return The found value, or a blank {@link java.util.ArrayList} if not found.
|
||||
*/
|
||||
@NotNull
|
||||
List<Integer> getInts(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Get a boolean from config.
|
||||
*
|
||||
* @param path The key to fetch the value from.
|
||||
* @return The found value, or false if not found.
|
||||
*/
|
||||
boolean getBool(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Get a list of booleans from config.
|
||||
*
|
||||
* @param path The key to fetch the value from.
|
||||
* @return The found value, or a blank {@link java.util.ArrayList} if not found.
|
||||
*/
|
||||
@NotNull
|
||||
List<Boolean> getBools(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Get a string from config.
|
||||
*
|
||||
* @param path The key to fetch the value from.
|
||||
* @return The found value, or an empty string if not found.
|
||||
*/
|
||||
@NotNull
|
||||
String getString(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Get a list of strings from config.
|
||||
*
|
||||
* @param path The key to fetch the value from.
|
||||
* @return The found value, or a blank {@link java.util.ArrayList} if not found.
|
||||
*/
|
||||
@NotNull
|
||||
List<String> getStrings(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Get a decimal from config.
|
||||
*
|
||||
* @param path The key to fetch the value from.
|
||||
* @return The found value, or 0 if not found.
|
||||
*/
|
||||
double getDouble(@NotNull String path);
|
||||
|
||||
/**
|
||||
* Get a list of decimals from config.
|
||||
*
|
||||
* @param path The key to fetch the value from.
|
||||
* @return The found value, or a blank {@link java.util.ArrayList} if not found.
|
||||
*/
|
||||
@NotNull
|
||||
List<Double> getDoubles(@NotNull String path);
|
||||
}
|
Loading…
Reference in New Issue
Block a user