Compare commits

...

2 Commits
5.7.0 ... 5.7.1

Author SHA1 Message Date
Auxilor
9275b22f72 Updated to 5.7.1 2021-07-09 22:32:14 +02:00
Auxilor
cc8392afd1 Added Config#getStrings(path, format) 2021-07-09 22:32:00 +02:00
4 changed files with 32 additions and 3 deletions

View File

@@ -173,6 +173,8 @@ public interface Config {
/**
* Get a list of strings from config.
* <p>
* Formatted by default.
*
* @param path The key to fetch the value from.
* @return The found value, or a blank {@link java.util.ArrayList} if not found.
@@ -180,6 +182,17 @@ public interface Config {
@NotNull
List<String> getStrings(@NotNull String path);
/**
* Get a list of strings from config.
*
* @param path The key to fetch the value from.
* @param format If the strings should be formatted.
* @return The found value, or a blank {@link java.util.ArrayList} if not found.
*/
@NotNull
List<String> getStrings(@NotNull String path,
boolean format);
/**
* Get a list of strings from config.
*

View File

@@ -294,7 +294,16 @@ public abstract class JsonConfigWrapper implements JSONConfig, Cloneable {
@Override
@NotNull
public List<String> getStrings(@NotNull final String path) {
return StringUtils.translateList((List<String>) Objects.requireNonNullElse(getOfKnownType(path, Object.class), new ArrayList<>()));
return getStrings(path, true);
}
@Override
@NotNull
public List<String> getStrings(@NotNull final String path,
final boolean format) {
List<String> strings = (List<String>) Objects.requireNonNullElse(getOfKnownType(path, Object.class), new ArrayList<>());
return format ? StringUtils.translateList(strings) : strings;
}
@Override

View File

@@ -219,8 +219,15 @@ public abstract class YamlConfigWrapper<T extends ConfigurationSection> implemen
@Override
@NotNull
public List<String> getStrings(@NotNull final String path) {
return getStrings(path, true);
}
@Override
@NotNull
public List<String> getStrings(@NotNull final String path,
final boolean format) {
if (cache.containsKey(path)) {
return StringUtils.translateList((List<String>) cache.get(path));
return format ? StringUtils.translateList((List<String>) cache.get(path)) : (List<String>) cache.get(path);
} else {
cache.put(path, has(path) ? new ArrayList<>(handle.getStringList(path)) : new ArrayList<>());
return getStrings(path);

View File

@@ -1,2 +1,2 @@
version = 5.7.0
version = 5.7.1
plugin-name = eco