#605 Logger - name methods after their log level

- Remove separate print stacktrace method
- Log level into the log similar to console output
This commit is contained in:
ljacqu 2016-07-12 22:05:36 +02:00
parent dccbd5262f
commit e7b980d435
32 changed files with 79 additions and 89 deletions

View File

@ -272,7 +272,7 @@ public class AuthMe extends JavaPlugin {
// If server is using PermissionsBukkit, print a warning that some features may not be supported // If server is using PermissionsBukkit, print a warning that some features may not be supported
if (PermissionsSystemType.PERMISSIONS_BUKKIT.equals(permsMan.getPermissionSystem())) { if (PermissionsSystemType.PERMISSIONS_BUKKIT.equals(permsMan.getPermissionSystem())) {
ConsoleLogger.showError("Warning! This server uses PermissionsBukkit for permissions. Some permissions features may not be supported!"); ConsoleLogger.warning("Warning! This server uses PermissionsBukkit for permissions. Some permissions features may not be supported!");
} }
// Purge on start if enabled // Purge on start if enabled
@ -303,13 +303,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 (!newSettings.getProperty(RestrictionSettings.FORCE_SINGLE_SESSION)) {
ConsoleLogger.showError("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 (newSettings.getProperty(PluginSettings.SESSIONS_TIMEOUT) == 0
&& newSettings.getProperty(PluginSettings.SESSIONS_ENABLED)) { && newSettings.getProperty(PluginSettings.SESSIONS_ENABLED)) {
ConsoleLogger.showError("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!");
} }
} }
@ -493,7 +493,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 (Settings.isStopEnabled) { if (Settings.isStopEnabled) {
ConsoleLogger.showError("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 {
getServer().getPluginManager().disablePlugin(this); getServer().getPluginManager().disablePlugin(this);
@ -544,7 +544,7 @@ public class AuthMe extends JavaPlugin {
public void run() { public void run() {
int accounts = database.getAccountsRegistered(); int accounts = database.getAccountsRegistered();
if (accounts >= 4000) { if (accounts >= 4000) {
ConsoleLogger.showError("YOU'RE USING THE SQLITE DATABASE WITH " ConsoleLogger.warning("YOU'RE USING THE SQLITE DATABASE WITH "
+ accounts + "+ ACCOUNTS; FOR BETTER PERFORMANCE, PLEASE UPGRADE TO MYSQL!!"); + accounts + "+ ACCOUNTS; FOR BETTER PERFORMANCE, PLEASE UPGRADE TO MYSQL!!");
} }
} }

View File

@ -59,7 +59,7 @@ public final class ConsoleLogger {
public static void info(String message) { public static void info(String message) {
logger.info(message); logger.info(message);
if (useLogging) { if (useLogging) {
writeLog(message); writeLog("[INFO] " + message);
} }
} }
@ -69,10 +69,10 @@ public final class ConsoleLogger {
* *
* @param message String * @param message String
*/ */
public static void showError(String message) { public static void warning(String message) {
logger.warning(message); logger.warning(message);
if (useLogging) { if (useLogging) {
writeLog("ERROR: " + message); writeLog("[WARN] " + message);
} }
} }
@ -96,17 +96,6 @@ public final class ConsoleLogger {
} }
} }
/**
* Write a StackTrace into the log.
*
* @param th The Throwable whose stack trace should be logged
*/
public static void writeStackTrace(Throwable th) {
if (useLogging) {
writeLog(Throwables.getStackTraceAsString(th));
}
}
/** /**
* Logs a Throwable with the provided message and saves the stack trace to the log file. * Logs a Throwable with the provided message and saves the stack trace to the log file.
* *
@ -114,8 +103,10 @@ public final class ConsoleLogger {
* @param th The Throwable to log * @param th The Throwable to log
*/ */
public static void logException(String message, Throwable th) { public static void logException(String message, Throwable th) {
showError(message + " " + StringUtils.formatException(th)); warning(message + " " + StringUtils.formatException(th));
writeStackTrace(th); if (useLogging) {
writeLog(Throwables.getStackTraceAsString(th));
}
} }
public static void close() { public static void close() {

View File

@ -60,7 +60,7 @@ public class PerformBackup {
if (!settings.getProperty(BackupSettings.ENABLED)) { if (!settings.getProperty(BackupSettings.ENABLED)) {
// Print a warning if the backup was requested via command or by another plugin // Print a warning if the backup was requested via command or by another plugin
if (cause == BackupCause.COMMAND || cause == BackupCause.OTHER) { if (cause == BackupCause.COMMAND || cause == BackupCause.OTHER) {
ConsoleLogger.showError("Can't perform a Backup: disabled in configuration. Cause of the Backup: " ConsoleLogger.warning("Can't perform a Backup: disabled in configuration. Cause of the Backup: "
+ cause.name()); + cause.name());
} }
return; return;
@ -76,7 +76,7 @@ public class PerformBackup {
if (doBackup()) { if (doBackup()) {
ConsoleLogger.info("A backup has been performed successfully. Cause of the Backup: " + cause.name()); ConsoleLogger.info("A backup has been performed successfully. Cause of the Backup: " + cause.name());
} else { } else {
ConsoleLogger.showError("Error while performing a backup! Cause of the Backup: " + cause.name()); ConsoleLogger.warning("Error while performing a backup! Cause of the Backup: " + cause.name());
} }
} }
@ -90,7 +90,7 @@ public class PerformBackup {
case SQLITE: case SQLITE:
return fileBackup(dbName + ".db"); return fileBackup(dbName + ".db");
default: default:
ConsoleLogger.showError("Unknown data source type '" + dataSourceType + "' for backup"); ConsoleLogger.warning("Unknown data source type '" + dataSourceType + "' for backup");
} }
return false; return false;
@ -113,7 +113,7 @@ public class PerformBackup {
ConsoleLogger.info("Backup created successfully."); ConsoleLogger.info("Backup created successfully.");
return true; return true;
} else { } else {
ConsoleLogger.showError("Could not create the backup! (Windows)"); ConsoleLogger.warning("Could not create the backup! (Windows)");
} }
} catch (IOException | InterruptedException e) { } catch (IOException | InterruptedException e) {
ConsoleLogger.logException("Error during Windows backup:", e); ConsoleLogger.logException("Error during Windows backup:", e);
@ -128,7 +128,7 @@ public class PerformBackup {
ConsoleLogger.info("Backup created successfully."); ConsoleLogger.info("Backup created successfully.");
return true; return true;
} else { } else {
ConsoleLogger.showError("Could not create the backup!"); ConsoleLogger.warning("Could not create the backup!");
} }
} catch (IOException | InterruptedException e) { } catch (IOException | InterruptedException e) {
ConsoleLogger.logException("Error during backup:", e); ConsoleLogger.logException("Error during backup:", e);
@ -147,8 +147,7 @@ public class PerformBackup {
copy("plugins" + File.separator + "AuthMe" + File.separator + backend, path + ".db"); copy("plugins" + File.separator + "AuthMe" + File.separator + backend, path + ".db");
return true; return true;
} catch (IOException ex) { } catch (IOException ex) {
ConsoleLogger.showError("Encountered an error during file backup: " + StringUtils.formatException(ex)); ConsoleLogger.logException("Encountered an error during file backup:", ex);
ConsoleLogger.writeStackTrace(ex);
} }
return false; return false;
} }
@ -166,7 +165,7 @@ public class PerformBackup {
if (new File(windowsPath + "\\bin\\mysqldump.exe").exists()) { if (new File(windowsPath + "\\bin\\mysqldump.exe").exists()) {
return true; return true;
} else { } else {
ConsoleLogger.showError("Mysql Windows Path is incorrect. Please check it"); ConsoleLogger.warning("Mysql Windows Path is incorrect. Please check it");
return false; return false;
} }
} }

