mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-24 01:27:35 +01:00
Abstract Messages into two layers; move to new 'output' package
- Abstract Messages into two layers: the top layer 'Messages' is how Messages can be retrieved and sent as before. In the background, package-private, MessagesManager actually does the file read and worries about I/O while Messages takes care of higher-level things (such as joining two lines or checking the current language).
This commit is contained in:
parent
2550e04112
commit
690a8d67a3
@ -1,8 +1,8 @@
|
|||||||
package fr.xephi.authme;
|
package fr.xephi.authme;
|
||||||
|
|
||||||
import fr.xephi.authme.permission.PlayerPermission;
|
import fr.xephi.authme.permission.PlayerPermission;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.util.Wrapper;
|
import fr.xephi.authme.util.Wrapper;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -17,6 +17,8 @@ import fr.xephi.authme.hooks.BungeeCordMessage;
|
|||||||
import fr.xephi.authme.hooks.EssSpawn;
|
import fr.xephi.authme.hooks.EssSpawn;
|
||||||
import fr.xephi.authme.listener.*;
|
import fr.xephi.authme.listener.*;
|
||||||
import fr.xephi.authme.modules.ModuleManager;
|
import fr.xephi.authme.modules.ModuleManager;
|
||||||
|
import fr.xephi.authme.output.MessageKey;
|
||||||
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.permission.PlayerPermission;
|
import fr.xephi.authme.permission.PlayerPermission;
|
||||||
import fr.xephi.authme.process.Management;
|
import fr.xephi.authme.process.Management;
|
||||||
@ -227,7 +229,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
this.otherAccounts = OtherAccounts.getInstance();
|
this.otherAccounts = OtherAccounts.getInstance();
|
||||||
|
|
||||||
// Setup messages
|
// Setup messages
|
||||||
this.messages = new Messages(Settings.messageFile, Settings.messagesLanguage);
|
this.messages = Messages.getInstance();
|
||||||
|
|
||||||
// Set up Metrics
|
// Set up Metrics
|
||||||
setupMetrics();
|
setupMetrics();
|
||||||
|
@ -5,8 +5,8 @@ import fr.xephi.authme.ConsoleLogger;
|
|||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
import fr.xephi.authme.command.CommandParts;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@ import fr.xephi.authme.cache.auth.PlayerCache;
|
|||||||
import fr.xephi.authme.command.CommandParts;
|
import fr.xephi.authme.command.CommandParts;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -4,8 +4,8 @@ import fr.xephi.authme.AuthMe;
|
|||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
import fr.xephi.authme.command.CommandParts;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,8 +4,8 @@ import fr.xephi.authme.AuthMe;
|
|||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
import fr.xephi.authme.command.CommandParts;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -5,8 +5,8 @@ import fr.xephi.authme.ConsoleLogger;
|
|||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
import fr.xephi.authme.command.CommandParts;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ import fr.xephi.authme.cache.auth.PlayerAuth;
|
|||||||
import fr.xephi.authme.command.CommandParts;
|
import fr.xephi.authme.command.CommandParts;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -6,8 +6,8 @@ import fr.xephi.authme.AuthMe;
|
|||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
import fr.xephi.authme.command.CommandParts;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.util.Profiler;
|
import fr.xephi.authme.util.Profiler;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -41,7 +41,7 @@ public class ReloadCommand extends ExecutableCommand {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Settings.reload();
|
Settings.reload();
|
||||||
plugin.setMessages(new Messages(Settings.messageFile, Settings.messagesLanguage));
|
Messages.getInstance().reloadManager();
|
||||||
plugin.getModuleManager().reloadModules();
|
plugin.getModuleManager().reloadModules();
|
||||||
plugin.setupDatabase();
|
plugin.setupDatabase();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -5,8 +5,8 @@ import fr.xephi.authme.cache.auth.PlayerAuth;
|
|||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
import fr.xephi.authme.command.CommandParts;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ import fr.xephi.authme.cache.auth.PlayerCache;
|
|||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
import fr.xephi.authme.command.CommandParts;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.task.MessageTask;
|
import fr.xephi.authme.task.MessageTask;
|
||||||
import fr.xephi.authme.task.TimeoutTask;
|
import fr.xephi.authme.task.TimeoutTask;
|
||||||
|
@ -5,8 +5,8 @@ import fr.xephi.authme.cache.auth.PlayerCache;
|
|||||||
import fr.xephi.authme.command.CommandParts;
|
import fr.xephi.authme.command.CommandParts;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.security.RandomString;
|
import fr.xephi.authme.security.RandomString;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -4,8 +4,8 @@ import fr.xephi.authme.AuthMe;
|
|||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
import fr.xephi.authme.command.CommandParts;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.task.ChangePasswordTask;
|
import fr.xephi.authme.task.ChangePasswordTask;
|
||||||
import fr.xephi.authme.util.Wrapper;
|
import fr.xephi.authme.util.Wrapper;
|
||||||
|
@ -4,8 +4,8 @@ import fr.xephi.authme.AuthMe;
|
|||||||
import fr.xephi.authme.command.CommandParts;
|
import fr.xephi.authme.command.CommandParts;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.converter.*;
|
import fr.xephi.authme.converter.*;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
@ -8,8 +8,8 @@ import fr.xephi.authme.command.CommandParts;
|
|||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.security.RandomString;
|
import fr.xephi.authme.security.RandomString;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.util.Wrapper;
|
import fr.xephi.authme.util.Wrapper;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -5,8 +5,8 @@ import fr.xephi.authme.command.CommandParts;
|
|||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.process.Management;
|
import fr.xephi.authme.process.Management;
|
||||||
import fr.xephi.authme.security.RandomString;
|
import fr.xephi.authme.security.RandomString;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.util.Wrapper;
|
import fr.xephi.authme.util.Wrapper;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -4,8 +4,8 @@ import fr.xephi.authme.AuthMe;
|
|||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
import fr.xephi.authme.command.CommandParts;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import fr.xephi.authme.ConsoleLogger;
|
|||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.datasource.FlatFile;
|
import fr.xephi.authme.datasource.FlatFile;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -11,8 +11,8 @@ import fr.xephi.authme.cache.limbo.LimboCache;
|
|||||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.permission.PlayerPermission;
|
import fr.xephi.authme.permission.PlayerPermission;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.util.GeoLiteAPI;
|
import fr.xephi.authme.util.GeoLiteAPI;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
@ -32,6 +32,8 @@ import org.bukkit.event.player.*;
|
|||||||
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import static fr.xephi.authme.output.MessageKey.USERNAME_ALREADY_ONLINE_ERROR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class AuthMePlayerListener implements Listener {
|
public class AuthMePlayerListener implements Listener {
|
||||||
@ -207,7 +209,7 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
// Check if forceSingleSession is set to true, so kick player that has
|
// Check if forceSingleSession is set to true, so kick player that has
|
||||||
// joined with same nick of online player
|
// joined with same nick of online player
|
||||||
if (Settings.isForceSingleSessionEnabled && player.isOnline()) {
|
if (Settings.isForceSingleSessionEnabled && player.isOnline()) {
|
||||||
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, m.getString("same_nick"));
|
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, m.retrieveSingle(USERNAME_ALREADY_ONLINE_ERROR));
|
||||||
if (LimboCache.getInstance().hasLimboPlayer(name))
|
if (LimboCache.getInstance().hasLimboPlayer(name))
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||||
|
|
||||||
@ -340,7 +342,8 @@ public class AuthMePlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!Settings.isForceSingleSessionEnabled) && (event.getReason().contains(m.getString("same_nick")))) {
|
if (!Settings.isForceSingleSessionEnabled && event.getReason().contains(
|
||||||
|
m.retrieveSingle(USERNAME_ALREADY_ONLINE_ERROR))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@ package fr.xephi.authme.listener;
|
|||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.util.GeoLiteAPI;
|
import fr.xephi.authme.util.GeoLiteAPI;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package fr.xephi.authme.settings;
|
package fr.xephi.authme.output;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keys for translatable messages managed by {@link Messages}.
|
* Keys for translatable messages managed by {@link Messages}.
|
72
src/main/java/fr/xephi/authme/output/Messages.java
Normal file
72
src/main/java/fr/xephi/authme/output/Messages.java
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
package fr.xephi.authme.output;
|
||||||
|
|
||||||
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
import fr.xephi.authme.util.StringUtils;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class for retrieving and sending translatable messages to players.
|
||||||
|
*/
|
||||||
|
public class Messages {
|
||||||
|
|
||||||
|
private static Messages singleton;
|
||||||
|
private final String language;
|
||||||
|
private MessagesManager manager;
|
||||||
|
|
||||||
|
|
||||||
|
private Messages(String language, MessagesManager manager) {
|
||||||
|
this.language = language;
|
||||||
|
this.manager = manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Messages getInstance() {
|
||||||
|
if (singleton == null) {
|
||||||
|
MessagesManager manager = new MessagesManager(Settings.messageFile);
|
||||||
|
singleton = new Messages(Settings.messagesLanguage, manager);
|
||||||
|
}
|
||||||
|
return singleton;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send the given message code to the player.
|
||||||
|
*
|
||||||
|
* @param sender The entity to send the message to
|
||||||
|
* @param key The key of the message to send
|
||||||
|
*/
|
||||||
|
public void send(CommandSender sender, MessageKey key) {
|
||||||
|
String[] lines = manager.retrieve(key.getKey());
|
||||||
|
for (String line : lines) {
|
||||||
|
sender.sendMessage(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the message from the text file and return it split by new line as an array.
|
||||||
|
*
|
||||||
|
* @param key The message key to retrieve
|
||||||
|
*
|
||||||
|
* @return The message split by new lines
|
||||||
|
*/
|
||||||
|
public String[] retrieve(MessageKey key) {
|
||||||
|
if (!Settings.messagesLanguage.equalsIgnoreCase(language)) {
|
||||||
|
reloadManager();
|
||||||
|
}
|
||||||
|
return manager.retrieve(key.getKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the message from the text file.
|
||||||
|
*
|
||||||
|
* @param key The message key to retrieve
|
||||||
|
*
|
||||||
|
* @return The message from the file
|
||||||
|
*/
|
||||||
|
public String retrieveSingle(MessageKey key) {
|
||||||
|
return StringUtils.join("\n", retrieve(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reloadManager() {
|
||||||
|
manager = new MessagesManager(Settings.messageFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
59
src/main/java/fr/xephi/authme/output/MessagesManager.java
Normal file
59
src/main/java/fr/xephi/authme/output/MessagesManager.java
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
package fr.xephi.authme.output;
|
||||||
|
|
||||||
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
|
import fr.xephi.authme.settings.CustomConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class for retrieving and sending translatable messages to players.
|
||||||
|
*/
|
||||||
|
class MessagesManager extends CustomConfiguration {
|
||||||
|
|
||||||
|
/** The section symbol, used in Minecraft for formatting codes. */
|
||||||
|
private static final String SECTION_SIGN = "\u00a7";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for Messages.
|
||||||
|
*
|
||||||
|
* @param file the configuration file
|
||||||
|
*/
|
||||||
|
MessagesManager(File file) {
|
||||||
|
super(file);
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the message from the configuration file.
|
||||||
|
*
|
||||||
|
* @param key The key to retrieve
|
||||||
|
*
|
||||||
|
* @return The message
|
||||||
|
*/
|
||||||
|
String[] retrieve(String key) {
|
||||||
|
String message = (String) get(key);
|
||||||
|
if (message != null) {
|
||||||
|
return formatMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Message is null: log key not being found and send error back as message
|
||||||
|
String retrievalError = "Error getting message with key '" + key + "'. ";
|
||||||
|
ConsoleLogger.showError(retrievalError + "Please verify your config file at '"
|
||||||
|
+ getConfigFile().getName() + "'");
|
||||||
|
return new String[]{
|
||||||
|
retrievalError + "Please contact the admin to verify or update the AuthMe messages file."};
|
||||||
|
}
|
||||||
|
|
||||||
|
static String[] formatMessage(String message) {
|
||||||
|
// TODO: Check that the codes actually exist, i.e. replace &c but not &y
|
||||||
|
// TODO: Allow '&' to be retained with the code '&&'
|
||||||
|
String[] lines = message.split("&n");
|
||||||
|
for (int i = 0; i < lines.length; ++i) {
|
||||||
|
// We don't initialize a StringBuilder here because mostly we will only have one entry
|
||||||
|
lines[i] = lines[i].replace("&", SECTION_SIGN);
|
||||||
|
}
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,8 +5,8 @@ import fr.xephi.authme.ConsoleLogger;
|
|||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.permission.PlayerPermission;
|
import fr.xephi.authme.permission.PlayerPermission;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ import fr.xephi.authme.events.ProtectInventoryEvent;
|
|||||||
import fr.xephi.authme.events.SpawnTeleportEvent;
|
import fr.xephi.authme.events.SpawnTeleportEvent;
|
||||||
import fr.xephi.authme.listener.AuthMePlayerListener;
|
import fr.xephi.authme.listener.AuthMePlayerListener;
|
||||||
import fr.xephi.authme.permission.PlayerPermission;
|
import fr.xephi.authme.permission.PlayerPermission;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.Spawn;
|
import fr.xephi.authme.settings.Spawn;
|
||||||
import fr.xephi.authme.task.MessageTask;
|
import fr.xephi.authme.task.MessageTask;
|
||||||
|
@ -11,8 +11,8 @@ import fr.xephi.authme.listener.AuthMePlayerListener;
|
|||||||
import fr.xephi.authme.permission.PlayerPermission;
|
import fr.xephi.authme.permission.PlayerPermission;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.security.RandomString;
|
import fr.xephi.authme.security.RandomString;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.task.MessageTask;
|
import fr.xephi.authme.task.MessageTask;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
|
@ -5,8 +5,8 @@ import fr.xephi.authme.cache.auth.PlayerAuth;
|
|||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
import fr.xephi.authme.util.Utils.GroupType;
|
import fr.xephi.authme.util.Utils.GroupType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -4,8 +4,8 @@ import fr.xephi.authme.AuthMe;
|
|||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||||
import fr.xephi.authme.events.LogoutEvent;
|
import fr.xephi.authme.events.LogoutEvent;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.task.MessageTask;
|
import fr.xephi.authme.task.MessageTask;
|
||||||
import fr.xephi.authme.task.TimeoutTask;
|
import fr.xephi.authme.task.TimeoutTask;
|
||||||
|
@ -7,8 +7,8 @@ import fr.xephi.authme.cache.auth.PlayerCache;
|
|||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.permission.PlayerPermission;
|
import fr.xephi.authme.permission.PlayerPermission;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -4,8 +4,8 @@ import fr.xephi.authme.AuthMe;
|
|||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.task.MessageTask;
|
import fr.xephi.authme.task.MessageTask;
|
||||||
import fr.xephi.authme.task.TimeoutTask;
|
import fr.xephi.authme.task.TimeoutTask;
|
||||||
|
@ -6,8 +6,8 @@ import fr.xephi.authme.cache.limbo.LimboCache;
|
|||||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||||
import fr.xephi.authme.events.LoginEvent;
|
import fr.xephi.authme.events.LoginEvent;
|
||||||
import fr.xephi.authme.events.RestoreInventoryEvent;
|
import fr.xephi.authme.events.RestoreInventoryEvent;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.task.MessageTask;
|
import fr.xephi.authme.task.MessageTask;
|
||||||
import fr.xephi.authme.task.TimeoutTask;
|
import fr.xephi.authme.task.TimeoutTask;
|
||||||
|
@ -7,8 +7,8 @@ import fr.xephi.authme.cache.backup.JsonCache;
|
|||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.task.MessageTask;
|
import fr.xephi.authme.task.MessageTask;
|
||||||
import fr.xephi.authme.task.TimeoutTask;
|
import fr.xephi.authme.task.TimeoutTask;
|
||||||
|
@ -1,115 +0,0 @@
|
|||||||
package fr.xephi.authme.settings;
|
|
||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
|
||||||
import fr.xephi.authme.util.StringUtils;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class for retrieving and sending translatable messages to players.
|
|
||||||
*/
|
|
||||||
// TODO ljacqu 20151124: This class is a weird mix between singleton and POJO
|
|
||||||
// TODO: change it into POJO
|
|
||||||
public class Messages extends CustomConfiguration {
|
|
||||||
|
|
||||||
/** The section symbol, used in Minecraft for formatting codes. */
|
|
||||||
private static final String SECTION_SIGN = "\u00a7";
|
|
||||||
private static Messages singleton;
|
|
||||||
private String language;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for Messages.
|
|
||||||
*
|
|
||||||
* @param file the configuration file
|
|
||||||
* @param lang the code of the language to use
|
|
||||||
*/
|
|
||||||
public Messages(File file, String lang) {
|
|
||||||
super(file);
|
|
||||||
load();
|
|
||||||
this.language = lang;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Messages getInstance() {
|
|
||||||
if (singleton == null) {
|
|
||||||
singleton = new Messages(Settings.messageFile, Settings.messagesLanguage);
|
|
||||||
}
|
|
||||||
return singleton;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send the given message code to the player.
|
|
||||||
*
|
|
||||||
* @param sender The entity to send the message to
|
|
||||||
* @param key The key of the message to send
|
|
||||||
*/
|
|
||||||
public void send(CommandSender sender, MessageKey key) {
|
|
||||||
String[] lines = retrieve(key);
|
|
||||||
for (String line : lines) {
|
|
||||||
sender.sendMessage(line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the message from the text file and return it split by new line as an array.
|
|
||||||
*
|
|
||||||
* @param key The message key to retrieve
|
|
||||||
*
|
|
||||||
* @return The message split by new lines
|
|
||||||
*/
|
|
||||||
public String[] retrieve(MessageKey key) {
|
|
||||||
return retrieve(key.getKey());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the message from the text file.
|
|
||||||
*
|
|
||||||
* @param key The message key to retrieve
|
|
||||||
*
|
|
||||||
* @return The message from the file
|
|
||||||
*/
|
|
||||||
public String retrieveSingle(MessageKey key) {
|
|
||||||
return StringUtils.join("\n", retrieve(key.getKey()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the message from the configuration file.
|
|
||||||
*
|
|
||||||
* @param key The key to retrieve
|
|
||||||
*
|
|
||||||
* @return The message
|
|
||||||
*/
|
|
||||||
private String[] retrieve(String key) {
|
|
||||||
if (!Settings.messagesLanguage.equalsIgnoreCase(language)) {
|
|
||||||
reloadMessages();
|
|
||||||
}
|
|
||||||
String message = (String) get(key);
|
|
||||||
if (message != null) {
|
|
||||||
return formatMessage(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Message is null: log key not being found and send error back as message
|
|
||||||
String retrievalError = "Error getting message with key '" + key + "'. ";
|
|
||||||
ConsoleLogger.showError(retrievalError + "Please verify your config file at '"
|
|
||||||
+ getConfigFile().getName() + "'");
|
|
||||||
return new String[]{
|
|
||||||
retrievalError + "Please contact the admin to verify or update the AuthMe messages file."};
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String[] formatMessage(String message) {
|
|
||||||
// TODO: Check that the codes actually exist, i.e. replace &c but not &y
|
|
||||||
// TODO: Allow '&' to be retained with the code '&&'
|
|
||||||
String[] lines = message.split("&n");
|
|
||||||
for (int i = 0; i < lines.length; ++i) {
|
|
||||||
// We don't initialize a StringBuilder here because mostly we will only have one entry
|
|
||||||
lines[i] = lines[i].replace("&", SECTION_SIGN);
|
|
||||||
}
|
|
||||||
return lines;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reloadMessages() {
|
|
||||||
singleton = new Messages(Settings.messageFile, Settings.messagesLanguage);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -5,8 +5,8 @@ import fr.xephi.authme.ConsoleLogger;
|
|||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@ package fr.xephi.authme.task;
|
|||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package fr.xephi.authme.util;
|
|||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.scheduler.BukkitScheduler;
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
|
@ -4,8 +4,8 @@ import fr.xephi.authme.AuthMe;
|
|||||||
import fr.xephi.authme.ReflectionTestUtils;
|
import fr.xephi.authme.ReflectionTestUtils;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.command.CommandParts;
|
import fr.xephi.authme.command.CommandParts;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.task.ChangePasswordTask;
|
import fr.xephi.authme.task.ChangePasswordTask;
|
||||||
import fr.xephi.authme.util.WrapperMock;
|
import fr.xephi.authme.util.WrapperMock;
|
||||||
|
@ -2,8 +2,8 @@ package fr.xephi.authme.command.executable.register;
|
|||||||
|
|
||||||
import fr.xephi.authme.command.CommandParts;
|
import fr.xephi.authme.command.CommandParts;
|
||||||
import fr.xephi.authme.process.Management;
|
import fr.xephi.authme.process.Management;
|
||||||
import fr.xephi.authme.settings.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.util.WrapperMock;
|
import fr.xephi.authme.util.WrapperMock;
|
||||||
import org.bukkit.command.BlockCommandSender;
|
import org.bukkit.command.BlockCommandSender;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package fr.xephi.authme.settings;
|
package fr.xephi.authme.output;
|
||||||
|
|
||||||
import fr.xephi.authme.util.StringUtils;
|
import fr.xephi.authme.util.StringUtils;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
@ -1,5 +1,6 @@
|
|||||||
package fr.xephi.authme.settings;
|
package fr.xephi.authme.output;
|
||||||
|
|
||||||
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.util.WrapperMock;
|
import fr.xephi.authme.util.WrapperMock;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@ -18,7 +19,7 @@ import static org.mockito.Mockito.verify;
|
|||||||
/**
|
/**
|
||||||
* Test for {@link Messages}.
|
* Test for {@link Messages}.
|
||||||
*/
|
*/
|
||||||
public class MessagesTest {
|
public class MessagesIntegrationTest {
|
||||||
|
|
||||||
private static final String YML_TEST_FILE = "messages_test.yml";
|
private static final String YML_TEST_FILE = "messages_test.yml";
|
||||||
private Messages messages;
|
private Messages messages;
|
||||||
@ -38,8 +39,9 @@ public class MessagesTest {
|
|||||||
throw new RuntimeException("File '" + YML_TEST_FILE + "' could not be loaded");
|
throw new RuntimeException("File '" + YML_TEST_FILE + "' could not be loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
File file = new File(url.getFile());
|
Settings.messageFile = new File(url.getFile());
|
||||||
messages = new Messages(file, "en");
|
Settings.messagesLanguage = "en";
|
||||||
|
messages = Messages.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
@ -2,7 +2,7 @@ package fr.xephi.authme.util;
|
|||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.settings.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.scheduler.BukkitScheduler;
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
|
Loading…
Reference in New Issue
Block a user