use of no.stelar7.api.l4j8.basic.utils.Pair in project L4J8 by stelar7.
the class DDragonAPI method getLanguageStrings.
public Map<String, String> getLanguageStrings(String version, String locale) {
DataCallBuilder builder = new DataCallBuilder().withLimiters(false).withProxy(Constants.DDRAGON_PROXY).withEndpoint(URLEndpoint.DDRAGON_LANGUAGE_STRINGS);
builder.withURLParameter(Constants.VERSION_PLACEHOLDER, version == null ? getVersions().get(0) : version);
builder.withURLParameter(Constants.LOCALE_PLACEHOLDER, locale == null ? "en_US" : locale);
Map<String, Object> data = new TreeMap<>();
data.put("version", version);
data.put("locale", locale);
Optional<?> chl = DataCall.getCacheProvider().get(URLEndpoint.DDRAGON_LANGUAGE_STRINGS, data);
if (chl.isPresent()) {
return ((LanguageStrings) chl.get()).getData();
}
try {
Object ret = builder.build();
if (ret instanceof Pair) {
return Collections.emptyMap();
}
LanguageStrings list = (LanguageStrings) ret;
data.put("value", list);
DataCall.getCacheProvider().store(URLEndpoint.DDRAGON_LANGUAGE_STRINGS, data);
return list.getData();
} catch (ClassCastException e) {
return Collections.emptyMap();
}
}
Aggregations