View File

@ -47,7 +47,7 @@ public class PlayerDataStorage {
cacheDir = new File(dataFolder, "playerdata"); cacheDir = new File(dataFolder, "playerdata");
if (!cacheDir.exists() && !cacheDir.isDirectory() && !cacheDir.mkdir()) { if (!cacheDir.exists() && !cacheDir.isDirectory() && !cacheDir.mkdir()) {
ConsoleLogger.showError("Failed to create userdata directory."); ConsoleLogger.warning("Failed to create userdata directory.");
} }
gson = new GsonBuilder() gson = new GsonBuilder()
.registerTypeAdapter(PlayerData.class, new PlayerDataSerializer()) .registerTypeAdapter(PlayerData.class, new PlayerDataSerializer())
@ -115,7 +115,7 @@ public class PlayerDataStorage {
if (file.exists()) { if (file.exists()) {
FileUtils.purgeDirectory(file); FileUtils.purgeDirectory(file);
if (!file.delete()) { if (!file.delete()) {
ConsoleLogger.showError("Failed to remove " + player.getName() + " cache."); ConsoleLogger.warning("Failed to remove " + player.getName() + " cache.");
} }
} }
} }

View File

@ -41,7 +41,7 @@ public class RecoverEmailCommand extends PlayerCommand {
final String playerName = player.getName(); final String playerName = player.getName();
if (!sendMailSsl.hasAllInformation()) { if (!sendMailSsl.hasAllInformation()) {
ConsoleLogger.showError("Mail API is not set"); ConsoleLogger.warning("Mail API is not set");
commandService.send(player, MessageKey.INCOMPLETE_EMAIL_SETTINGS); commandService.send(player, MessageKey.INCOMPLETE_EMAIL_SETTINGS);
return; return;
} }
@ -63,7 +63,7 @@ public class RecoverEmailCommand extends PlayerCommand {
return; return;
} }
if (StringUtils.isEmpty(commandService.getProperty(EmailSettings.MAIL_ACCOUNT))) { if (StringUtils.isEmpty(commandService.getProperty(EmailSettings.MAIL_ACCOUNT))) {
ConsoleLogger.showError("No mail account set in settings"); ConsoleLogger.warning("No mail account set in settings");
commandService.send(player, MessageKey.ERROR); commandService.send(player, MessageKey.ERROR);
return; return;
} }

