Add world aliases for Chat (#3912)

Allows world names to be overridden with a defined value from the config in EssentialsX Chat.

Closes #1793.
This commit is contained in:
Josh Roy 2021-02-05 15:31:13 -05:00 committed by GitHub
parent 1301e8fc99
commit adef08af3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 1 deletions

View file

@ -129,6 +129,7 @@ public class Settings implements net.ess3.api.ISettings {
private Set<Predicate<String>> nickBlacklist;
private double maxProjectileSpeed;
private boolean removeEffectsOnHeal;
private Map<String, String> worldAliases;
public Settings(final IEssentials ess) {
this.ess = ess;
@ -542,6 +543,20 @@ public class Settings implements net.ess3.api.ISettings {
return mFormat;
}
@Override
public String getWorldAlias(String world) {
return worldAliases.getOrDefault(world.toLowerCase(), world);
}
private Map<String, String> _getWorldAliases() {
final Map<String, String> map = new HashMap<>();
final ConfigurationSection section = config.getConfigurationSection("");
for (String world : section.getKeys(false)) {
map.put(world.toLowerCase(), FormatUtil.replaceFormat(section.getString(world)));
}
return map;
}
@Override
public boolean getAnnounceNewPlayers() {
return !config.getString("newbies.announce-format", "-").isEmpty();
@ -656,6 +671,7 @@ public class Settings implements net.ess3.api.ISettings {
vanishingItemPolicy = _getVanishingItemsPolicy();
bindingItemPolicy = _getBindingItemsPolicy();
currencySymbol = _getCurrencySymbol();
worldAliases = _getWorldAliases();
}
void _lateLoadItemSpawnBlacklist() {