Close #449 Rename NewSetting class to Settings :)

This commit is contained in:
ljacqu 2016-07-23 15:50:40 +02:00
parent bcc31afb90
commit 19de5a0525
74 changed files with 248 additions and 248 deletions

View File

@ -4,7 +4,7 @@ import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.permission.PlayerStatePermission;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.ProtectionSettings;
import fr.xephi.authme.util.BukkitService;
import org.bukkit.entity.Player;
@ -20,7 +20,7 @@ import static fr.xephi.authme.util.BukkitService.TICKS_PER_SECOND;
*/
public class AntiBot {
private final NewSetting settings;
private final Settings settings;
private final Messages messages;
private final PermissionsManager permissionsManager;
private final BukkitService bukkitService;
@ -29,7 +29,7 @@ public class AntiBot {
private AntiBotStatus antiBotStatus = AntiBotStatus.DISABLED;
@Inject
AntiBot(NewSetting settings, Messages messages, PermissionsManager permissionsManager,
AntiBot(Settings settings, Messages messages, PermissionsManager permissionsManager,
BukkitService bukkitService) {
this.settings = settings;
this.messages = messages;

View File

@ -34,7 +34,7 @@ import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.permission.PermissionsSystemType;
import fr.xephi.authme.process.Management;
import fr.xephi.authme.security.crypts.SHA256;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.SettingsMigrationService;
import fr.xephi.authme.settings.SpawnLoader;
import fr.xephi.authme.settings.properties.DatabaseSettings;
@ -103,7 +103,7 @@ public class AuthMe extends JavaPlugin {
private Management management;
private CommandHandler commandHandler;
private PermissionsManager permsMan;
private NewSetting newSettings;
private Settings settings;
private Messages messages;
private DataSource database;
private PluginHooks pluginHooks;
@ -193,8 +193,8 @@ public class AuthMe extends JavaPlugin {
ConsoleLogger.setLogFile(new File(getDataFolder(), "authme.log"));
// Load settings and custom configurations, if it fails, stop the server due to security reasons.
newSettings = createNewSetting();
if (newSettings == null) {
settings = createSettings();
if (settings == null) {
getLogger().warning("Could not load configuration. Aborting.");
getServer().shutdown();
setEnabled(false);
@ -202,11 +202,11 @@ public class AuthMe extends JavaPlugin {
}
// Apply settings to the logger
ConsoleLogger.setLoggingOptions(newSettings);
ConsoleLogger.setLoggingOptions(settings);
// Connect to the database and setup tables
try {
setupDatabase(newSettings);
setupDatabase(settings);
} catch (Exception e) {
ConsoleLogger.logException("Fatal error occurred during database connection! "
+ "Authme initialization aborted!", e);
@ -214,7 +214,7 @@ public class AuthMe extends JavaPlugin {
return;
}
// Convert deprecated PLAINTEXT hash entries
MigrationService.changePlainTextToSha256(newSettings, database, new SHA256());
MigrationService.changePlainTextToSha256(settings, database, new SHA256());
// Injector initialization
injector = new InjectorBuilder().addDefaultHandlers("fr.xephi.authme").create();
@ -227,20 +227,20 @@ public class AuthMe extends JavaPlugin {
injector.provide(DataFolder.class, getDataFolder());
// Register elements we instantiate manually
injector.register(NewSetting.class, newSettings);
injector.register(Settings.class, settings);
injector.register(DataSource.class, database);
instantiateServices(injector);
// Set up Metrics
MetricsStarter.setupMetrics(this, newSettings);
MetricsStarter.setupMetrics(this, settings);
// Set console filter
setupConsoleFilter();
// Do a backup on start
// TODO: maybe create a backup manager?
new PerformBackup(this, newSettings).doBackup(PerformBackup.BackupCause.START);
new PerformBackup(this, settings).doBackup(PerformBackup.BackupCause.START);
// Set up the BungeeCord hook
setupBungeeCordHook();
@ -297,13 +297,13 @@ public class AuthMe extends JavaPlugin {
*/
private void showSettingsWarnings() {
// Force single session disabled
if (!newSettings.getProperty(RestrictionSettings.FORCE_SINGLE_SESSION)) {
if (!settings.getProperty(RestrictionSettings.FORCE_SINGLE_SESSION)) {
ConsoleLogger.warning("WARNING!!! By disabling ForceSingleSession, your server protection is inadequate!");
}
// Session timeout disabled
if (newSettings.getProperty(PluginSettings.SESSIONS_TIMEOUT) == 0
&& newSettings.getProperty(PluginSettings.SESSIONS_ENABLED)) {
if (settings.getProperty(PluginSettings.SESSIONS_TIMEOUT) == 0
&& settings.getProperty(PluginSettings.SESSIONS_ENABLED)) {
ConsoleLogger.warning("WARNING!!! You set session timeout to 0, this may cause security issues!");
}
}
@ -341,7 +341,7 @@ public class AuthMe extends JavaPlugin {
int playersOnline = bukkitService.getOnlinePlayers().size();
if (playersOnline < 1) {
database.purgeLogged();
} else if (newSettings.getProperty(SecuritySettings.USE_RELOAD_COMMAND_SUPPORT)) {
} else if (settings.getProperty(SecuritySettings.USE_RELOAD_COMMAND_SUPPORT)) {
for (PlayerAuth auth : database.getLoggedPlayers()) {
if (auth != null) {
auth.setLastLogin(new Date().getTime());
@ -357,7 +357,7 @@ public class AuthMe extends JavaPlugin {
* Set up the BungeeCord hook.
*/
private void setupBungeeCordHook() {
if (newSettings.getProperty(HooksSettings.BUNGEECORD)) {
if (settings.getProperty(HooksSettings.BUNGEECORD)) {
Messenger messenger = Bukkit.getMessenger();
messenger.registerOutgoingPluginChannel(this, "BungeeCord");
messenger.registerIncomingPluginChannel(this, "BungeeCord", injector.getSingleton(BungeeCordMessage.class));
@ -369,12 +369,12 @@ public class AuthMe extends JavaPlugin {
*
* @return The settings instance, or null if it could not be constructed
*/
private NewSetting createNewSetting() {
private Settings createSettings() {
File configFile = new File(getDataFolder(), "config.yml");
PropertyMap properties = SettingsFieldRetriever.getAllPropertyFields();
SettingsMigrationService migrationService = new SettingsMigrationService();
return FileUtils.copyFileFromResource(configFile, "config.yml")
? new NewSetting(configFile, getDataFolder(), properties, migrationService)
? new Settings(configFile, getDataFolder(), properties, migrationService)
: null;
}
@ -382,7 +382,7 @@ public class AuthMe extends JavaPlugin {
* Set up the console filter.
*/
private void setupConsoleFilter() {
if (!newSettings.getProperty(SecuritySettings.REMOVE_PASSWORD_FROM_CONSOLE)) {
if (!settings.getProperty(SecuritySettings.REMOVE_PASSWORD_FROM_CONSOLE)) {
return;
}
// Try to set the log4j filter
@ -414,8 +414,8 @@ public class AuthMe extends JavaPlugin {
}
// Do backup on stop if enabled
if (newSettings != null) {
new PerformBackup(this, newSettings).doBackup(PerformBackup.BackupCause.STOP);
if (settings != null) {
new PerformBackup(this, settings).doBackup(PerformBackup.BackupCause.STOP);
}
new Thread(new Runnable() {
@ -474,7 +474,7 @@ public class AuthMe extends JavaPlugin {
// Stop/unload the server/plugin as defined in the configuration
public void stopOrUnload() {
if (newSettings == null || newSettings.getProperty(SecuritySettings.STOP_SERVER_ON_PROBLEM)) {
if (settings == null || settings.getProperty(SecuritySettings.STOP_SERVER_ON_PROBLEM)) {
ConsoleLogger.warning("THE SERVER IS GOING TO SHUT DOWN AS DEFINED IN THE CONFIGURATION!");
getServer().shutdown();
} else {
@ -492,7 +492,7 @@ public class AuthMe extends JavaPlugin {
* @throws IOException if flat file cannot be read
* @see AuthMe#database
*/
public void setupDatabase(NewSetting settings) throws ClassNotFoundException, SQLException, IOException {
public void setupDatabase(Settings settings) throws ClassNotFoundException, SQLException, IOException {
if (this.database != null) {
this.database.close();
}
@ -552,7 +552,7 @@ public class AuthMe extends JavaPlugin {
limboCache.restoreData(player);
limboCache.removeFromCache(player);
} else {
if (newSettings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) {
if (settings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) {
Location loc = spawnLoader.getPlayerLocationOrSpawn(player);
final PlayerAuth auth = PlayerAuth.builder()
.name(player.getName().toLowerCase())
@ -560,8 +560,8 @@ public class AuthMe extends JavaPlugin {
.location(loc).build();
database.updateQuitLoc(auth);
}
if (newSettings.getProperty(RestrictionSettings.TELEPORT_UNAUTHED_TO_SPAWN)
&& !newSettings.getProperty(RestrictionSettings.NO_TELEPORT)) {
if (settings.getProperty(RestrictionSettings.TELEPORT_UNAUTHED_TO_SPAWN)
&& !settings.getProperty(RestrictionSettings.NO_TELEPORT)) {
PlayerDataStorage playerDataStorage = injector.getIfAvailable(PlayerDataStorage.class);
if (playerDataStorage != null && !playerDataStorage.hasData(player)) {
playerDataStorage.saveData(player);
@ -576,7 +576,7 @@ public class AuthMe extends JavaPlugin {
}
private void scheduleRecallEmailTask() {
if (!newSettings.getProperty(RECALL_PLAYERS)) {
if (!settings.getProperty(RECALL_PLAYERS)) {
return;
}
Bukkit.getScheduler().runTaskTimerAsynchronously(this, new Runnable() {
@ -592,7 +592,7 @@ public class AuthMe extends JavaPlugin {
}
}
}
}, 1, 1200 * newSettings.getProperty(EmailSettings.DELAY_RECALL));
}, 1, 1200 * settings.getProperty(EmailSettings.DELAY_RECALL));
}
public String replaceAllInfo(String message, Player player) {

View File

@ -2,7 +2,7 @@ package fr.xephi.authme;
import com.google.common.base.Throwables;
import fr.xephi.authme.output.LogLevel;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.PluginSettings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import fr.xephi.authme.util.StringUtils;
@ -58,7 +58,7 @@ public final class ConsoleLogger {
*
* @param settings The settings instance
*/
public static void setLoggingOptions(NewSetting settings) {
public static void setLoggingOptions(Settings settings) {
ConsoleLogger.logLevel = settings.getProperty(PluginSettings.LOG_LEVEL);
ConsoleLogger.useLogging = settings.getProperty(SecuritySettings.USE_LOGGING);
if (useLogging) {

View File

@ -1,7 +1,7 @@
package fr.xephi.authme;
import fr.xephi.authme.datasource.DataSourceType;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.BackupSettings;
import fr.xephi.authme.settings.properties.DatabaseSettings;
import fr.xephi.authme.util.StringUtils;
@ -30,7 +30,7 @@ public class PerformBackup {
private final String tblname;
private final String path;
private final File dataFolder;
private final NewSetting settings;
private final Settings settings;
/**
* Constructor for PerformBackup.
@ -38,7 +38,7 @@ public class PerformBackup {
* @param instance AuthMe
* @param settings The plugin settings
*/
public PerformBackup(AuthMe instance, NewSetting settings) {
public PerformBackup(AuthMe instance, Settings settings) {
this.dataFolder = instance.getDataFolder();
this.settings = settings;
this.dbName = settings.getProperty(DatabaseSettings.MYSQL_DATABASE);

View File

@ -2,7 +2,7 @@ package fr.xephi.authme.cache;
import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.security.RandomString;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import javax.inject.Inject;
@ -21,7 +21,7 @@ public class CaptchaManager implements SettingsDependent {
private int captchaLength;
@Inject
CaptchaManager(NewSetting settings) {
CaptchaManager(Settings settings) {
this.playerCounts = new ConcurrentHashMap<>();
this.captchaCodes = new ConcurrentHashMap<>();
reload(settings);
@ -123,7 +123,7 @@ public class CaptchaManager implements SettingsDependent {
}
@Override
public void reload(NewSetting settings) {
public void reload(Settings settings) {
this.isEnabled = settings.getProperty(SecuritySettings.USE_CAPTCHA);
this.threshold = settings.getProperty(SecuritySettings.MAX_LOGIN_TRIES_BEFORE_CAPTCHA);
this.captchaLength = settings.getProperty(SecuritySettings.CAPTCHA_LENGTH);

View File

@ -1,7 +1,7 @@
package fr.xephi.authme.cache;
import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.PluginSettings;
import javax.inject.Inject;
@ -22,7 +22,7 @@ public class SessionManager implements SettingsDependent {
private int timeoutInMinutes;
@Inject
SessionManager(NewSetting settings) {
SessionManager(Settings settings) {
reload(settings);
}
@ -64,7 +64,7 @@ public class SessionManager implements SettingsDependent {
}
@Override
public void reload(NewSetting settings) {
public void reload(Settings settings) {
timeoutInMinutes = settings.getProperty(PluginSettings.SESSIONS_TIMEOUT);
boolean oldEnabled = enabled;
enabled = timeoutInMinutes > 0 && settings.getProperty(PluginSettings.SESSIONS_ENABLED);

View File

@ -3,7 +3,7 @@ package fr.xephi.authme.cache;
import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.Utils;
@ -30,7 +30,7 @@ public class TempbanManager implements SettingsDependent {
private int length;
@Inject
TempbanManager(BukkitService bukkitService, Messages messages, NewSetting settings) {
TempbanManager(BukkitService bukkitService, Messages messages, Settings settings) {
this.ipLoginFailureCounts = new ConcurrentHashMap<>();
this.bukkitService = bukkitService;
this.messages = messages;
@ -108,7 +108,7 @@ public class TempbanManager implements SettingsDependent {
}
@Override
public void reload(NewSetting settings) {
public void reload(Settings settings) {
this.isEnabled = settings.getProperty(SecuritySettings.TEMPBAN_ON_MAX_LOGINS);
this.threshold = settings.getProperty(SecuritySettings.MAX_LOGIN_TEMPBAN);
this.length = settings.getProperty(SecuritySettings.TEMPBAN_LENGTH);

View File

@ -2,7 +2,7 @@ package fr.xephi.authme.cache.limbo;
import fr.xephi.authme.cache.backup.PlayerDataStorage;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.SpawnLoader;
import fr.xephi.authme.settings.properties.PluginSettings;
import fr.xephi.authme.util.StringUtils;
@ -23,12 +23,12 @@ public class LimboCache {
private final Map<String, PlayerData> cache = new ConcurrentHashMap<>();
private PlayerDataStorage playerDataStorage;
private NewSetting settings;
private Settings settings;
private PermissionsManager permissionsManager;
private SpawnLoader spawnLoader;
@Inject
LimboCache(NewSetting settings, PermissionsManager permissionsManager,
LimboCache(Settings settings, PermissionsManager permissionsManager,
SpawnLoader spawnLoader, PlayerDataStorage playerDataStorage) {
this.settings = settings;
this.permissionsManager = permissionsManager;

View File

@ -2,7 +2,7 @@ package fr.xephi.authme.command;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.domain.Property;
import fr.xephi.authme.util.ValidationService;
import org.bukkit.command.CommandSender;
@ -18,7 +18,7 @@ public class CommandService {
@Inject
private Messages messages;
@Inject
private NewSetting settings;
private Settings settings;
@Inject
private ValidationService validationService;
@ -79,7 +79,7 @@ public class CommandService {
*
* @return The settings manager
*/
public NewSetting getSettings() {
public Settings getSettings() {
return settings;
}

View File

@ -9,7 +9,7 @@ import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.initialization.Reloadable;
import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.DatabaseSettings;
import org.bukkit.command.CommandSender;
@ -29,7 +29,7 @@ public class ReloadCommand implements ExecutableCommand {
private Injector injector;
@Inject
private NewSetting settings;
private Settings settings;
@Inject
private DataSource dataSource;

View File

@ -10,7 +10,7 @@ import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.permission.DefaultPermission;
import fr.xephi.authme.permission.PermissionNode;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.PluginSettings;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
@ -48,7 +48,7 @@ public class HelpProvider implements SettingsDependent {
private String helpHeader;
@Inject
HelpProvider(PermissionsManager permissionsManager, NewSetting settings) {
HelpProvider(PermissionsManager permissionsManager, Settings settings) {
this.permissionsManager = permissionsManager;
reload(settings);
}
@ -102,7 +102,7 @@ public class HelpProvider implements SettingsDependent {
}
@Override
public void reload(NewSetting settings) {
public void reload(Settings settings) {
helpHeader = settings.getProperty(PluginSettings.HELP_HEADER);
}

View File

@ -4,7 +4,7 @@ import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.initialization.DataFolder;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.ConverterSettings;
import org.bukkit.command.CommandSender;
@ -20,11 +20,11 @@ import java.io.IOException;
public class CrazyLoginConverter implements Converter {
private final DataSource database;
private final NewSetting settings;
private final Settings settings;
private final File dataFolder;
@Inject
CrazyLoginConverter(@DataFolder File dataFolder, DataSource dataSource, NewSetting settings) {
CrazyLoginConverter(@DataFolder File dataFolder, DataSource dataSource, Settings settings) {
this.dataFolder = dataFolder;
this.database = dataSource;
this.settings = settings;

View File

@ -6,7 +6,7 @@ import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.initialization.DataFolder;
import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.ConverterSettings;
import org.bukkit.command.CommandSender;
@ -24,12 +24,12 @@ import java.util.Map.Entry;
public class RakamakConverter implements Converter {
private final DataSource database;
private final NewSetting settings;
private final Settings settings;
private final File pluginFolder;
private final PasswordSecurity passwordSecurity;
@Inject
RakamakConverter(@DataFolder File dataFolder, DataSource dataSource, NewSetting settings,
RakamakConverter(@DataFolder File dataFolder, DataSource dataSource, Settings settings,
PasswordSecurity passwordSecurity) {
this.database = dataSource;
this.settings = settings;

View File

@ -7,19 +7,19 @@ import fr.xephi.authme.datasource.DataSourceType;
import fr.xephi.authme.datasource.SQLite;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import org.bukkit.command.CommandSender;
import javax.inject.Inject;
public class SqliteToSql implements Converter {
private final NewSetting settings;
private final Settings settings;
private final DataSource dataSource;
private final Messages messages;
@Inject
SqliteToSql(NewSetting settings, DataSource dataSource, Messages messages) {
SqliteToSql(Settings settings, DataSource dataSource, Messages messages) {
this.settings = settings;
this.dataSource = dataSource;
this.messages = messages;

View File

@ -1,6 +1,6 @@
package fr.xephi.authme.datasource;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.DatabaseSettings;
/**
@ -23,7 +23,7 @@ public final class Columns {
public final String ID;
public final String IS_LOGGED;
public Columns(NewSetting settings) {
public Columns(Settings settings) {
NAME = settings.getProperty(DatabaseSettings.MYSQL_COL_NAME);
REAL_NAME = settings.getProperty(DatabaseSettings.MYSQL_COL_REALNAME);
PASSWORD = settings.getProperty(DatabaseSettings.MYSQL_COL_PASSWORD);

View File

@ -8,7 +8,7 @@ import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.security.HashAlgorithm;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.security.crypts.XFBCRYPT;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.DatabaseSettings;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.settings.properties.SecuritySettings;
@ -45,7 +45,7 @@ public class MySQL implements DataSource {
private int phpBbGroup;
private String wordpressPrefix;
public MySQL(NewSetting settings) throws ClassNotFoundException, SQLException, PoolInitializationException {
public MySQL(Settings settings) throws ClassNotFoundException, SQLException, PoolInitializationException {
setParameters(settings);
// Set the connection arguments (and check if connection is ok)
@ -76,12 +76,12 @@ public class MySQL implements DataSource {
}
@VisibleForTesting
MySQL(NewSetting settings, HikariDataSource hikariDataSource) {
MySQL(Settings settings, HikariDataSource hikariDataSource) {
ds = hikariDataSource;
setParameters(settings);
}
private void setParameters(NewSetting settings) {
private void setParameters(Settings settings) {
this.host = settings.getProperty(DatabaseSettings.MYSQL_HOST);
this.port = settings.getProperty(DatabaseSettings.MYSQL_PORT);
this.username = settings.getProperty(DatabaseSettings.MYSQL_USERNAME);

View File

@ -4,7 +4,7 @@ import com.google.common.annotations.VisibleForTesting;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.DatabaseSettings;
import fr.xephi.authme.util.StringUtils;
@ -38,7 +38,7 @@ public class SQLite implements DataSource {
* @throws ClassNotFoundException if no driver could be found for the datasource
* @throws SQLException when initialization of a SQL datasource failed
*/
public SQLite(NewSetting settings) throws ClassNotFoundException, SQLException {
public SQLite(Settings settings) throws ClassNotFoundException, SQLException {
this.database = settings.getProperty(DatabaseSettings.MYSQL_DATABASE);
this.tableName = settings.getProperty(DatabaseSettings.MYSQL_TABLE);
this.col = new Columns(settings);
@ -53,7 +53,7 @@ public class SQLite implements DataSource {
}
@VisibleForTesting
SQLite(NewSetting settings, Connection connection) {
SQLite(Settings settings, Connection connection) {
this.database = settings.getProperty(DatabaseSettings.MYSQL_DATABASE);
this.tableName = settings.getProperty(DatabaseSettings.MYSQL_TABLE);
this.col = new Columns(settings);

View File

@ -7,7 +7,7 @@ import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.BukkitService;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
@ -27,7 +27,7 @@ public class BungeeCordMessage implements PluginMessageListener {
private PlayerCache playerCache;
@Inject
private NewSetting settings;
private Settings settings;
BungeeCordMessage() { }

View File

@ -2,7 +2,7 @@ package fr.xephi.authme.initialization;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.DatabaseSettings;
import fr.xephi.authme.settings.properties.PluginSettings;
import org.mcstats.Metrics;
@ -15,7 +15,7 @@ public class MetricsStarter {
private MetricsStarter() {
}
public static void setupMetrics(AuthMe plugin, NewSetting settings) {
public static void setupMetrics(AuthMe plugin, Settings settings) {
try {
final Metrics metrics = new Metrics(plugin);

View File

@ -1,6 +1,6 @@
package fr.xephi.authme.initialization;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
/**
* Interface for classes that keep a local copy of certain settings.
@ -12,5 +12,5 @@ public interface SettingsDependent {
*
* @param settings the settings instance
*/
void reload(NewSetting settings);
void reload(Settings settings);
}

View File

@ -6,7 +6,7 @@ import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.process.Management;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.SpawnLoader;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
@ -56,7 +56,7 @@ public class AuthMePlayerListener implements Listener {
public static final ConcurrentHashMap<String, String> joinMessage = new ConcurrentHashMap<>();
@Inject
private NewSetting settings;
private Settings settings;
@Inject
private Messages m;
@Inject

View File

@ -4,7 +4,7 @@ import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.hooks.PluginHooks;
import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.util.ValidationService;
import org.bukkit.entity.Entity;
@ -27,7 +27,7 @@ class ListenerService implements SettingsDependent {
private boolean isRegistrationForced;
@Inject
ListenerService(NewSetting settings, DataSource dataSource, PluginHooks pluginHooks,
ListenerService(Settings settings, DataSource dataSource, PluginHooks pluginHooks,
PlayerCache playerCache, ValidationService validationService) {
this.dataSource = dataSource;
this.pluginHooks = pluginHooks;
@ -74,7 +74,7 @@ class ListenerService implements SettingsDependent {
}
@Override
public void reload(NewSetting settings) {
public void reload(Settings settings) {
isRegistrationForced = settings.getProperty(RegistrationSettings.FORCE);
}

View File

@ -9,7 +9,7 @@ import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.permission.PlayerStatePermission;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.ProtectionSettings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
@ -32,7 +32,7 @@ import java.util.regex.Pattern;
class OnJoinVerifier implements Reloadable {
@Inject
private NewSetting settings;
private Settings settings;
@Inject
private DataSource dataSource;
@Inject

View File

@ -5,7 +5,7 @@ import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.util.BukkitService;
import org.bukkit.entity.Player;
@ -30,7 +30,7 @@ public class ProtocolLibService implements SettingsDependent {
private PlayerCache playerCache;
@Inject
ProtocolLibService(AuthMe plugin, NewSetting settings, BukkitService bukkitService, PlayerCache playerCache) {
ProtocolLibService(AuthMe plugin, Settings settings, BukkitService bukkitService, PlayerCache playerCache) {
this.plugin = plugin;
this.bukkitService = bukkitService;
this.playerCache = playerCache;
@ -99,7 +99,7 @@ public class ProtocolLibService implements SettingsDependent {
}
@Override
public void reload(NewSetting settings) {
public void reload(Settings settings) {
boolean oldProtectInventory = this.protectInvBeforeLogin;
this.protectInvBeforeLogin = settings.getProperty(RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN);

View File

@ -3,7 +3,7 @@ package fr.xephi.authme.mail;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.EmailSettings;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.StringUtils;
@ -33,7 +33,7 @@ public class SendMailSSL {
@Inject
private AuthMe plugin;
@Inject
private NewSetting settings;
private Settings settings;
@Inject
private BukkitService bukkitService;

View File

@ -2,7 +2,7 @@ package fr.xephi.authme.output;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
@ -30,7 +30,7 @@ public class Messages implements SettingsDependent {
* @param settings The settings
*/
@Inject
Messages(NewSetting settings) {
Messages(Settings settings) {
reload(settings);
this.defaultFile = settings.getDefaultMessagesFile();
}
@ -118,7 +118,7 @@ public class Messages implements SettingsDependent {
}
@Override
public void reload(NewSetting settings) {
public void reload(Settings settings) {
File messageFile = settings.getMessagesFile();
this.configuration = YamlConfiguration.loadConfiguration(messageFile);
this.fileName = messageFile.getName();

View File

@ -4,7 +4,7 @@ import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.cache.limbo.PlayerData;
import fr.xephi.authme.initialization.Reloadable;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.settings.properties.PluginSettings;
import fr.xephi.authme.settings.properties.SecuritySettings;
@ -22,7 +22,7 @@ public class AuthGroupHandler implements Reloadable {
private PermissionsManager permissionsManager;
@Inject
private NewSetting settings;
private Settings settings;
@Inject
private LimboCache limboCache;

View File

@ -6,7 +6,7 @@ import fr.xephi.authme.permission.AuthGroupHandler;
import fr.xephi.authme.permission.AuthGroupType;
import fr.xephi.authme.permission.PermissionNode;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.domain.Property;
import fr.xephi.authme.util.ValidationService;
import org.bukkit.command.CommandSender;
@ -20,7 +20,7 @@ import javax.inject.Inject;
public class ProcessService {
@Inject
private NewSetting settings;
private Settings settings;
@Inject
private Messages messages;
@ -50,7 +50,7 @@ public class ProcessService {
*
* @return settings manager
*/
public NewSetting getSettings() {
public Settings getSettings() {
return settings;
}

View File

@ -6,7 +6,7 @@ import fr.xephi.authme.events.PasswordEncryptionEvent;
import fr.xephi.authme.initialization.Reloadable;
import fr.xephi.authme.security.crypts.EncryptionMethod;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import org.bukkit.plugin.PluginManager;
@ -19,7 +19,7 @@ import javax.inject.Inject;
public class PasswordSecurity implements Reloadable {
@Inject
private NewSetting settings;
private Settings settings;
@Inject
private DataSource dataSource;

View File

@ -5,7 +5,7 @@ import fr.xephi.authme.security.crypts.description.HasSalt;
import fr.xephi.authme.security.crypts.description.Recommendation;
import fr.xephi.authme.security.crypts.description.SaltType;
import fr.xephi.authme.security.crypts.description.Usage;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.util.StringUtils;
@ -18,7 +18,7 @@ public class BCRYPT implements EncryptionMethod {
private final int bCryptLog2Rounds;
@Inject
public BCRYPT(NewSetting settings) {
public BCRYPT(Settings settings) {
bCryptLog2Rounds = settings.getProperty(HooksSettings.BCRYPT_LOG2_ROUND);
}

View File

@ -5,7 +5,7 @@ import fr.xephi.authme.security.crypts.description.HasSalt;
import fr.xephi.authme.security.crypts.description.Recommendation;
import fr.xephi.authme.security.crypts.description.SaltType;
import fr.xephi.authme.security.crypts.description.Usage;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import javax.inject.Inject;
@ -19,7 +19,7 @@ public class SALTED2MD5 extends SeparateSaltMethod {
private final int saltLength;
@Inject
public SALTED2MD5(NewSetting settings) {
public SALTED2MD5(Settings settings) {
saltLength = settings.getProperty(SecuritySettings.DOUBLE_MD5_SALT_LENGTH);
}

View File

@ -5,7 +5,7 @@ import com.google.common.io.ByteStreams;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.util.BukkitService;
import org.bukkit.entity.Player;
@ -30,7 +30,7 @@ public class BungeeService implements SettingsDependent {
* @param settings AuthMe settings.
*/
@Inject
BungeeService(AuthMe plugin, BukkitService bukkitService, NewSetting settings) {
BungeeService(AuthMe plugin, BukkitService bukkitService, Settings settings) {
this.plugin = plugin;
this.bukkitService = bukkitService;
reload(settings);
@ -100,7 +100,7 @@ public class BungeeService implements SettingsDependent {
}
@Override
public void reload(NewSetting settings) {
public void reload(Settings settings) {
this.isEnabled = settings.getProperty(HooksSettings.BUNGEECORD);
this.bungeeServer = settings.getProperty(HooksSettings.BUNGEECORD_SERVER);
}

View File

@ -28,9 +28,9 @@ import java.util.Map;
import static fr.xephi.authme.util.FileUtils.copyFileFromResource;
/**
* The new settings manager.
* The AuthMe settings manager.
*/
public class NewSetting {
public class Settings {
private final File pluginFolder;
private final File configFile;
@ -50,7 +50,7 @@ public class NewSetting {
* @param propertyMap Collection of all available settings
* @param migrationService Migration service to check the settings file with
*/
public NewSetting(File configFile, File pluginFolder, PropertyMap propertyMap,
public Settings(File configFile, File pluginFolder, PropertyMap propertyMap,
SettingsMigrationService migrationService) {
this.configuration = YamlConfiguration.loadConfiguration(configFile);
this.configFile = configFile;
@ -70,7 +70,7 @@ public class NewSetting {
* @param migrationService Migration service, or null to skip migration checks
*/
@VisibleForTesting
NewSetting(FileConfiguration configuration, File configFile, File pluginFolder, PropertyMap propertyMap,
Settings(FileConfiguration configuration, File configFile, File pluginFolder, PropertyMap propertyMap,
SettingsMigrationService migrationService) {
this.configuration = configuration;
this.configFile = configFile;

View File

@ -31,7 +31,7 @@ import java.io.IOException;
public class SpawnLoader implements Reloadable {
private final File authMeConfigurationFile;
private final NewSetting settings;
private final Settings settings;
private final PluginHooks pluginHooks;
private FileConfiguration authMeConfiguration;
private String[] spawnPriority;
@ -46,7 +46,7 @@ public class SpawnLoader implements Reloadable {
* @param dataSource The plugin auth database instance
*/
@Inject
SpawnLoader(@DataFolder File pluginFolder, NewSetting settings, PluginHooks pluginHooks,
SpawnLoader(@DataFolder File pluginFolder, Settings settings, PluginHooks pluginHooks,
DataSource dataSource) {
File spawnFile = new File(pluginFolder, "spawn.yml");
// TODO ljacqu 20160312: Check if resource could be copied and handle the case if not

View File

@ -6,7 +6,7 @@ import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.cache.limbo.PlayerData;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.util.BukkitService;
@ -26,7 +26,7 @@ public class PlayerDataTaskManager {
private Messages messages;
@Inject
private NewSetting settings;
private Settings settings;
@Inject
private BukkitService bukkitService;

View File

@ -4,7 +4,7 @@ import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.hooks.PluginHooks;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.PurgeSettings;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.Utils;
@ -24,7 +24,7 @@ import static fr.xephi.authme.util.StringUtils.makePath;
class PurgeExecutor {
@Inject
private NewSetting settings;
private Settings settings;
@Inject
private DataSource dataSource;

View File

@ -3,7 +3,7 @@ package fr.xephi.authme.task.purge;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.PurgeSettings;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.CollectionUtils;
@ -25,7 +25,7 @@ public class PurgeService {
private DataSource dataSource;
@Inject
private NewSetting settings;
private Settings settings;
@Inject
private PermissionsManager permissionsManager;

View File

@ -10,7 +10,7 @@ import fr.xephi.authme.datasource.SQLite;
import fr.xephi.authme.security.HashAlgorithm;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.security.crypts.SHA256;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.DatabaseSettings;
import fr.xephi.authme.settings.properties.SecuritySettings;
@ -31,7 +31,7 @@ public final class MigrationService {
* @param dataSource The data source
* @param authmeSha256 Instance to the AuthMe SHA256 encryption method implementation
*/
public static void changePlainTextToSha256(NewSetting settings, DataSource dataSource,
public static void changePlainTextToSha256(Settings settings, DataSource dataSource,
SHA256 authmeSha256) {
if (HashAlgorithm.PLAINTEXT == settings.getProperty(SecuritySettings.PASSWORD_HASH)) {
ConsoleLogger.warning("Your HashAlgorithm has been detected as plaintext and is now deprecated;"
@ -61,7 +61,7 @@ public final class MigrationService {
* @param dataSource The data source
* @return The converted datasource (SQLite), or null if no migration was necessary
*/
public static DataSource convertFlatfileToSqlite(NewSetting settings, DataSource dataSource) {
public static DataSource convertFlatfileToSqlite(Settings settings, DataSource dataSource) {
if (DataSourceType.FILE == settings.getProperty(DatabaseSettings.BACKEND)) {
ConsoleLogger.warning("FlatFile backend has been detected and is now deprecated; it will be changed "
+ "to SQLite... Connection will be impossible until conversion is done!");

View File

@ -10,7 +10,7 @@ import fr.xephi.authme.events.AuthMeTeleportEvent;
import fr.xephi.authme.events.FirstSpawnTeleportEvent;
import fr.xephi.authme.events.SpawnTeleportEvent;
import fr.xephi.authme.initialization.Reloadable;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.SpawnLoader;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import org.bukkit.Location;
@ -30,7 +30,7 @@ import static fr.xephi.authme.settings.properties.RestrictionSettings.TELEPORT_U
public class TeleportationService implements Reloadable {
@Inject
private NewSetting settings;
private Settings settings;
@Inject
private BukkitService bukkitService;

View File

@ -5,7 +5,7 @@ import fr.xephi.authme.initialization.Reloadable;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.permission.PlayerStatePermission;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.domain.Property;
import fr.xephi.authme.settings.properties.EmailSettings;
import fr.xephi.authme.settings.properties.ProtectionSettings;
@ -27,7 +27,7 @@ import java.util.regex.Pattern;
public class ValidationService implements Reloadable {
@Inject
private NewSetting settings;
private Settings settings;
@Inject
private DataSource dataSource;
@Inject

View File

@ -4,7 +4,7 @@ import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.permission.PlayerStatePermission;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.ProtectionSettings;
import fr.xephi.authme.util.BukkitService;
import org.bukkit.entity.Player;
@ -41,7 +41,7 @@ import static org.mockito.Mockito.verify;
public class AntiBotTest {
@Mock
private NewSetting settings;
private Settings settings;
@Mock
private Messages messages;
@Mock

View File

@ -12,7 +12,7 @@ import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.process.Management;
import fr.xephi.authme.process.login.ProcessSyncPlayerLogin;
import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.task.purge.PurgeService;
import org.bukkit.Bukkit;
import org.bukkit.Server;
@ -92,7 +92,7 @@ public class AuthMeInitializationTest {
@Test
public void shouldInitializeAllServices() {
// given
NewSetting settings = new NewSetting(settingsFile, dataFolder, getAllPropertyFields(), alwaysFulfilled());
Settings settings = new Settings(settingsFile, dataFolder, getAllPropertyFields(), alwaysFulfilled());
// TODO ljacqu 20160619: At some point setting the "plugin" field should no longer be necessary
// We only require it right now because of usages of AuthMe#getInstance()
@ -104,7 +104,7 @@ public class AuthMeInitializationTest {
injector.register(PluginManager.class, pluginManager);
injector.register(AuthMe.class, authMe);
injector.register(NewSetting.class, settings);
injector.register(Settings.class, settings);
injector.register(DataSource.class, mock(DataSource.class));
// when

View File

@ -1,7 +1,7 @@
package fr.xephi.authme;
import fr.xephi.authme.output.LogLevel;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.PluginSettings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import fr.xephi.authme.util.StringUtils;
@ -45,7 +45,7 @@ public class ConsoleLoggerTest {
private Logger logger;
@Mock
private NewSetting settings;
private Settings settings;
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@ -144,8 +144,8 @@ public class ConsoleLoggerTest {
TestHelper.validateHasOnlyPrivateEmptyConstructor(ConsoleLogger.class);
}
private static NewSetting newSettings(boolean logToFile, LogLevel logLevel) {
NewSetting settings = mock(NewSetting.class);
private static Settings newSettings(boolean logToFile, LogLevel logLevel) {
Settings settings = mock(Settings.class);
given(settings.getProperty(SecuritySettings.USE_LOGGING)).willReturn(logToFile);
given(settings.getProperty(PluginSettings.LOG_LEVEL)).willReturn(logLevel);
return settings;

View File

@ -1,7 +1,7 @@
package fr.xephi.authme.cache;
import fr.xephi.authme.ReflectionTestUtils;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import org.junit.Test;
@ -21,7 +21,7 @@ public class CaptchaManagerTest {
@Test
public void shouldAddCounts() {
// given
NewSetting settings = mockSettings(3, 4);
Settings settings = mockSettings(3, 4);
CaptchaManager manager = new CaptchaManager(settings);
String player = "tester";
@ -41,7 +41,7 @@ public class CaptchaManagerTest {
public void shouldCreateAndCheckCaptcha() {
// given
String player = "Miner";
NewSetting settings = mockSettings(1, 4);
Settings settings = mockSettings(1, 4);
CaptchaManager manager = new CaptchaManager(settings);
String captchaCode = manager.getCaptchaCodeOrGenerateNew(player);
@ -66,7 +66,7 @@ public class CaptchaManagerTest {
public void shouldHaveSameCodeAfterGeneration() {
// given
String player = "Tester";
NewSetting settings = mockSettings(1, 5);
Settings settings = mockSettings(1, 5);
CaptchaManager manager = new CaptchaManager(settings);
// when
@ -88,7 +88,7 @@ public class CaptchaManagerTest {
public void shouldIncreaseAndResetCount() {
// given
String player = "plaYer";
NewSetting settings = mockSettings(2, 3);
Settings settings = mockSettings(2, 3);
CaptchaManager manager = new CaptchaManager(settings);
// when
@ -111,7 +111,7 @@ public class CaptchaManagerTest {
public void shouldNotIncreaseCountForDisabledCaptcha() {
// given
String player = "someone_";
NewSetting settings = mockSettings(1, 3);
Settings settings = mockSettings(1, 3);
given(settings.getProperty(SecuritySettings.USE_CAPTCHA)).willReturn(false);
CaptchaManager manager = new CaptchaManager(settings);
@ -127,7 +127,7 @@ public class CaptchaManagerTest {
public void shouldNotCheckCountIfCaptchaIsDisabled() {
// given
String player = "Robert001";
NewSetting settings = mockSettings(1, 5);
Settings settings = mockSettings(1, 5);
CaptchaManager manager = new CaptchaManager(settings);
given(settings.getProperty(SecuritySettings.USE_CAPTCHA)).willReturn(false);
@ -144,8 +144,8 @@ public class CaptchaManagerTest {
assertThat(result, equalTo(false));
}
private static NewSetting mockSettings(int maxTries, int captchaLength) {
NewSetting settings = mock(NewSetting.class);
private static Settings mockSettings(int maxTries, int captchaLength) {
Settings settings = mock(Settings.class);
given(settings.getProperty(SecuritySettings.USE_CAPTCHA)).willReturn(true);
given(settings.getProperty(SecuritySettings.MAX_LOGIN_TRIES_BEFORE_CAPTCHA)).willReturn(maxTries);
given(settings.getProperty(SecuritySettings.CAPTCHA_LENGTH)).willReturn(captchaLength);

View File

@ -1,7 +1,7 @@
package fr.xephi.authme.cache;
import fr.xephi.authme.ReflectionTestUtils;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.PluginSettings;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -24,7 +24,7 @@ public class SessionManagerTest {
@Test
public void shouldHaveSession() {
// given
NewSetting settings = mockSettings(true, 10);
Settings settings = mockSettings(true, 10);
SessionManager manager = new SessionManager(settings);
String player = "playah";
@ -38,7 +38,7 @@ public class SessionManagerTest {
@Test
public void shouldNotHaveSession() {
// given
NewSetting settings = mockSettings(true, 10);
Settings settings = mockSettings(true, 10);
SessionManager manager = new SessionManager(settings);
String player = "playah";
@ -49,7 +49,7 @@ public class SessionManagerTest {
@Test
public void shouldNotAddSessionBecauseDisabled() {
// given
NewSetting settings = mockSettings(false, 10);
Settings settings = mockSettings(false, 10);
SessionManager manager = new SessionManager(settings);
String player = "playah";
@ -63,7 +63,7 @@ public class SessionManagerTest {
@Test
public void shouldNotAddSessionBecauseTimeoutIsZero() {
// given
NewSetting settings = mockSettings(true, 0);
Settings settings = mockSettings(true, 0);
SessionManager manager = new SessionManager(settings);
String player = "playah";
@ -77,7 +77,7 @@ public class SessionManagerTest {
@Test
public void shouldRemoveSession() {
// given
NewSetting settings = mockSettings(true, 10);
Settings settings = mockSettings(true, 10);
String player = "user";
SessionManager manager = new SessionManager(settings);
manager.addSession(player);
@ -93,7 +93,7 @@ public class SessionManagerTest {
public void shouldDenySessionIfTimeoutHasExpired() {
// given
int timeout = 20;
NewSetting settings = mockSettings(true, timeout);
Settings settings = mockSettings(true, timeout);
String player = "patrick";
SessionManager manager = new SessionManager(settings);
Map<String, Long> sessions = getSessionsMap(manager);
@ -110,7 +110,7 @@ public class SessionManagerTest {
@Test
public void shouldClearAllSessionsAfterDisable() {
// given
NewSetting settings = mockSettings(true, 10);
Settings settings = mockSettings(true, 10);
SessionManager manager = new SessionManager(settings);
manager.addSession("player01");
manager.addSession("player02");
@ -129,8 +129,8 @@ public class SessionManagerTest {
}
private static NewSetting mockSettings(boolean isEnabled, int sessionTimeout) {
NewSetting settings = mock(NewSetting.class);
private static Settings mockSettings(boolean isEnabled, int sessionTimeout) {
Settings settings = mock(Settings.class);
given(settings.getProperty(PluginSettings.SESSIONS_ENABLED)).willReturn(isEnabled);
given(settings.getProperty(PluginSettings.SESSIONS_TIMEOUT)).willReturn(sessionTimeout);
return settings;

View File

@ -4,7 +4,7 @@ import fr.xephi.authme.ReflectionTestUtils;
import fr.xephi.authme.TestHelper;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import fr.xephi.authme.util.BukkitService;
import org.bukkit.entity.Player;
@ -44,7 +44,7 @@ public class TempbanManagerTest {
@Test
public void shouldAddCounts() {
// given
NewSetting settings = mockSettings(3, 60);
Settings settings = mockSettings(3, 60);
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
String address = "192.168.1.1";
@ -64,7 +64,7 @@ public class TempbanManagerTest {
public void shouldIncreaseAndResetCount() {
// given
String address = "192.168.1.2";
NewSetting settings = mockSettings(3, 60);
Settings settings = mockSettings(3, 60);
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
// when
@ -88,7 +88,7 @@ public class TempbanManagerTest {
public void shouldNotIncreaseCountForDisabledTempban() {
// given
String address = "192.168.1.3";
NewSetting settings = mockSettings(1, 5);
Settings settings = mockSettings(1, 5);
given(settings.getProperty(SecuritySettings.TEMPBAN_ON_MAX_LOGINS)).willReturn(false);
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
@ -104,7 +104,7 @@ public class TempbanManagerTest {
public void shouldNotCheckCountIfTempbanIsDisabled() {
// given
String address = "192.168.1.4";
NewSetting settings = mockSettings(1, 5);
Settings settings = mockSettings(1, 5);
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
given(settings.getProperty(SecuritySettings.TEMPBAN_ON_MAX_LOGINS)).willReturn(false);
@ -124,7 +124,7 @@ public class TempbanManagerTest {
@Test
public void shouldNotIssueBanIfDisabled() {
// given
NewSetting settings = mockSettings(0, 0);
Settings settings = mockSettings(0, 0);
given(settings.getProperty(SecuritySettings.TEMPBAN_ON_MAX_LOGINS)).willReturn(false);
Player player = mock(Player.class);
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
@ -144,7 +144,7 @@ public class TempbanManagerTest {
TestHelper.mockPlayerIp(player, ip);
String banReason = "IP ban too many logins";
given(messages.retrieveSingle(MessageKey.TEMPBAN_MAX_LOGINS)).willReturn(banReason);
NewSetting settings = mockSettings(2, 100);
Settings settings = mockSettings(2, 100);
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
// when
@ -171,7 +171,7 @@ public class TempbanManagerTest {
TestHelper.mockPlayerIp(player, ip);
String banReason = "kick msg";
given(messages.retrieveSingle(MessageKey.TEMPBAN_MAX_LOGINS)).willReturn(banReason);
NewSetting settings = mockSettings(10, 60);
Settings settings = mockSettings(10, 60);
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
manager.increaseCount(ip);
manager.increaseCount(ip);
@ -186,8 +186,8 @@ public class TempbanManagerTest {
assertHasCount(manager, ip, null);
}
private static NewSetting mockSettings(int maxTries, int tempbanLength) {
NewSetting settings = mock(NewSetting.class);
private static Settings mockSettings(int maxTries, int tempbanLength) {
Settings settings = mock(Settings.class);
given(settings.getProperty(SecuritySettings.TEMPBAN_ON_MAX_LOGINS)).willReturn(true);
given(settings.getProperty(SecuritySettings.MAX_LOGIN_TEMPBAN)).willReturn(maxTries);
given(settings.getProperty(SecuritySettings.TEMPBAN_LENGTH)).willReturn(tempbanLength);

View File

@ -3,7 +3,7 @@ package fr.xephi.authme.cache.limbo;
import fr.xephi.authme.ReflectionTestUtils;
import fr.xephi.authme.cache.backup.PlayerDataStorage;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.SpawnLoader;
import fr.xephi.authme.settings.properties.PluginSettings;
import org.bukkit.Location;
@ -35,7 +35,7 @@ public class LimboCacheTest {
private LimboCache limboCache;
@Mock
private NewSetting settings;
private Settings settings;
@Mock
private PermissionsManager permissionsManager;

View File

@ -2,7 +2,7 @@ package fr.xephi.authme.command;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.domain.Property;
import fr.xephi.authme.settings.properties.SecuritySettings;
import fr.xephi.authme.util.ValidationService;
@ -31,7 +31,7 @@ public class CommandServiceTest {
@Mock
private Messages messages;
@Mock
private NewSetting settings;
private Settings settings;
@Mock
private ValidationService validationService;
@ -91,7 +91,7 @@ public class CommandServiceTest {
@Test
public void shouldReturnSettings() {
// given/when
NewSetting result = commandService.getSettings();
Settings result = commandService.getSettings();
// then
assertThat(result, equalTo(settings));

View File

@ -10,7 +10,7 @@ import fr.xephi.authme.initialization.Reloadable;
import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.output.LogLevel;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.DatabaseSettings;
import fr.xephi.authme.settings.properties.PluginSettings;
import fr.xephi.authme.settings.properties.SecuritySettings;
@ -53,7 +53,7 @@ public class ReloadCommandTest {
private Injector injector;
@Mock
private NewSetting settings;
private Settings settings;
@Mock
private DataSource dataSource;

View File

@ -6,7 +6,7 @@ import fr.xephi.authme.command.FoundResultStatus;
import fr.xephi.authme.command.TestCommandsUtil;
import fr.xephi.authme.permission.AdminPermission;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.PluginSettings;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
@ -57,7 +57,7 @@ public class HelpProviderTest {
@Before
public void setUpHelpProvider() {
permissionsManager = mock(PermissionsManager.class);
NewSetting settings = mock(NewSetting.class);
Settings settings = mock(Settings.class);
given(settings.getProperty(PluginSettings.HELP_HEADER)).willReturn(HELP_HEADER);
helpProvider = new HelpProvider(permissionsManager, settings);
sender = mock(CommandSender.class);

View File

@ -6,7 +6,7 @@ import fr.xephi.authme.TestHelper;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.initialization.DataFolder;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.ConverterSettings;
import org.bukkit.command.CommandSender;
import org.junit.BeforeClass;
@ -42,7 +42,7 @@ public class CrazyLoginConverterTest {
private DataSource dataSource;
@Mock
private NewSetting settings;
private Settings settings;
@DataFolder
private File dataFolder = TestHelper.getJarFile(TestHelper.PROJECT_ROOT + "converter/");

View File

@ -8,7 +8,7 @@ import fr.xephi.authme.TestHelper;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.security.HashAlgorithm;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.domain.Property;
import fr.xephi.authme.settings.properties.SecuritySettings;
import org.junit.Before;
@ -72,7 +72,7 @@ public abstract class AbstractResourceClosingTest {
private static final Map<String, HashAlgorithm[]> CUSTOM_ALGORITHMS = getCustomAlgorithmList();
/** Mock of a settings instance. */
private static NewSetting settings;
private static Settings settings;
/** The datasource to test. */
private DataSource dataSource;
@ -101,7 +101,7 @@ public abstract class AbstractResourceClosingTest {
@SuppressWarnings({ "unchecked", "rawtypes" })
@BeforeClass
public static void initializeSettings() throws IOException, ClassNotFoundException {
settings = mock(NewSetting.class);
settings = mock(Settings.class);
given(settings.getProperty(any(Property.class))).willAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) {
@ -152,7 +152,7 @@ public abstract class AbstractResourceClosingTest {
}
/* Create a DataSource instance with the given mock settings and mock connection. */
protected abstract DataSource createDataSource(NewSetting settings, Connection connection) throws Exception;
protected abstract DataSource createDataSource(Settings settings, Connection connection) throws Exception;
/* Get all methods of the DataSource interface, minus the ones in the ignored list. */
private static List<Method> getDataSourceMethods() {

View File

@ -3,7 +3,7 @@ package fr.xephi.authme.datasource;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import fr.xephi.authme.TestHelper;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.domain.Property;
import fr.xephi.authme.settings.properties.DatabaseSettings;
import org.junit.After;
@ -29,7 +29,7 @@ import static org.mockito.Mockito.when;
public class MySqlIntegrationTest extends AbstractDataSourceIntegrationTest {
/** Mock of a settings instance. */
private static NewSetting settings;
private static Settings settings;
/** SQL statement to execute before running a test. */
private static String sqlInitialize;
/** Connection to the H2 test database. */
@ -44,7 +44,7 @@ public class MySqlIntegrationTest extends AbstractDataSourceIntegrationTest {
// Check that we have an H2 driver
Class.forName("org.h2.jdbcx.JdbcDataSource");
settings = mock(NewSetting.class);
settings = mock(Settings.class);
when(settings.getProperty(any(Property.class))).thenAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {

View File

@ -2,7 +2,7 @@ package fr.xephi.authme.datasource;
import com.zaxxer.hikari.HikariDataSource;
import fr.xephi.authme.security.HashAlgorithm;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import java.lang.reflect.Method;
import java.sql.Connection;
@ -20,7 +20,7 @@ public class MySqlResourceClosingTest extends AbstractResourceClosingTest {
}
@Override
protected DataSource createDataSource(NewSetting settings, Connection connection) throws Exception {
protected DataSource createDataSource(Settings settings, Connection connection) throws Exception {
HikariDataSource hikariDataSource = mock(HikariDataSource.class);
given(hikariDataSource.getConnection()).willReturn(connection);
return new MySQL(settings, hikariDataSource);

View File

@ -2,7 +2,7 @@ package fr.xephi.authme.datasource;
import fr.xephi.authme.TestHelper;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.domain.Property;
import fr.xephi.authme.settings.properties.DatabaseSettings;
import org.junit.After;
@ -32,7 +32,7 @@ import static org.mockito.Mockito.when;
public class SQLiteIntegrationTest extends AbstractDataSourceIntegrationTest {
/** Mock of a settings instance. */
private static NewSetting settings;
private static Settings settings;
/** Collection of SQL statements to execute for initialization of a test. */
private static String[] sqlInitialize;
/** Connection to the SQLite test database. */
@ -47,7 +47,7 @@ public class SQLiteIntegrationTest extends AbstractDataSourceIntegrationTest {
// Check that we have an implementation for SQLite
Class.forName("org.sqlite.JDBC");
settings = mock(NewSetting.class);
settings = mock(Settings.class);
when(settings.getProperty(any(Property.class))).thenAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {

View File

@ -1,7 +1,7 @@
package fr.xephi.authme.datasource;
import fr.xephi.authme.security.HashAlgorithm;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import java.lang.reflect.Method;
import java.sql.Connection;
@ -16,7 +16,7 @@ public class SQLiteResourceClosingTest extends AbstractResourceClosingTest {
}
@Override
protected DataSource createDataSource(NewSetting settings, Connection connection) throws Exception {
protected DataSource createDataSource(Settings settings, Connection connection) throws Exception {
return new SQLite(settings, connection);
}

View File

@ -6,7 +6,7 @@ import ch.jalu.injector.testing.InjectDelayed;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.hooks.PluginHooks;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.util.ValidationService;
import org.bukkit.entity.Entity;
@ -35,7 +35,7 @@ public class ListenerServiceTest {
private ListenerService listenerService;
@Mock
private NewSetting settings;
private Settings settings;
@Mock
private DataSource dataSource;

View File

@ -8,7 +8,7 @@ import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.permission.PlayerStatePermission;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.util.BukkitService;
@ -53,7 +53,7 @@ public class OnJoinVerifierTest {
private OnJoinVerifier onJoinVerifier;
@Mock
private NewSetting settings;
private Settings settings;
@Mock
private DataSource dataSource;
@Mock

View File

@ -2,7 +2,7 @@ package fr.xephi.authme.output;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.TestHelper;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.junit.Before;
@ -53,7 +53,7 @@ public class MessagesIntegrationTest {
@Before
public void setUpMessages() {
File testFile = TestHelper.getJarFile(YML_TEST_FILE);
NewSetting settings = mock(NewSetting.class);
Settings settings = mock(Settings.class);
given(settings.getMessagesFile()).willReturn(testFile);
given(settings.getDefaultMessagesFile()).willReturn(YML_DEFAULT_TEST_FILE);
messages = new Messages(settings);
@ -235,7 +235,7 @@ public class MessagesIntegrationTest {
@Test
public void shouldAllowNullAsDefaultFile() {
// given
NewSetting settings = mock(NewSetting.class);
Settings settings = mock(Settings.class);
given(settings.getMessagesFile()).willReturn(TestHelper.getJarFile(YML_TEST_FILE));
Messages testMessages = new Messages(settings);
// Key not present in test file
@ -254,7 +254,7 @@ public class MessagesIntegrationTest {
MessageKey key = MessageKey.WRONG_PASSWORD;
// assumption: message comes back as defined in messages_test.yml
assumeThat(messages.retrieveSingle(key), equalTo("§cWrong password!"));
NewSetting settings = mock(NewSetting.class);
Settings settings = mock(Settings.class);
given(settings.getMessagesFile()).willReturn(TestHelper.getJarFile(
TestHelper.PROJECT_ROOT + "output/messages_test2.yml"));

View File

@ -7,7 +7,7 @@ import fr.xephi.authme.permission.AuthGroupType;
import fr.xephi.authme.permission.PermissionNode;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.permission.PlayerPermission;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import fr.xephi.authme.util.ValidationService;
import org.bukkit.command.CommandSender;
@ -37,7 +37,7 @@ public class ProcessServiceTest {
private ValidationService validationService;
@Mock
private NewSetting settings;
private Settings settings;
@Mock
private Messages messages;
@ -64,7 +64,7 @@ public class ProcessServiceTest {
@Test
public void shouldReturnSettings() {
// given/when
NewSetting result = processService.getSettings();
Settings result = processService.getSettings();
// then
assertThat(result, equalTo(settings));

View File

@ -4,7 +4,7 @@ import ch.jalu.injector.Injector;
import ch.jalu.injector.InjectorBuilder;
import fr.xephi.authme.security.crypts.EncryptionMethod;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import fr.xephi.authme.util.StringUtils;
@ -29,11 +29,11 @@ public class HashAlgorithmIntegrationTest {
@BeforeClass
public static void setUpConfigAndInjector() {
NewSetting settings = mock(NewSetting.class);
Settings settings = mock(Settings.class);
given(settings.getProperty(HooksSettings.BCRYPT_LOG2_ROUND)).willReturn(8);
given(settings.getProperty(SecuritySettings.DOUBLE_MD5_SALT_LENGTH)).willReturn(16);
injector = new InjectorBuilder().addDefaultHandlers("fr.xephi.authme").create();
injector.register(NewSetting.class, settings);
injector.register(Settings.class, settings);
}
@Test

View File

@ -9,7 +9,7 @@ import fr.xephi.authme.events.PasswordEncryptionEvent;
import fr.xephi.authme.security.crypts.EncryptionMethod;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.security.crypts.JOOMLA;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import org.bukkit.event.Event;
@ -45,7 +45,7 @@ public class PasswordSecurityTest {
private Injector injector;
@Mock
private NewSetting settings;
private Settings settings;
@Mock
private PluginManager pluginManager;
@ -81,7 +81,7 @@ public class PasswordSecurityTest {
}
}).when(pluginManager).callEvent(any(Event.class));
injector = new InjectorBuilder().addDefaultHandlers("!! impossible package !!").create();
injector.register(NewSetting.class, settings);
injector.register(Settings.class, settings);
injector.register(DataSource.class, dataSource);
injector.register(PluginManager.class, pluginManager);
}

View File

@ -1,7 +1,7 @@
package fr.xephi.authme.security.crypts;
import fr.xephi.authme.TestHelper;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.HooksSettings;
import org.junit.BeforeClass;
@ -27,8 +27,8 @@ public class BcryptTest extends AbstractEncryptionMethodTest {
);
}
private static NewSetting mockSettings() {
NewSetting settings = mock(NewSetting.class);
private static Settings mockSettings() {
Settings settings = mock(Settings.class);
given(settings.getProperty(HooksSettings.BCRYPT_LOG2_ROUND)).willReturn(8);
return settings;
}

View File

@ -1,6 +1,6 @@
package fr.xephi.authme.security.crypts;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import static org.mockito.BDDMockito.given;
@ -19,8 +19,8 @@ public class SALTED2MD5Test extends AbstractEncryptionMethodTest {
new HashedPassword("ad25606eae5b760c8a2469d65578ac39", "04eee598")); // âË_3(íù*)
}
private static NewSetting mockSettings() {
NewSetting settings = mock(NewSetting.class);
private static Settings mockSettings() {
Settings settings = mock(Settings.class);
given(settings.getProperty(SecuritySettings.DOUBLE_MD5_SALT_LENGTH)).willReturn(8);
return settings;
}

View File

@ -23,7 +23,7 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
/**
* Test for {@link NewSetting} and the project's config.yml,
* Test for {@link Settings} and the project's config.yml,
* verifying that no settings are missing from the file.
*/
public class ConfigFileConsistencyTest {

View File

@ -27,9 +27,9 @@ import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
/**
* Integration test for {@link NewSetting}.
* Integration test for {@link Settings}.
*/
public class NewSettingIntegrationTest {
public class SettingsIntegrationTest {
/** File name of the sample config including all {@link TestConfiguration} values. */
private static final String COMPLETE_FILE = TestHelper.PROJECT_ROOT + "settings/config-sample-values.yml";
@ -63,7 +63,7 @@ public class NewSettingIntegrationTest {
File newFile = temporaryFolder.newFile();
// when / then
NewSetting settings = new NewSetting(configuration, newFile, testPluginFolder, propertyMap,
Settings settings = new Settings(configuration, newFile, testPluginFolder, propertyMap,
checkAllPropertiesPresent());
Map<Property<?>, Object> expectedValues = ImmutableMap.<Property<?>, Object>builder()
.put(TestConfiguration.DURATION_IN_SECONDS, 22)
@ -90,13 +90,13 @@ public class NewSettingIntegrationTest {
File file = copyFileFromResources(INCOMPLETE_FILE);
YamlConfiguration configuration = YamlConfiguration.loadConfiguration(file);
// Expectation: File is rewritten to since it does not have all configurations
new NewSetting(configuration, file, testPluginFolder, propertyMap, checkAllPropertiesPresent());
new Settings(configuration, file, testPluginFolder, propertyMap, checkAllPropertiesPresent());
// Load the settings again -> checks that what we wrote can be loaded again
configuration = YamlConfiguration.loadConfiguration(file);
// then
NewSetting settings = new NewSetting(configuration, file, testPluginFolder, propertyMap,
Settings settings = new Settings(configuration, file, testPluginFolder, propertyMap,
checkAllPropertiesPresent());
Map<Property<?>, Object> expectedValues = ImmutableMap.<Property<?>, Object>builder()
.put(TestConfiguration.DURATION_IN_SECONDS, 22)
@ -133,14 +133,14 @@ public class NewSettingIntegrationTest {
}
// when
new NewSetting(configuration, file, testPluginFolder, propertyMap, checkAllPropertiesPresent());
new Settings(configuration, file, testPluginFolder, propertyMap, checkAllPropertiesPresent());
// reload the file as settings should have been rewritten
configuration = YamlConfiguration.loadConfiguration(file);
// then
// assert that we won't rewrite the settings again! One rewrite should produce a valid, complete configuration
File unusedFile = new File("config-difficult-values.unused.yml");
NewSetting settings = new NewSetting(configuration, unusedFile, testPluginFolder, propertyMap,
Settings settings = new Settings(configuration, unusedFile, testPluginFolder, propertyMap,
checkAllPropertiesPresent());
assertThat(unusedFile.exists(), equalTo(false));
assertThat(configuration.contains(TestConfiguration.DUST_LEVEL.getPath()), equalTo(true));
@ -171,7 +171,7 @@ public class NewSettingIntegrationTest {
// given
YamlConfiguration configuration = YamlConfiguration.loadConfiguration(temporaryFolder.newFile());
File fullConfigFile = copyFileFromResources(COMPLETE_FILE);
NewSetting settings = new NewSetting(configuration, fullConfigFile, testPluginFolder, propertyMap,
Settings settings = new Settings(configuration, fullConfigFile, testPluginFolder, propertyMap,
TestSettingsMigrationServices.alwaysFulfilled());
// when

View File

@ -38,9 +38,9 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
/**
* Unit tests for {@link NewSetting}.
* Unit tests for {@link Settings}.
*/
public class NewSettingTest {
public class SettingsTest {
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@ -71,7 +71,7 @@ public class NewSettingTest {
setReturnValue(configuration, TestConfiguration.SYSTEM_NAME, "myTestSys");
// when / then
NewSetting settings = new NewSetting(configuration, null, null, null, null);
Settings settings = new Settings(configuration, null, null, null, null);
assertThat(settings.getProperty(TestConfiguration.VERSION_NUMBER), equalTo(20));
assertThat(settings.getProperty(TestConfiguration.SKIP_BORING_FEATURES), equalTo(true));
@ -87,7 +87,7 @@ public class NewSettingTest {
public void shouldReturnDefaultFile() throws IOException {
// given
YamlConfiguration configuration = mock(YamlConfiguration.class);
NewSetting settings = new NewSetting(configuration, null, null, null, null);
Settings settings = new Settings(configuration, null, null, null, null);
// when
String defaultFile = settings.getDefaultMessagesFile();
@ -103,7 +103,7 @@ public class NewSettingTest {
public void shouldSetProperty() {
// given
YamlConfiguration configuration = mock(YamlConfiguration.class);
NewSetting settings = new NewSetting(configuration, null, null, null, null);
Settings settings = new Settings(configuration, null, null, null, null);
// when
settings.setProperty(TestConfiguration.DUST_LEVEL, -4);
@ -123,7 +123,7 @@ public class NewSettingTest {
YamlConfiguration configuration = mock(YamlConfiguration.class);
given(configuration.contains(anyString())).willReturn(true);
setReturnValue(configuration, MESSAGES_LANGUAGE, languageCode);
NewSetting settings = new NewSetting(configuration, null, testPluginFolder,
Settings settings = new Settings(configuration, null, testPluginFolder,
TestConfiguration.generatePropertyMap(), TestSettingsMigrationServices.alwaysFulfilled());
// when
@ -140,7 +140,7 @@ public class NewSettingTest {
YamlConfiguration configuration = mock(YamlConfiguration.class);
given(configuration.contains(anyString())).willReturn(true);
setReturnValue(configuration, MESSAGES_LANGUAGE, "doesntexist");
NewSetting settings = new NewSetting(configuration, null, testPluginFolder,
Settings settings = new Settings(configuration, null, testPluginFolder,
TestConfiguration.generatePropertyMap(), TestSettingsMigrationServices.alwaysFulfilled());
// when
@ -161,7 +161,7 @@ public class NewSettingTest {
YamlConfiguration configuration = mock(YamlConfiguration.class);
setReturnValue(configuration, RegistrationSettings.USE_WELCOME_MESSAGE, true);
NewSetting settings = new NewSetting(configuration, null, testPluginFolder,
Settings settings = new Settings(configuration, null, testPluginFolder,
TestConfiguration.generatePropertyMap(), TestSettingsMigrationServices.alwaysFulfilled());
// when
@ -182,7 +182,7 @@ public class NewSettingTest {
Files.write(emailFile.toPath(), emailMessage.getBytes());
YamlConfiguration configuration = mock(YamlConfiguration.class);
NewSetting settings = new NewSetting(configuration, null, testPluginFolder,
Settings settings = new Settings(configuration, null, testPluginFolder,
TestConfiguration.generatePropertyMap(), TestSettingsMigrationServices.alwaysFulfilled());
// when
@ -207,7 +207,7 @@ public class NewSettingTest {
}
}
private static void assertDefaultValue(Property<?> property, NewSetting setting) {
private static void assertDefaultValue(Property<?> property, Settings setting) {
assertThat(property.getPath() + " has default value",
setting.getProperty(property).equals(property.getDefaultValue()), equalTo(true));
}

View File

@ -36,7 +36,7 @@ public class SpawnLoaderTest {
private SpawnLoader spawnLoader;
@Mock
private NewSetting settings;
private Settings settings;
@Mock
private DataSource dataSource;

View File

@ -6,7 +6,7 @@ import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.cache.limbo.PlayerData;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.util.BukkitService;
@ -40,7 +40,7 @@ public class PlayerDataTaskManagerTest {
private Messages messages;
@Mock
private NewSetting settings;
private Settings settings;
@Mock
private BukkitService bukkitService;

View File

@ -4,7 +4,7 @@ import fr.xephi.authme.ReflectionTestUtils;
import fr.xephi.authme.TestHelper;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.PurgeSettings;
import fr.xephi.authme.util.BukkitService;
import org.bukkit.OfflinePlayer;
@ -57,7 +57,7 @@ public class PurgeServiceTest {
@Mock
private DataSource dataSource;
@Mock
private NewSetting settings;
private Settings settings;
@Mock
private PermissionsManager permissionsManager;
@Mock

View File

@ -6,7 +6,7 @@ import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.security.HashAlgorithm;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.security.crypts.SHA256;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import org.junit.BeforeClass;
import org.junit.Test;
@ -36,7 +36,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
public class MigrationServiceTest {
@Mock
private NewSetting settings;
private Settings settings;
@Mock
private DataSource dataSource;

View File

@ -5,7 +5,7 @@ import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.PlayerData;
import fr.xephi.authme.events.FirstSpawnTeleportEvent;
import fr.xephi.authme.events.SpawnTeleportEvent;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.SpawnLoader;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import org.bukkit.Location;
@ -46,7 +46,7 @@ public class TeleportationServiceTest {
private TeleportationService teleportationService;
@Mock
private NewSetting settings;
private Settings settings;
@Mock
private BukkitService bukkitService;

View File

@ -8,7 +8,7 @@ import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.permission.PlayerStatePermission;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.EmailSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.settings.properties.SecuritySettings;
@ -35,7 +35,7 @@ public class ValidationServiceTest {
@InjectDelayed
private ValidationService validationService;
@Mock
private NewSetting settings;
private Settings settings;
@Mock
private DataSource dataSource;
@Mock

View File

@ -8,7 +8,7 @@ import fr.xephi.authme.security.crypts.HexSaltedMethod;
import fr.xephi.authme.security.crypts.description.AsciiRestricted;
import fr.xephi.authme.security.crypts.description.HasSalt;
import fr.xephi.authme.security.crypts.description.Recommendation;
import fr.xephi.authme.settings.NewSetting;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.domain.Property;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@ -140,7 +140,7 @@ public class EncryptionMethodInfoGatherer {
@SuppressWarnings("unchecked")
private static Injector createInitializer() {
NewSetting settings = mock(NewSetting.class);
Settings settings = mock(Settings.class);
// Return the default value for any property
when(settings.getProperty(any(Property.class))).thenAnswer(new Answer<Object>() {
@Override
@ -153,7 +153,7 @@ public class EncryptionMethodInfoGatherer {
// By passing some bogus "package" to the constructor, the injector will throw if it needs to
// instantiate any dependency other than what we provide.
Injector injector = new InjectorBuilder().addDefaultHandlers("!!No package!!").create();
injector.register(NewSetting.class, settings);
injector.register(Settings.class, settings);
return injector;
}