View File

@ -69,7 +69,7 @@ public class RegisterCommand extends PlayerCommand {
private void handleEmailRegistration(Player player, List<String> arguments) { private void handleEmailRegistration(Player player, List<String> arguments) {
if (!sendMailSsl.hasAllInformation()) { if (!sendMailSsl.hasAllInformation()) {
commandService.send(player, MessageKey.INCOMPLETE_EMAIL_SETTINGS); commandService.send(player, MessageKey.INCOMPLETE_EMAIL_SETTINGS);
ConsoleLogger.showError("Cannot register player '" + player.getName() + "': no email or password is set " ConsoleLogger.warning("Cannot register player '" + player.getName() + "': no email or password is set "
+ "to send emails from. Please adjust your config at " + EmailSettings.MAIL_ACCOUNT.getPath()); + "to send emails from. Please adjust your config at " + EmailSettings.MAIL_ACCOUNT.getPath());
return; return;
} }

View File

@ -61,7 +61,7 @@ public class CrazyLoginConverter implements Converter {
} }
ConsoleLogger.info("CrazyLogin database has been imported correctly"); ConsoleLogger.info("CrazyLogin database has been imported correctly");
} catch (IOException ex) { } catch (IOException ex) {
ConsoleLogger.showError("Can't open the crazylogin database file! Does it exist?"); ConsoleLogger.warning("Can't open the crazylogin database file! Does it exist?");
ConsoleLogger.logException("Encountered", ex); ConsoleLogger.logException("Encountered", ex);
} }
} }

View File

@ -43,7 +43,7 @@ public class ForceFlatToSqlite {
} }
if (!skippedPlayers.isEmpty()) { if (!skippedPlayers.isEmpty()) {
ConsoleLogger.showError("Warning: skipped conversion for players which were already in SQLite: " ConsoleLogger.warning("Warning: skipped conversion for players which were already in SQLite: "
+ StringUtils.join(", ", skippedPlayers)); + StringUtils.join(", ", skippedPlayers));
} }
ConsoleLogger.info("Database successfully converted from " + source.getClass().getSimpleName() ConsoleLogger.info("Database successfully converted from " + source.getClass().getSimpleName()

View File

@ -89,7 +89,7 @@ public class RakamakConverter implements Converter {
ConsoleLogger.info("Rakamak database has been imported correctly"); ConsoleLogger.info("Rakamak database has been imported correctly");
sender.sendMessage("Rakamak database has been imported correctly"); sender.sendMessage("Rakamak database has been imported correctly");
} catch (IOException ex) { } catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.warning(ex.getMessage());
sender.sendMessage("Can't open the rakamak database file! Does it exist?"); sender.sendMessage("Can't open the rakamak database file! Does it exist?");
} }
} }

View File

@ -160,7 +160,7 @@ public class CacheDataSource implements DataSource {
try { try {
executorService.awaitTermination(5, TimeUnit.SECONDS); executorService.awaitTermination(5, TimeUnit.SECONDS);
} catch (InterruptedException e) { } catch (InterruptedException e) {
ConsoleLogger.writeStackTrace(e); ConsoleLogger.logException("Could not close executor service:", e);
} }
} }

View File

