Merge branch 'global-replacements'

This commit is contained in:
ljacqu 2018-03-10 16:59:56 +01:00
commit 15f49dcbb3
48 changed files with 298 additions and 70 deletions

View File

@ -74,7 +74,7 @@ public class RegisterAdminCommand implements ExecutableCommand {
final Player player = bukkitService.getPlayerExact(playerName); final Player player = bukkitService.getPlayerExact(playerName);
if (player != null) { if (player != null) {
bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(() -> bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(() ->
player.kickPlayer(commonService.retrieveSingleMessage(MessageKey.KICK_FOR_ADMIN_REGISTER))); player.kickPlayer(commonService.retrieveSingleMessage(player, MessageKey.KICK_FOR_ADMIN_REGISTER)));
} }
}); });
} }

View File

@ -97,7 +97,7 @@ public class TempbanManager implements SettingsDependent, HasCleanup {
if (isEnabled) { if (isEnabled) {
final String name = player.getName(); final String name = player.getName();
final String ip = PlayerUtils.getPlayerIp(player); final String ip = PlayerUtils.getPlayerIp(player);
final String reason = messages.retrieveSingle(MessageKey.TEMPBAN_MAX_LOGINS); final String reason = messages.retrieveSingle(player, MessageKey.TEMPBAN_MAX_LOGINS);
final Date expires = new Date(); final Date expires = new Date();
long newTime = expires.getTime() + (length * MILLIS_PER_MINUTE); long newTime = expires.getTime() + (length * MILLIS_PER_MINUTE);

View File

@ -49,9 +49,9 @@ class LimboPlayerTaskManager {
*/ */
void registerMessageTask(Player player, LimboPlayer limbo, boolean isRegistered) { void registerMessageTask(Player player, LimboPlayer limbo, boolean isRegistered) {
int interval = settings.getProperty(RegistrationSettings.MESSAGE_INTERVAL); int interval = settings.getProperty(RegistrationSettings.MESSAGE_INTERVAL);
MessageResult messageResult = getMessageKey(player.getName(), isRegistered); MessageResult result = getMessageKey(player.getName(), isRegistered);
if (interval > 0) { if (interval > 0) {
String[] joinMessage = messages.retrieveSingle(messageResult.messageKey, messageResult.args).split("\n"); String[] joinMessage = messages.retrieveSingle(player, result.messageKey, result.args).split("\n");
MessageTask messageTask = new MessageTask(player, joinMessage); MessageTask messageTask = new MessageTask(player, joinMessage);
bukkitService.runTaskTimer(messageTask, 2 * TICKS_PER_SECOND, interval * TICKS_PER_SECOND); bukkitService.runTaskTimer(messageTask, 2 * TICKS_PER_SECOND, interval * TICKS_PER_SECOND);
limbo.setMessageTask(messageTask); limbo.setMessageTask(messageTask);
@ -67,7 +67,7 @@ class LimboPlayerTaskManager {
void registerTimeoutTask(Player player, LimboPlayer limbo) { void registerTimeoutTask(Player player, LimboPlayer limbo) {
final int timeout = settings.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND; final int timeout = settings.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND;
if (timeout > 0) { if (timeout > 0) {
String message = messages.retrieveSingle(MessageKey.LOGIN_TIMEOUT_ERROR); String message = messages.retrieveSingle(player, MessageKey.LOGIN_TIMEOUT_ERROR);
BukkitTask task = bukkitService.runTaskLater(new TimeoutTask(player, message, playerCache), timeout); BukkitTask task = bukkitService.runTaskLater(new TimeoutTask(player, message, playerCache), timeout);
limbo.setTimeoutTask(task); limbo.setTimeoutTask(task);
} }

View File

@ -123,7 +123,7 @@ public class OnJoinVerifier implements Reloadable {
return false; return false;
} else if (!permissionsManager.hasPermission(player, PlayerStatePermission.IS_VIP)) { } else if (!permissionsManager.hasPermission(player, PlayerStatePermission.IS_VIP)) {
// Server is full and player is NOT VIP; set kick message and proceed with kick // Server is full and player is NOT VIP; set kick message and proceed with kick
event.setKickMessage(messages.retrieveSingle(MessageKey.KICK_FULL_SERVER)); event.setKickMessage(messages.retrieveSingle(player, MessageKey.KICK_FULL_SERVER));
return true; return true;
} }
@ -135,12 +135,12 @@ public class OnJoinVerifier implements Reloadable {
} }
Player nonVipPlayer = generateKickPlayer(onlinePlayers); Player nonVipPlayer = generateKickPlayer(onlinePlayers);
if (nonVipPlayer != null) { if (nonVipPlayer != null) {
nonVipPlayer.kickPlayer(messages.retrieveSingle(MessageKey.KICK_FOR_VIP)); nonVipPlayer.kickPlayer(messages.retrieveSingle(player, MessageKey.KICK_FOR_VIP));
event.allow(); event.allow();
return false; return false;
} else { } else {
ConsoleLogger.info("VIP player " + player.getName() + " tried to join, but the server was full"); ConsoleLogger.info("VIP player " + player.getName() + " tried to join, but the server was full");
event.setKickMessage(messages.retrieveSingle(MessageKey.KICK_FULL_SERVER)); event.setKickMessage(messages.retrieveSingle(player, MessageKey.KICK_FULL_SERVER));
return true; return true;
} }
} }

View File

@ -257,7 +257,7 @@ public class PlayerListener implements Listener {
try { try {
runOnJoinChecks(JoiningPlayer.fromName(name), event.getAddress().getHostAddress()); runOnJoinChecks(JoiningPlayer.fromName(name), event.getAddress().getHostAddress());
} catch (FailedVerificationException e) { } catch (FailedVerificationException e) {
event.setKickMessage(m.retrieveSingle(e.getReason(), e.getArgs())); event.setKickMessage(m.retrieveSingle(name, e.getReason(), e.getArgs()));
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER); event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
} }
} }
@ -285,7 +285,7 @@ public class PlayerListener implements Listener {
try { try {
runOnJoinChecks(JoiningPlayer.fromPlayerObject(player), event.getAddress().getHostAddress()); runOnJoinChecks(JoiningPlayer.fromPlayerObject(player), event.getAddress().getHostAddress());
} catch (FailedVerificationException e) { } catch (FailedVerificationException e) {
event.setKickMessage(m.retrieveSingle(e.getReason(), e.getArgs())); event.setKickMessage(m.retrieveSingle(player, e.getReason(), e.getArgs()));
event.setResult(PlayerLoginEvent.Result.KICK_OTHER); event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
} }
} }

View File

@ -5,6 +5,7 @@ import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.util.expiring.Duration; import fr.xephi.authme.util.expiring.Duration;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import javax.inject.Inject; import javax.inject.Inject;
import java.util.Map; import java.util.Map;
@ -18,7 +19,9 @@ public class Messages {
// Custom Authme tag replaced to new line // Custom Authme tag replaced to new line
private static final String NEWLINE_TAG = "%nl%"; private static final String NEWLINE_TAG = "%nl%";
private static final String PLAYER_TAG = "%username%"; // 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. */ /** Contains the keys of the singular messages for time units. */
private static final Map<TimeUnit, MessageKey> TIME_UNIT_SINGULARS = ImmutableMap.<TimeUnit, MessageKey>builder() private static final Map<TimeUnit, MessageKey> TIME_UNIT_SINGULARS = ImmutableMap.<TimeUnit, MessageKey>builder()
@ -51,9 +54,9 @@ public class Messages {
* @param key The key of the message to send * @param key The key of the message to send
*/ */
public void send(CommandSender sender, MessageKey key) { public void send(CommandSender sender, MessageKey key) {
String[] lines = retrieve(key); String[] lines = retrieve(key, sender);
for (String line : lines) { for (String line : lines) {
sender.sendMessage(line.replaceAll(PLAYER_TAG, sender.getName())); sender.sendMessage(line);
} }
} }
@ -67,7 +70,7 @@ public class Messages {
* @param replacements The replacements to apply for the tags * @param replacements The replacements to apply for the tags
*/ */
public void send(CommandSender sender, MessageKey key, String... replacements) { public void send(CommandSender sender, MessageKey key, String... replacements) {
String message = retrieveSingle(key, replacements).replaceAll(PLAYER_TAG, sender.getName()); String message = retrieveSingle(sender, key, replacements);
for (String line : message.split("\n")) { for (String line : message.split("\n")) {
sender.sendMessage(line); sender.sendMessage(line);
} }
@ -77,10 +80,11 @@ public class Messages {
* Retrieve the message from the text file and return it split by new line as an array. * Retrieve the message from the text file and return it split by new line as an array.
* *
* @param key The message key to retrieve * @param key The message key to retrieve
* @param sender The entity to send the message to
* @return The message split by new lines * @return The message split by new lines
*/ */
public String[] retrieve(MessageKey key) { public String[] retrieve(MessageKey key, CommandSender sender) {
String message = retrieveMessage(key); String message = retrieveMessage(key, sender);
if (message.isEmpty()) { if (message.isEmpty()) {
// Return empty array instead of array with 1 empty string as entry // Return empty array instead of array with 1 empty string as entry
return new String[0]; return new String[0];
@ -101,18 +105,43 @@ public class Messages {
? TIME_UNIT_SINGULARS.get(duration.getTimeUnit()) ? TIME_UNIT_SINGULARS.get(duration.getTimeUnit())
: TIME_UNIT_PLURALS.get(duration.getTimeUnit()); : TIME_UNIT_PLURALS.get(duration.getTimeUnit());
return value + " " + retrieveMessage(timeUnitKey); return value + " " + retrieveMessage(timeUnitKey, "");
} }
/** /**
* Retrieve the message from the text file. * Retrieve the message from the text file.
* *
* @param key The message key to retrieve * @param key The message key to retrieve
* @param sender The entity to send the message to
* @return The message from the file * @return The message from the file
*/ */
private String retrieveMessage(MessageKey key) { private String retrieveMessage(MessageKey key, CommandSender sender) {
return formatMessage( String message = messagesFileHandler.getMessage(key.getKey());
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(DISPLAYNAME_TAG, displayName);
}
/**
* Retrieve the message from the text file.
*
* @param key The message key to retrieve
* @param name The name of the entity to send the message to
* @return The message from the file
*/
private String retrieveMessage(MessageKey key, String name) {
String message = messagesFileHandler.getMessage(key.getKey());
return ChatColor.translateAlternateColorCodes('&', message)
.replace(NEWLINE_TAG, "\n")
.replace(USERNAME_TAG, name)
.replace(DISPLAYNAME_TAG, name);
} }
/** /**
@ -120,12 +149,13 @@ public class Messages {
* logs an error if the number of supplied replacements doesn't correspond to the number of tags * logs an error if the number of supplied replacements doesn't correspond to the number of tags
* the message key contains. * the message key contains.
* *
* @param sender The entity to send the message to
* @param key The key of the message to send * @param key The key of the message to send
* @param replacements The replacements to apply for the tags * @param replacements The replacements to apply for the tags
* @return The message from the file with replacements * @return The message from the file with replacements
*/ */
public String retrieveSingle(MessageKey key, String... replacements) { public String retrieveSingle(CommandSender sender, MessageKey key, String... replacements) {
String message = retrieveMessage(key); String message = retrieveMessage(key, sender);
String[] tags = key.getTags(); String[] tags = key.getTags();
if (replacements.length == tags.length) { if (replacements.length == tags.length) {
for (int i = 0; i < tags.length; ++i) { for (int i = 0; i < tags.length; ++i) {
@ -137,9 +167,26 @@ public class Messages {
return message; return message;
} }
private static String formatMessage(String message) { /**
return ChatColor.translateAlternateColorCodes('&', message) * Retrieve the given message code with the given tag replacements. Note that this method
.replace(NEWLINE_TAG, "\n"); * logs an error if the number of supplied replacements doesn't correspond to the number of tags
* the message key contains.
*
* @param name The name of the entity to send the message to
* @param key The key of the message to send
* @param replacements The replacements to apply for the tags
* @return The message from the file with replacements
*/
public String retrieveSingle(String name, MessageKey key, String... replacements) {
String message = retrieveMessage(key, name);
String[] tags = key.getTags();
if (replacements.length == tags.length) {
for (int i = 0; i < tags.length; ++i) {
message = message.replace(tags[i], replacements[i]);
}
} else {
ConsoleLogger.warning("Invalid number of replacements for message key '" + key + "'");
}
return message;
} }
} }

View File

@ -138,7 +138,7 @@ public class AsynchronousJoin implements AsynchronousProcess {
private void handlePlayerWithUnmetNameRestriction(Player player, String ip) { private void handlePlayerWithUnmetNameRestriction(Player player, String ip) {
bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(() -> { bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(() -> {
player.kickPlayer(service.retrieveSingleMessage(MessageKey.NOT_OWNER_ERROR)); player.kickPlayer(service.retrieveSingleMessage(player, MessageKey.NOT_OWNER_ERROR));
if (service.getProperty(RestrictionSettings.BAN_UNKNOWN_IP)) { if (service.getProperty(RestrictionSettings.BAN_UNKNOWN_IP)) {
server.banIP(ip); server.banIP(ip);
} }
@ -188,7 +188,7 @@ public class AsynchronousJoin implements AsynchronousProcess {
&& countOnlinePlayersByIp(ip) > service.getProperty(RestrictionSettings.MAX_JOIN_PER_IP)) { && countOnlinePlayersByIp(ip) > service.getProperty(RestrictionSettings.MAX_JOIN_PER_IP)) {
bukkitService.scheduleSyncTaskFromOptionallyAsyncTask( bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(
() -> player.kickPlayer(service.retrieveSingleMessage(MessageKey.SAME_IP_ONLINE))); () -> player.kickPlayer(service.retrieveSingleMessage(player, MessageKey.SAME_IP_ONLINE)));
return false; return false;
} }
return true; return true;

View File

@ -197,7 +197,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
tempbanManager.tempbanPlayer(player); tempbanManager.tempbanPlayer(player);
} else if (service.getProperty(RestrictionSettings.KICK_ON_WRONG_PASSWORD)) { } else if (service.getProperty(RestrictionSettings.KICK_ON_WRONG_PASSWORD)) {
bukkitService.scheduleSyncTaskFromOptionallyAsyncTask( bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(
() -> player.kickPlayer(service.retrieveSingleMessage(MessageKey.WRONG_PASSWORD))); () -> player.kickPlayer(service.retrieveSingleMessage(player, MessageKey.WRONG_PASSWORD)));
} else { } else {
service.send(player, MessageKey.WRONG_PASSWORD); service.send(player, MessageKey.WRONG_PASSWORD);

View File

@ -58,7 +58,7 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess {
// Kick Player after Registration is enabled, kick the player // Kick Player after Registration is enabled, kick the player
if (service.getProperty(RegistrationSettings.FORCE_KICK_AFTER_REGISTER)) { if (service.getProperty(RegistrationSettings.FORCE_KICK_AFTER_REGISTER)) {
player.kickPlayer(service.retrieveSingleMessage(MessageKey.REGISTER_SUCCESS)); player.kickPlayer(service.retrieveSingleMessage(player, MessageKey.REGISTER_SUCCESS));
return; return;
} }

View File

@ -63,11 +63,12 @@ public class CommonService {
/** /**
* Retrieves a message in one piece. * Retrieves a message in one piece.
* *
* @param sender The entity to send the message to
* @param key the key of the message * @param key the key of the message
* @return the message * @return the message
*/ */
public String retrieveSingleMessage(MessageKey key) { public String retrieveSingleMessage(CommandSender sender, MessageKey key) {
return messages.retrieveSingle(key); return messages.retrieveSingle(sender, key);
} }
/** /**

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
registration: registration:
disabled: '&cРегистрациите са изключени!' disabled: '&cРегистрациите са изключени!'

View File

@ -1,6 +1,10 @@
#Tradução pt/br Authme Reloaded #Tradução pt/br Authme Reloaded
#Feito por GabrielDev(DeathRush) e Frani (PotterCraft_) #Feito por GabrielDev(DeathRush) e Frani (PotterCraft_)
# http://gamersboard.com.br/ | www.magitechserver.com # 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
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
registration: registration:
disabled: '&cRegistrace je zakázána!' 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
registration: registration:
disabled: '&cRegistrierungen sind deaktiviert' 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
registration: registration:
register_request: '&3Please, register to the server with the command: /register <password> <ConfirmPassword>' 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
registration: registration:
disabled: '&cEn-ludo registriĝo estas malebligita!' 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. # 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
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
registration: registration:
disabled: '&cMängusisene registreerimine välja lülitatud!' 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
registration: registration:
disabled: '&cErregistroa desgaitua' 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
registration: registration:
disabled: '&cRekisteröinti on suljettu!' disabled: '&cRekisteröinti on suljettu!'

View File

@ -1,7 +1,10 @@
# Traduction par: André & Twonox # Traduction par: André & Twonox
# Pour afficher une apostrophe, vous devez en mettre deux consécutivement (ex: «J''ai» au lieu de «J'ai») # 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
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
registration: registration:
disabled: '&cO rexistro está deshabilitado' 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
registration: registration:
disabled: '&cA regisztráció letiltva!' 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
registration: registration:
disabled: '&cRegister dalam game tidak diaktifkan!' 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: registration:
disabled: '&cLa registrazione tramite i comandi di gioco è disabilitata.' disabled: '&cLa registrazione tramite i comandi di gioco è disabilitata.'
name_taken: '&cHai già eseguito la registrazione, non puoi eseguirla nuovamente.' name_taken: '&cHai già eseguito la registrazione, non puoi eseguirla nuovamente.'
@ -10,7 +14,7 @@ registration:
success: '&2Registrato correttamente!' success: '&2Registrato correttamente!'
kicked_admin_registered: 'Un amministratore ti ha appena registrato, per favore rientra nel server' 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: password:
match_error: '&cLe password non corrispondono!' match_error: '&cLe password non corrispondono!'
name_in_password: '&cNon puoi usare il tuo nome utente come password, per favore scegline un''altra...' 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' 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...' wrong_length: '&cLa password che hai inserito è troppo corta o troppo lunga, per favore scegline un''altra...'
# Login # Autenticazione
login: login:
command_usage: '&cUtilizzo: /login <password>' command_usage: '&cUtilizzo: /login <password>'
wrong_password: '&cPassword non corretta!' wrong_password: '&cPassword non corretta!'
@ -26,7 +30,7 @@ login:
login_request: '&cPer favore, esegui l''autenticazione con il comando: /login <password>' 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!' timeout_error: '&4Tempo scaduto per eseguire l''autenticazione, sei stato espulso dal server, per favore riprova!'
# Errors # Errori
error: error:
denied_command: '&cPer poter usare questo comando devi essere autenticato!' denied_command: '&cPer poter usare questo comando devi essere autenticato!'
denied_chat: '&cPer poter scrivere messaggi in chat 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_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!' auto_disabled: '&2Il servizio di AntiBot è stato automaticamente disabilitato dopo %m minuti!'
# Unregister # Rimozione dal Database
unregister: unregister:
success: '&2Sei stato correttamente rimosso dal database!' success: '&2Sei stato correttamente rimosso dal database!'
command_usage: '&cUtilizzo: /unregister <password>' command_usage: '&cUtilizzo: /unregister <password>'
# Other messages # Altri messaggi
misc: misc:
account_not_activated: '&cIl tuo account non è stato ancora verificato, controlla fra le tue email per scoprire come attivarlo!' account_not_activated: '&cIl tuo account non è stato ancora verificato, controlla fra le tue email per scoprire come attivarlo!'
password_changed: '&2Password cambiata correttamente!' password_changed: '&2Password cambiata correttamente!'
@ -61,12 +65,12 @@ misc:
accounts_owned_self: 'Possiedi %count account:' accounts_owned_self: 'Possiedi %count account:'
accounts_owned_other: 'Il giocatore %name possiede %count account:' accounts_owned_other: 'Il giocatore %name possiede %count account:'
# Session messages # Messaggi della sessione
session: session:
valid_session: '&2Autenticato automaticamente attraverso la precedente sessione!' valid_session: '&2Autenticato automaticamente attraverso la precedente sessione!'
invalid_session: '&cIl tuo indirizzo IP è cambiato e la tua sessione è stata terminata!' 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: on_join_validation:
same_ip_online: 'Un giocatore con il tuo stesso IP è già connesso sul server!' 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!' 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.' 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.' 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: recovery:
forgot_password_hint: '&3Hai dimenticato la tua password? Puoi recuperarla eseguendo il comando: /email recovery <email>' forgot_password_hint: '&3Hai dimenticato la tua password? Puoi recuperarla eseguendo il comando: /email recovery <email>'
command_usage: '&cUtilizzo: /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' 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>' register_captcha_valid: '&2Il captcha inserito è valido! Ora puoi eseguire la registrazione con: /register <password> <confermaPassword>'
# Verification code # Codice di verifica
verification: 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.' 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>' 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!' 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!' email_needed: '&3Per verificare la tua identità devi collegare un indirizzo email al tuo account!'
# Time units # Unità di tempo
time: time:
second: 'secondo' second: 'secondo'
seconds: 'secondi' seconds: 'secondi'

View File

@ -1,5 +1,9 @@
#Translated by Kirito (kds123321@naver.com), System32(me@syst32.com), Adeuran(adeuran@tistory.com) #Translated by Kirito (kds123321@naver.com), System32(me@syst32.com), Adeuran(adeuran@tistory.com)
#14.05.2017 Thanks for use #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
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
registration: registration:
disabled: '&6Registracija yra isjungta' 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
registration: registration:
disabled: '&cRegistratie is uitgeschakeld!' 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
registration: registration:
disabled: '&4Rejestracja jest wyłączona.' 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
registration: registration:
disabled: '&cRegisto de novos utilizadores desactivado' 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
registration: registration:
disabled: '&cInregistrarea in joc nu este activata!' 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
registration: registration:
disabled: '&cРегистрация отключена.' disabled: '&cРегистрация отключена.'

View File

@ -4,6 +4,10 @@
# in future there can be more translators # # in future there can be more translators #
# if they are not listed here # # if they are not listed here #
# check Translators on GitHub Wiki. # # 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
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
registration: registration:
disabled: '&cOyun icin kayit olma kapatildi!' 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
registration: registration:
disabled: '&cВнутрішньоігрову реєстрацію зараз вимкнено.' 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
registration: registration:
disabled: '&cKhông cho phép đăng ký tài khoản trong máy chủ!' 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
registration: registration:
disabled: '&8[&6玩家系统&8] &c目前服务器暂时禁止注册请到服务器论坛以得到更多资讯' disabled: '&8[&6玩家系统&8] &c目前服务器暂时禁止注册请到服务器论坛以得到更多资讯'

View File

@ -1,6 +1,10 @@
# Translator: lifehome<m@lifeho.me> # # Translator: lifehome<m@lifeho.me> #
# Last modif: 1508689979 UTC # # 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
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
registration: registration:
disabled: '&c遊戲內註冊已停用!' disabled: '&c遊戲內註冊已停用!'

View File

@ -1,5 +1,9 @@
# Translators: MineWolf50, lifehome, haer0248 # # 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
registration: registration:

View File

@ -160,7 +160,7 @@ public class RegisterAdminCommandTest {
Player player = mock(Player.class); Player player = mock(Player.class);
given(bukkitService.getPlayerExact(user)).willReturn(player); given(bukkitService.getPlayerExact(user)).willReturn(player);
String kickForAdminRegister = "Admin registered you -- log in again"; String kickForAdminRegister = "Admin registered you -- log in again";
given(commandService.retrieveSingleMessage(MessageKey.KICK_FOR_ADMIN_REGISTER)).willReturn(kickForAdminRegister); given(commandService.retrieveSingleMessage(player, MessageKey.KICK_FOR_ADMIN_REGISTER)).willReturn(kickForAdminRegister);
CommandSender sender = mock(CommandSender.class); CommandSender sender = mock(CommandSender.class);
setBukkitServiceToScheduleSyncTaskFromOptionallyAsyncTask(bukkitService); setBukkitServiceToScheduleSyncTaskFromOptionallyAsyncTask(bukkitService);
setBukkitServiceToRunTaskOptionallyAsync(bukkitService); setBukkitServiceToRunTaskOptionallyAsync(bukkitService);

View File

@ -149,7 +149,7 @@ public class TempbanManagerTest {
String ip = "123.45.67.89"; String ip = "123.45.67.89";
TestHelper.mockPlayerIp(player, ip); TestHelper.mockPlayerIp(player, ip);
String banReason = "IP ban too many logins"; String banReason = "IP ban too many logins";
given(messages.retrieveSingle(MessageKey.TEMPBAN_MAX_LOGINS)).willReturn(banReason); given(messages.retrieveSingle(player, MessageKey.TEMPBAN_MAX_LOGINS)).willReturn(banReason);
Settings settings = mockSettings(2, 100, ""); Settings settings = mockSettings(2, 100, "");
TempbanManager manager = new TempbanManager(bukkitService, messages, settings); TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
setBukkitServiceToScheduleSyncDelayedTask(bukkitService); setBukkitServiceToScheduleSyncDelayedTask(bukkitService);
@ -195,7 +195,7 @@ public class TempbanManagerTest {
String ip = "22.44.66.88"; String ip = "22.44.66.88";
TestHelper.mockPlayerIp(player, ip); TestHelper.mockPlayerIp(player, ip);
String banReason = "kick msg"; String banReason = "kick msg";
given(messages.retrieveSingle(MessageKey.TEMPBAN_MAX_LOGINS)).willReturn(banReason); given(messages.retrieveSingle(player, MessageKey.TEMPBAN_MAX_LOGINS)).willReturn(banReason);
Settings settings = mockSettings(10, 60, ""); Settings settings = mockSettings(10, 60, "");
TempbanManager manager = new TempbanManager(bukkitService, messages, settings); TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
manager.increaseCount(ip, "user"); manager.increaseCount(ip, "user");

View File

@ -71,7 +71,7 @@ public class LimboPlayerTaskManagerTest {
Player player = mock(Player.class); Player player = mock(Player.class);
LimboPlayer limboPlayer = mock(LimboPlayer.class); LimboPlayer limboPlayer = mock(LimboPlayer.class);
MessageKey key = MessageKey.REGISTER_MESSAGE; MessageKey key = MessageKey.REGISTER_MESSAGE;
given(messages.retrieveSingle(key)).willReturn("Please register!"); given(messages.retrieveSingle(player, key)).willReturn("Please register!");
int interval = 12; int interval = 12;
given(settings.getProperty(RegistrationSettings.MESSAGE_INTERVAL)).willReturn(interval); given(settings.getProperty(RegistrationSettings.MESSAGE_INTERVAL)).willReturn(interval);
@ -80,7 +80,7 @@ public class LimboPlayerTaskManagerTest {
// then // then
verify(limboPlayer).setMessageTask(any(MessageTask.class)); verify(limboPlayer).setMessageTask(any(MessageTask.class));
verify(messages).retrieveSingle(key); verify(messages).retrieveSingle(player, key);
verify(bukkitService).runTaskTimer( verify(bukkitService).runTaskTimer(
any(MessageTask.class), eq(2L * TICKS_PER_SECOND), eq((long) interval * TICKS_PER_SECOND)); any(MessageTask.class), eq(2L * TICKS_PER_SECOND), eq((long) interval * TICKS_PER_SECOND));
} }
@ -110,7 +110,7 @@ public class LimboPlayerTaskManagerTest {
MessageTask existingMessageTask = mock(MessageTask.class); MessageTask existingMessageTask = mock(MessageTask.class);
limboPlayer.setMessageTask(existingMessageTask); limboPlayer.setMessageTask(existingMessageTask);
given(settings.getProperty(RegistrationSettings.MESSAGE_INTERVAL)).willReturn(8); given(settings.getProperty(RegistrationSettings.MESSAGE_INTERVAL)).willReturn(8);
given(messages.retrieveSingle(MessageKey.REGISTER_MESSAGE)).willReturn("Please register!"); given(messages.retrieveSingle(player, MessageKey.REGISTER_MESSAGE)).willReturn("Please register!");
// when // when
limboPlayerTaskManager.registerMessageTask(player, limboPlayer, false); limboPlayerTaskManager.registerMessageTask(player, limboPlayer, false);
@ -119,7 +119,7 @@ public class LimboPlayerTaskManagerTest {
assertThat(limboPlayer.getMessageTask(), not(nullValue())); assertThat(limboPlayer.getMessageTask(), not(nullValue()));
assertThat(limboPlayer.getMessageTask(), not(sameInstance(existingMessageTask))); assertThat(limboPlayer.getMessageTask(), not(sameInstance(existingMessageTask)));
verify(registrationCaptchaManager).isCaptchaRequired(name); verify(registrationCaptchaManager).isCaptchaRequired(name);
verify(messages).retrieveSingle(MessageKey.REGISTER_MESSAGE); verify(messages).retrieveSingle(player, MessageKey.REGISTER_MESSAGE);
verify(existingMessageTask).cancel(); verify(existingMessageTask).cancel();
} }
@ -134,14 +134,14 @@ public class LimboPlayerTaskManagerTest {
given(registrationCaptchaManager.isCaptchaRequired(name)).willReturn(true); given(registrationCaptchaManager.isCaptchaRequired(name)).willReturn(true);
String captcha = "M032"; String captcha = "M032";
given(registrationCaptchaManager.getCaptchaCodeOrGenerateNew(name)).willReturn(captcha); given(registrationCaptchaManager.getCaptchaCodeOrGenerateNew(name)).willReturn(captcha);
given(messages.retrieveSingle(MessageKey.CAPTCHA_FOR_REGISTRATION_REQUIRED, captcha)).willReturn("Need to use captcha"); given(messages.retrieveSingle(player, MessageKey.CAPTCHA_FOR_REGISTRATION_REQUIRED, captcha)).willReturn("Need to use captcha");
// when // when
limboPlayerTaskManager.registerMessageTask(player, limboPlayer, false); limboPlayerTaskManager.registerMessageTask(player, limboPlayer, false);
// then // then
assertThat(limboPlayer.getMessageTask(), not(nullValue())); assertThat(limboPlayer.getMessageTask(), not(nullValue()));
verify(messages).retrieveSingle(MessageKey.CAPTCHA_FOR_REGISTRATION_REQUIRED, captcha); verify(messages).retrieveSingle(player, MessageKey.CAPTCHA_FOR_REGISTRATION_REQUIRED, captcha);
} }
@Test @Test
@ -159,7 +159,7 @@ public class LimboPlayerTaskManagerTest {
// then // then
verify(limboPlayer).setTimeoutTask(bukkitTask); verify(limboPlayer).setTimeoutTask(bukkitTask);
verify(bukkitService).runTaskLater(any(TimeoutTask.class), eq(600L)); // 30 * TICKS_PER_SECOND verify(bukkitService).runTaskLater(any(TimeoutTask.class), eq(600L)); // 30 * TICKS_PER_SECOND
verify(messages).retrieveSingle(MessageKey.LOGIN_TIMEOUT_ERROR); verify(messages).retrieveSingle(player, MessageKey.LOGIN_TIMEOUT_ERROR);
} }
@Test @Test
@ -194,7 +194,7 @@ public class LimboPlayerTaskManagerTest {
verify(existingTask).cancel(); verify(existingTask).cancel();
assertThat(limboPlayer.getTimeoutTask(), equalTo(bukkitTask)); assertThat(limboPlayer.getTimeoutTask(), equalTo(bukkitTask));
verify(bukkitService).runTaskLater(any(TimeoutTask.class), eq(360L)); // 18 * TICKS_PER_SECOND verify(bukkitService).runTaskLater(any(TimeoutTask.class), eq(360L)); // 18 * TICKS_PER_SECOND
verify(messages).retrieveSingle(MessageKey.LOGIN_TIMEOUT_ERROR); verify(messages).retrieveSingle(player, MessageKey.LOGIN_TIMEOUT_ERROR);
} }
} }

View File

@ -101,7 +101,7 @@ public class OnJoinVerifierTest {
event.setResult(PlayerLoginEvent.Result.KICK_FULL); event.setResult(PlayerLoginEvent.Result.KICK_FULL);
given(permissionsManager.hasPermission(player, PlayerStatePermission.IS_VIP)).willReturn(false); given(permissionsManager.hasPermission(player, PlayerStatePermission.IS_VIP)).willReturn(false);
String serverFullMessage = "server is full"; String serverFullMessage = "server is full";
given(messages.retrieveSingle(MessageKey.KICK_FULL_SERVER)).willReturn(serverFullMessage); given(messages.retrieveSingle(player, MessageKey.KICK_FULL_SERVER)).willReturn(serverFullMessage);
// when // when
boolean result = onJoinVerifier.refusePlayerForFullServer(event); boolean result = onJoinVerifier.refusePlayerForFullServer(event);
@ -125,7 +125,7 @@ public class OnJoinVerifierTest {
given(permissionsManager.hasPermission(onlinePlayers.get(1), PlayerStatePermission.IS_VIP)).willReturn(false); given(permissionsManager.hasPermission(onlinePlayers.get(1), PlayerStatePermission.IS_VIP)).willReturn(false);
returnOnlineListFromBukkitServer(onlinePlayers); returnOnlineListFromBukkitServer(onlinePlayers);
given(server.getMaxPlayers()).willReturn(onlinePlayers.size()); given(server.getMaxPlayers()).willReturn(onlinePlayers.size());
given(messages.retrieveSingle(MessageKey.KICK_FOR_VIP)).willReturn("kick for vip"); given(messages.retrieveSingle(player, MessageKey.KICK_FOR_VIP)).willReturn("kick for vip");
// when // when
boolean result = onJoinVerifier.refusePlayerForFullServer(event); boolean result = onJoinVerifier.refusePlayerForFullServer(event);
@ -149,7 +149,7 @@ public class OnJoinVerifierTest {
given(permissionsManager.hasPermission(onlinePlayers.get(0), PlayerStatePermission.IS_VIP)).willReturn(true); given(permissionsManager.hasPermission(onlinePlayers.get(0), PlayerStatePermission.IS_VIP)).willReturn(true);
returnOnlineListFromBukkitServer(onlinePlayers); returnOnlineListFromBukkitServer(onlinePlayers);
given(server.getMaxPlayers()).willReturn(onlinePlayers.size()); given(server.getMaxPlayers()).willReturn(onlinePlayers.size());
given(messages.retrieveSingle(MessageKey.KICK_FULL_SERVER)).willReturn("kick full server"); given(messages.retrieveSingle(player, MessageKey.KICK_FULL_SERVER)).willReturn("kick full server");
// when // when
boolean result = onJoinVerifier.refusePlayerForFullServer(event); boolean result = onJoinVerifier.refusePlayerForFullServer(event);

View File

@ -596,7 +596,7 @@ public class PlayerListenerTest {
MessageKey.INVALID_NAME_CHARACTERS, "[a-z]"); MessageKey.INVALID_NAME_CHARACTERS, "[a-z]");
doThrow(exception).when(onJoinVerifier).checkIsValidName(name); doThrow(exception).when(onJoinVerifier).checkIsValidName(name);
String message = "Invalid characters!"; String message = "Invalid characters!";
given(messages.retrieveSingle(exception.getReason(), exception.getArgs())).willReturn(message); given(messages.retrieveSingle(player, exception.getReason(), exception.getArgs())).willReturn(message);
// when // when
listener.onPlayerLogin(event); listener.onPlayerLogin(event);

View File

@ -81,9 +81,11 @@ public class MessagesIntegrationTest {
public void shouldLoadMessageAndSplitAtNewLines() { public void shouldLoadMessageAndSplitAtNewLines() {
// given // given
MessageKey key = MessageKey.UNKNOWN_USER; MessageKey key = MessageKey.UNKNOWN_USER;
CommandSender sender = mock(CommandSender.class);
given(sender.getName()).willReturn("Tester");
// when // when
String[] message = messages.retrieve(key); String[] message = messages.retrieve(key, sender);
// then // then
String[] lines = new String[]{"We've got", "new lines", "and ' apostrophes"}; String[] lines = new String[]{"We've got", "new lines", "and ' apostrophes"};
@ -94,9 +96,11 @@ public class MessagesIntegrationTest {
public void shouldLoadMessageAsStringWithNewLines() { public void shouldLoadMessageAsStringWithNewLines() {
// given // given
MessageKey key = MessageKey.UNKNOWN_USER; MessageKey key = MessageKey.UNKNOWN_USER;
CommandSender sender = mock(CommandSender.class);
given(sender.getName()).willReturn("Tester");
// when // when
String message = messages.retrieveSingle(key); String message = messages.retrieveSingle(sender, key);
// then // then
assertThat(message, equalTo("We've got\nnew lines\nand ' apostrophes")); assertThat(message, equalTo("We've got\nnew lines\nand ' apostrophes"));
@ -106,9 +110,11 @@ public class MessagesIntegrationTest {
public void shouldFormatColorCodes() { public void shouldFormatColorCodes() {
// given // given
MessageKey key = MessageKey.LOGIN_SUCCESS; MessageKey key = MessageKey.LOGIN_SUCCESS;
CommandSender sender = mock(CommandSender.class);
given(sender.getName()).willReturn("Tester");
// when // when
String[] message = messages.retrieve(key); String[] message = messages.retrieve(key, sender);
// then // then
assertThat(message, arrayWithSize(1)); assertThat(message, arrayWithSize(1));
@ -120,6 +126,7 @@ public class MessagesIntegrationTest {
// given // given
MessageKey key = MessageKey.EMAIL_ALREADY_USED_ERROR; MessageKey key = MessageKey.EMAIL_ALREADY_USED_ERROR;
CommandSender sender = mock(CommandSender.class); CommandSender sender = mock(CommandSender.class);
given(sender.getName()).willReturn("Tester");
// when // when
messages.send(sender, key); messages.send(sender, key);
@ -133,6 +140,8 @@ public class MessagesIntegrationTest {
// given // given
MessageKey key = MessageKey.LOGIN_SUCCESS; MessageKey key = MessageKey.LOGIN_SUCCESS;
Player player = Mockito.mock(Player.class); Player player = Mockito.mock(Player.class);
given(player.getName()).willReturn("Tester");
given(player.getDisplayName()).willReturn("§cTesty");
// when // when
messages.send(player, key); messages.send(player, key);
@ -146,6 +155,8 @@ public class MessagesIntegrationTest {
// given // given
MessageKey key = MessageKey.UNKNOWN_USER; MessageKey key = MessageKey.UNKNOWN_USER;
Player player = Mockito.mock(Player.class); Player player = Mockito.mock(Player.class);
given(player.getName()).willReturn("Tester");
given(player.getDisplayName()).willReturn("§cTesty");
// when // when
messages.send(player, key); messages.send(player, key);
@ -157,11 +168,27 @@ public class MessagesIntegrationTest {
assertThat(captor.getAllValues(), contains(lines)); assertThat(captor.getAllValues(), contains(lines));
} }
@Test
public void shouldSendMessageToPlayerWithNameReplacement() {
// given
MessageKey key = MessageKey.REGISTER_MESSAGE;
Player player = Mockito.mock(Player.class);
given(player.getName()).willReturn("Tester");
given(player.getDisplayName()).willReturn("§cTesty");
// when
messages.send(player, key);
// then
verify(player).sendMessage("§3Please Tester, register to the §cTesty§3.");
}
@Test @Test
public void shouldSendMessageToPlayerWithTagReplacement() { public void shouldSendMessageToPlayerWithTagReplacement() {
// given // given
MessageKey key = MessageKey.CAPTCHA_WRONG_ERROR; MessageKey key = MessageKey.CAPTCHA_WRONG_ERROR;
CommandSender sender = Mockito.mock(CommandSender.class); CommandSender sender = Mockito.mock(CommandSender.class);
given(sender.getName()).willReturn("Tester");
// when // when
messages.send(sender, key, "1234"); messages.send(sender, key, "1234");
@ -175,6 +202,7 @@ public class MessagesIntegrationTest {
// given // given
MessageKey key = MessageKey.CAPTCHA_WRONG_ERROR; MessageKey key = MessageKey.CAPTCHA_WRONG_ERROR;
CommandSender sender = mock(CommandSender.class); CommandSender sender = mock(CommandSender.class);
given(sender.getName()).willReturn("Tester");
// when // when
messages.send(sender, key); messages.send(sender, key);
@ -189,9 +217,11 @@ public class MessagesIntegrationTest {
Logger logger = mock(Logger.class); Logger logger = mock(Logger.class);
ConsoleLogger.setLogger(logger); ConsoleLogger.setLogger(logger);
MessageKey key = MessageKey.CAPTCHA_WRONG_ERROR; MessageKey key = MessageKey.CAPTCHA_WRONG_ERROR;
CommandSender sender = mock(CommandSender.class);
given(sender.getName()).willReturn("Tester");
// when // when
messages.send(mock(CommandSender.class), key, "rep", "rep2"); messages.send(sender, key, "rep", "rep2");
// then // then
verify(logger).warning(argThat(containsString("Invalid number of replacements"))); verify(logger).warning(argThat(containsString("Invalid number of replacements")));
@ -203,9 +233,11 @@ public class MessagesIntegrationTest {
Logger logger = mock(Logger.class); Logger logger = mock(Logger.class);
ConsoleLogger.setLogger(logger); ConsoleLogger.setLogger(logger);
MessageKey key = MessageKey.UNKNOWN_USER; MessageKey key = MessageKey.UNKNOWN_USER;
CommandSender sender = mock(CommandSender.class);
given(sender.getName()).willReturn("Tester");
// when // when
messages.send(mock(CommandSender.class), key, "Replacement"); messages.send(sender, key, "Replacement");
// then // then
verify(logger).warning(argThat(containsString("Invalid number of replacements"))); verify(logger).warning(argThat(containsString("Invalid number of replacements")));
@ -216,9 +248,11 @@ public class MessagesIntegrationTest {
// given // given
// Key is present in both files // Key is present in both files
MessageKey key = MessageKey.WRONG_PASSWORD; MessageKey key = MessageKey.WRONG_PASSWORD;
CommandSender sender = mock(CommandSender.class);
given(sender.getName()).willReturn("Tester");
// when // when
String message = messages.retrieveSingle(key); String message = messages.retrieveSingle(sender, key);
// then // then
assertThat(message, equalTo("§cWrong password!")); assertThat(message, equalTo("§cWrong password!"));
@ -228,9 +262,11 @@ public class MessagesIntegrationTest {
public void shouldRetrieveMessageWithReplacements() { public void shouldRetrieveMessageWithReplacements() {
// given // given
MessageKey key = MessageKey.CAPTCHA_WRONG_ERROR; MessageKey key = MessageKey.CAPTCHA_WRONG_ERROR;
CommandSender sender = mock(CommandSender.class);
given(sender.getName()).willReturn("Tester");
// when // when
String result = messages.retrieveSingle(key, "24680"); String result = messages.retrieveSingle(sender.getName(), key, "24680");
// then // then
assertThat(result, equalTo("Use /captcha 24680 to solve the captcha")); assertThat(result, equalTo("Use /captcha 24680 to solve the captcha"));

View File

@ -83,15 +83,16 @@ public class CommonServiceTest {
public void shouldRetrieveSingleMessage() { public void shouldRetrieveSingleMessage() {
// given // given
MessageKey key = MessageKey.ACCOUNT_NOT_ACTIVATED; MessageKey key = MessageKey.ACCOUNT_NOT_ACTIVATED;
Player player = mock(Player.class);
String text = "Test text"; String text = "Test text";
given(messages.retrieveSingle(key)).willReturn(text); given(messages.retrieveSingle(player, key)).willReturn(text);
// when // when
String result = commonService.retrieveSingleMessage(key); String result = commonService.retrieveSingleMessage(player, key);
// then // then
assertThat(result, equalTo(text)); assertThat(result, equalTo(text));
verify(messages).retrieveSingle(key); verify(messages).retrieveSingle(player, key);
} }
@Test @Test

View File

@ -2,6 +2,8 @@
error: error:
unregistered_user: 'We''ve got%nl%new lines%nl%and '' apostrophes' unregistered_user: 'We''ve got%nl%new lines%nl%and '' apostrophes'
registration:
register_request: '&3Please %username%, register to the %displayname%&3.'
login: login:
success: '&cHere we have&bdefined some colors &dand some other &lthings' success: '&cHere we have&bdefined some colors &dand some other &lthings'
wrong_password: '&cWrong password!' wrong_password: '&cWrong password!'