Added TranslateList and JSON parity
This commit is contained in:
@@ -4,6 +4,7 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.willfp.eco.core.config.Config;
|
||||
import com.willfp.eco.core.config.JSONConfig;
|
||||
import com.willfp.eco.util.StringUtils;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@@ -272,7 +273,7 @@ public abstract class JSONConfigWrapper implements JSONConfig, Cloneable {
|
||||
@Override
|
||||
@NotNull
|
||||
public String getString(@NotNull final String path) {
|
||||
return Objects.requireNonNullElse(getOfKnownType(path, String.class), "");
|
||||
return StringUtils.translate(Objects.requireNonNullElse(getOfKnownType(path, String.class), ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,6 +39,32 @@ public class StringUtils {
|
||||
.add(Pattern.compile("<#" + "([A-Fa-f0-9]{6})" + ">"))
|
||||
.build();
|
||||
|
||||
/**
|
||||
* Translate a list of strings - converts Placeholders and Color codes.
|
||||
*
|
||||
* @param list The messages to translate.
|
||||
* @param player The player to translate placeholders with respect to.
|
||||
* @return The message, translated.
|
||||
*/
|
||||
public List<String> translateList(@NotNull final List<String> list,
|
||||
@Nullable final Player player) {
|
||||
list.replaceAll(s -> translate(s, player));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate a list of strings - converts Placeholders and Color codes.
|
||||
*
|
||||
* @param list The messages to translate.
|
||||
* @return The message, translated.
|
||||
*/
|
||||
public List<String> translateList(@NotNull final List<String> list) {
|
||||
list.replaceAll(s -> translate(s, null));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate a string - converts Placeholders and Color codes.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user