@ -50,7 +50,7 @@ public class FlatFile implements DataSource {
} catch (IOException e) { } catch (IOException e) {
ConsoleLogger.logException("Cannot open flatfile", e); ConsoleLogger.logException("Cannot open flatfile", e);
if (Settings.isStopEnabled) { if (Settings.isStopEnabled) {
ConsoleLogger.showError("Can't use FLAT FILE... SHUTDOWN..."); ConsoleLogger.warning("Can't use FLAT FILE... SHUTDOWN...");
instance.getServer().shutdown(); instance.getServer().shutdown();
} }
if (!Settings.isStopEnabled) { if (!Settings.isStopEnabled) {
@ -82,7 +82,7 @@ public class FlatFile implements DataSource {
} }
} }
} catch (IOException ex) { } catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.warning(ex.getMessage());
return false; return false;
} finally { } finally {
silentClose(br); silentClose(br);
@ -109,7 +109,7 @@ public class FlatFile implements DataSource {
bw = new BufferedWriter(new FileWriter(source, true)); bw = new BufferedWriter(new FileWriter(source, true));
bw.write(auth.getNickname() + ":" + auth.getPassword().getHash() + ":" + auth.getIp() + ":" + auth.getLastLogin() + ":" + auth.getQuitLocX() + ":" + auth.getQuitLocY() + ":" + auth.getQuitLocZ() + ":" + auth.getWorld() + ":" + auth.getEmail() + "\n"); bw.write(auth.getNickname() + ":" + auth.getPassword().getHash() + ":" + auth.getIp() + ":" + auth.getLastLogin() + ":" + auth.getQuitLocX() + ":" + auth.getQuitLocY() + ":" + auth.getQuitLocZ() + ":" + auth.getWorld() + ":" + auth.getEmail() + "\n");
} catch (IOException ex) { } catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.warning(ex.getMessage());
return false; return false;
} finally { } finally {
silentClose(bw); silentClose(bw);
@ -145,7 +145,7 @@ public class FlatFile implements DataSource {
} }
} }
} catch (IOException ex) { } catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.warning(ex.getMessage());
return false; return false;
} finally { } finally {
silentClose(br); silentClose(br);
@ -179,7 +179,7 @@ public class FlatFile implements DataSource {
} }
} }
} catch (IOException ex) { } catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.warning(ex.getMessage());
return false; return false;
} finally { } finally {
silentClose(br); silentClose(br);
@ -216,7 +216,7 @@ public class FlatFile implements DataSource {
} }
} }
} catch (IOException ex) { } catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.warning(ex.getMessage());
return false; return false;
} finally { } finally {
silentClose(br); silentClose(br);
@ -246,7 +246,7 @@ public class FlatFile implements DataSource {
} }
} }
} catch (IOException ex) { } catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.warning(ex.getMessage());
return list; return list;
} finally { } finally {
silentClose(br); silentClose(br);
@ -279,7 +279,7 @@ public class FlatFile implements DataSource {
bw.write(l + "\n"); bw.write(l + "\n");
} }
} catch (IOException ex) { } catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.warning(ex.getMessage());
return; return;
} finally { } finally {
silentClose(br); silentClose(br);
@ -309,7 +309,7 @@ public class FlatFile implements DataSource {
bw.write(l + "\n"); bw.write(l + "\n");
} }
} catch (IOException ex) { } catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.warning(ex.getMessage());
return false; return false;
} finally { } finally {
silentClose(br); silentClose(br);
@ -331,7 +331,7 @@ public class FlatFile implements DataSource {
} }
} }
} catch (IOException ex) { } catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.warning(ex.getMessage());
return null; return null;
} finally { } finally {
silentClose(br); silentClose(br);
@ -364,10 +364,10 @@ public class FlatFile implements DataSource {
} }
} }
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.warning(ex.getMessage());
return false; return false;
} catch (IOException ex) { } catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.warning(ex.getMessage());
return false; return false;
} finally { } finally {
if (br != null) { if (br != null) {
@ -399,10 +399,10 @@ public class FlatFile implements DataSource {
} }
return countIp; return countIp;
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.warning(ex.getMessage());
return new ArrayList<>(); return new ArrayList<>();
} catch (IOException ex) { } catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.warning(ex.getMessage());
return new ArrayList<>(); return new ArrayList<>();
} finally { } finally {
if (br != null) { if (br != null) {
@ -429,7 +429,7 @@ public class FlatFile implements DataSource {
} }
return countEmail; return countEmail;
} catch (IOException ex) { } catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.warning(ex.getMessage());
} finally { } finally {
if (br != null) { if (br != null) {
try { try {
@ -473,7 +473,7 @@ public class FlatFile implements DataSource {
result++; result++;
} }
} catch (Exception ex) { } catch (Exception ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.warning(ex.getMessage());
return result; return result;
} finally { } finally {
silentClose(br); silentClose(br);

View File

@ -52,14 +52,14 @@ public class MySQL implements DataSource {
this.setConnectionArguments(); this.setConnectionArguments();
} catch (RuntimeException e) { } catch (RuntimeException e) {
if (e instanceof IllegalArgumentException) { if (e instanceof IllegalArgumentException) {
ConsoleLogger.showError("Invalid database arguments! Please check your configuration!"); ConsoleLogger.warning("Invalid database arguments! Please check your configuration!");
ConsoleLogger.showError("If this error persists, please report it to the developer!"); ConsoleLogger.warning("If this error persists, please report it to the developer!");
} }
if (e instanceof PoolInitializationException) { if (e instanceof PoolInitializationException) {
ConsoleLogger.showError("Can't initialize database connection! Please check your configuration!"); ConsoleLogger.warning("Can't initialize database connection! Please check your configuration!");
ConsoleLogger.showError("If this error persists, please report it to the developer!"); ConsoleLogger.warning("If this error persists, please report it to the developer!");
} }
ConsoleLogger.showError("Can't use the Hikari Connection Pool! Please, report this error to the developer!"); ConsoleLogger.warning("Can't use the Hikari Connection Pool! Please, report this error to the developer!");
throw e; throw e;
} }
@ -69,7 +69,7 @@ public class MySQL implements DataSource {
} catch (SQLException e) { } catch (SQLException e) {
close(); close();
ConsoleLogger.logException("Can't initialize the MySQL database:", e); ConsoleLogger.logException("Can't initialize the MySQL database:", e);
ConsoleLogger.showError("Please check your database settings in the config.yml file!"); ConsoleLogger.warning("Please check your database settings in the config.yml file!");
throw e; throw e;
} }
} }
@ -879,7 +879,7 @@ public class MySQL implements DataSource {
final int columnType; final int columnType;
try (ResultSet rs = metaData.getColumns(null, null, tableName, col.LAST_LOGIN)) { try (ResultSet rs = metaData.getColumns(null, null, tableName, col.LAST_LOGIN)) {
if (!rs.next()) { if (!rs.next()) {
ConsoleLogger.showError("Could not get LAST_LOGIN meta data. This should never happen!"); ConsoleLogger.warning("Could not get LAST_LOGIN meta data. This should never happen!");
return; return;
} }
columnType = rs.getInt("DATA_TYPE"); columnType = rs.getInt("DATA_TYPE");

View File

@ -157,7 +157,7 @@ public class SQLite implements DataSource {
rs = pst.executeQuery(); rs = pst.executeQuery();
return rs.next(); return rs.next();
} catch (SQLException ex) { } catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.warning(ex.getMessage());
return false; return false;
} finally { } finally {
close(rs); close(rs);
@ -212,7 +212,7 @@ public class SQLite implements DataSource {
HashedPassword password = auth.getPassword(); HashedPassword password = auth.getPassword();
if (col.SALT.isEmpty()) { if (col.SALT.isEmpty()) {
if (!StringUtils.isEmpty(auth.getPassword().getSalt())) { if (!StringUtils.isEmpty(auth.getPassword().getSalt())) {
ConsoleLogger.showError("Warning! Detected hashed password with separate salt but the salt column " ConsoleLogger.warning("Warning! Detected hashed password with separate salt but the salt column "
+ "is not set in the config!"); + "is not set in the config!");
} }
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + col.NAME + "," + col.PASSWORD + pst = con.prepareStatement("INSERT INTO " + tableName + "(" + col.NAME + "," + col.PASSWORD +

View File

@ -53,7 +53,7 @@ public class AuthMeServerListener implements Listener {
if (pluginName.equalsIgnoreCase("ProtocolLib")) { if (pluginName.equalsIgnoreCase("ProtocolLib")) {
protocolLibService.disable(); protocolLibService.disable();
ConsoleLogger.showError("ProtocolLib has been disabled, unhooking packet adapters!"); ConsoleLogger.warning("ProtocolLib has been disabled, unhooking packet adapters!");
} }
} }

View File

@ -24,7 +24,7 @@ class AuthMeTabCompletePacketAdapter extends PacketAdapter {
event.setCancelled(true); event.setCancelled(true);
} }
} catch (FieldAccessException e) { } catch (FieldAccessException e) {
ConsoleLogger.showError("Couldn't access field."); ConsoleLogger.warning("Couldn't access field.");
} }
} }
} }

