Add DisplayNameNoColor tag in welcome/join messages #1344

This commit is contained in:
Gabriele C 2017-10-09 09:25:20 +02:00
parent fafbef6be7
commit 41af94aab2
4 changed files with 22 additions and 16 deletions

View File

@ -1,5 +1,5 @@
<!-- AUTO-GENERATED FILE! Do not edit this directly -->
<!-- File auto-generated on Sat Sep 30 19:52:39 CEST 2017. See docs/config/config.tpl.md -->
<!-- File auto-generated on Mon Oct 09 09:22:33 CEST 2017. See docs/config/config.tpl.md -->
## AuthMe Configuration
The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder,
@ -292,7 +292,8 @@ settings:
# keep empty to use the original one.
# Available variables:
# {PLAYERNAME}: the player name (no colors)
# {DISPLAYNAME}: the player name (with colors)
# {DISPLAYNAME}: the player display name (with colors)
# {DISPLAYNAMENOCOLOR}: the player display name (without colors)
customJoinMessage: ''
# Should we remove the leave messages of unlogged users?
removeUnloggedLeaveMessage: false
@ -442,7 +443,7 @@ Security:
# How many minutes before resetting the count for failed logins by IP and username
# Default: 480 minutes (8 hours)
minutesBeforeCounterReset: 480
# If not empty this command will be executed instead of using the internal server ban system.
# The command to execute instead of using the internal ban system, empty if disabled.
# Available placeholders: %player%, %ip%
customCommand: ''
recoveryCode:
@ -543,4 +544,4 @@ To change settings on a running server, save your changes to config.yml and use
---
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sat Sep 30 19:52:39 CEST 2017
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Mon Oct 09 09:22:33 CEST 2017

View File

@ -15,6 +15,7 @@ import fr.xephi.authme.settings.SpawnLoader;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
@ -172,7 +173,8 @@ public class PlayerListener implements Listener {
event.setJoinMessage(customJoinMessage
.replace("{PLAYERNAME}", player.getName())
.replace("{DISPLAYNAME}", player.getDisplayName())
.replace("{PLAYERLISTNAME}", player.getPlayerListName()));
.replace("{DISPLAYNAMENOCOLOR}", ChatColor.stripColor(player.getDisplayName()))
);
}
if (!settings.getProperty(RegistrationSettings.DELAY_JOIN_MESSAGE)) {

View File

@ -13,6 +13,7 @@ import fr.xephi.authme.util.lazytags.Tag;
import fr.xephi.authme.util.lazytags.TagReplacer;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import javax.annotation.PostConstruct;
@ -55,16 +56,18 @@ public class WelcomeMessageConfiguration implements Reloadable {
/** List of all supported tags for the welcome message. */
private final List<Tag<Player>> availableTags = Arrays.asList(
createTag("&", () -> String.valueOf(ChatColor.COLOR_CHAR)),
createTag("{PLAYER}", pl -> pl.getName()),
createTag("{ONLINE}", () -> Integer.toString(bukkitService.getOnlinePlayers().size())),
createTag("{MAXPLAYERS}", () -> Integer.toString(server.getMaxPlayers())),
createTag("{IP}", pl -> PlayerUtils.getPlayerIp(pl)),
createTag("{LOGINS}", () -> Integer.toString(playerCache.getLogged())),
createTag("{WORLD}", pl -> pl.getWorld().getName()),
createTag("{SERVER}", () -> server.getServerName()),
createTag("{VERSION}", () -> server.getBukkitVersion()),
createTag("{COUNTRY}", pl -> geoIpService.getCountryName(PlayerUtils.getPlayerIp(pl))));
createTag("&", () -> String.valueOf(ChatColor.COLOR_CHAR)),
createTag("{PLAYER}", HumanEntity::getName),
createTag("{DISPLAYNAME}", Player::getDisplayName),
createTag("{DISPLAYNAMENOCOLOR}", Player::getDisplayName),
createTag("{ONLINE}", () -> Integer.toString(bukkitService.getOnlinePlayers().size())),
createTag("{MAXPLAYERS}", () -> Integer.toString(server.getMaxPlayers())),
createTag("{IP}", PlayerUtils::getPlayerIp),
createTag("{LOGINS}", () -> Integer.toString(playerCache.getLogged())),
createTag("{WORLD}", pl -> pl.getWorld().getName()),
createTag("{SERVER}", () -> server.getServerName()),
createTag("{VERSION}", () -> server.getBukkitVersion()),
createTag("{COUNTRY}", pl -> geoIpService.getCountryName(PlayerUtils.getPlayerIp(pl))));
private TagReplacer<Player> messageSupplier;

View File

@ -81,7 +81,7 @@ public final class RegistrationSettings implements SettingsHolder {
"Available variables:",
"{PLAYERNAME}: the player name (no colors)",
"{DISPLAYNAME}: the player display name (with colors)",
"{PLAYERLISTNAME}: the player list name (with colors)"})
"{DISPLAYNAMENOCOLOR}: the player display name (without colors)"})
public static final Property<String> CUSTOM_JOIN_MESSAGE =
newProperty("settings.customJoinMessage", "");