Add DisplayNameNoColor tag in welcome/join messages #1344
This commit is contained in:
@@ -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)) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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", "");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user