mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-22 08:25:12 +00:00
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:
parent
1301e8fc99
commit
adef08af3e
4 changed files with 25 additions and 1 deletions
|
@ -33,6 +33,8 @@ public interface ISettings extends IConf {
|
||||||
|
|
||||||
String getChatFormat(String group);
|
String getChatFormat(String group);
|
||||||
|
|
||||||
|
String getWorldAlias(String world);
|
||||||
|
|
||||||
int getChatRadius();
|
int getChatRadius();
|
||||||
|
|
||||||
int getNearRadius();
|
int getNearRadius();
|
||||||
|
|
|
@ -129,6 +129,7 @@ public class Settings implements net.ess3.api.ISettings {
|
||||||
private Set<Predicate<String>> nickBlacklist;
|
private Set<Predicate<String>> nickBlacklist;
|
||||||
private double maxProjectileSpeed;
|
private double maxProjectileSpeed;
|
||||||
private boolean removeEffectsOnHeal;
|
private boolean removeEffectsOnHeal;
|
||||||
|
private Map<String, String> worldAliases;
|
||||||
|
|
||||||
public Settings(final IEssentials ess) {
|
public Settings(final IEssentials ess) {
|
||||||
this.ess = ess;
|
this.ess = ess;
|
||||||
|
@ -542,6 +543,20 @@ public class Settings implements net.ess3.api.ISettings {
|
||||||
return mFormat;
|
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
|
@Override
|
||||||
public boolean getAnnounceNewPlayers() {
|
public boolean getAnnounceNewPlayers() {
|
||||||
return !config.getString("newbies.announce-format", "-").isEmpty();
|
return !config.getString("newbies.announce-format", "-").isEmpty();
|
||||||
|
@ -656,6 +671,7 @@ public class Settings implements net.ess3.api.ISettings {
|
||||||
vanishingItemPolicy = _getVanishingItemsPolicy();
|
vanishingItemPolicy = _getVanishingItemsPolicy();
|
||||||
bindingItemPolicy = _getBindingItemsPolicy();
|
bindingItemPolicy = _getBindingItemsPolicy();
|
||||||
currencySymbol = _getCurrencySymbol();
|
currencySymbol = _getCurrencySymbol();
|
||||||
|
worldAliases = _getWorldAliases();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _lateLoadItemSpawnBlacklist() {
|
void _lateLoadItemSpawnBlacklist() {
|
||||||
|
|
|
@ -828,6 +828,12 @@ chat:
|
||||||
# You can use permissions to control whether players can use formatting codes in their chat messages.
|
# You can use permissions to control whether players can use formatting codes in their chat messages.
|
||||||
# See https://essentialsx.net/wiki/Color-Permissions.html for more information.
|
# See https://essentialsx.net/wiki/Color-Permissions.html for more information.
|
||||||
|
|
||||||
|
# World aliases allow you to replace the world name with something different in the chat format.
|
||||||
|
# If you are using world aliases, make sure to remove the '#' at the start to allow the setting to be read.
|
||||||
|
world-aliases:
|
||||||
|
# plots: "&dP&r"
|
||||||
|
# creative: "&eC&r"
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# +------------------------------------------------------+ #
|
# +------------------------------------------------------+ #
|
||||||
# | EssentialsX Protect | #
|
# | EssentialsX Protect | #
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer {
|
||||||
|
|
||||||
String format = ess.getSettings().getChatFormat(group);
|
String format = ess.getSettings().getChatFormat(group);
|
||||||
format = format.replace("{0}", group);
|
format = format.replace("{0}", group);
|
||||||
format = format.replace("{1}", world);
|
format = format.replace("{1}", ess.getSettings().getWorldAlias(world));
|
||||||
format = format.replace("{2}", world.substring(0, 1).toUpperCase(Locale.ENGLISH));
|
format = format.replace("{2}", world.substring(0, 1).toUpperCase(Locale.ENGLISH));
|
||||||
format = format.replace("{3}", team == null ? "" : team.getPrefix());
|
format = format.replace("{3}", team == null ? "" : team.getPrefix());
|
||||||
format = format.replace("{4}", team == null ? "" : team.getSuffix());
|
format = format.replace("{4}", team == null ? "" : team.getSuffix());
|
||||||
|
|
Loading…
Reference in a new issue