Search in sources :

Example 1 with LanguageStrings

use of no.stelar7.api.l4j8.pojo.staticdata.language.LanguageStrings in project L4J8 by stelar7.

the class StaticAPI method getLanguageStrings.

public Map<String, String> getLanguageStrings(Platform server, @Nullable String version, @Nullable String locale) {
    DataCallBuilder builder = new DataCallBuilder().withEndpoint(URLEndpoint.V3_STATIC_LANGUAGE_STRINGS).withURLData(Constants.URL_PARAM_DATA_BY_ID, String.valueOf(true)).withPlatform(server);
    if (version != null) {
        builder.withURLData(Constants.VERSION_PLACEHOLDER_DATA, version);
    }
    if (locale != null) {
        builder.withURLData(Constants.LOCALE_PLACEHOLDER_DATA, locale);
    }
    Optional chl = DataCall.getCacheProvider().get(URLEndpoint.V3_STATIC_LANGUAGE_STRINGS, server, version, locale);
    if (chl.isPresent()) {
        return ((LanguageStrings) chl.get()).getData();
    }
    try {
        LanguageStrings list = (LanguageStrings) builder.build();
        DataCall.getCacheProvider().store(URLEndpoint.V3_STATIC_LANGUAGE_STRINGS, list, server, version, locale);
        return list.getData();
    } catch (ClassCastException e) {
        return null;
    }
}
Also used : LanguageStrings(no.stelar7.api.l4j8.pojo.staticdata.language.LanguageStrings)

Aggregations

LanguageStrings (no.stelar7.api.l4j8.pojo.staticdata.language.LanguageStrings)1