mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-25 18:17:34 +01:00
Close #449 Rename NewSetting class to Settings :)
This commit is contained in:
parent
bcc31afb90
commit
19de5a0525
@ -4,7 +4,7 @@ import fr.xephi.authme.output.MessageKey;
|
|||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.permission.PlayerStatePermission;
|
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.ProtectionSettings;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.util.BukkitService;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -20,7 +20,7 @@ import static fr.xephi.authme.util.BukkitService.TICKS_PER_SECOND;
|
|||||||
*/
|
*/
|
||||||
public class AntiBot {
|
public class AntiBot {
|
||||||
|
|
||||||
private final NewSetting settings;
|
private final Settings settings;
|
||||||
private final Messages messages;
|
private final Messages messages;
|
||||||
private final PermissionsManager permissionsManager;
|
private final PermissionsManager permissionsManager;
|
||||||
private final BukkitService bukkitService;
|
private final BukkitService bukkitService;
|
||||||
@ -29,7 +29,7 @@ public class AntiBot {
|
|||||||
private AntiBotStatus antiBotStatus = AntiBotStatus.DISABLED;
|
private AntiBotStatus antiBotStatus = AntiBotStatus.DISABLED;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
AntiBot(NewSetting settings, Messages messages, PermissionsManager permissionsManager,
|
AntiBot(Settings settings, Messages messages, PermissionsManager permissionsManager,
|
||||||
BukkitService bukkitService) {
|
BukkitService bukkitService) {
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.messages = messages;
|
this.messages = messages;
|
||||||
|
@ -34,7 +34,7 @@ import fr.xephi.authme.permission.PermissionsManager;
|
|||||||
import fr.xephi.authme.permission.PermissionsSystemType;
|
import fr.xephi.authme.permission.PermissionsSystemType;
|
||||||
import fr.xephi.authme.process.Management;
|
import fr.xephi.authme.process.Management;
|
||||||
import fr.xephi.authme.security.crypts.SHA256;
|
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.SettingsMigrationService;
|
||||||
import fr.xephi.authme.settings.SpawnLoader;
|
import fr.xephi.authme.settings.SpawnLoader;
|
||||||
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
||||||
@ -103,7 +103,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
private Management management;
|
private Management management;
|
||||||
private CommandHandler commandHandler;
|
private CommandHandler commandHandler;
|
||||||
private PermissionsManager permsMan;
|
private PermissionsManager permsMan;
|
||||||
private NewSetting newSettings;
|
private Settings settings;
|
||||||
private Messages messages;
|
private Messages messages;
|
||||||
private DataSource database;
|
private DataSource database;
|
||||||
private PluginHooks pluginHooks;
|
private PluginHooks pluginHooks;
|
||||||
@ -193,8 +193,8 @@ public class AuthMe extends JavaPlugin {
|
|||||||
ConsoleLogger.setLogFile(new File(getDataFolder(), "authme.log"));
|
ConsoleLogger.setLogFile(new File(getDataFolder(), "authme.log"));
|
||||||
|
|
||||||
// Load settings and custom configurations, if it fails, stop the server due to security reasons.
|
// Load settings and custom configurations, if it fails, stop the server due to security reasons.
|
||||||
newSettings = createNewSetting();
|
settings = createSettings();
|
||||||
if (newSettings == null) {
|
if (settings == null) {
|
||||||
getLogger().warning("Could not load configuration. Aborting.");
|
getLogger().warning("Could not load configuration. Aborting.");
|
||||||
getServer().shutdown();
|
getServer().shutdown();
|
||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
@ -202,11 +202,11 @@ public class AuthMe extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Apply settings to the logger
|
// Apply settings to the logger
|
||||||
ConsoleLogger.setLoggingOptions(newSettings);
|
ConsoleLogger.setLoggingOptions(settings);
|
||||||
|
|
||||||
// Connect to the database and setup tables
|
// Connect to the database and setup tables
|
||||||
try {
|
try {
|
||||||
setupDatabase(newSettings);
|
setupDatabase(settings);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ConsoleLogger.logException("Fatal error occurred during database connection! "
|
ConsoleLogger.logException("Fatal error occurred during database connection! "
|
||||||
+ "Authme initialization aborted!", e);
|
+ "Authme initialization aborted!", e);
|
||||||
@ -214,7 +214,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Convert deprecated PLAINTEXT hash entries
|
// Convert deprecated PLAINTEXT hash entries
|
||||||
MigrationService.changePlainTextToSha256(newSettings, database, new SHA256());
|
MigrationService.changePlainTextToSha256(settings, database, new SHA256());
|
||||||
|
|
||||||
// Injector initialization
|
// Injector initialization
|
||||||
injector = new InjectorBuilder().addDefaultHandlers("fr.xephi.authme").create();
|
injector = new InjectorBuilder().addDefaultHandlers("fr.xephi.authme").create();
|
||||||
@ -227,20 +227,20 @@ public class AuthMe extends JavaPlugin {
|
|||||||
injector.provide(DataFolder.class, getDataFolder());
|
injector.provide(DataFolder.class, getDataFolder());
|
||||||
|
|
||||||
// Register elements we instantiate manually
|
// Register elements we instantiate manually
|
||||||
injector.register(NewSetting.class, newSettings);
|
injector.register(Settings.class, settings);
|
||||||
injector.register(DataSource.class, database);
|
injector.register(DataSource.class, database);
|
||||||
|
|
||||||
instantiateServices(injector);
|
instantiateServices(injector);
|
||||||
|
|
||||||
// Set up Metrics
|
// Set up Metrics
|
||||||
MetricsStarter.setupMetrics(this, newSettings);
|
MetricsStarter.setupMetrics(this, settings);
|
||||||
|
|
||||||
// Set console filter
|
// Set console filter
|
||||||
setupConsoleFilter();
|
setupConsoleFilter();
|
||||||
|
|
||||||
// Do a backup on start
|
// Do a backup on start
|
||||||
// TODO: maybe create a backup manager?
|
// 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
|
// Set up the BungeeCord hook
|
||||||
setupBungeeCordHook();
|
setupBungeeCordHook();
|
||||||
@ -297,13 +297,13 @@ public class AuthMe extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
private void showSettingsWarnings() {
|
private void showSettingsWarnings() {
|
||||||
// Force single session disabled
|
// 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!");
|
ConsoleLogger.warning("WARNING!!! By disabling ForceSingleSession, your server protection is inadequate!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Session timeout disabled
|
// Session timeout disabled
|
||||||
if (newSettings.getProperty(PluginSettings.SESSIONS_TIMEOUT) == 0
|
if (settings.getProperty(PluginSettings.SESSIONS_TIMEOUT) == 0
|
||||||
&& newSettings.getProperty(PluginSettings.SESSIONS_ENABLED)) {
|
&& settings.getProperty(PluginSettings.SESSIONS_ENABLED)) {
|
||||||
ConsoleLogger.warning("WARNING!!! You set session timeout to 0, this may cause security issues!");
|
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();
|
int playersOnline = bukkitService.getOnlinePlayers().size();
|
||||||
if (playersOnline < 1) {
|
if (playersOnline < 1) {
|
||||||
database.purgeLogged();
|
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()) {
|
for (PlayerAuth auth : database.getLoggedPlayers()) {
|
||||||
if (auth != null) {
|
if (auth != null) {
|
||||||
auth.setLastLogin(new Date().getTime());
|
auth.setLastLogin(new Date().getTime());
|
||||||
@ -357,7 +357,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
* Set up the BungeeCord hook.
|
* Set up the BungeeCord hook.
|
||||||
*/
|
*/
|
||||||
private void setupBungeeCordHook() {
|
private void setupBungeeCordHook() {
|
||||||
if (newSettings.getProperty(HooksSettings.BUNGEECORD)) {
|
if (settings.getProperty(HooksSettings.BUNGEECORD)) {
|
||||||
Messenger messenger = Bukkit.getMessenger();
|
Messenger messenger = Bukkit.getMessenger();
|
||||||
messenger.registerOutgoingPluginChannel(this, "BungeeCord");
|
messenger.registerOutgoingPluginChannel(this, "BungeeCord");
|
||||||
messenger.registerIncomingPluginChannel(this, "BungeeCord", injector.getSingleton(BungeeCordMessage.class));
|
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
|
* @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");
|
File configFile = new File(getDataFolder(), "config.yml");
|
||||||
PropertyMap properties = SettingsFieldRetriever.getAllPropertyFields();
|
PropertyMap properties = SettingsFieldRetriever.getAllPropertyFields();
|
||||||
SettingsMigrationService migrationService = new SettingsMigrationService();
|
SettingsMigrationService migrationService = new SettingsMigrationService();
|
||||||
return FileUtils.copyFileFromResource(configFile, "config.yml")
|
return FileUtils.copyFileFromResource(configFile, "config.yml")
|
||||||
? new NewSetting(configFile, getDataFolder(), properties, migrationService)
|
? new Settings(configFile, getDataFolder(), properties, migrationService)
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,7 +382,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
* Set up the console filter.
|
* Set up the console filter.
|
||||||
*/
|
*/
|
||||||
private void setupConsoleFilter() {
|
private void setupConsoleFilter() {
|
||||||
if (!newSettings.getProperty(SecuritySettings.REMOVE_PASSWORD_FROM_CONSOLE)) {
|
if (!settings.getProperty(SecuritySettings.REMOVE_PASSWORD_FROM_CONSOLE)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Try to set the log4j filter
|
// Try to set the log4j filter
|
||||||
@ -414,8 +414,8 @@ public class AuthMe extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Do backup on stop if enabled
|
// Do backup on stop if enabled
|
||||||
if (newSettings != null) {
|
if (settings != null) {
|
||||||
new PerformBackup(this, newSettings).doBackup(PerformBackup.BackupCause.STOP);
|
new PerformBackup(this, settings).doBackup(PerformBackup.BackupCause.STOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@ -474,7 +474,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
|
|
||||||
// Stop/unload the server/plugin as defined in the configuration
|
// Stop/unload the server/plugin as defined in the configuration
|
||||||
public void stopOrUnload() {
|
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!");
|
ConsoleLogger.warning("THE SERVER IS GOING TO SHUT DOWN AS DEFINED IN THE CONFIGURATION!");
|
||||||
getServer().shutdown();
|
getServer().shutdown();
|
||||||
} else {
|
} else {
|
||||||
@ -492,7 +492,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
* @throws IOException if flat file cannot be read
|
* @throws IOException if flat file cannot be read
|
||||||
* @see AuthMe#database
|
* @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) {
|
if (this.database != null) {
|
||||||
this.database.close();
|
this.database.close();
|
||||||
}
|
}
|
||||||
@ -552,7 +552,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
limboCache.restoreData(player);
|
limboCache.restoreData(player);
|
||||||
limboCache.removeFromCache(player);
|
limboCache.removeFromCache(player);
|
||||||
} else {
|
} else {
|
||||||
if (newSettings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) {
|
if (settings.getProperty(RestrictionSettings.SAVE_QUIT_LOCATION)) {
|
||||||
Location loc = spawnLoader.getPlayerLocationOrSpawn(player);
|
Location loc = spawnLoader.getPlayerLocationOrSpawn(player);
|
||||||
final PlayerAuth auth = PlayerAuth.builder()
|
final PlayerAuth auth = PlayerAuth.builder()
|
||||||
.name(player.getName().toLowerCase())
|
.name(player.getName().toLowerCase())
|
||||||
@ -560,8 +560,8 @@ public class AuthMe extends JavaPlugin {
|
|||||||
.location(loc).build();
|
.location(loc).build();
|
||||||
database.updateQuitLoc(auth);
|
database.updateQuitLoc(auth);
|
||||||
}
|
}
|
||||||
if (newSettings.getProperty(RestrictionSettings.TELEPORT_UNAUTHED_TO_SPAWN)
|
if (settings.getProperty(RestrictionSettings.TELEPORT_UNAUTHED_TO_SPAWN)
|
||||||
&& !newSettings.getProperty(RestrictionSettings.NO_TELEPORT)) {
|
&& !settings.getProperty(RestrictionSettings.NO_TELEPORT)) {
|
||||||
PlayerDataStorage playerDataStorage = injector.getIfAvailable(PlayerDataStorage.class);
|
PlayerDataStorage playerDataStorage = injector.getIfAvailable(PlayerDataStorage.class);
|
||||||
if (playerDataStorage != null && !playerDataStorage.hasData(player)) {
|
if (playerDataStorage != null && !playerDataStorage.hasData(player)) {
|
||||||
playerDataStorage.saveData(player);
|
playerDataStorage.saveData(player);
|
||||||
@ -576,7 +576,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void scheduleRecallEmailTask() {
|
private void scheduleRecallEmailTask() {
|
||||||
if (!newSettings.getProperty(RECALL_PLAYERS)) {
|
if (!settings.getProperty(RECALL_PLAYERS)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Bukkit.getScheduler().runTaskTimerAsynchronously(this, new Runnable() {
|
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) {
|
public String replaceAllInfo(String message, Player player) {
|
||||||
|
@ -2,7 +2,7 @@ package fr.xephi.authme;
|
|||||||
|
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import fr.xephi.authme.output.LogLevel;
|
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.PluginSettings;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
import fr.xephi.authme.util.StringUtils;
|
import fr.xephi.authme.util.StringUtils;
|
||||||
@ -58,7 +58,7 @@ public final class ConsoleLogger {
|
|||||||
*
|
*
|
||||||
* @param settings The settings instance
|
* @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.logLevel = settings.getProperty(PluginSettings.LOG_LEVEL);
|
||||||
ConsoleLogger.useLogging = settings.getProperty(SecuritySettings.USE_LOGGING);
|
ConsoleLogger.useLogging = settings.getProperty(SecuritySettings.USE_LOGGING);
|
||||||
if (useLogging) {
|
if (useLogging) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package fr.xephi.authme;
|
package fr.xephi.authme;
|
||||||
|
|
||||||
import fr.xephi.authme.datasource.DataSourceType;
|
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.BackupSettings;
|
||||||
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
||||||
import fr.xephi.authme.util.StringUtils;
|
import fr.xephi.authme.util.StringUtils;
|
||||||
@ -30,7 +30,7 @@ public class PerformBackup {
|
|||||||
private final String tblname;
|
private final String tblname;
|
||||||
private final String path;
|
private final String path;
|
||||||
private final File dataFolder;
|
private final File dataFolder;
|
||||||
private final NewSetting settings;
|
private final Settings settings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for PerformBackup.
|
* Constructor for PerformBackup.
|
||||||
@ -38,7 +38,7 @@ public class PerformBackup {
|
|||||||
* @param instance AuthMe
|
* @param instance AuthMe
|
||||||
* @param settings The plugin settings
|
* @param settings The plugin settings
|
||||||
*/
|
*/
|
||||||
public PerformBackup(AuthMe instance, NewSetting settings) {
|
public PerformBackup(AuthMe instance, Settings settings) {
|
||||||
this.dataFolder = instance.getDataFolder();
|
this.dataFolder = instance.getDataFolder();
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.dbName = settings.getProperty(DatabaseSettings.MYSQL_DATABASE);
|
this.dbName = settings.getProperty(DatabaseSettings.MYSQL_DATABASE);
|
||||||
|
@ -2,7 +2,7 @@ package fr.xephi.authme.cache;
|
|||||||
|
|
||||||
import fr.xephi.authme.initialization.SettingsDependent;
|
import fr.xephi.authme.initialization.SettingsDependent;
|
||||||
import fr.xephi.authme.security.RandomString;
|
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 fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@ -21,7 +21,7 @@ public class CaptchaManager implements SettingsDependent {
|
|||||||
private int captchaLength;
|
private int captchaLength;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
CaptchaManager(NewSetting settings) {
|
CaptchaManager(Settings settings) {
|
||||||
this.playerCounts = new ConcurrentHashMap<>();
|
this.playerCounts = new ConcurrentHashMap<>();
|
||||||
this.captchaCodes = new ConcurrentHashMap<>();
|
this.captchaCodes = new ConcurrentHashMap<>();
|
||||||
reload(settings);
|
reload(settings);
|
||||||
@ -123,7 +123,7 @@ public class CaptchaManager implements SettingsDependent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reload(NewSetting settings) {
|
public void reload(Settings settings) {
|
||||||
this.isEnabled = settings.getProperty(SecuritySettings.USE_CAPTCHA);
|
this.isEnabled = settings.getProperty(SecuritySettings.USE_CAPTCHA);
|
||||||
this.threshold = settings.getProperty(SecuritySettings.MAX_LOGIN_TRIES_BEFORE_CAPTCHA);
|
this.threshold = settings.getProperty(SecuritySettings.MAX_LOGIN_TRIES_BEFORE_CAPTCHA);
|
||||||
this.captchaLength = settings.getProperty(SecuritySettings.CAPTCHA_LENGTH);
|
this.captchaLength = settings.getProperty(SecuritySettings.CAPTCHA_LENGTH);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package fr.xephi.authme.cache;
|
package fr.xephi.authme.cache;
|
||||||
|
|
||||||
import fr.xephi.authme.initialization.SettingsDependent;
|
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 fr.xephi.authme.settings.properties.PluginSettings;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@ -22,7 +22,7 @@ public class SessionManager implements SettingsDependent {
|
|||||||
private int timeoutInMinutes;
|
private int timeoutInMinutes;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
SessionManager(NewSetting settings) {
|
SessionManager(Settings settings) {
|
||||||
reload(settings);
|
reload(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ public class SessionManager implements SettingsDependent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reload(NewSetting settings) {
|
public void reload(Settings settings) {
|
||||||
timeoutInMinutes = settings.getProperty(PluginSettings.SESSIONS_TIMEOUT);
|
timeoutInMinutes = settings.getProperty(PluginSettings.SESSIONS_TIMEOUT);
|
||||||
boolean oldEnabled = enabled;
|
boolean oldEnabled = enabled;
|
||||||
enabled = timeoutInMinutes > 0 && settings.getProperty(PluginSettings.SESSIONS_ENABLED);
|
enabled = timeoutInMinutes > 0 && settings.getProperty(PluginSettings.SESSIONS_ENABLED);
|
||||||
|
@ -3,7 +3,7 @@ package fr.xephi.authme.cache;
|
|||||||
import fr.xephi.authme.initialization.SettingsDependent;
|
import fr.xephi.authme.initialization.SettingsDependent;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
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.settings.properties.SecuritySettings;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.util.BukkitService;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
@ -30,7 +30,7 @@ public class TempbanManager implements SettingsDependent {
|
|||||||
private int length;
|
private int length;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
TempbanManager(BukkitService bukkitService, Messages messages, NewSetting settings) {
|
TempbanManager(BukkitService bukkitService, Messages messages, Settings settings) {
|
||||||
this.ipLoginFailureCounts = new ConcurrentHashMap<>();
|
this.ipLoginFailureCounts = new ConcurrentHashMap<>();
|
||||||
this.bukkitService = bukkitService;
|
this.bukkitService = bukkitService;
|
||||||
this.messages = messages;
|
this.messages = messages;
|
||||||
@ -108,7 +108,7 @@ public class TempbanManager implements SettingsDependent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reload(NewSetting settings) {
|
public void reload(Settings settings) {
|
||||||
this.isEnabled = settings.getProperty(SecuritySettings.TEMPBAN_ON_MAX_LOGINS);
|
this.isEnabled = settings.getProperty(SecuritySettings.TEMPBAN_ON_MAX_LOGINS);
|
||||||
this.threshold = settings.getProperty(SecuritySettings.MAX_LOGIN_TEMPBAN);
|
this.threshold = settings.getProperty(SecuritySettings.MAX_LOGIN_TEMPBAN);
|
||||||
this.length = settings.getProperty(SecuritySettings.TEMPBAN_LENGTH);
|
this.length = settings.getProperty(SecuritySettings.TEMPBAN_LENGTH);
|
||||||
|
@ -2,7 +2,7 @@ package fr.xephi.authme.cache.limbo;
|
|||||||
|
|
||||||
import fr.xephi.authme.cache.backup.PlayerDataStorage;
|
import fr.xephi.authme.cache.backup.PlayerDataStorage;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
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.SpawnLoader;
|
||||||
import fr.xephi.authme.settings.properties.PluginSettings;
|
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||||
import fr.xephi.authme.util.StringUtils;
|
import fr.xephi.authme.util.StringUtils;
|
||||||
@ -23,12 +23,12 @@ public class LimboCache {
|
|||||||
private final Map<String, PlayerData> cache = new ConcurrentHashMap<>();
|
private final Map<String, PlayerData> cache = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private PlayerDataStorage playerDataStorage;
|
private PlayerDataStorage playerDataStorage;
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
private PermissionsManager permissionsManager;
|
private PermissionsManager permissionsManager;
|
||||||
private SpawnLoader spawnLoader;
|
private SpawnLoader spawnLoader;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
LimboCache(NewSetting settings, PermissionsManager permissionsManager,
|
LimboCache(Settings settings, PermissionsManager permissionsManager,
|
||||||
SpawnLoader spawnLoader, PlayerDataStorage playerDataStorage) {
|
SpawnLoader spawnLoader, PlayerDataStorage playerDataStorage) {
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.permissionsManager = permissionsManager;
|
this.permissionsManager = permissionsManager;
|
||||||
|
@ -2,7 +2,7 @@ package fr.xephi.authme.command;
|
|||||||
|
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
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.domain.Property;
|
||||||
import fr.xephi.authme.util.ValidationService;
|
import fr.xephi.authme.util.ValidationService;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -18,7 +18,7 @@ public class CommandService {
|
|||||||
@Inject
|
@Inject
|
||||||
private Messages messages;
|
private Messages messages;
|
||||||
@Inject
|
@Inject
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
@Inject
|
@Inject
|
||||||
private ValidationService validationService;
|
private ValidationService validationService;
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ public class CommandService {
|
|||||||
*
|
*
|
||||||
* @return The settings manager
|
* @return The settings manager
|
||||||
*/
|
*/
|
||||||
public NewSetting getSettings() {
|
public Settings getSettings() {
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import fr.xephi.authme.datasource.DataSource;
|
|||||||
import fr.xephi.authme.initialization.Reloadable;
|
import fr.xephi.authme.initialization.Reloadable;
|
||||||
import fr.xephi.authme.initialization.SettingsDependent;
|
import fr.xephi.authme.initialization.SettingsDependent;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
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.DatabaseSettings;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ public class ReloadCommand implements ExecutableCommand {
|
|||||||
private Injector injector;
|
private Injector injector;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
|
@ -10,7 +10,7 @@ import fr.xephi.authme.initialization.SettingsDependent;
|
|||||||
import fr.xephi.authme.permission.DefaultPermission;
|
import fr.xephi.authme.permission.DefaultPermission;
|
||||||
import fr.xephi.authme.permission.PermissionNode;
|
import fr.xephi.authme.permission.PermissionNode;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
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 fr.xephi.authme.settings.properties.PluginSettings;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -48,7 +48,7 @@ public class HelpProvider implements SettingsDependent {
|
|||||||
private String helpHeader;
|
private String helpHeader;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
HelpProvider(PermissionsManager permissionsManager, NewSetting settings) {
|
HelpProvider(PermissionsManager permissionsManager, Settings settings) {
|
||||||
this.permissionsManager = permissionsManager;
|
this.permissionsManager = permissionsManager;
|
||||||
reload(settings);
|
reload(settings);
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ public class HelpProvider implements SettingsDependent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reload(NewSetting settings) {
|
public void reload(Settings settings) {
|
||||||
helpHeader = settings.getProperty(PluginSettings.HELP_HEADER);
|
helpHeader = settings.getProperty(PluginSettings.HELP_HEADER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,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.initialization.DataFolder;
|
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 fr.xephi.authme.settings.properties.ConverterSettings;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
@ -20,11 +20,11 @@ import java.io.IOException;
|
|||||||
public class CrazyLoginConverter implements Converter {
|
public class CrazyLoginConverter implements Converter {
|
||||||
|
|
||||||
private final DataSource database;
|
private final DataSource database;
|
||||||
private final NewSetting settings;
|
private final Settings settings;
|
||||||
private final File dataFolder;
|
private final File dataFolder;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
CrazyLoginConverter(@DataFolder File dataFolder, DataSource dataSource, NewSetting settings) {
|
CrazyLoginConverter(@DataFolder File dataFolder, DataSource dataSource, Settings settings) {
|
||||||
this.dataFolder = dataFolder;
|
this.dataFolder = dataFolder;
|
||||||
this.database = dataSource;
|
this.database = dataSource;
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
|
@ -6,7 +6,7 @@ import fr.xephi.authme.datasource.DataSource;
|
|||||||
import fr.xephi.authme.initialization.DataFolder;
|
import fr.xephi.authme.initialization.DataFolder;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
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 fr.xephi.authme.settings.properties.ConverterSettings;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
@ -24,12 +24,12 @@ import java.util.Map.Entry;
|
|||||||
public class RakamakConverter implements Converter {
|
public class RakamakConverter implements Converter {
|
||||||
|
|
||||||
private final DataSource database;
|
private final DataSource database;
|
||||||
private final NewSetting settings;
|
private final Settings settings;
|
||||||
private final File pluginFolder;
|
private final File pluginFolder;
|
||||||
private final PasswordSecurity passwordSecurity;
|
private final PasswordSecurity passwordSecurity;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
RakamakConverter(@DataFolder File dataFolder, DataSource dataSource, NewSetting settings,
|
RakamakConverter(@DataFolder File dataFolder, DataSource dataSource, Settings settings,
|
||||||
PasswordSecurity passwordSecurity) {
|
PasswordSecurity passwordSecurity) {
|
||||||
this.database = dataSource;
|
this.database = dataSource;
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
|
@ -7,19 +7,19 @@ import fr.xephi.authme.datasource.DataSourceType;
|
|||||||
import fr.xephi.authme.datasource.SQLite;
|
import fr.xephi.authme.datasource.SQLite;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.settings.NewSetting;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
public class SqliteToSql implements Converter {
|
public class SqliteToSql implements Converter {
|
||||||
|
|
||||||
private final NewSetting settings;
|
private final Settings settings;
|
||||||
private final DataSource dataSource;
|
private final DataSource dataSource;
|
||||||
private final Messages messages;
|
private final Messages messages;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
SqliteToSql(NewSetting settings, DataSource dataSource, Messages messages) {
|
SqliteToSql(Settings settings, DataSource dataSource, Messages messages) {
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
this.messages = messages;
|
this.messages = messages;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package fr.xephi.authme.datasource;
|
package fr.xephi.authme.datasource;
|
||||||
|
|
||||||
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.DatabaseSettings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,7 +23,7 @@ public final class Columns {
|
|||||||
public final String ID;
|
public final String ID;
|
||||||
public final String IS_LOGGED;
|
public final String IS_LOGGED;
|
||||||
|
|
||||||
public Columns(NewSetting settings) {
|
public Columns(Settings settings) {
|
||||||
NAME = settings.getProperty(DatabaseSettings.MYSQL_COL_NAME);
|
NAME = settings.getProperty(DatabaseSettings.MYSQL_COL_NAME);
|
||||||
REAL_NAME = settings.getProperty(DatabaseSettings.MYSQL_COL_REALNAME);
|
REAL_NAME = settings.getProperty(DatabaseSettings.MYSQL_COL_REALNAME);
|
||||||
PASSWORD = settings.getProperty(DatabaseSettings.MYSQL_COL_PASSWORD);
|
PASSWORD = settings.getProperty(DatabaseSettings.MYSQL_COL_PASSWORD);
|
||||||
|
@ -8,7 +8,7 @@ import fr.xephi.authme.cache.auth.PlayerAuth;
|
|||||||
import fr.xephi.authme.security.HashAlgorithm;
|
import fr.xephi.authme.security.HashAlgorithm;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||||
import fr.xephi.authme.security.crypts.XFBCRYPT;
|
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.DatabaseSettings;
|
||||||
import fr.xephi.authme.settings.properties.HooksSettings;
|
import fr.xephi.authme.settings.properties.HooksSettings;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
@ -45,7 +45,7 @@ public class MySQL implements DataSource {
|
|||||||
private int phpBbGroup;
|
private int phpBbGroup;
|
||||||
private String wordpressPrefix;
|
private String wordpressPrefix;
|
||||||
|
|
||||||
public MySQL(NewSetting settings) throws ClassNotFoundException, SQLException, PoolInitializationException {
|
public MySQL(Settings settings) throws ClassNotFoundException, SQLException, PoolInitializationException {
|
||||||
setParameters(settings);
|
setParameters(settings);
|
||||||
|
|
||||||
// Set the connection arguments (and check if connection is ok)
|
// Set the connection arguments (and check if connection is ok)
|
||||||
@ -76,12 +76,12 @@ public class MySQL implements DataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
MySQL(NewSetting settings, HikariDataSource hikariDataSource) {
|
MySQL(Settings settings, HikariDataSource hikariDataSource) {
|
||||||
ds = hikariDataSource;
|
ds = hikariDataSource;
|
||||||
setParameters(settings);
|
setParameters(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setParameters(NewSetting settings) {
|
private void setParameters(Settings settings) {
|
||||||
this.host = settings.getProperty(DatabaseSettings.MYSQL_HOST);
|
this.host = settings.getProperty(DatabaseSettings.MYSQL_HOST);
|
||||||
this.port = settings.getProperty(DatabaseSettings.MYSQL_PORT);
|
this.port = settings.getProperty(DatabaseSettings.MYSQL_PORT);
|
||||||
this.username = settings.getProperty(DatabaseSettings.MYSQL_USERNAME);
|
this.username = settings.getProperty(DatabaseSettings.MYSQL_USERNAME);
|
||||||
|
@ -4,7 +4,7 @@ import com.google.common.annotations.VisibleForTesting;
|
|||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
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.settings.properties.DatabaseSettings;
|
||||||
import fr.xephi.authme.util.StringUtils;
|
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 ClassNotFoundException if no driver could be found for the datasource
|
||||||
* @throws SQLException when initialization of a SQL datasource failed
|
* @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.database = settings.getProperty(DatabaseSettings.MYSQL_DATABASE);
|
||||||
this.tableName = settings.getProperty(DatabaseSettings.MYSQL_TABLE);
|
this.tableName = settings.getProperty(DatabaseSettings.MYSQL_TABLE);
|
||||||
this.col = new Columns(settings);
|
this.col = new Columns(settings);
|
||||||
@ -53,7 +53,7 @@ public class SQLite implements DataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
SQLite(NewSetting settings, Connection connection) {
|
SQLite(Settings settings, Connection connection) {
|
||||||
this.database = settings.getProperty(DatabaseSettings.MYSQL_DATABASE);
|
this.database = settings.getProperty(DatabaseSettings.MYSQL_DATABASE);
|
||||||
this.tableName = settings.getProperty(DatabaseSettings.MYSQL_TABLE);
|
this.tableName = settings.getProperty(DatabaseSettings.MYSQL_TABLE);
|
||||||
this.col = new Columns(settings);
|
this.col = new Columns(settings);
|
||||||
|
@ -7,7 +7,7 @@ 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.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
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 fr.xephi.authme.util.BukkitService;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
@ -27,7 +27,7 @@ public class BungeeCordMessage implements PluginMessageListener {
|
|||||||
private PlayerCache playerCache;
|
private PlayerCache playerCache;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
|
|
||||||
BungeeCordMessage() { }
|
BungeeCordMessage() { }
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package fr.xephi.authme.initialization;
|
|||||||
|
|
||||||
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.NewSetting;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
||||||
import fr.xephi.authme.settings.properties.PluginSettings;
|
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||||
import org.mcstats.Metrics;
|
import org.mcstats.Metrics;
|
||||||
@ -15,7 +15,7 @@ public class MetricsStarter {
|
|||||||
private MetricsStarter() {
|
private MetricsStarter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setupMetrics(AuthMe plugin, NewSetting settings) {
|
public static void setupMetrics(AuthMe plugin, Settings settings) {
|
||||||
try {
|
try {
|
||||||
final Metrics metrics = new Metrics(plugin);
|
final Metrics metrics = new Metrics(plugin);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package fr.xephi.authme.initialization;
|
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.
|
* Interface for classes that keep a local copy of certain settings.
|
||||||
@ -12,5 +12,5 @@ public interface SettingsDependent {
|
|||||||
*
|
*
|
||||||
* @param settings the settings instance
|
* @param settings the settings instance
|
||||||
*/
|
*/
|
||||||
void reload(NewSetting settings);
|
void reload(Settings settings);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import fr.xephi.authme.datasource.DataSource;
|
|||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.process.Management;
|
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.SpawnLoader;
|
||||||
import fr.xephi.authme.settings.properties.HooksSettings;
|
import fr.xephi.authme.settings.properties.HooksSettings;
|
||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
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<>();
|
public static final ConcurrentHashMap<String, String> joinMessage = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
@Inject
|
@Inject
|
||||||
private Messages m;
|
private Messages m;
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -4,7 +4,7 @@ import fr.xephi.authme.cache.auth.PlayerCache;
|
|||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.hooks.PluginHooks;
|
import fr.xephi.authme.hooks.PluginHooks;
|
||||||
import fr.xephi.authme.initialization.SettingsDependent;
|
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.settings.properties.RegistrationSettings;
|
||||||
import fr.xephi.authme.util.ValidationService;
|
import fr.xephi.authme.util.ValidationService;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -27,7 +27,7 @@ class ListenerService implements SettingsDependent {
|
|||||||
private boolean isRegistrationForced;
|
private boolean isRegistrationForced;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ListenerService(NewSetting settings, DataSource dataSource, PluginHooks pluginHooks,
|
ListenerService(Settings settings, DataSource dataSource, PluginHooks pluginHooks,
|
||||||
PlayerCache playerCache, ValidationService validationService) {
|
PlayerCache playerCache, ValidationService validationService) {
|
||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
this.pluginHooks = pluginHooks;
|
this.pluginHooks = pluginHooks;
|
||||||
@ -74,7 +74,7 @@ class ListenerService implements SettingsDependent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reload(NewSetting settings) {
|
public void reload(Settings settings) {
|
||||||
isRegistrationForced = settings.getProperty(RegistrationSettings.FORCE);
|
isRegistrationForced = settings.getProperty(RegistrationSettings.FORCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import fr.xephi.authme.output.MessageKey;
|
|||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.permission.PlayerStatePermission;
|
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.ProtectionSettings;
|
||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
@ -32,7 +32,7 @@ import java.util.regex.Pattern;
|
|||||||
class OnJoinVerifier implements Reloadable {
|
class OnJoinVerifier implements Reloadable {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
@Inject
|
@Inject
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -5,7 +5,7 @@ import fr.xephi.authme.AuthMe;
|
|||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.initialization.SettingsDependent;
|
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.settings.properties.RestrictionSettings;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.util.BukkitService;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -30,7 +30,7 @@ public class ProtocolLibService implements SettingsDependent {
|
|||||||
private PlayerCache playerCache;
|
private PlayerCache playerCache;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ProtocolLibService(AuthMe plugin, NewSetting settings, BukkitService bukkitService, PlayerCache playerCache) {
|
ProtocolLibService(AuthMe plugin, Settings settings, BukkitService bukkitService, PlayerCache playerCache) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.bukkitService = bukkitService;
|
this.bukkitService = bukkitService;
|
||||||
this.playerCache = playerCache;
|
this.playerCache = playerCache;
|
||||||
@ -99,7 +99,7 @@ public class ProtocolLibService implements SettingsDependent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reload(NewSetting settings) {
|
public void reload(Settings settings) {
|
||||||
boolean oldProtectInventory = this.protectInvBeforeLogin;
|
boolean oldProtectInventory = this.protectInvBeforeLogin;
|
||||||
|
|
||||||
this.protectInvBeforeLogin = settings.getProperty(RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN);
|
this.protectInvBeforeLogin = settings.getProperty(RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN);
|
||||||
|
@ -3,7 +3,7 @@ package fr.xephi.authme.mail;
|
|||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
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.settings.properties.EmailSettings;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.util.BukkitService;
|
||||||
import fr.xephi.authme.util.StringUtils;
|
import fr.xephi.authme.util.StringUtils;
|
||||||
@ -33,7 +33,7 @@ public class SendMailSSL {
|
|||||||
@Inject
|
@Inject
|
||||||
private AuthMe plugin;
|
private AuthMe plugin;
|
||||||
@Inject
|
@Inject
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
@Inject
|
@Inject
|
||||||
private BukkitService bukkitService;
|
private BukkitService bukkitService;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package fr.xephi.authme.output;
|
|||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.initialization.SettingsDependent;
|
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 fr.xephi.authme.util.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -30,7 +30,7 @@ public class Messages implements SettingsDependent {
|
|||||||
* @param settings The settings
|
* @param settings The settings
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
Messages(NewSetting settings) {
|
Messages(Settings settings) {
|
||||||
reload(settings);
|
reload(settings);
|
||||||
this.defaultFile = settings.getDefaultMessagesFile();
|
this.defaultFile = settings.getDefaultMessagesFile();
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ public class Messages implements SettingsDependent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reload(NewSetting settings) {
|
public void reload(Settings settings) {
|
||||||
File messageFile = settings.getMessagesFile();
|
File messageFile = settings.getMessagesFile();
|
||||||
this.configuration = YamlConfiguration.loadConfiguration(messageFile);
|
this.configuration = YamlConfiguration.loadConfiguration(messageFile);
|
||||||
this.fileName = messageFile.getName();
|
this.fileName = messageFile.getName();
|
||||||
|
@ -4,7 +4,7 @@ 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.PlayerData;
|
import fr.xephi.authme.cache.limbo.PlayerData;
|
||||||
import fr.xephi.authme.initialization.Reloadable;
|
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.HooksSettings;
|
||||||
import fr.xephi.authme.settings.properties.PluginSettings;
|
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
@ -22,7 +22,7 @@ public class AuthGroupHandler implements Reloadable {
|
|||||||
private PermissionsManager permissionsManager;
|
private PermissionsManager permissionsManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private LimboCache limboCache;
|
private LimboCache limboCache;
|
||||||
|
@ -6,7 +6,7 @@ import fr.xephi.authme.permission.AuthGroupHandler;
|
|||||||
import fr.xephi.authme.permission.AuthGroupType;
|
import fr.xephi.authme.permission.AuthGroupType;
|
||||||
import fr.xephi.authme.permission.PermissionNode;
|
import fr.xephi.authme.permission.PermissionNode;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
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.settings.domain.Property;
|
||||||
import fr.xephi.authme.util.ValidationService;
|
import fr.xephi.authme.util.ValidationService;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -20,7 +20,7 @@ import javax.inject.Inject;
|
|||||||
public class ProcessService {
|
public class ProcessService {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Messages messages;
|
private Messages messages;
|
||||||
@ -50,7 +50,7 @@ public class ProcessService {
|
|||||||
*
|
*
|
||||||
* @return settings manager
|
* @return settings manager
|
||||||
*/
|
*/
|
||||||
public NewSetting getSettings() {
|
public Settings getSettings() {
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import fr.xephi.authme.events.PasswordEncryptionEvent;
|
|||||||
import fr.xephi.authme.initialization.Reloadable;
|
import fr.xephi.authme.initialization.Reloadable;
|
||||||
import fr.xephi.authme.security.crypts.EncryptionMethod;
|
import fr.xephi.authme.security.crypts.EncryptionMethod;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
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 fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ import javax.inject.Inject;
|
|||||||
public class PasswordSecurity implements Reloadable {
|
public class PasswordSecurity implements Reloadable {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
|
@ -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.Recommendation;
|
||||||
import fr.xephi.authme.security.crypts.description.SaltType;
|
import fr.xephi.authme.security.crypts.description.SaltType;
|
||||||
import fr.xephi.authme.security.crypts.description.Usage;
|
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.settings.properties.HooksSettings;
|
||||||
import fr.xephi.authme.util.StringUtils;
|
import fr.xephi.authme.util.StringUtils;
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ public class BCRYPT implements EncryptionMethod {
|
|||||||
private final int bCryptLog2Rounds;
|
private final int bCryptLog2Rounds;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public BCRYPT(NewSetting settings) {
|
public BCRYPT(Settings settings) {
|
||||||
bCryptLog2Rounds = settings.getProperty(HooksSettings.BCRYPT_LOG2_ROUND);
|
bCryptLog2Rounds = settings.getProperty(HooksSettings.BCRYPT_LOG2_ROUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.Recommendation;
|
||||||
import fr.xephi.authme.security.crypts.description.SaltType;
|
import fr.xephi.authme.security.crypts.description.SaltType;
|
||||||
import fr.xephi.authme.security.crypts.description.Usage;
|
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 fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@ -19,7 +19,7 @@ public class SALTED2MD5 extends SeparateSaltMethod {
|
|||||||
private final int saltLength;
|
private final int saltLength;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public SALTED2MD5(NewSetting settings) {
|
public SALTED2MD5(Settings settings) {
|
||||||
saltLength = settings.getProperty(SecuritySettings.DOUBLE_MD5_SALT_LENGTH);
|
saltLength = settings.getProperty(SecuritySettings.DOUBLE_MD5_SALT_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import com.google.common.io.ByteStreams;
|
|||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.initialization.SettingsDependent;
|
import fr.xephi.authme.initialization.SettingsDependent;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
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.HooksSettings;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.util.BukkitService;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -30,7 +30,7 @@ public class BungeeService implements SettingsDependent {
|
|||||||
* @param settings AuthMe settings.
|
* @param settings AuthMe settings.
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
BungeeService(AuthMe plugin, BukkitService bukkitService, NewSetting settings) {
|
BungeeService(AuthMe plugin, BukkitService bukkitService, Settings settings) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.bukkitService = bukkitService;
|
this.bukkitService = bukkitService;
|
||||||
reload(settings);
|
reload(settings);
|
||||||
@ -100,7 +100,7 @@ public class BungeeService implements SettingsDependent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reload(NewSetting settings) {
|
public void reload(Settings settings) {
|
||||||
this.isEnabled = settings.getProperty(HooksSettings.BUNGEECORD);
|
this.isEnabled = settings.getProperty(HooksSettings.BUNGEECORD);
|
||||||
this.bungeeServer = settings.getProperty(HooksSettings.BUNGEECORD_SERVER);
|
this.bungeeServer = settings.getProperty(HooksSettings.BUNGEECORD_SERVER);
|
||||||
}
|
}
|
||||||
|
@ -28,9 +28,9 @@ import java.util.Map;
|
|||||||
import static fr.xephi.authme.util.FileUtils.copyFileFromResource;
|
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 pluginFolder;
|
||||||
private final File configFile;
|
private final File configFile;
|
||||||
@ -50,7 +50,7 @@ public class NewSetting {
|
|||||||
* @param propertyMap Collection of all available settings
|
* @param propertyMap Collection of all available settings
|
||||||
* @param migrationService Migration service to check the settings file with
|
* @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) {
|
SettingsMigrationService migrationService) {
|
||||||
this.configuration = YamlConfiguration.loadConfiguration(configFile);
|
this.configuration = YamlConfiguration.loadConfiguration(configFile);
|
||||||
this.configFile = configFile;
|
this.configFile = configFile;
|
||||||
@ -70,7 +70,7 @@ public class NewSetting {
|
|||||||
* @param migrationService Migration service, or null to skip migration checks
|
* @param migrationService Migration service, or null to skip migration checks
|
||||||
*/
|
*/
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
NewSetting(FileConfiguration configuration, File configFile, File pluginFolder, PropertyMap propertyMap,
|
Settings(FileConfiguration configuration, File configFile, File pluginFolder, PropertyMap propertyMap,
|
||||||
SettingsMigrationService migrationService) {
|
SettingsMigrationService migrationService) {
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
this.configFile = configFile;
|
this.configFile = configFile;
|
@ -31,7 +31,7 @@ import java.io.IOException;
|
|||||||
public class SpawnLoader implements Reloadable {
|
public class SpawnLoader implements Reloadable {
|
||||||
|
|
||||||
private final File authMeConfigurationFile;
|
private final File authMeConfigurationFile;
|
||||||
private final NewSetting settings;
|
private final Settings settings;
|
||||||
private final PluginHooks pluginHooks;
|
private final PluginHooks pluginHooks;
|
||||||
private FileConfiguration authMeConfiguration;
|
private FileConfiguration authMeConfiguration;
|
||||||
private String[] spawnPriority;
|
private String[] spawnPriority;
|
||||||
@ -46,7 +46,7 @@ public class SpawnLoader implements Reloadable {
|
|||||||
* @param dataSource The plugin auth database instance
|
* @param dataSource The plugin auth database instance
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
SpawnLoader(@DataFolder File pluginFolder, NewSetting settings, PluginHooks pluginHooks,
|
SpawnLoader(@DataFolder File pluginFolder, Settings settings, PluginHooks pluginHooks,
|
||||||
DataSource dataSource) {
|
DataSource dataSource) {
|
||||||
File spawnFile = new File(pluginFolder, "spawn.yml");
|
File spawnFile = new File(pluginFolder, "spawn.yml");
|
||||||
// TODO ljacqu 20160312: Check if resource could be copied and handle the case if not
|
// TODO ljacqu 20160312: Check if resource could be copied and handle the case if not
|
||||||
|
@ -6,7 +6,7 @@ import fr.xephi.authme.cache.limbo.LimboCache;
|
|||||||
import fr.xephi.authme.cache.limbo.PlayerData;
|
import fr.xephi.authme.cache.limbo.PlayerData;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
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.RegistrationSettings;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.util.BukkitService;
|
||||||
@ -26,7 +26,7 @@ public class PlayerDataTaskManager {
|
|||||||
private Messages messages;
|
private Messages messages;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private BukkitService bukkitService;
|
private BukkitService bukkitService;
|
||||||
|
@ -4,7 +4,7 @@ import fr.xephi.authme.ConsoleLogger;
|
|||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.hooks.PluginHooks;
|
import fr.xephi.authme.hooks.PluginHooks;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
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.settings.properties.PurgeSettings;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.util.BukkitService;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.Utils;
|
||||||
@ -24,7 +24,7 @@ import static fr.xephi.authme.util.StringUtils.makePath;
|
|||||||
class PurgeExecutor {
|
class PurgeExecutor {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
|
@ -3,7 +3,7 @@ package fr.xephi.authme.task.purge;
|
|||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
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.settings.properties.PurgeSettings;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.util.BukkitService;
|
||||||
import fr.xephi.authme.util.CollectionUtils;
|
import fr.xephi.authme.util.CollectionUtils;
|
||||||
@ -25,7 +25,7 @@ public class PurgeService {
|
|||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private PermissionsManager permissionsManager;
|
private PermissionsManager permissionsManager;
|
||||||
|
@ -10,7 +10,7 @@ import fr.xephi.authme.datasource.SQLite;
|
|||||||
import fr.xephi.authme.security.HashAlgorithm;
|
import fr.xephi.authme.security.HashAlgorithm;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||||
import fr.xephi.authme.security.crypts.SHA256;
|
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.DatabaseSettings;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ public final class MigrationService {
|
|||||||
* @param dataSource The data source
|
* @param dataSource The data source
|
||||||
* @param authmeSha256 Instance to the AuthMe SHA256 encryption method implementation
|
* @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) {
|
SHA256 authmeSha256) {
|
||||||
if (HashAlgorithm.PLAINTEXT == settings.getProperty(SecuritySettings.PASSWORD_HASH)) {
|
if (HashAlgorithm.PLAINTEXT == settings.getProperty(SecuritySettings.PASSWORD_HASH)) {
|
||||||
ConsoleLogger.warning("Your HashAlgorithm has been detected as plaintext and is now deprecated;"
|
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
|
* @param dataSource The data source
|
||||||
* @return The converted datasource (SQLite), or null if no migration was necessary
|
* @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)) {
|
if (DataSourceType.FILE == settings.getProperty(DatabaseSettings.BACKEND)) {
|
||||||
ConsoleLogger.warning("FlatFile backend has been detected and is now deprecated; it will be changed "
|
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!");
|
+ "to SQLite... Connection will be impossible until conversion is done!");
|
||||||
|
@ -10,7 +10,7 @@ import fr.xephi.authme.events.AuthMeTeleportEvent;
|
|||||||
import fr.xephi.authme.events.FirstSpawnTeleportEvent;
|
import fr.xephi.authme.events.FirstSpawnTeleportEvent;
|
||||||
import fr.xephi.authme.events.SpawnTeleportEvent;
|
import fr.xephi.authme.events.SpawnTeleportEvent;
|
||||||
import fr.xephi.authme.initialization.Reloadable;
|
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.SpawnLoader;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -30,7 +30,7 @@ import static fr.xephi.authme.settings.properties.RestrictionSettings.TELEPORT_U
|
|||||||
public class TeleportationService implements Reloadable {
|
public class TeleportationService implements Reloadable {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private BukkitService bukkitService;
|
private BukkitService bukkitService;
|
||||||
|
@ -5,7 +5,7 @@ import fr.xephi.authme.initialization.Reloadable;
|
|||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.permission.PlayerStatePermission;
|
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.domain.Property;
|
||||||
import fr.xephi.authme.settings.properties.EmailSettings;
|
import fr.xephi.authme.settings.properties.EmailSettings;
|
||||||
import fr.xephi.authme.settings.properties.ProtectionSettings;
|
import fr.xephi.authme.settings.properties.ProtectionSettings;
|
||||||
@ -27,7 +27,7 @@ import java.util.regex.Pattern;
|
|||||||
public class ValidationService implements Reloadable {
|
public class ValidationService implements Reloadable {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
@Inject
|
@Inject
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -4,7 +4,7 @@ import fr.xephi.authme.output.MessageKey;
|
|||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.permission.PlayerStatePermission;
|
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.ProtectionSettings;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.util.BukkitService;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -41,7 +41,7 @@ import static org.mockito.Mockito.verify;
|
|||||||
public class AntiBotTest {
|
public class AntiBotTest {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
@Mock
|
@Mock
|
||||||
private Messages messages;
|
private Messages messages;
|
||||||
@Mock
|
@Mock
|
||||||
|
@ -12,7 +12,7 @@ import fr.xephi.authme.permission.PermissionsManager;
|
|||||||
import fr.xephi.authme.process.Management;
|
import fr.xephi.authme.process.Management;
|
||||||
import fr.xephi.authme.process.login.ProcessSyncPlayerLogin;
|
import fr.xephi.authme.process.login.ProcessSyncPlayerLogin;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
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 fr.xephi.authme.task.purge.PurgeService;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
@ -92,7 +92,7 @@ public class AuthMeInitializationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldInitializeAllServices() {
|
public void shouldInitializeAllServices() {
|
||||||
// given
|
// 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
|
// 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()
|
// 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(PluginManager.class, pluginManager);
|
||||||
|
|
||||||
injector.register(AuthMe.class, authMe);
|
injector.register(AuthMe.class, authMe);
|
||||||
injector.register(NewSetting.class, settings);
|
injector.register(Settings.class, settings);
|
||||||
injector.register(DataSource.class, mock(DataSource.class));
|
injector.register(DataSource.class, mock(DataSource.class));
|
||||||
|
|
||||||
// when
|
// when
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package fr.xephi.authme;
|
package fr.xephi.authme;
|
||||||
|
|
||||||
import fr.xephi.authme.output.LogLevel;
|
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.PluginSettings;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
import fr.xephi.authme.util.StringUtils;
|
import fr.xephi.authme.util.StringUtils;
|
||||||
@ -45,7 +45,7 @@ public class ConsoleLoggerTest {
|
|||||||
private Logger logger;
|
private Logger logger;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||||
@ -144,8 +144,8 @@ public class ConsoleLoggerTest {
|
|||||||
TestHelper.validateHasOnlyPrivateEmptyConstructor(ConsoleLogger.class);
|
TestHelper.validateHasOnlyPrivateEmptyConstructor(ConsoleLogger.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static NewSetting newSettings(boolean logToFile, LogLevel logLevel) {
|
private static Settings newSettings(boolean logToFile, LogLevel logLevel) {
|
||||||
NewSetting settings = mock(NewSetting.class);
|
Settings settings = mock(Settings.class);
|
||||||
given(settings.getProperty(SecuritySettings.USE_LOGGING)).willReturn(logToFile);
|
given(settings.getProperty(SecuritySettings.USE_LOGGING)).willReturn(logToFile);
|
||||||
given(settings.getProperty(PluginSettings.LOG_LEVEL)).willReturn(logLevel);
|
given(settings.getProperty(PluginSettings.LOG_LEVEL)).willReturn(logLevel);
|
||||||
return settings;
|
return settings;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package fr.xephi.authme.cache;
|
package fr.xephi.authme.cache;
|
||||||
|
|
||||||
import fr.xephi.authme.ReflectionTestUtils;
|
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 fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ public class CaptchaManagerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldAddCounts() {
|
public void shouldAddCounts() {
|
||||||
// given
|
// given
|
||||||
NewSetting settings = mockSettings(3, 4);
|
Settings settings = mockSettings(3, 4);
|
||||||
CaptchaManager manager = new CaptchaManager(settings);
|
CaptchaManager manager = new CaptchaManager(settings);
|
||||||
String player = "tester";
|
String player = "tester";
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ public class CaptchaManagerTest {
|
|||||||
public void shouldCreateAndCheckCaptcha() {
|
public void shouldCreateAndCheckCaptcha() {
|
||||||
// given
|
// given
|
||||||
String player = "Miner";
|
String player = "Miner";
|
||||||
NewSetting settings = mockSettings(1, 4);
|
Settings settings = mockSettings(1, 4);
|
||||||
CaptchaManager manager = new CaptchaManager(settings);
|
CaptchaManager manager = new CaptchaManager(settings);
|
||||||
String captchaCode = manager.getCaptchaCodeOrGenerateNew(player);
|
String captchaCode = manager.getCaptchaCodeOrGenerateNew(player);
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ public class CaptchaManagerTest {
|
|||||||
public void shouldHaveSameCodeAfterGeneration() {
|
public void shouldHaveSameCodeAfterGeneration() {
|
||||||
// given
|
// given
|
||||||
String player = "Tester";
|
String player = "Tester";
|
||||||
NewSetting settings = mockSettings(1, 5);
|
Settings settings = mockSettings(1, 5);
|
||||||
CaptchaManager manager = new CaptchaManager(settings);
|
CaptchaManager manager = new CaptchaManager(settings);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
@ -88,7 +88,7 @@ public class CaptchaManagerTest {
|
|||||||
public void shouldIncreaseAndResetCount() {
|
public void shouldIncreaseAndResetCount() {
|
||||||
// given
|
// given
|
||||||
String player = "plaYer";
|
String player = "plaYer";
|
||||||
NewSetting settings = mockSettings(2, 3);
|
Settings settings = mockSettings(2, 3);
|
||||||
CaptchaManager manager = new CaptchaManager(settings);
|
CaptchaManager manager = new CaptchaManager(settings);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
@ -111,7 +111,7 @@ public class CaptchaManagerTest {
|
|||||||
public void shouldNotIncreaseCountForDisabledCaptcha() {
|
public void shouldNotIncreaseCountForDisabledCaptcha() {
|
||||||
// given
|
// given
|
||||||
String player = "someone_";
|
String player = "someone_";
|
||||||
NewSetting settings = mockSettings(1, 3);
|
Settings settings = mockSettings(1, 3);
|
||||||
given(settings.getProperty(SecuritySettings.USE_CAPTCHA)).willReturn(false);
|
given(settings.getProperty(SecuritySettings.USE_CAPTCHA)).willReturn(false);
|
||||||
CaptchaManager manager = new CaptchaManager(settings);
|
CaptchaManager manager = new CaptchaManager(settings);
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ public class CaptchaManagerTest {
|
|||||||
public void shouldNotCheckCountIfCaptchaIsDisabled() {
|
public void shouldNotCheckCountIfCaptchaIsDisabled() {
|
||||||
// given
|
// given
|
||||||
String player = "Robert001";
|
String player = "Robert001";
|
||||||
NewSetting settings = mockSettings(1, 5);
|
Settings settings = mockSettings(1, 5);
|
||||||
CaptchaManager manager = new CaptchaManager(settings);
|
CaptchaManager manager = new CaptchaManager(settings);
|
||||||
given(settings.getProperty(SecuritySettings.USE_CAPTCHA)).willReturn(false);
|
given(settings.getProperty(SecuritySettings.USE_CAPTCHA)).willReturn(false);
|
||||||
|
|
||||||
@ -144,8 +144,8 @@ public class CaptchaManagerTest {
|
|||||||
assertThat(result, equalTo(false));
|
assertThat(result, equalTo(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static NewSetting mockSettings(int maxTries, int captchaLength) {
|
private static Settings mockSettings(int maxTries, int captchaLength) {
|
||||||
NewSetting settings = mock(NewSetting.class);
|
Settings settings = mock(Settings.class);
|
||||||
given(settings.getProperty(SecuritySettings.USE_CAPTCHA)).willReturn(true);
|
given(settings.getProperty(SecuritySettings.USE_CAPTCHA)).willReturn(true);
|
||||||
given(settings.getProperty(SecuritySettings.MAX_LOGIN_TRIES_BEFORE_CAPTCHA)).willReturn(maxTries);
|
given(settings.getProperty(SecuritySettings.MAX_LOGIN_TRIES_BEFORE_CAPTCHA)).willReturn(maxTries);
|
||||||
given(settings.getProperty(SecuritySettings.CAPTCHA_LENGTH)).willReturn(captchaLength);
|
given(settings.getProperty(SecuritySettings.CAPTCHA_LENGTH)).willReturn(captchaLength);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package fr.xephi.authme.cache;
|
package fr.xephi.authme.cache;
|
||||||
|
|
||||||
import fr.xephi.authme.ReflectionTestUtils;
|
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 fr.xephi.authme.settings.properties.PluginSettings;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@ -24,7 +24,7 @@ public class SessionManagerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldHaveSession() {
|
public void shouldHaveSession() {
|
||||||
// given
|
// given
|
||||||
NewSetting settings = mockSettings(true, 10);
|
Settings settings = mockSettings(true, 10);
|
||||||
SessionManager manager = new SessionManager(settings);
|
SessionManager manager = new SessionManager(settings);
|
||||||
String player = "playah";
|
String player = "playah";
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ public class SessionManagerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldNotHaveSession() {
|
public void shouldNotHaveSession() {
|
||||||
// given
|
// given
|
||||||
NewSetting settings = mockSettings(true, 10);
|
Settings settings = mockSettings(true, 10);
|
||||||
SessionManager manager = new SessionManager(settings);
|
SessionManager manager = new SessionManager(settings);
|
||||||
String player = "playah";
|
String player = "playah";
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ public class SessionManagerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldNotAddSessionBecauseDisabled() {
|
public void shouldNotAddSessionBecauseDisabled() {
|
||||||
// given
|
// given
|
||||||
NewSetting settings = mockSettings(false, 10);
|
Settings settings = mockSettings(false, 10);
|
||||||
SessionManager manager = new SessionManager(settings);
|
SessionManager manager = new SessionManager(settings);
|
||||||
String player = "playah";
|
String player = "playah";
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ public class SessionManagerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldNotAddSessionBecauseTimeoutIsZero() {
|
public void shouldNotAddSessionBecauseTimeoutIsZero() {
|
||||||
// given
|
// given
|
||||||
NewSetting settings = mockSettings(true, 0);
|
Settings settings = mockSettings(true, 0);
|
||||||
SessionManager manager = new SessionManager(settings);
|
SessionManager manager = new SessionManager(settings);
|
||||||
String player = "playah";
|
String player = "playah";
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ public class SessionManagerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldRemoveSession() {
|
public void shouldRemoveSession() {
|
||||||
// given
|
// given
|
||||||
NewSetting settings = mockSettings(true, 10);
|
Settings settings = mockSettings(true, 10);
|
||||||
String player = "user";
|
String player = "user";
|
||||||
SessionManager manager = new SessionManager(settings);
|
SessionManager manager = new SessionManager(settings);
|
||||||
manager.addSession(player);
|
manager.addSession(player);
|
||||||
@ -93,7 +93,7 @@ public class SessionManagerTest {
|
|||||||
public void shouldDenySessionIfTimeoutHasExpired() {
|
public void shouldDenySessionIfTimeoutHasExpired() {
|
||||||
// given
|
// given
|
||||||
int timeout = 20;
|
int timeout = 20;
|
||||||
NewSetting settings = mockSettings(true, timeout);
|
Settings settings = mockSettings(true, timeout);
|
||||||
String player = "patrick";
|
String player = "patrick";
|
||||||
SessionManager manager = new SessionManager(settings);
|
SessionManager manager = new SessionManager(settings);
|
||||||
Map<String, Long> sessions = getSessionsMap(manager);
|
Map<String, Long> sessions = getSessionsMap(manager);
|
||||||
@ -110,7 +110,7 @@ public class SessionManagerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldClearAllSessionsAfterDisable() {
|
public void shouldClearAllSessionsAfterDisable() {
|
||||||
// given
|
// given
|
||||||
NewSetting settings = mockSettings(true, 10);
|
Settings settings = mockSettings(true, 10);
|
||||||
SessionManager manager = new SessionManager(settings);
|
SessionManager manager = new SessionManager(settings);
|
||||||
manager.addSession("player01");
|
manager.addSession("player01");
|
||||||
manager.addSession("player02");
|
manager.addSession("player02");
|
||||||
@ -129,8 +129,8 @@ public class SessionManagerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static NewSetting mockSettings(boolean isEnabled, int sessionTimeout) {
|
private static Settings mockSettings(boolean isEnabled, int sessionTimeout) {
|
||||||
NewSetting settings = mock(NewSetting.class);
|
Settings settings = mock(Settings.class);
|
||||||
given(settings.getProperty(PluginSettings.SESSIONS_ENABLED)).willReturn(isEnabled);
|
given(settings.getProperty(PluginSettings.SESSIONS_ENABLED)).willReturn(isEnabled);
|
||||||
given(settings.getProperty(PluginSettings.SESSIONS_TIMEOUT)).willReturn(sessionTimeout);
|
given(settings.getProperty(PluginSettings.SESSIONS_TIMEOUT)).willReturn(sessionTimeout);
|
||||||
return settings;
|
return settings;
|
||||||
|
@ -4,7 +4,7 @@ import fr.xephi.authme.ReflectionTestUtils;
|
|||||||
import fr.xephi.authme.TestHelper;
|
import fr.xephi.authme.TestHelper;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
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.settings.properties.SecuritySettings;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.util.BukkitService;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -44,7 +44,7 @@ public class TempbanManagerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldAddCounts() {
|
public void shouldAddCounts() {
|
||||||
// given
|
// given
|
||||||
NewSetting settings = mockSettings(3, 60);
|
Settings settings = mockSettings(3, 60);
|
||||||
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
|
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
|
||||||
String address = "192.168.1.1";
|
String address = "192.168.1.1";
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ public class TempbanManagerTest {
|
|||||||
public void shouldIncreaseAndResetCount() {
|
public void shouldIncreaseAndResetCount() {
|
||||||
// given
|
// given
|
||||||
String address = "192.168.1.2";
|
String address = "192.168.1.2";
|
||||||
NewSetting settings = mockSettings(3, 60);
|
Settings settings = mockSettings(3, 60);
|
||||||
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
|
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
@ -88,7 +88,7 @@ public class TempbanManagerTest {
|
|||||||
public void shouldNotIncreaseCountForDisabledTempban() {
|
public void shouldNotIncreaseCountForDisabledTempban() {
|
||||||
// given
|
// given
|
||||||
String address = "192.168.1.3";
|
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);
|
given(settings.getProperty(SecuritySettings.TEMPBAN_ON_MAX_LOGINS)).willReturn(false);
|
||||||
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
|
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ public class TempbanManagerTest {
|
|||||||
public void shouldNotCheckCountIfTempbanIsDisabled() {
|
public void shouldNotCheckCountIfTempbanIsDisabled() {
|
||||||
// given
|
// given
|
||||||
String address = "192.168.1.4";
|
String address = "192.168.1.4";
|
||||||
NewSetting settings = mockSettings(1, 5);
|
Settings settings = mockSettings(1, 5);
|
||||||
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
|
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
|
||||||
given(settings.getProperty(SecuritySettings.TEMPBAN_ON_MAX_LOGINS)).willReturn(false);
|
given(settings.getProperty(SecuritySettings.TEMPBAN_ON_MAX_LOGINS)).willReturn(false);
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ public class TempbanManagerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldNotIssueBanIfDisabled() {
|
public void shouldNotIssueBanIfDisabled() {
|
||||||
// given
|
// given
|
||||||
NewSetting settings = mockSettings(0, 0);
|
Settings settings = mockSettings(0, 0);
|
||||||
given(settings.getProperty(SecuritySettings.TEMPBAN_ON_MAX_LOGINS)).willReturn(false);
|
given(settings.getProperty(SecuritySettings.TEMPBAN_ON_MAX_LOGINS)).willReturn(false);
|
||||||
Player player = mock(Player.class);
|
Player player = mock(Player.class);
|
||||||
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
|
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
|
||||||
@ -144,7 +144,7 @@ public class TempbanManagerTest {
|
|||||||
TestHelper.mockPlayerIp(player, ip);
|
TestHelper.mockPlayerIp(player, ip);
|
||||||
String banReason = "IP ban too many logins";
|
String banReason = "IP ban too many logins";
|
||||||
given(messages.retrieveSingle(MessageKey.TEMPBAN_MAX_LOGINS)).willReturn(banReason);
|
given(messages.retrieveSingle(MessageKey.TEMPBAN_MAX_LOGINS)).willReturn(banReason);
|
||||||
NewSetting settings = mockSettings(2, 100);
|
Settings settings = mockSettings(2, 100);
|
||||||
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
|
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
@ -171,7 +171,7 @@ public class TempbanManagerTest {
|
|||||||
TestHelper.mockPlayerIp(player, ip);
|
TestHelper.mockPlayerIp(player, ip);
|
||||||
String banReason = "kick msg";
|
String banReason = "kick msg";
|
||||||
given(messages.retrieveSingle(MessageKey.TEMPBAN_MAX_LOGINS)).willReturn(banReason);
|
given(messages.retrieveSingle(MessageKey.TEMPBAN_MAX_LOGINS)).willReturn(banReason);
|
||||||
NewSetting settings = mockSettings(10, 60);
|
Settings settings = mockSettings(10, 60);
|
||||||
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
|
TempbanManager manager = new TempbanManager(bukkitService, messages, settings);
|
||||||
manager.increaseCount(ip);
|
manager.increaseCount(ip);
|
||||||
manager.increaseCount(ip);
|
manager.increaseCount(ip);
|
||||||
@ -186,8 +186,8 @@ public class TempbanManagerTest {
|
|||||||
assertHasCount(manager, ip, null);
|
assertHasCount(manager, ip, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static NewSetting mockSettings(int maxTries, int tempbanLength) {
|
private static Settings mockSettings(int maxTries, int tempbanLength) {
|
||||||
NewSetting settings = mock(NewSetting.class);
|
Settings settings = mock(Settings.class);
|
||||||
given(settings.getProperty(SecuritySettings.TEMPBAN_ON_MAX_LOGINS)).willReturn(true);
|
given(settings.getProperty(SecuritySettings.TEMPBAN_ON_MAX_LOGINS)).willReturn(true);
|
||||||
given(settings.getProperty(SecuritySettings.MAX_LOGIN_TEMPBAN)).willReturn(maxTries);
|
given(settings.getProperty(SecuritySettings.MAX_LOGIN_TEMPBAN)).willReturn(maxTries);
|
||||||
given(settings.getProperty(SecuritySettings.TEMPBAN_LENGTH)).willReturn(tempbanLength);
|
given(settings.getProperty(SecuritySettings.TEMPBAN_LENGTH)).willReturn(tempbanLength);
|
||||||
|
@ -3,7 +3,7 @@ package fr.xephi.authme.cache.limbo;
|
|||||||
import fr.xephi.authme.ReflectionTestUtils;
|
import fr.xephi.authme.ReflectionTestUtils;
|
||||||
import fr.xephi.authme.cache.backup.PlayerDataStorage;
|
import fr.xephi.authme.cache.backup.PlayerDataStorage;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
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.SpawnLoader;
|
||||||
import fr.xephi.authme.settings.properties.PluginSettings;
|
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -35,7 +35,7 @@ public class LimboCacheTest {
|
|||||||
private LimboCache limboCache;
|
private LimboCache limboCache;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private PermissionsManager permissionsManager;
|
private PermissionsManager permissionsManager;
|
||||||
|
@ -2,7 +2,7 @@ package fr.xephi.authme.command;
|
|||||||
|
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
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.domain.Property;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
import fr.xephi.authme.util.ValidationService;
|
import fr.xephi.authme.util.ValidationService;
|
||||||
@ -31,7 +31,7 @@ public class CommandServiceTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private Messages messages;
|
private Messages messages;
|
||||||
@Mock
|
@Mock
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
@Mock
|
@Mock
|
||||||
private ValidationService validationService;
|
private ValidationService validationService;
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ public class CommandServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldReturnSettings() {
|
public void shouldReturnSettings() {
|
||||||
// given/when
|
// given/when
|
||||||
NewSetting result = commandService.getSettings();
|
Settings result = commandService.getSettings();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result, equalTo(settings));
|
assertThat(result, equalTo(settings));
|
||||||
|
@ -10,7 +10,7 @@ import fr.xephi.authme.initialization.Reloadable;
|
|||||||
import fr.xephi.authme.initialization.SettingsDependent;
|
import fr.xephi.authme.initialization.SettingsDependent;
|
||||||
import fr.xephi.authme.output.LogLevel;
|
import fr.xephi.authme.output.LogLevel;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
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.DatabaseSettings;
|
||||||
import fr.xephi.authme.settings.properties.PluginSettings;
|
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
@ -53,7 +53,7 @@ public class ReloadCommandTest {
|
|||||||
private Injector injector;
|
private Injector injector;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
|
@ -6,7 +6,7 @@ import fr.xephi.authme.command.FoundResultStatus;
|
|||||||
import fr.xephi.authme.command.TestCommandsUtil;
|
import fr.xephi.authme.command.TestCommandsUtil;
|
||||||
import fr.xephi.authme.permission.AdminPermission;
|
import fr.xephi.authme.permission.AdminPermission;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
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 fr.xephi.authme.settings.properties.PluginSettings;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -57,7 +57,7 @@ public class HelpProviderTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUpHelpProvider() {
|
public void setUpHelpProvider() {
|
||||||
permissionsManager = mock(PermissionsManager.class);
|
permissionsManager = mock(PermissionsManager.class);
|
||||||
NewSetting settings = mock(NewSetting.class);
|
Settings settings = mock(Settings.class);
|
||||||
given(settings.getProperty(PluginSettings.HELP_HEADER)).willReturn(HELP_HEADER);
|
given(settings.getProperty(PluginSettings.HELP_HEADER)).willReturn(HELP_HEADER);
|
||||||
helpProvider = new HelpProvider(permissionsManager, settings);
|
helpProvider = new HelpProvider(permissionsManager, settings);
|
||||||
sender = mock(CommandSender.class);
|
sender = mock(CommandSender.class);
|
||||||
|
@ -6,7 +6,7 @@ import fr.xephi.authme.TestHelper;
|
|||||||
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.initialization.DataFolder;
|
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 fr.xephi.authme.settings.properties.ConverterSettings;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
@ -42,7 +42,7 @@ public class CrazyLoginConverterTest {
|
|||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
|
|
||||||
@DataFolder
|
@DataFolder
|
||||||
private File dataFolder = TestHelper.getJarFile(TestHelper.PROJECT_ROOT + "converter/");
|
private File dataFolder = TestHelper.getJarFile(TestHelper.PROJECT_ROOT + "converter/");
|
||||||
|
@ -8,7 +8,7 @@ import fr.xephi.authme.TestHelper;
|
|||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.security.HashAlgorithm;
|
import fr.xephi.authme.security.HashAlgorithm;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
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.domain.Property;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@ -72,7 +72,7 @@ public abstract class AbstractResourceClosingTest {
|
|||||||
private static final Map<String, HashAlgorithm[]> CUSTOM_ALGORITHMS = getCustomAlgorithmList();
|
private static final Map<String, HashAlgorithm[]> CUSTOM_ALGORITHMS = getCustomAlgorithmList();
|
||||||
|
|
||||||
/** Mock of a settings instance. */
|
/** Mock of a settings instance. */
|
||||||
private static NewSetting settings;
|
private static Settings settings;
|
||||||
|
|
||||||
/** The datasource to test. */
|
/** The datasource to test. */
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
@ -101,7 +101,7 @@ public abstract class AbstractResourceClosingTest {
|
|||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void initializeSettings() throws IOException, ClassNotFoundException {
|
public static void initializeSettings() throws IOException, ClassNotFoundException {
|
||||||
settings = mock(NewSetting.class);
|
settings = mock(Settings.class);
|
||||||
given(settings.getProperty(any(Property.class))).willAnswer(new Answer() {
|
given(settings.getProperty(any(Property.class))).willAnswer(new Answer() {
|
||||||
@Override
|
@Override
|
||||||
public Object answer(InvocationOnMock invocation) {
|
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. */
|
/* 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. */
|
/* Get all methods of the DataSource interface, minus the ones in the ignored list. */
|
||||||
private static List<Method> getDataSourceMethods() {
|
private static List<Method> getDataSourceMethods() {
|
||||||
|
@ -3,7 +3,7 @@ package fr.xephi.authme.datasource;
|
|||||||
import com.zaxxer.hikari.HikariConfig;
|
import com.zaxxer.hikari.HikariConfig;
|
||||||
import com.zaxxer.hikari.HikariDataSource;
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
import fr.xephi.authme.TestHelper;
|
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.domain.Property;
|
||||||
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
@ -29,7 +29,7 @@ import static org.mockito.Mockito.when;
|
|||||||
public class MySqlIntegrationTest extends AbstractDataSourceIntegrationTest {
|
public class MySqlIntegrationTest extends AbstractDataSourceIntegrationTest {
|
||||||
|
|
||||||
/** Mock of a settings instance. */
|
/** Mock of a settings instance. */
|
||||||
private static NewSetting settings;
|
private static Settings settings;
|
||||||
/** SQL statement to execute before running a test. */
|
/** SQL statement to execute before running a test. */
|
||||||
private static String sqlInitialize;
|
private static String sqlInitialize;
|
||||||
/** Connection to the H2 test database. */
|
/** Connection to the H2 test database. */
|
||||||
@ -44,7 +44,7 @@ public class MySqlIntegrationTest extends AbstractDataSourceIntegrationTest {
|
|||||||
// Check that we have an H2 driver
|
// Check that we have an H2 driver
|
||||||
Class.forName("org.h2.jdbcx.JdbcDataSource");
|
Class.forName("org.h2.jdbcx.JdbcDataSource");
|
||||||
|
|
||||||
settings = mock(NewSetting.class);
|
settings = mock(Settings.class);
|
||||||
when(settings.getProperty(any(Property.class))).thenAnswer(new Answer() {
|
when(settings.getProperty(any(Property.class))).thenAnswer(new Answer() {
|
||||||
@Override
|
@Override
|
||||||
public Object answer(InvocationOnMock invocation) throws Throwable {
|
public Object answer(InvocationOnMock invocation) throws Throwable {
|
||||||
|
@ -2,7 +2,7 @@ package fr.xephi.authme.datasource;
|
|||||||
|
|
||||||
import com.zaxxer.hikari.HikariDataSource;
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
import fr.xephi.authme.security.HashAlgorithm;
|
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.lang.reflect.Method;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@ -20,7 +20,7 @@ public class MySqlResourceClosingTest extends AbstractResourceClosingTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DataSource createDataSource(NewSetting settings, Connection connection) throws Exception {
|
protected DataSource createDataSource(Settings settings, Connection connection) throws Exception {
|
||||||
HikariDataSource hikariDataSource = mock(HikariDataSource.class);
|
HikariDataSource hikariDataSource = mock(HikariDataSource.class);
|
||||||
given(hikariDataSource.getConnection()).willReturn(connection);
|
given(hikariDataSource.getConnection()).willReturn(connection);
|
||||||
return new MySQL(settings, hikariDataSource);
|
return new MySQL(settings, hikariDataSource);
|
||||||
|
@ -2,7 +2,7 @@ package fr.xephi.authme.datasource;
|
|||||||
|
|
||||||
import fr.xephi.authme.TestHelper;
|
import fr.xephi.authme.TestHelper;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
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.domain.Property;
|
||||||
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
@ -32,7 +32,7 @@ import static org.mockito.Mockito.when;
|
|||||||
public class SQLiteIntegrationTest extends AbstractDataSourceIntegrationTest {
|
public class SQLiteIntegrationTest extends AbstractDataSourceIntegrationTest {
|
||||||
|
|
||||||
/** Mock of a settings instance. */
|
/** Mock of a settings instance. */
|
||||||
private static NewSetting settings;
|
private static Settings settings;
|
||||||
/** Collection of SQL statements to execute for initialization of a test. */
|
/** Collection of SQL statements to execute for initialization of a test. */
|
||||||
private static String[] sqlInitialize;
|
private static String[] sqlInitialize;
|
||||||
/** Connection to the SQLite test database. */
|
/** Connection to the SQLite test database. */
|
||||||
@ -47,7 +47,7 @@ public class SQLiteIntegrationTest extends AbstractDataSourceIntegrationTest {
|
|||||||
// Check that we have an implementation for SQLite
|
// Check that we have an implementation for SQLite
|
||||||
Class.forName("org.sqlite.JDBC");
|
Class.forName("org.sqlite.JDBC");
|
||||||
|
|
||||||
settings = mock(NewSetting.class);
|
settings = mock(Settings.class);
|
||||||
when(settings.getProperty(any(Property.class))).thenAnswer(new Answer() {
|
when(settings.getProperty(any(Property.class))).thenAnswer(new Answer() {
|
||||||
@Override
|
@Override
|
||||||
public Object answer(InvocationOnMock invocation) throws Throwable {
|
public Object answer(InvocationOnMock invocation) throws Throwable {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package fr.xephi.authme.datasource;
|
package fr.xephi.authme.datasource;
|
||||||
|
|
||||||
import fr.xephi.authme.security.HashAlgorithm;
|
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.lang.reflect.Method;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@ -16,7 +16,7 @@ public class SQLiteResourceClosingTest extends AbstractResourceClosingTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DataSource createDataSource(NewSetting settings, Connection connection) throws Exception {
|
protected DataSource createDataSource(Settings settings, Connection connection) throws Exception {
|
||||||
return new SQLite(settings, connection);
|
return new SQLite(settings, connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import ch.jalu.injector.testing.InjectDelayed;
|
|||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.hooks.PluginHooks;
|
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.settings.properties.RegistrationSettings;
|
||||||
import fr.xephi.authme.util.ValidationService;
|
import fr.xephi.authme.util.ValidationService;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -35,7 +35,7 @@ public class ListenerServiceTest {
|
|||||||
private ListenerService listenerService;
|
private ListenerService listenerService;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
|
@ -8,7 +8,7 @@ import fr.xephi.authme.output.MessageKey;
|
|||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.permission.PlayerStatePermission;
|
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.RegistrationSettings;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.util.BukkitService;
|
||||||
@ -53,7 +53,7 @@ public class OnJoinVerifierTest {
|
|||||||
private OnJoinVerifier onJoinVerifier;
|
private OnJoinVerifier onJoinVerifier;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
@Mock
|
@Mock
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
@Mock
|
@Mock
|
||||||
|
@ -2,7 +2,7 @@ package fr.xephi.authme.output;
|
|||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.TestHelper;
|
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.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@ -53,7 +53,7 @@ public class MessagesIntegrationTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUpMessages() {
|
public void setUpMessages() {
|
||||||
File testFile = TestHelper.getJarFile(YML_TEST_FILE);
|
File testFile = TestHelper.getJarFile(YML_TEST_FILE);
|
||||||
NewSetting settings = mock(NewSetting.class);
|
Settings settings = mock(Settings.class);
|
||||||
given(settings.getMessagesFile()).willReturn(testFile);
|
given(settings.getMessagesFile()).willReturn(testFile);
|
||||||
given(settings.getDefaultMessagesFile()).willReturn(YML_DEFAULT_TEST_FILE);
|
given(settings.getDefaultMessagesFile()).willReturn(YML_DEFAULT_TEST_FILE);
|
||||||
messages = new Messages(settings);
|
messages = new Messages(settings);
|
||||||
@ -235,7 +235,7 @@ public class MessagesIntegrationTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldAllowNullAsDefaultFile() {
|
public void shouldAllowNullAsDefaultFile() {
|
||||||
// given
|
// given
|
||||||
NewSetting settings = mock(NewSetting.class);
|
Settings settings = mock(Settings.class);
|
||||||
given(settings.getMessagesFile()).willReturn(TestHelper.getJarFile(YML_TEST_FILE));
|
given(settings.getMessagesFile()).willReturn(TestHelper.getJarFile(YML_TEST_FILE));
|
||||||
Messages testMessages = new Messages(settings);
|
Messages testMessages = new Messages(settings);
|
||||||
// Key not present in test file
|
// Key not present in test file
|
||||||
@ -254,7 +254,7 @@ public class MessagesIntegrationTest {
|
|||||||
MessageKey key = MessageKey.WRONG_PASSWORD;
|
MessageKey key = MessageKey.WRONG_PASSWORD;
|
||||||
// assumption: message comes back as defined in messages_test.yml
|
// assumption: message comes back as defined in messages_test.yml
|
||||||
assumeThat(messages.retrieveSingle(key), equalTo("§cWrong password!"));
|
assumeThat(messages.retrieveSingle(key), equalTo("§cWrong password!"));
|
||||||
NewSetting settings = mock(NewSetting.class);
|
Settings settings = mock(Settings.class);
|
||||||
given(settings.getMessagesFile()).willReturn(TestHelper.getJarFile(
|
given(settings.getMessagesFile()).willReturn(TestHelper.getJarFile(
|
||||||
TestHelper.PROJECT_ROOT + "output/messages_test2.yml"));
|
TestHelper.PROJECT_ROOT + "output/messages_test2.yml"));
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import fr.xephi.authme.permission.AuthGroupType;
|
|||||||
import fr.xephi.authme.permission.PermissionNode;
|
import fr.xephi.authme.permission.PermissionNode;
|
||||||
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.NewSetting;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
import fr.xephi.authme.util.ValidationService;
|
import fr.xephi.authme.util.ValidationService;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -37,7 +37,7 @@ public class ProcessServiceTest {
|
|||||||
private ValidationService validationService;
|
private ValidationService validationService;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private Messages messages;
|
private Messages messages;
|
||||||
@ -64,7 +64,7 @@ public class ProcessServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
public void shouldReturnSettings() {
|
public void shouldReturnSettings() {
|
||||||
// given/when
|
// given/when
|
||||||
NewSetting result = processService.getSettings();
|
Settings result = processService.getSettings();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result, equalTo(settings));
|
assertThat(result, equalTo(settings));
|
||||||
|
@ -4,7 +4,7 @@ import ch.jalu.injector.Injector;
|
|||||||
import ch.jalu.injector.InjectorBuilder;
|
import ch.jalu.injector.InjectorBuilder;
|
||||||
import fr.xephi.authme.security.crypts.EncryptionMethod;
|
import fr.xephi.authme.security.crypts.EncryptionMethod;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
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.HooksSettings;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
import fr.xephi.authme.util.StringUtils;
|
import fr.xephi.authme.util.StringUtils;
|
||||||
@ -29,11 +29,11 @@ public class HashAlgorithmIntegrationTest {
|
|||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpConfigAndInjector() {
|
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(HooksSettings.BCRYPT_LOG2_ROUND)).willReturn(8);
|
||||||
given(settings.getProperty(SecuritySettings.DOUBLE_MD5_SALT_LENGTH)).willReturn(16);
|
given(settings.getProperty(SecuritySettings.DOUBLE_MD5_SALT_LENGTH)).willReturn(16);
|
||||||
injector = new InjectorBuilder().addDefaultHandlers("fr.xephi.authme").create();
|
injector = new InjectorBuilder().addDefaultHandlers("fr.xephi.authme").create();
|
||||||
injector.register(NewSetting.class, settings);
|
injector.register(Settings.class, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -9,7 +9,7 @@ import fr.xephi.authme.events.PasswordEncryptionEvent;
|
|||||||
import fr.xephi.authme.security.crypts.EncryptionMethod;
|
import fr.xephi.authme.security.crypts.EncryptionMethod;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||||
import fr.xephi.authme.security.crypts.JOOMLA;
|
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.HooksSettings;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
@ -45,7 +45,7 @@ public class PasswordSecurityTest {
|
|||||||
private Injector injector;
|
private Injector injector;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private PluginManager pluginManager;
|
private PluginManager pluginManager;
|
||||||
@ -81,7 +81,7 @@ public class PasswordSecurityTest {
|
|||||||
}
|
}
|
||||||
}).when(pluginManager).callEvent(any(Event.class));
|
}).when(pluginManager).callEvent(any(Event.class));
|
||||||
injector = new InjectorBuilder().addDefaultHandlers("!! impossible package !!").create();
|
injector = new InjectorBuilder().addDefaultHandlers("!! impossible package !!").create();
|
||||||
injector.register(NewSetting.class, settings);
|
injector.register(Settings.class, settings);
|
||||||
injector.register(DataSource.class, dataSource);
|
injector.register(DataSource.class, dataSource);
|
||||||
injector.register(PluginManager.class, pluginManager);
|
injector.register(PluginManager.class, pluginManager);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package fr.xephi.authme.security.crypts;
|
package fr.xephi.authme.security.crypts;
|
||||||
|
|
||||||
import fr.xephi.authme.TestHelper;
|
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 fr.xephi.authme.settings.properties.HooksSettings;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
|
||||||
@ -27,8 +27,8 @@ public class BcryptTest extends AbstractEncryptionMethodTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static NewSetting mockSettings() {
|
private static Settings mockSettings() {
|
||||||
NewSetting settings = mock(NewSetting.class);
|
Settings settings = mock(Settings.class);
|
||||||
given(settings.getProperty(HooksSettings.BCRYPT_LOG2_ROUND)).willReturn(8);
|
given(settings.getProperty(HooksSettings.BCRYPT_LOG2_ROUND)).willReturn(8);
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package fr.xephi.authme.security.crypts;
|
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 fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
|
|
||||||
import static org.mockito.BDDMockito.given;
|
import static org.mockito.BDDMockito.given;
|
||||||
@ -19,8 +19,8 @@ public class SALTED2MD5Test extends AbstractEncryptionMethodTest {
|
|||||||
new HashedPassword("ad25606eae5b760c8a2469d65578ac39", "04eee598")); // âË_3(íù*)
|
new HashedPassword("ad25606eae5b760c8a2469d65578ac39", "04eee598")); // âË_3(íù*)
|
||||||
}
|
}
|
||||||
|
|
||||||
private static NewSetting mockSettings() {
|
private static Settings mockSettings() {
|
||||||
NewSetting settings = mock(NewSetting.class);
|
Settings settings = mock(Settings.class);
|
||||||
given(settings.getProperty(SecuritySettings.DOUBLE_MD5_SALT_LENGTH)).willReturn(8);
|
given(settings.getProperty(SecuritySettings.DOUBLE_MD5_SALT_LENGTH)).willReturn(8);
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import static org.junit.Assert.assertThat;
|
|||||||
import static org.junit.Assert.fail;
|
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.
|
* verifying that no settings are missing from the file.
|
||||||
*/
|
*/
|
||||||
public class ConfigFileConsistencyTest {
|
public class ConfigFileConsistencyTest {
|
||||||
|
@ -27,9 +27,9 @@ import static org.hamcrest.Matchers.equalTo;
|
|||||||
import static org.junit.Assert.assertThat;
|
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. */
|
/** 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";
|
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();
|
File newFile = temporaryFolder.newFile();
|
||||||
|
|
||||||
// when / then
|
// when / then
|
||||||
NewSetting settings = new NewSetting(configuration, newFile, testPluginFolder, propertyMap,
|
Settings settings = new Settings(configuration, newFile, testPluginFolder, propertyMap,
|
||||||
checkAllPropertiesPresent());
|
checkAllPropertiesPresent());
|
||||||
Map<Property<?>, Object> expectedValues = ImmutableMap.<Property<?>, Object>builder()
|
Map<Property<?>, Object> expectedValues = ImmutableMap.<Property<?>, Object>builder()
|
||||||
.put(TestConfiguration.DURATION_IN_SECONDS, 22)
|
.put(TestConfiguration.DURATION_IN_SECONDS, 22)
|
||||||
@ -90,13 +90,13 @@ public class NewSettingIntegrationTest {
|
|||||||
File file = copyFileFromResources(INCOMPLETE_FILE);
|
File file = copyFileFromResources(INCOMPLETE_FILE);
|
||||||
YamlConfiguration configuration = YamlConfiguration.loadConfiguration(file);
|
YamlConfiguration configuration = YamlConfiguration.loadConfiguration(file);
|
||||||
// Expectation: File is rewritten to since it does not have all configurations
|
// 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
|
// Load the settings again -> checks that what we wrote can be loaded again
|
||||||
configuration = YamlConfiguration.loadConfiguration(file);
|
configuration = YamlConfiguration.loadConfiguration(file);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
NewSetting settings = new NewSetting(configuration, file, testPluginFolder, propertyMap,
|
Settings settings = new Settings(configuration, file, testPluginFolder, propertyMap,
|
||||||
checkAllPropertiesPresent());
|
checkAllPropertiesPresent());
|
||||||
Map<Property<?>, Object> expectedValues = ImmutableMap.<Property<?>, Object>builder()
|
Map<Property<?>, Object> expectedValues = ImmutableMap.<Property<?>, Object>builder()
|
||||||
.put(TestConfiguration.DURATION_IN_SECONDS, 22)
|
.put(TestConfiguration.DURATION_IN_SECONDS, 22)
|
||||||
@ -133,14 +133,14 @@ public class NewSettingIntegrationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// when
|
// when
|
||||||
new NewSetting(configuration, file, testPluginFolder, propertyMap, checkAllPropertiesPresent());
|
new Settings(configuration, file, testPluginFolder, propertyMap, checkAllPropertiesPresent());
|
||||||
// reload the file as settings should have been rewritten
|
// reload the file as settings should have been rewritten
|
||||||
configuration = YamlConfiguration.loadConfiguration(file);
|
configuration = YamlConfiguration.loadConfiguration(file);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
// assert that we won't rewrite the settings again! One rewrite should produce a valid, complete configuration
|
// 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");
|
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());
|
checkAllPropertiesPresent());
|
||||||
assertThat(unusedFile.exists(), equalTo(false));
|
assertThat(unusedFile.exists(), equalTo(false));
|
||||||
assertThat(configuration.contains(TestConfiguration.DUST_LEVEL.getPath()), equalTo(true));
|
assertThat(configuration.contains(TestConfiguration.DUST_LEVEL.getPath()), equalTo(true));
|
||||||
@ -171,7 +171,7 @@ public class NewSettingIntegrationTest {
|
|||||||
// given
|
// given
|
||||||
YamlConfiguration configuration = YamlConfiguration.loadConfiguration(temporaryFolder.newFile());
|
YamlConfiguration configuration = YamlConfiguration.loadConfiguration(temporaryFolder.newFile());
|
||||||
File fullConfigFile = copyFileFromResources(COMPLETE_FILE);
|
File fullConfigFile = copyFileFromResources(COMPLETE_FILE);
|
||||||
NewSetting settings = new NewSetting(configuration, fullConfigFile, testPluginFolder, propertyMap,
|
Settings settings = new Settings(configuration, fullConfigFile, testPluginFolder, propertyMap,
|
||||||
TestSettingsMigrationServices.alwaysFulfilled());
|
TestSettingsMigrationServices.alwaysFulfilled());
|
||||||
|
|
||||||
// when
|
// when
|
@ -38,9 +38,9 @@ import static org.mockito.Mockito.verify;
|
|||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unit tests for {@link NewSetting}.
|
* Unit tests for {@link Settings}.
|
||||||
*/
|
*/
|
||||||
public class NewSettingTest {
|
public class SettingsTest {
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||||
@ -71,7 +71,7 @@ public class NewSettingTest {
|
|||||||
setReturnValue(configuration, TestConfiguration.SYSTEM_NAME, "myTestSys");
|
setReturnValue(configuration, TestConfiguration.SYSTEM_NAME, "myTestSys");
|
||||||
|
|
||||||
// when / then
|
// 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.VERSION_NUMBER), equalTo(20));
|
||||||
assertThat(settings.getProperty(TestConfiguration.SKIP_BORING_FEATURES), equalTo(true));
|
assertThat(settings.getProperty(TestConfiguration.SKIP_BORING_FEATURES), equalTo(true));
|
||||||
@ -87,7 +87,7 @@ public class NewSettingTest {
|
|||||||
public void shouldReturnDefaultFile() throws IOException {
|
public void shouldReturnDefaultFile() throws IOException {
|
||||||
// given
|
// given
|
||||||
YamlConfiguration configuration = mock(YamlConfiguration.class);
|
YamlConfiguration configuration = mock(YamlConfiguration.class);
|
||||||
NewSetting settings = new NewSetting(configuration, null, null, null, null);
|
Settings settings = new Settings(configuration, null, null, null, null);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
String defaultFile = settings.getDefaultMessagesFile();
|
String defaultFile = settings.getDefaultMessagesFile();
|
||||||
@ -103,7 +103,7 @@ public class NewSettingTest {
|
|||||||
public void shouldSetProperty() {
|
public void shouldSetProperty() {
|
||||||
// given
|
// given
|
||||||
YamlConfiguration configuration = mock(YamlConfiguration.class);
|
YamlConfiguration configuration = mock(YamlConfiguration.class);
|
||||||
NewSetting settings = new NewSetting(configuration, null, null, null, null);
|
Settings settings = new Settings(configuration, null, null, null, null);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
settings.setProperty(TestConfiguration.DUST_LEVEL, -4);
|
settings.setProperty(TestConfiguration.DUST_LEVEL, -4);
|
||||||
@ -123,7 +123,7 @@ public class NewSettingTest {
|
|||||||
YamlConfiguration configuration = mock(YamlConfiguration.class);
|
YamlConfiguration configuration = mock(YamlConfiguration.class);
|
||||||
given(configuration.contains(anyString())).willReturn(true);
|
given(configuration.contains(anyString())).willReturn(true);
|
||||||
setReturnValue(configuration, MESSAGES_LANGUAGE, languageCode);
|
setReturnValue(configuration, MESSAGES_LANGUAGE, languageCode);
|
||||||
NewSetting settings = new NewSetting(configuration, null, testPluginFolder,
|
Settings settings = new Settings(configuration, null, testPluginFolder,
|
||||||
TestConfiguration.generatePropertyMap(), TestSettingsMigrationServices.alwaysFulfilled());
|
TestConfiguration.generatePropertyMap(), TestSettingsMigrationServices.alwaysFulfilled());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
@ -140,7 +140,7 @@ public class NewSettingTest {
|
|||||||
YamlConfiguration configuration = mock(YamlConfiguration.class);
|
YamlConfiguration configuration = mock(YamlConfiguration.class);
|
||||||
given(configuration.contains(anyString())).willReturn(true);
|
given(configuration.contains(anyString())).willReturn(true);
|
||||||
setReturnValue(configuration, MESSAGES_LANGUAGE, "doesntexist");
|
setReturnValue(configuration, MESSAGES_LANGUAGE, "doesntexist");
|
||||||
NewSetting settings = new NewSetting(configuration, null, testPluginFolder,
|
Settings settings = new Settings(configuration, null, testPluginFolder,
|
||||||
TestConfiguration.generatePropertyMap(), TestSettingsMigrationServices.alwaysFulfilled());
|
TestConfiguration.generatePropertyMap(), TestSettingsMigrationServices.alwaysFulfilled());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
@ -161,7 +161,7 @@ public class NewSettingTest {
|
|||||||
|
|
||||||
YamlConfiguration configuration = mock(YamlConfiguration.class);
|
YamlConfiguration configuration = mock(YamlConfiguration.class);
|
||||||
setReturnValue(configuration, RegistrationSettings.USE_WELCOME_MESSAGE, true);
|
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());
|
TestConfiguration.generatePropertyMap(), TestSettingsMigrationServices.alwaysFulfilled());
|
||||||
|
|
||||||
// when
|
// when
|
||||||
@ -182,7 +182,7 @@ public class NewSettingTest {
|
|||||||
Files.write(emailFile.toPath(), emailMessage.getBytes());
|
Files.write(emailFile.toPath(), emailMessage.getBytes());
|
||||||
|
|
||||||
YamlConfiguration configuration = mock(YamlConfiguration.class);
|
YamlConfiguration configuration = mock(YamlConfiguration.class);
|
||||||
NewSetting settings = new NewSetting(configuration, null, testPluginFolder,
|
Settings settings = new Settings(configuration, null, testPluginFolder,
|
||||||
TestConfiguration.generatePropertyMap(), TestSettingsMigrationServices.alwaysFulfilled());
|
TestConfiguration.generatePropertyMap(), TestSettingsMigrationServices.alwaysFulfilled());
|
||||||
|
|
||||||
// when
|
// 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",
|
assertThat(property.getPath() + " has default value",
|
||||||
setting.getProperty(property).equals(property.getDefaultValue()), equalTo(true));
|
setting.getProperty(property).equals(property.getDefaultValue()), equalTo(true));
|
||||||
}
|
}
|
@ -36,7 +36,7 @@ public class SpawnLoaderTest {
|
|||||||
private SpawnLoader spawnLoader;
|
private SpawnLoader spawnLoader;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
|
@ -6,7 +6,7 @@ import fr.xephi.authme.cache.limbo.LimboCache;
|
|||||||
import fr.xephi.authme.cache.limbo.PlayerData;
|
import fr.xephi.authme.cache.limbo.PlayerData;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
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.RegistrationSettings;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.util.BukkitService;
|
||||||
@ -40,7 +40,7 @@ public class PlayerDataTaskManagerTest {
|
|||||||
private Messages messages;
|
private Messages messages;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private BukkitService bukkitService;
|
private BukkitService bukkitService;
|
||||||
|
@ -4,7 +4,7 @@ import fr.xephi.authme.ReflectionTestUtils;
|
|||||||
import fr.xephi.authme.TestHelper;
|
import fr.xephi.authme.TestHelper;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
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.settings.properties.PurgeSettings;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.util.BukkitService;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
@ -57,7 +57,7 @@ public class PurgeServiceTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
@Mock
|
@Mock
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
@Mock
|
@Mock
|
||||||
private PermissionsManager permissionsManager;
|
private PermissionsManager permissionsManager;
|
||||||
@Mock
|
@Mock
|
||||||
|
@ -6,7 +6,7 @@ import fr.xephi.authme.datasource.DataSource;
|
|||||||
import fr.xephi.authme.security.HashAlgorithm;
|
import fr.xephi.authme.security.HashAlgorithm;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||||
import fr.xephi.authme.security.crypts.SHA256;
|
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 fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -36,7 +36,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
|
|||||||
public class MigrationServiceTest {
|
public class MigrationServiceTest {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
|
@ -5,7 +5,7 @@ import fr.xephi.authme.cache.auth.PlayerCache;
|
|||||||
import fr.xephi.authme.cache.limbo.PlayerData;
|
import fr.xephi.authme.cache.limbo.PlayerData;
|
||||||
import fr.xephi.authme.events.FirstSpawnTeleportEvent;
|
import fr.xephi.authme.events.FirstSpawnTeleportEvent;
|
||||||
import fr.xephi.authme.events.SpawnTeleportEvent;
|
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.SpawnLoader;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -46,7 +46,7 @@ public class TeleportationServiceTest {
|
|||||||
private TeleportationService teleportationService;
|
private TeleportationService teleportationService;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private BukkitService bukkitService;
|
private BukkitService bukkitService;
|
||||||
|
@ -8,7 +8,7 @@ import fr.xephi.authme.datasource.DataSource;
|
|||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.permission.PlayerStatePermission;
|
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.EmailSettings;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
@ -35,7 +35,7 @@ public class ValidationServiceTest {
|
|||||||
@InjectDelayed
|
@InjectDelayed
|
||||||
private ValidationService validationService;
|
private ValidationService validationService;
|
||||||
@Mock
|
@Mock
|
||||||
private NewSetting settings;
|
private Settings settings;
|
||||||
@Mock
|
@Mock
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
@Mock
|
@Mock
|
||||||
|
@ -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.AsciiRestricted;
|
||||||
import fr.xephi.authme.security.crypts.description.HasSalt;
|
import fr.xephi.authme.security.crypts.description.HasSalt;
|
||||||
import fr.xephi.authme.security.crypts.description.Recommendation;
|
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 fr.xephi.authme.settings.domain.Property;
|
||||||
import org.mockito.invocation.InvocationOnMock;
|
import org.mockito.invocation.InvocationOnMock;
|
||||||
import org.mockito.stubbing.Answer;
|
import org.mockito.stubbing.Answer;
|
||||||
@ -140,7 +140,7 @@ public class EncryptionMethodInfoGatherer {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static Injector createInitializer() {
|
private static Injector createInitializer() {
|
||||||
NewSetting settings = mock(NewSetting.class);
|
Settings settings = mock(Settings.class);
|
||||||
// Return the default value for any property
|
// Return the default value for any property
|
||||||
when(settings.getProperty(any(Property.class))).thenAnswer(new Answer<Object>() {
|
when(settings.getProperty(any(Property.class))).thenAnswer(new Answer<Object>() {
|
||||||
@Override
|
@Override
|
||||||
@ -153,7 +153,7 @@ public class EncryptionMethodInfoGatherer {
|
|||||||
// By passing some bogus "package" to the constructor, the injector will throw if it needs to
|
// By passing some bogus "package" to the constructor, the injector will throw if it needs to
|
||||||
// instantiate any dependency other than what we provide.
|
// instantiate any dependency other than what we provide.
|
||||||
Injector injector = new InjectorBuilder().addDefaultHandlers("!!No package!!").create();
|
Injector injector = new InjectorBuilder().addDefaultHandlers("!!No package!!").create();
|
||||||
injector.register(NewSetting.class, settings);
|
injector.register(Settings.class, settings);
|
||||||
return injector;
|
return injector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user