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 --> <!-- 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 ## AuthMe Configuration
The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder, 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. # keep empty to use the original one.
# Available variables: # Available variables:
# {PLAYERNAME}: the player name (no colors) # {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: '' customJoinMessage: ''
# Should we remove the leave messages of unlogged users? # Should we remove the leave messages of unlogged users?
removeUnloggedLeaveMessage: false removeUnloggedLeaveMessage: false
@ -442,7 +443,7 @@ Security:
# How many minutes before resetting the count for failed logins by IP and username # How many minutes before resetting the count for failed logins by IP and username
# Default: 480 minutes (8 hours) # Default: 480 minutes (8 hours)
minutesBeforeCounterReset: 480 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% # Available placeholders: %player%, %ip%
customCommand: '' customCommand: ''
recoveryCode: 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.HooksSettings;
import fr.xephi.authme.settings.properties.RegistrationSettings; import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings; import fr.xephi.authme.settings.properties.RestrictionSettings;
import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.HumanEntity; import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -172,7 +173,8 @@ public class PlayerListener implements Listener {
event.setJoinMessage(customJoinMessage event.setJoinMessage(customJoinMessage
.replace("{PLAYERNAME}", player.getName()) .replace("{PLAYERNAME}", player.getName())
.replace("{DISPLAYNAME}", player.getDisplayName()) .replace("{DISPLAYNAME}", player.getDisplayName())
.replace("{PLAYERLISTNAME}", player.getPlayerListName())); .replace("{DISPLAYNAMENOCOLOR}", ChatColor.stripColor(player.getDisplayName()))
);
} }
if (!settings.getProperty(RegistrationSettings.DELAY_JOIN_MESSAGE)) { 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 fr.xephi.authme.util.lazytags.TagReplacer;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
@ -56,10 +57,12 @@ public class WelcomeMessageConfiguration implements Reloadable {
/** List of all supported tags for the welcome message. */ /** List of all supported tags for the welcome message. */
private final List<Tag<Player>> availableTags = Arrays.asList( private final List<Tag<Player>> availableTags = Arrays.asList(
createTag("&", () -> String.valueOf(ChatColor.COLOR_CHAR)), createTag("&", () -> String.valueOf(ChatColor.COLOR_CHAR)),
createTag("{PLAYER}", pl -> pl.getName()), createTag("{PLAYER}", HumanEntity::getName),
createTag("{DISPLAYNAME}", Player::getDisplayName),
createTag("{DISPLAYNAMENOCOLOR}", Player::getDisplayName),
createTag("{ONLINE}", () -> Integer.toString(bukkitService.getOnlinePlayers().size())), createTag("{ONLINE}", () -> Integer.toString(bukkitService.getOnlinePlayers().size())),
createTag("{MAXPLAYERS}", () -> Integer.toString(server.getMaxPlayers())), createTag("{MAXPLAYERS}", () -> Integer.toString(server.getMaxPlayers())),
createTag("{IP}", pl -> PlayerUtils.getPlayerIp(pl)), createTag("{IP}", PlayerUtils::getPlayerIp),
createTag("{LOGINS}", () -> Integer.toString(playerCache.getLogged())), createTag("{LOGINS}", () -> Integer.toString(playerCache.getLogged())),
createTag("{WORLD}", pl -> pl.getWorld().getName()), createTag("{WORLD}", pl -> pl.getWorld().getName()),
createTag("{SERVER}", () -> server.getServerName()), createTag("{SERVER}", () -> server.getServerName()),

View File

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