View File

@ -42,11 +42,11 @@ public class ProtocolLibService implements SettingsDependent {
// Check if ProtocolLib is enabled on the server. // Check if ProtocolLib is enabled on the server.
if (!plugin.getServer().getPluginManager().isPluginEnabled("ProtocolLib")) { if (!plugin.getServer().getPluginManager().isPluginEnabled("ProtocolLib")) {
if (protectInvBeforeLogin) { if (protectInvBeforeLogin) {
ConsoleLogger.showError("WARNING! The protectInventory feature requires ProtocolLib! Disabling it..."); ConsoleLogger.warning("WARNING! The protectInventory feature requires ProtocolLib! Disabling it...");
} }
if (denyTabCompleteBeforeLogin) { if (denyTabCompleteBeforeLogin) {
ConsoleLogger.showError("WARNING! The denyTabComplete feature requires ProtocolLib! Disabling it..."); ConsoleLogger.warning("WARNING! The denyTabComplete feature requires ProtocolLib! Disabling it...");
} }
this.isEnabled = false; this.isEnabled = false;

View File

@ -58,7 +58,7 @@ public class SendMailSSL {
*/ */
public void sendPasswordMail(final PlayerAuth auth, final String newPass) { public void sendPasswordMail(final PlayerAuth auth, final String newPass) {
if (!hasAllInformation()) { if (!hasAllInformation()) {
ConsoleLogger.showError("Cannot perform email registration: not all email settings are complete"); ConsoleLogger.warning("Cannot perform email registration: not all email settings are complete");
return; return;
} }

View File

@ -75,7 +75,7 @@ public class Messages implements SettingsDependent {
String message = configuration.getString(code); String message = configuration.getString(code);
if (message == null) { if (message == null) {
ConsoleLogger.showError("Error getting message with key '" + code + "'. " ConsoleLogger.warning("Error getting message with key '" + code + "'. "
+ "Please verify your config file at '" + fileName + "'"); + "Please verify your config file at '" + fileName + "'");
return formatMessage(getDefault(code)); return formatMessage(getDefault(code));
} }
@ -112,7 +112,7 @@ public class Messages implements SettingsDependent {
message = message.replace(tags[i], replacements[i]); message = message.replace(tags[i], replacements[i]);
} }
} else { } else {
ConsoleLogger.showError("Invalid number of replacements for message key '" + key + "'"); ConsoleLogger.warning("Invalid number of replacements for message key '" + key + "'");
} }
return message; return message;
} }

View File

@ -45,7 +45,7 @@ public class AuthGroupHandler {
// Make sure group support is available // Make sure group support is available
if (!permissionsManager.hasGroupSupport()) { if (!permissionsManager.hasGroupSupport()) {
ConsoleLogger.showError("The current permissions system doesn't have group support, unable to set group!"); ConsoleLogger.warning("The current permissions system doesn't have group support, unable to set group!");
return false; return false;
} }

View File

@ -47,7 +47,7 @@ public class AsyncAddEmail implements AsynchronousProcess {
playerCache.updatePlayer(auth); playerCache.updatePlayer(auth);
service.send(player, MessageKey.EMAIL_ADDED_SUCCESS); service.send(player, MessageKey.EMAIL_ADDED_SUCCESS);
} else { } else {
ConsoleLogger.showError("Could not save email for player '" + player + "'"); ConsoleLogger.warning("Could not save email for player '" + player + "'");
service.send(player, MessageKey.ERROR); service.send(player, MessageKey.ERROR);
} }
} }

View File

@ -204,7 +204,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
} }
} }
} else { } else {
ConsoleLogger.showError("Player " + name + " wasn't online during login process, aborted... "); ConsoleLogger.warning("Player " + name + " wasn't online during login process, aborted... ");
} }
} }

View File

@ -38,7 +38,7 @@ public class BCRYPT implements EncryptionMethod {
try { try {
return hash.getHash().length() > 3 && BCryptService.checkpw(password, hash.getHash()); return hash.getHash().length() > 3 && BCryptService.checkpw(password, hash.getHash());
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
ConsoleLogger.showError("Bcrypt checkpw() returned " + StringUtils.formatException(e)); ConsoleLogger.warning("Bcrypt checkpw() returned " + StringUtils.formatException(e));
} }
return false; return false;
} }

View File

@ -32,7 +32,7 @@ public class CryptPBKDF2Django extends HexSaltedMethod {
try { try {
iterations = Integer.parseInt(line[1]); iterations = Integer.parseInt(line[1]);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
ConsoleLogger.showError("Could not read number of rounds for CryptPBKDF2Django:" ConsoleLogger.warning("Could not read number of rounds for CryptPBKDF2Django:"
+ StringUtils.formatException(e)); + StringUtils.formatException(e));
return false; return false;
} }

View File

@ -36,7 +36,7 @@ public class IPB4 implements EncryptionMethod {
try { try {
return hash.getHash().length() > 3 && BCryptService.checkpw(password, hash.getHash()); return hash.getHash().length() > 3 && BCryptService.checkpw(password, hash.getHash());
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
ConsoleLogger.showError("Bcrypt checkpw() returned " + StringUtils.formatException(e)); ConsoleLogger.warning("Bcrypt checkpw() returned " + StringUtils.formatException(e));
} }
return false; return false;
} }

