Add Display Name tag replacement too

#1509
This commit is contained in:
Maxetto 2018-03-07 19:08:36 +01:00
parent f9d1a3aef2
commit 9b7139a17a
31 changed files with 165 additions and 15 deletions

View File

@ -5,6 +5,7 @@ import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.util.expiring.Duration;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import javax.inject.Inject;
import java.util.Map;
@ -18,7 +19,9 @@ public class Messages {
// Custom Authme tag replaced to new line
private static final String NEWLINE_TAG = "%nl%";
// Global tag replacements
private static final String USERNAME_TAG = "%username%";
private static final String DISPLAYNAME_TAG = "%displayname%";
/** Contains the keys of the singular messages for time units. */
private static final Map<TimeUnit, MessageKey> TIME_UNIT_SINGULARS = ImmutableMap.<TimeUnit, MessageKey>builder()
@ -114,10 +117,15 @@ public class Messages {
*/
private String retrieveMessage(MessageKey key, CommandSender sender) {
String message = messagesFileHandler.getMessage(key.getKey());
String displayName = sender.getName();
if (sender instanceof Player) {
displayName = ((Player) sender).getDisplayName();
}
return ChatColor.translateAlternateColorCodes('&', message)
.replace(NEWLINE_TAG, "\n")
.replace(USERNAME_TAG, sender.getName());
.replace(USERNAME_TAG, sender.getName())
.replace(DISPLAYNAME_TAG, displayName);
}
/**
@ -132,7 +140,8 @@ public class Messages {
return ChatColor.translateAlternateColorCodes('&', message)
.replace(NEWLINE_TAG, "\n")
.replace(USERNAME_TAG, name);
.replace(USERNAME_TAG, name)
.replace(DISPLAYNAME_TAG, name);
}
/**

View File

@ -1,3 +1,8 @@
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:
disabled: '&cРегистрациите са изключени!'

View File

@ -1,6 +1,10 @@
#Tradução pt/br Authme Reloaded
#Feito por GabrielDev(DeathRush) e Frani (PotterCraft_)
# http://gamersboard.com.br/ | www.magitechserver.com
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:

View File

@ -1,3 +1,8 @@
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:
disabled: '&cRegistrace je zakázána!'

View File

@ -1,3 +1,8 @@
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:
disabled: '&cRegistrierungen sind deaktiviert'

View File

@ -1,3 +1,8 @@
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:
register_request: '&3Please, register to the server with the command: /register <password> <ConfirmPassword>'

View File

@ -1,3 +1,8 @@
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:
disabled: '&cEn-ludo registriĝo estas malebligita!'

View File

@ -1,4 +1,8 @@
# This file must be in ANSI if win, or UTF-8 if linux.
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:

View File

@ -1,3 +1,8 @@
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:
disabled: '&cMängusisene registreerimine välja lülitatud!'

View File

@ -1,3 +1,8 @@
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:
disabled: '&cErregistroa desgaitua'

View File

@ -1,3 +1,8 @@
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:
disabled: '&cRekisteröinti on suljettu!'

View File

@ -1,7 +1,10 @@
# Traduction par: André & Twonox
# Pour afficher une apostrophe, vous devez en mettre deux consécutivement (ex: «J''ai» au lieu de «J'ai»)
# Pour passer à la ligne, utilisez: %nl%
# List of global tags:
# %nl% - Pour passer à la ligne.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:

View File

@ -1,3 +1,8 @@
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:
disabled: '&cO rexistro está deshabilitado'

View File

@ -1,3 +1,8 @@
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:
disabled: '&cA regisztráció letiltva!'

View File

@ -1,3 +1,8 @@
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:
disabled: '&cRegister dalam game tidak diaktifkan!'

View File

@ -1,6 +1,10 @@
# Lingua Italiana creata da Maxetto e sgdc3.
# Lingua Italiana creata da Maxetto.
# Tag globali disponibili:
# %nl% - Vai a capo.
# %username% - Sostituisce il nome dell'utente che riceve il messaggio.
# %displayname% - Sostituisce il nickname (e i colori) dell'utente che riceve il messaggio.
# Registration
# Registrazione
registration:
disabled: '&cLa registrazione tramite i comandi di gioco è disabilitata.'
name_taken: '&cHai già eseguito la registrazione, non puoi eseguirla nuovamente.'
@ -10,7 +14,7 @@ registration:
success: '&2Registrato correttamente!'
kicked_admin_registered: 'Un amministratore ti ha appena registrato, per favore rientra nel server'
# Password errors on registration
# Errori della password durante la registrazione
password:
match_error: '&cLe password non corrispondono!'
name_in_password: '&cNon puoi usare il tuo nome utente come password, per favore scegline un''altra...'
@ -18,7 +22,7 @@ password:
forbidden_characters: '&4La tua password contiene caratteri non consentiti. I caratteri consentiti sono: %valid_chars'
wrong_length: '&cLa password che hai inserito è troppo corta o troppo lunga, per favore scegline un''altra...'
# Login
# Autenticazione
login:
command_usage: '&cUtilizzo: /login <password>'
wrong_password: '&cPassword non corretta!'
@ -26,7 +30,7 @@ login:
login_request: '&cPer favore, esegui l''autenticazione con il comando: /login <password>'
timeout_error: '&4Tempo scaduto per eseguire l''autenticazione, sei stato espulso dal server, per favore riprova!'
# Errors
# Errori
error:
denied_command: '&cPer poter usare questo comando devi essere autenticato!'
denied_chat: '&cPer poter scrivere messaggi in chat devi essere autenticato!'
@ -45,12 +49,12 @@ antibot:
auto_enabled: '&4Il servizio di AntiBot è stato automaticamente abilitato a seguito delle numerose connessioni!'
auto_disabled: '&2Il servizio di AntiBot è stato automaticamente disabilitato dopo %m minuti!'
# Unregister
# Rimozione dal Database
unregister:
success: '&2Sei stato correttamente rimosso dal database!'
command_usage: '&cUtilizzo: /unregister <password>'
# Other messages
# Altri messaggi
misc:
account_not_activated: '&cIl tuo account non è stato ancora verificato, controlla fra le tue email per scoprire come attivarlo!'
password_changed: '&2Password cambiata correttamente!'
@ -61,12 +65,12 @@ misc:
accounts_owned_self: 'Possiedi %count account:'
accounts_owned_other: 'Il giocatore %name possiede %count account:'
# Session messages
# Messaggi della sessione
session:
valid_session: '&2Autenticato automaticamente attraverso la precedente sessione!'
invalid_session: '&cIl tuo indirizzo IP è cambiato e la tua sessione è stata terminata!'
# Error messages when joining
# Messaggi di errore durante l'accesso
on_join_validation:
same_ip_online: 'Un giocatore con il tuo stesso IP è già connesso sul server!'
same_nick_online: '&4Un giocatore con il tuo stesso nome utente è già connesso sul server!'
@ -96,7 +100,7 @@ email:
change_password_expired: 'Non puoi più cambiare la tua password con questo comando.'
email_cooldown_error: '&cUna email di recupero ti è già stata inviata recentemente. Devi attendere %time prima di poterne richiedere una nuova.'
# Password recovery by email
# Recupero password via Email
recovery:
forgot_password_hint: '&3Hai dimenticato la tua password? Puoi recuperarla eseguendo il comando: /email recovery <email>'
command_usage: '&cUtilizzo: /email recovery <email>'
@ -116,7 +120,7 @@ captcha:
captcha_for_registration: 'Per poterti registrare devi prima risolvere un captcha, per favore scrivi: /captcha %captcha_code'
register_captcha_valid: '&2Il captcha inserito è valido! Ora puoi eseguire la registrazione con: /register <password> <confermaPassword>'
# Verification code
# Codice di verifica
verification:
code_required: '&3Questo comando va a modificare dati sensibili e richiede una verifica tramite email! Controlla la tua posta in arrivo e segui le istruzioni nell''email.'
command_usage: '&cUtilizzo: /verification <codice>'
@ -126,7 +130,7 @@ verification:
code_expired: '&3Il tuo codice è scaduto! Esegui nuovamente un comando che modifica dati sensibili per ricevere uno nuovo codice!'
email_needed: '&3Per verificare la tua identità devi collegare un indirizzo email al tuo account!'
# Time units
# Unità di tempo
time:
second: 'secondo'
seconds: 'secondi'

View File

@ -1,5 +1,9 @@
#Translated by Kirito (kds123321@naver.com), System32(me@syst32.com), Adeuran(adeuran@tistory.com)
#14.05.2017 Thanks for use
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:

View File

@ -1,3 +1,8 @@
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:
disabled: '&6Registracija yra isjungta'

View File

@ -1,3 +1,8 @@
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:
disabled: '&cRegistratie is uitgeschakeld!'

View File

@ -1,3 +1,8 @@
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:
disabled: '&4Rejestracja jest wyłączona.'

View File

@ -1,3 +1,8 @@
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:
disabled: '&cRegisto de novos utilizadores desactivado'

View File

@ -1,3 +1,8 @@
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:
disabled: '&cInregistrarea in joc nu este activata!'

View File

@ -1,3 +1,8 @@
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:
disabled: '&cРегистрация отключена.'

View File

@ -4,6 +4,10 @@
# in future there can be more translators #
# if they are not listed here #
# check Translators on GitHub Wiki. #
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:

View File

@ -1,3 +1,8 @@
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:
disabled: '&cOyun icin kayit olma kapatildi!'

View File

@ -1,3 +1,8 @@
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:
disabled: '&cВнутрішньоігрову реєстрацію зараз вимкнено.'

View File

@ -1,3 +1,8 @@
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:
disabled: '&cKhông cho phép đăng ký tài khoản trong máy chủ!'

View File

@ -1,3 +1,8 @@
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:
disabled: '&8[&6玩家系统&8] &c目前服务器暂时禁止注册请到服务器论坛以得到更多资讯'

View File

@ -1,6 +1,10 @@
# Translator: lifehome<m@lifeho.me> #
# Last modif: 1508689979 UTC #
# -------------------------------------------- #
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:

View File

@ -1,3 +1,8 @@
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration:
disabled: '&c遊戲內註冊已停用!'

View File

@ -1,5 +1,9 @@
# Translators: MineWolf50, lifehome, haer0248 #
# -------------------------------------------- #
# List of global tags:
# %nl% - Goes to new line.
# %username% - Replaces the username of the player receiving the message.
# %displayname% - Replaces the nickname (and colors) of the player receiving the message.
# Registration
registration: