mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-10-05 18:17:32 +02:00
Removed the cache from BSBLocale
because YAMLConfiguration is a cache itself.
This commit is contained in:
parent
62480d7249
commit
afa292986d
@ -15,12 +15,10 @@ public class BSBLocale {
|
|||||||
|
|
||||||
private Locale locale;
|
private Locale locale;
|
||||||
private YamlConfiguration config;
|
private YamlConfiguration config;
|
||||||
private Map<String, String> cache;
|
|
||||||
|
|
||||||
public BSBLocale(Locale locale, File file) {
|
public BSBLocale(Locale locale, File file) {
|
||||||
this.locale = locale;
|
this.locale = locale;
|
||||||
this.config = YamlConfiguration.loadConfiguration(file);
|
this.config = YamlConfiguration.loadConfiguration(file);
|
||||||
this.cache = new HashMap<>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,19 +27,12 @@ public class BSBLocale {
|
|||||||
* @return Text for this locale reference or the reference if nothing has been found
|
* @return Text for this locale reference or the reference if nothing has been found
|
||||||
*/
|
*/
|
||||||
public String get(String reference) {
|
public String get(String reference) {
|
||||||
if (cache.containsKey(reference)) {
|
if (config.contains(reference)) {
|
||||||
return cache.get(reference);
|
return config.getString(reference);
|
||||||
} else if (config.contains(reference)) {
|
|
||||||
cache.put(reference, ChatColor.translateAlternateColorCodes('&', config.getString(reference)));
|
|
||||||
return cache.get(reference);
|
|
||||||
}
|
}
|
||||||
return reference; // return reference in case nothing has been found
|
return reference; // return reference in case nothing has been found
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearCache() {
|
|
||||||
this.cache.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the locale language
|
* Returns the locale language
|
||||||
* @return the locale language
|
* @return the locale language
|
||||||
|
Loading…
Reference in New Issue
Block a user