View File

@ -31,7 +31,7 @@ public class XFBCRYPT implements EncryptionMethod {
try { try {
return hash.getHash().length() > 3 && BCryptService.checkpw(password, hash.getHash()); return hash.getHash().length() > 3 && BCryptService.checkpw(password, hash.getHash());
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
ConsoleLogger.showError("XfBCrypt checkpw() returned " + StringUtils.formatException(e)); ConsoleLogger.warning("XfBCrypt checkpw() returned " + StringUtils.formatException(e));
} }
return false; return false;
} }

View File

@ -77,7 +77,7 @@ final class Node {
} }
if (commonNode == null) { if (commonNode == null) {
ConsoleLogger.showError("Could not find common node for '" + fullPath1 + "' at index " + commonCount); ConsoleLogger.warning("Could not find common node for '" + fullPath1 + "' at index " + commonCount);
return fullPath1.compareTo(fullPath2); // fallback return fullPath1.compareTo(fullPath2); // fallback
} else if (commonCount >= path1.length || commonCount >= path2.length) { } else if (commonCount >= path1.length || commonCount >= path2.length) {
return Integer.compare(path1.length, path2.length); return Integer.compare(path1.length, path2.length);

View File

@ -76,7 +76,7 @@ public class PurgeService implements Reloadable {
if (!settings.getProperty(PurgeSettings.USE_AUTO_PURGE)) { if (!settings.getProperty(PurgeSettings.USE_AUTO_PURGE)) {
return; return;
} else if (daysBeforePurge <= 0) { } else if (daysBeforePurge <= 0) {
ConsoleLogger.showError("Did not run auto purge: configured days before purging must be positive"); ConsoleLogger.warning("Did not run auto purge: configured days before purging must be positive");
return; return;
} }

View File

@ -190,7 +190,7 @@ public class BukkitService {
return Arrays.asList((Player[]) obj); return Arrays.asList((Player[]) obj);
} else { } else {
String type = (obj == null) ? "null" : obj.getClass().getName(); String type = (obj == null) ? "null" : obj.getClass().getName();
ConsoleLogger.showError("Unknown list of online players of type " + type); ConsoleLogger.warning("Unknown list of online players of type " + type);
} }
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
ConsoleLogger.logException("Could not retrieve list of online players:", e); ConsoleLogger.logException("Could not retrieve list of online players:", e);
@ -230,7 +230,7 @@ public class BukkitService {
Method method = Bukkit.class.getDeclaredMethod("getOnlinePlayers"); Method method = Bukkit.class.getDeclaredMethod("getOnlinePlayers");
return method.getReturnType() == Collection.class; return method.getReturnType() == Collection.class;
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
ConsoleLogger.showError("Error verifying if getOnlinePlayers is a collection! Method doesn't exist"); ConsoleLogger.warning("Error verifying if getOnlinePlayers is a collection! Method doesn't exist");
} }
return false; return false;
} }

View File

@ -30,7 +30,7 @@ public class FileUtils {
if (destinationFile.exists()) { if (destinationFile.exists()) {
return true; return true;
} else if (!destinationFile.getParentFile().exists() && !destinationFile.getParentFile().mkdirs()) { } else if (!destinationFile.getParentFile().exists() && !destinationFile.getParentFile().mkdirs()) {
ConsoleLogger.showError("Cannot create parent directories for '" + destinationFile + "'"); ConsoleLogger.warning("Cannot create parent directories for '" + destinationFile + "'");
return false; return false;
} }
@ -38,7 +38,7 @@ public class FileUtils {
final String normalizedPath = resourcePath.replace("\\", "/"); final String normalizedPath = resourcePath.replace("\\", "/");
try (InputStream is = AuthMe.class.getClassLoader().getResourceAsStream(normalizedPath)) { try (InputStream is = AuthMe.class.getClassLoader().getResourceAsStream(normalizedPath)) {
if (is == null) { if (is == null) {
ConsoleLogger.showError(format("Cannot copy resource '%s' to file '%s': cannot load resource", ConsoleLogger.warning(format("Cannot copy resource '%s' to file '%s': cannot load resource",
resourcePath, destinationFile.getPath())); resourcePath, destinationFile.getPath()));
} else { } else {
Files.copy(is, destinationFile.toPath()); Files.copy(is, destinationFile.toPath());

View File

@ -65,7 +65,7 @@ public class GeoLiteAPI {
} }
} else { } else {
if (!dataFile.delete()) { if (!dataFile.delete()) {
ConsoleLogger.showError("Failed to delete GeoLiteAPI database"); ConsoleLogger.warning("Failed to delete GeoLiteAPI database");
} }
} }
} }

View File

@ -34,14 +34,14 @@ public final class MigrationService {
public static void changePlainTextToSha256(NewSetting settings, DataSource dataSource, public static void changePlainTextToSha256(NewSetting settings, DataSource dataSource,
SHA256 authmeSha256) { SHA256 authmeSha256) {
if (HashAlgorithm.PLAINTEXT == settings.getProperty(SecuritySettings.PASSWORD_HASH)) { if (HashAlgorithm.PLAINTEXT == settings.getProperty(SecuritySettings.PASSWORD_HASH)) {
ConsoleLogger.showError("Your HashAlgorithm has been detected as plaintext and is now deprecated;" ConsoleLogger.warning("Your HashAlgorithm has been detected as plaintext and is now deprecated;"
+ " it will be changed and hashed now to the AuthMe default hashing method"); + " it will be changed and hashed now to the AuthMe default hashing method");
ConsoleLogger.showError("Don't stop your server; wait for the conversion to have been completed!"); ConsoleLogger.warning("Don't stop your server; wait for the conversion to have been completed!");
List<PlayerAuth> allAuths = dataSource.getAllAuths(); List<PlayerAuth> allAuths = dataSource.getAllAuths();
for (PlayerAuth auth : allAuths) { for (PlayerAuth auth : allAuths) {
String hash = auth.getPassword().getHash(); String hash = auth.getPassword().getHash();
if (hash.startsWith("$SHA$")) { if (hash.startsWith("$SHA$")) {
ConsoleLogger.showError("Skipping conversion for " + auth.getNickname() + "; detected SHA hash"); ConsoleLogger.warning("Skipping conversion for " + auth.getNickname() + "; detected SHA hash");
} else { } else {
HashedPassword hashedPassword = authmeSha256.computeHash(hash, auth.getNickname()); HashedPassword hashedPassword = authmeSha256.computeHash(hash, auth.getNickname());
auth.setPassword(hashedPassword); auth.setPassword(hashedPassword);
@ -63,7 +63,7 @@ public final class MigrationService {
*/ */
public static DataSource convertFlatfileToSqlite(NewSetting settings, DataSource dataSource) { public static DataSource convertFlatfileToSqlite(NewSetting settings, DataSource dataSource) {
if (DataSourceType.FILE == settings.getProperty(DatabaseSettings.BACKEND)) { if (DataSourceType.FILE == settings.getProperty(DatabaseSettings.BACKEND)) {
ConsoleLogger.showError("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!");
FlatFile flatFile = (FlatFile) dataSource; FlatFile flatFile = (FlatFile) dataSource;
try { try {

View File

@ -51,7 +51,7 @@ public final class Utils {
try { try {
return Pattern.compile(pattern); return Pattern.compile(pattern);
} catch (Exception e) { } catch (Exception e) {
ConsoleLogger.showError("Failed to compile pattern '" + pattern + "' - defaulting to allowing everything"); ConsoleLogger.warning("Failed to compile pattern '" + pattern + "' - defaulting to allowing everything");
return Pattern.compile(".*?"); return Pattern.compile(".*?");
} }
} }