diff --git a/README.md b/README.md
index da3267fb..d648a6bc 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,7 @@
- Build status: [](https://travis-ci.org/Xephi/AuthMeReloaded) [](https://www.versioneye.com/user/projects/55bab9e8653762002000190a)
- Build status (CircleCI): [](https://circleci.com/gh/Xephi/AuthMeReloaded)
+- Alternative Dev Build download link (via CircleCi): Download
- Code Coverage: [](https://coveralls.io/github/AuthMe-Team/AuthMeReloaded?branch=master)
diff --git a/circle.yml b/circle.yml
index 672011c2..da709f38 100644
--- a/circle.yml
+++ b/circle.yml
@@ -7,7 +7,9 @@ general:
test:
override:
- mvn clean install -B
-
+ post:
+ - cp ./target/AuthMe*.jar $CIRCLE_ARTIFACTS
+ - cp ./target/AuthMe-*-SNAPSHOT.jar $CIRCLE_ARTIFACTS/AuthMe.jar
notify:
webhooks:
- url: https://webhooks.gitter.im/e/7b92ac1a1741748b26bf
diff --git a/pom.xml b/pom.xml
index 33743bb1..7a77f60f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -129,7 +129,7 @@
org.apache.maven.plugins
maven-compiler-plugin
- 3.3
+ 3.5
1.7
${javaVersion}
@@ -140,7 +140,7 @@
org.apache.maven.plugins
maven-shade-plugin
- 2.4.2
+ 2.4.3
false
false
@@ -298,7 +298,7 @@
org.slf4j
slf4j-jdk14
- 1.7.13
+ 1.7.14
compile
true
@@ -335,7 +335,7 @@
com.maxmind.geoip
geoip-api
- 1.2.15
+ 1.3.0
compile
true
diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java
index 9dc1d685..980e3e95 100644
--- a/src/main/java/fr/xephi/authme/AuthMe.java
+++ b/src/main/java/fr/xephi/authme/AuthMe.java
@@ -1,9 +1,35 @@
package fr.xephi.authme;
-import com.earth2me.essentials.Essentials;
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Logger;
+
import com.google.common.base.Charsets;
import com.google.common.io.Resources;
+import org.apache.logging.log4j.LogManager;
+
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.Server;
+import org.bukkit.World;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.PluginManager;
+import org.bukkit.plugin.java.JavaPlugin;
+import org.bukkit.scheduler.BukkitTask;
+
+import com.earth2me.essentials.Essentials;
import com.onarandombox.MultiverseCore.MultiverseCore;
+import net.minelink.ctplus.CombatTagPlus;
+
import fr.xephi.authme.api.API;
import fr.xephi.authme.api.NewAPI;
import fr.xephi.authme.cache.auth.PlayerAuth;
@@ -58,33 +84,6 @@ import fr.xephi.authme.util.GeoLiteAPI;
import fr.xephi.authme.util.StringUtils;
import fr.xephi.authme.util.Utils;
import fr.xephi.authme.util.Wrapper;
-import net.minelink.ctplus.CombatTagPlus;
-import org.apache.logging.log4j.LogManager;
-import org.bukkit.Bukkit;
-import org.bukkit.Location;
-import org.bukkit.Server;
-import org.bukkit.World;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-import org.bukkit.plugin.PluginManager;
-import org.bukkit.plugin.java.JavaPlugin;
-import org.bukkit.scheduler.BukkitTask;
-import org.mcstats.Metrics;
-import org.mcstats.Metrics.Graph;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import static fr.xephi.authme.settings.properties.EmailSettings.MAIL_ACCOUNT;
import static fr.xephi.authme.settings.properties.EmailSettings.MAIL_PASSWORD;
@@ -213,7 +212,7 @@ public class AuthMe extends JavaPlugin {
// Load settings and custom configurations, if it fails, stop the server due to security reasons.
newSettings = createNewSetting();
- if (loadSettings()) {
+ if (!loadSettings()) {
server.shutdown();
setEnabled(false);
return;
@@ -225,9 +224,8 @@ public class AuthMe extends JavaPlugin {
try {
setupDatabase();
} catch (Exception e) {
- ConsoleLogger.writeStackTrace(e);
- ConsoleLogger.showError(e.getMessage());
- ConsoleLogger.showError("Fatal error occurred during database connection! Authme initialization ABORTED!");
+ ConsoleLogger.logException("Fatal error occurred during database connection! "
+ + "Authme initialization aborted!", e);
stopOrUnload();
return;
}
@@ -242,9 +240,8 @@ public class AuthMe extends JavaPlugin {
// Setup otherAccounts file
this.otherAccounts = OtherAccounts.getInstance();
-
// Set up Metrics
- setupMetrics();
+ MetricsStarter.setupMetrics(plugin, newSettings);
// Set console filter
setupConsoleFilter();
@@ -429,12 +426,11 @@ public class AuthMe extends JavaPlugin {
try {
settings = new Settings(this);
Settings.reload();
- } catch (Exception e) {
- ConsoleLogger.writeStackTrace(e);
- ConsoleLogger.showError("Can't load the configuration file... Something went wrong. "
- + "To avoid security issues the server will shut down!");
- server.shutdown();
return true;
+ } catch (Exception e) {
+ ConsoleLogger.logException("Can't load the configuration file... Something went wrong. "
+ + "To avoid security issues the server will shut down!", e);
+ server.shutdown();
}
return false;
}
@@ -463,46 +459,6 @@ public class AuthMe extends JavaPlugin {
}
}
- /**
- * Set up Metrics.
- */
- private void setupMetrics() {
- try {
- Metrics metrics = new Metrics(this);
- Graph languageGraph = metrics.createGraph("Messages language");
- Graph backendGraph = metrics.createGraph("Database backend");
-
- // Custom graphs
- if (newSettings.getMessagesFile().exists()) {
- String messagesLanguage = newSettings.getProperty(PluginSettings.MESSAGES_LANGUAGE);
- languageGraph.addPlotter(new Metrics.Plotter(messagesLanguage) {
-
- @Override
- public int getValue() {
- return 1;
- }
- });
- }
-
- DataSource.DataSourceType dataSource = newSettings.getProperty(DatabaseSettings.BACKEND);
- backendGraph.addPlotter(new Metrics.Plotter(dataSource.toString()) {
-
- @Override
- public int getValue() {
- return 1;
- }
- });
-
- metrics.start();
- ConsoleLogger.info("Metrics started successfully!");
- } catch (Exception e) {
- // Failed to submit the metrics data
- ConsoleLogger.showError("Can't start Metrics! The plugin will work anyway... (Encountered "
- + StringUtils.formatException(e) + ")");
- ConsoleLogger.writeStackTrace(e);
- }
- }
-
@Override
public void onDisable() {
// Save player data
@@ -516,40 +472,6 @@ public class AuthMe extends JavaPlugin {
new PerformBackup(plugin, newSettings).doBackup(PerformBackup.BackupCause.STOP);
}
- List pendingTasks = getServer().getScheduler().getPendingTasks();
- for (Iterator iterator = pendingTasks.iterator(); iterator.hasNext();) {
- BukkitTask pendingTask = iterator.next();
- if (!pendingTask.getOwner().equals(this) || pendingTask.isSync()) {
- //remove all irrelevant tasks
- iterator.remove();
- }
- }
-
- getLogger().log(Level.INFO, "Waiting for {0} tasks to finish", pendingTasks.size());
- int progress = 0;
- try {
- for (BukkitTask pendingTask : pendingTasks) {
- int maxTries = 5;
- int taskId = pendingTask.getTaskId();
- while (getServer().getScheduler().isCurrentlyRunning(taskId)) {
- if (maxTries <= 0) {
- getLogger().log(Level.INFO, "Async task {0} times out after to many tries", taskId);
- break;
- }
-
- //one second
- Thread.sleep(1000);
- maxTries--;
- }
-
- progress++;
- getLogger().log(Level.INFO, "Progress: {0} / {1}", new Object[]{progress, pendingTasks.size()});
- }
- } catch (InterruptedException interruptedException) {
-
- }
-
-
// Close the database
if (database != null) {
database.close();
diff --git a/src/main/java/fr/xephi/authme/ConsoleLogger.java b/src/main/java/fr/xephi/authme/ConsoleLogger.java
index fee14296..605cabc0 100644
--- a/src/main/java/fr/xephi/authme/ConsoleLogger.java
+++ b/src/main/java/fr/xephi/authme/ConsoleLogger.java
@@ -2,6 +2,7 @@ package fr.xephi.authme;
import com.google.common.base.Throwables;
import fr.xephi.authme.settings.Settings;
+import fr.xephi.authme.util.StringUtils;
import fr.xephi.authme.util.Wrapper;
import java.io.IOException;
@@ -32,10 +33,9 @@ public final class ConsoleLogger {
*/
public static void info(String message) {
wrapper.getLogger().info(message);
- if (!Settings.useLogging) {
- return;
+ if (Settings.useLogging) {
+ writeLog(message);
}
- writeLog("" + message);
}
/**
@@ -45,10 +45,9 @@ public final class ConsoleLogger {
*/
public static void showError(String message) {
wrapper.getLogger().warning(message);
- if (!Settings.useLogging) {
- return;
+ if (Settings.useLogging) {
+ writeLog("ERROR: " + message);
}
- writeLog("ERROR: " + message);
}
/**
@@ -72,12 +71,22 @@ public final class ConsoleLogger {
/**
* Write a StackTrace into the log.
*
- * @param ex Exception
+ * @param th The Throwable whose stack trace should be logged
*/
- public static void writeStackTrace(Exception ex) {
- if (!Settings.useLogging) {
- return;
+ public static void writeStackTrace(Throwable th) {
+ if (Settings.useLogging) {
+ writeLog(Throwables.getStackTraceAsString(th));
}
- writeLog(Throwables.getStackTraceAsString(ex));
+ }
+
+ /**
+ * Logs a Throwable with the provided message and saves the stack trace to the log file.
+ *
+ * @param message The message to accompany the exception
+ * @param th The Throwable to log
+ */
+ public static void logException(String message, Throwable th) {
+ showError(message + " " + StringUtils.formatException(th));
+ writeStackTrace(th);
}
}
diff --git a/src/main/java/fr/xephi/authme/MetricsStarter.java b/src/main/java/fr/xephi/authme/MetricsStarter.java
new file mode 100644
index 00000000..eac9ebaf
--- /dev/null
+++ b/src/main/java/fr/xephi/authme/MetricsStarter.java
@@ -0,0 +1,45 @@
+package fr.xephi.authme;
+
+import fr.xephi.authme.settings.NewSetting;
+import fr.xephi.authme.settings.properties.DatabaseSettings;
+import fr.xephi.authme.settings.properties.PluginSettings;
+import org.mcstats.Metrics;
+import org.mcstats.Metrics.Graph;
+
+import java.io.IOException;
+
+public class MetricsStarter {
+
+ private MetricsStarter() {
+ }
+
+ public static void setupMetrics(AuthMe plugin, NewSetting settings) {
+ try {
+ final Metrics metrics = new Metrics(plugin);
+
+ final Graph languageGraph = metrics.createGraph("Messages Language");
+ final String messagesLanguage = settings.getProperty(PluginSettings.MESSAGES_LANGUAGE);
+ languageGraph.addPlotter(new Metrics.Plotter(messagesLanguage) {
+ @Override
+ public int getValue() {
+ return 1;
+ }
+ });
+
+ final Graph databaseBackend = metrics.createGraph("Database Backend");
+ final String dataSource = settings.getProperty(DatabaseSettings.BACKEND).toString();
+ databaseBackend.addPlotter(new Metrics.Plotter(dataSource) {
+ @Override
+ public int getValue() {
+ return 1;
+ }
+ });
+
+ // Submit metrics
+ metrics.start();
+ } catch (IOException e) {
+ // Failed to submit the metrics data
+ ConsoleLogger.logException("Can't start Metrics! The plugin will work anyway...", e);
+ }
+ }
+}
diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/ReloadCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/ReloadCommand.java
index db21c859..39acd6a1 100644
--- a/src/main/java/fr/xephi/authme/command/executable/authme/ReloadCommand.java
+++ b/src/main/java/fr/xephi/authme/command/executable/authme/ReloadCommand.java
@@ -24,8 +24,7 @@ public class ReloadCommand implements ExecutableCommand {
commandService.send(sender, MessageKey.CONFIG_RELOAD_SUCCESS);
} catch (Exception e) {
sender.sendMessage("Error occurred during reload of AuthMe: aborting");
- ConsoleLogger.showError("Fatal error occurred! AuthMe instance ABORTED!");
- ConsoleLogger.writeStackTrace(e);
+ ConsoleLogger.logException("Aborting! Encountered exception during reload of AuthMe:", e);
plugin.stopOrUnload();
}
}
diff --git a/src/main/java/fr/xephi/authme/converter/RoyalAuthConverter.java b/src/main/java/fr/xephi/authme/converter/RoyalAuthConverter.java
index 5e85ce6e..42bd681d 100644
--- a/src/main/java/fr/xephi/authme/converter/RoyalAuthConverter.java
+++ b/src/main/java/fr/xephi/authme/converter/RoyalAuthConverter.java
@@ -33,8 +33,7 @@ public class RoyalAuthConverter implements Converter {
PlayerAuth auth = new PlayerAuth(name, ra.getHash(), "127.0.0.1", ra.getLastLogin(), "your@email.com", o.getName());
data.saveAuth(auth);
} catch (Exception e) {
- ConsoleLogger.writeStackTrace(e);
- ConsoleLogger.showError("Error while trying to import " + o.getName() + " RoyalAuth datas");
+ ConsoleLogger.logException("Error while trying to import " + o.getName() + " RoyalAuth data", e);
}
}
}
diff --git a/src/main/java/fr/xephi/authme/converter/vAuthFileReader.java b/src/main/java/fr/xephi/authme/converter/vAuthFileReader.java
index 16b89e5a..bb25b04b 100644
--- a/src/main/java/fr/xephi/authme/converter/vAuthFileReader.java
+++ b/src/main/java/fr/xephi/authme/converter/vAuthFileReader.java
@@ -8,6 +8,7 @@ import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import java.io.File;
+import java.io.IOException;
import java.util.Scanner;
import java.util.UUID;
@@ -27,7 +28,7 @@ class vAuthFileReader {
}
public void convert() {
- final File file = new File(plugin.getDataFolder().getParent() + "" + File.separator + "vAuth" + File.separator + "passwords.yml");
+ final File file = new File(plugin.getDataFolder().getParent() + File.separator + "vAuth" + File.separator + "passwords.yml");
Scanner scanner;
try {
scanner = new Scanner(file);
@@ -52,8 +53,8 @@ class vAuthFileReader {
database.saveAuth(auth);
}
scanner.close();
- } catch (Exception e) {
- ConsoleLogger.writeStackTrace(e);
+ } catch (IOException e) {
+ ConsoleLogger.logException("Error while trying to import some vAuth data", e);
}
}
@@ -63,12 +64,10 @@ class vAuthFileReader {
}
private String getName(UUID uuid) {
- try {
- for (OfflinePlayer op : Bukkit.getOfflinePlayers()) {
- if (op.getUniqueId().compareTo(uuid) == 0)
- return op.getName();
+ for (OfflinePlayer op : Bukkit.getOfflinePlayers()) {
+ if (op.getUniqueId().compareTo(uuid) == 0) {
+ return op.getName();
}
- } catch (Exception ignored) {
}
return null;
}
diff --git a/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java b/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java
index e573c6d0..e66c5cd2 100644
--- a/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java
+++ b/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java
@@ -5,17 +5,13 @@ import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.cache.RemovalListener;
-import com.google.common.cache.RemovalListeners;
import com.google.common.cache.RemovalNotification;
-import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.security.crypts.HashedPassword;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
/**
@@ -23,7 +19,6 @@ import java.util.concurrent.TimeUnit;
public class CacheDataSource implements DataSource {
private final DataSource source;
- private final ExecutorService exec;
private final LoadingCache> cachedAuths;
/**
@@ -33,10 +28,9 @@ public class CacheDataSource implements DataSource {
*/
public CacheDataSource(DataSource src) {
this.source = src;
- this.exec = Executors.newCachedThreadPool();
- cachedAuths = CacheBuilder.newBuilder()
- .expireAfterWrite(5, TimeUnit.MINUTES)
- .removalListener(RemovalListeners.asynchronous(new RemovalListener>() {
+ this.cachedAuths = CacheBuilder.newBuilder()
+ .expireAfterWrite(8, TimeUnit.MINUTES)
+ .removalListener(new RemovalListener>() {
@Override
public void onRemoval(RemovalNotification> removalNotification) {
String name = removalNotification.getKey();
@@ -44,7 +38,7 @@ public class CacheDataSource implements DataSource {
cachedAuths.getUnchecked(name);
}
}
- }, exec))
+ })
.build(
new CacheLoader>() {
public Optional load(String key) {
@@ -168,24 +162,13 @@ public class CacheDataSource implements DataSource {
@Override
public synchronized void close() {
- try {
- exec.shutdown();
- exec.awaitTermination(8, TimeUnit.SECONDS);
- } catch (InterruptedException e) {
- ConsoleLogger.writeStackTrace(e);
- }
source.close();
}
@Override
public void reload() { // unused method
- exec.execute(new Runnable() {
- @Override
- public void run() {
- source.reload();
- cachedAuths.invalidateAll();
- }
- });
+ source.reload();
+ cachedAuths.invalidateAll();
}
@Override
@@ -214,13 +197,8 @@ public class CacheDataSource implements DataSource {
@Override
public synchronized void purgeBanned(final List banned) {
- exec.execute(new Runnable() {
- @Override
- public void run() {
- source.purgeBanned(banned);
- cachedAuths.invalidateAll(banned);
- }
- });
+ source.purgeBanned(banned);
+ cachedAuths.invalidateAll(banned);
}
@Override
@@ -235,33 +213,18 @@ public class CacheDataSource implements DataSource {
@Override
public void setLogged(final String user) {
- exec.execute(new Runnable() {
- @Override
- public void run() {
- source.setLogged(user.toLowerCase());
- }
- });
+ source.setLogged(user.toLowerCase());
}
@Override
public void setUnlogged(final String user) {
- exec.execute(new Runnable() {
- @Override
- public void run() {
- source.setUnlogged(user.toLowerCase());
- }
- });
+ source.setUnlogged(user.toLowerCase());
}
@Override
public void purgeLogged() {
- exec.execute(new Runnable() {
- @Override
- public void run() {
- source.purgeLogged();
- cachedAuths.invalidateAll();
- }
- });
+ source.purgeLogged();
+ cachedAuths.invalidateAll();
}
@Override
@@ -270,14 +233,9 @@ public class CacheDataSource implements DataSource {
}
@Override
- public void updateName(final String oldOne, final String newOne) {
- exec.execute(new Runnable() {
- @Override
- public void run() {
- source.updateName(oldOne, newOne);
- cachedAuths.invalidate(oldOne);
- }
- });
+ public void updateName(final String oldOne, final String newOne) { // unused method
+ source.updateName(oldOne, newOne);
+ cachedAuths.invalidate(oldOne);
}
@Override
diff --git a/src/main/java/fr/xephi/authme/datasource/MySQL.java b/src/main/java/fr/xephi/authme/datasource/MySQL.java
index 3c48c6da..03da26d3 100644
--- a/src/main/java/fr/xephi/authme/datasource/MySQL.java
+++ b/src/main/java/fr/xephi/authme/datasource/MySQL.java
@@ -257,8 +257,7 @@ public class MySQL implements DataSource {
ResultSet rs = pst.executeQuery();
return rs.next();
} catch (SQLException ex) {
- ConsoleLogger.showError(ex.getMessage());
- ConsoleLogger.writeStackTrace(ex);
+ logSqlException(ex);
}
return false;
}
@@ -276,8 +275,7 @@ public class MySQL implements DataSource {
!columnSalt.isEmpty() ? rs.getString(columnSalt) : null);
}
} catch (SQLException ex) {
- ConsoleLogger.showError(ex.getMessage());
- ConsoleLogger.writeStackTrace(ex);
+ logSqlException(ex);
}
return null;
}
@@ -322,8 +320,7 @@ public class MySQL implements DataSource {
}
}
} catch (SQLException ex) {
- ConsoleLogger.showError(ex.getMessage());
- ConsoleLogger.writeStackTrace(ex);
+ logSqlException(ex);
return null;
}
return pAuth;
@@ -525,8 +522,7 @@ public class MySQL implements DataSource {
}
return true;
} catch (SQLException ex) {
- ConsoleLogger.showError(ex.getMessage());
- ConsoleLogger.writeStackTrace(ex);
+ logSqlException(ex);
}
return false;
}
@@ -589,8 +585,7 @@ public class MySQL implements DataSource {
}
return true;
} catch (SQLException ex) {
- ConsoleLogger.showError(ex.getMessage());
- ConsoleLogger.writeStackTrace(ex);
+ logSqlException(ex);
}
return false;
}
@@ -623,8 +618,7 @@ public class MySQL implements DataSource {
pst.setLong(1, until);
result = pst.executeUpdate();
} catch (SQLException ex) {
- ConsoleLogger.showError(ex.getMessage());
- ConsoleLogger.writeStackTrace(ex);
+ logSqlException(ex);
}
return result;
}
@@ -647,8 +641,7 @@ public class MySQL implements DataSource {
st.executeUpdate();
st.close();
} catch (SQLException ex) {
- ConsoleLogger.showError(ex.getMessage());
- ConsoleLogger.writeStackTrace(ex);
+ logSqlException(ex);
}
return list;
}
@@ -680,8 +673,7 @@ public class MySQL implements DataSource {
pst.executeUpdate();
return true;
} catch (SQLException ex) {
- ConsoleLogger.showError(ex.getMessage());
- ConsoleLogger.writeStackTrace(ex);
+ logSqlException(ex);
}
return false;
}
@@ -702,8 +694,7 @@ public class MySQL implements DataSource {
pst.close();
return true;
} catch (SQLException ex) {
- ConsoleLogger.showError(ex.getMessage());
- ConsoleLogger.writeStackTrace(ex);
+ logSqlException(ex);
}
return false;
}
@@ -722,8 +713,7 @@ public class MySQL implements DataSource {
rs.close();
pst.close();
} catch (SQLException ex) {
- ConsoleLogger.showError(ex.getMessage());
- ConsoleLogger.writeStackTrace(ex);
+ logSqlException(ex);
}
return countIp;
}
@@ -739,8 +729,7 @@ public class MySQL implements DataSource {
pst.close();
return true;
} catch (SQLException ex) {
- ConsoleLogger.showError(ex.getMessage());
- ConsoleLogger.writeStackTrace(ex);
+ logSqlException(ex);
}
return false;
}
@@ -750,9 +739,8 @@ public class MySQL implements DataSource {
try {
reloadArguments();
} catch (Exception ex) {
- ConsoleLogger.showError(ex.getMessage());
- ConsoleLogger.showError("Can't reconnect to MySQL database... Please check your MySQL configuration!");
- ConsoleLogger.writeStackTrace(ex);
+ ConsoleLogger.logException("Can't reconnect to MySQL database... " +
+ "Please check your MySQL configuration! Encountered", ex);
AuthMe.getInstance().stopOrUnload();
}
}
@@ -778,8 +766,7 @@ public class MySQL implements DataSource {
rs.close();
pst.close();
} catch (SQLException ex) {
- ConsoleLogger.showError(ex.getMessage());
- ConsoleLogger.writeStackTrace(ex);
+ logSqlException(ex);
}
return result;
}
@@ -798,8 +785,7 @@ public class MySQL implements DataSource {
rs.close();
pst.close();
} catch (SQLException ex) {
- ConsoleLogger.showError(ex.getMessage());
- ConsoleLogger.writeStackTrace(ex);
+ logSqlException(ex);
}
return result;
}
@@ -818,8 +804,7 @@ public class MySQL implements DataSource {
rs.close();
pst.close();
} catch (SQLException ex) {
- ConsoleLogger.showError(ex.getMessage());
- ConsoleLogger.writeStackTrace(ex);
+ logSqlException(ex);
}
return countEmail;
}
@@ -834,8 +819,7 @@ public class MySQL implements DataSource {
}
pst.close();
} catch (SQLException ex) {
- ConsoleLogger.showError(ex.getMessage());
- ConsoleLogger.writeStackTrace(ex);
+ logSqlException(ex);
}
}
@@ -854,8 +838,7 @@ public class MySQL implements DataSource {
ResultSet rs = pst.executeQuery();
isLogged = rs.next() && (rs.getInt(columnLogged) == 1);
} catch (SQLException ex) {
- ConsoleLogger.showError(ex.getMessage());
- ConsoleLogger.writeStackTrace(ex);
+ logSqlException(ex);
}
return isLogged;
}
@@ -870,8 +853,7 @@ public class MySQL implements DataSource {
pst.executeUpdate();
pst.close();
} catch (SQLException ex) {
- ConsoleLogger.showError(ex.getMessage());
- ConsoleLogger.writeStackTrace(ex);
+ logSqlException(ex);
}
}
@@ -885,8 +867,7 @@ public class MySQL implements DataSource {
pst.executeUpdate();
pst.close();
} catch (SQLException ex) {
- ConsoleLogger.showError(ex.getMessage());
- ConsoleLogger.writeStackTrace(ex);
+ logSqlException(ex);
}
}
@@ -899,9 +880,8 @@ public class MySQL implements DataSource {
pst.setInt(2, 1);
pst.executeUpdate();
pst.close();
- } catch (Exception ex) {
- ConsoleLogger.showError(ex.getMessage());
- ConsoleLogger.writeStackTrace(ex);
+ } catch (SQLException ex) {
+ logSqlException(ex);
}
}
@@ -916,9 +896,8 @@ public class MySQL implements DataSource {
}
rs.close();
st.close();
- } catch (Exception ex) {
- ConsoleLogger.showError(ex.getMessage());
- ConsoleLogger.writeStackTrace(ex);
+ } catch (SQLException ex) {
+ logSqlException(ex);
}
return result;
}
@@ -931,9 +910,8 @@ public class MySQL implements DataSource {
pst.setString(1, newOne);
pst.setString(2, oldOne);
pst.executeUpdate();
- } catch (Exception ex) {
- ConsoleLogger.showError(ex.getMessage());
- ConsoleLogger.writeStackTrace(ex);
+ } catch (SQLException ex) {
+ logSqlException(ex);
}
}
@@ -977,9 +955,8 @@ public class MySQL implements DataSource {
pst.close();
rs.close();
st.close();
- } catch (Exception ex) {
- ConsoleLogger.showError(ex.getMessage());
- ConsoleLogger.writeStackTrace(ex);
+ } catch (SQLException ex) {
+ logSqlException(ex);
}
return auths;
}
@@ -1021,11 +998,14 @@ public class MySQL implements DataSource {
}
auths.add(pAuth);
}
- } catch (Exception ex) {
- ConsoleLogger.showError(ex.getMessage());
- ConsoleLogger.writeStackTrace(ex);
+ } catch (SQLException ex) {
+ logSqlException(ex);
}
return auths;
}
+ private static void logSqlException(SQLException e) {
+ ConsoleLogger.logException("Error during SQL operation:", e);
+ }
+
}
diff --git a/src/main/java/fr/xephi/authme/datasource/SQLite.java b/src/main/java/fr/xephi/authme/datasource/SQLite.java
index 9b14b1cc..ca9c2565 100644
--- a/src/main/java/fr/xephi/authme/datasource/SQLite.java
+++ b/src/main/java/fr/xephi/authme/datasource/SQLite.java
@@ -170,8 +170,7 @@ public class SQLite implements DataSource {
!columnSalt.isEmpty() ? rs.getString(columnSalt) : null);
}
} catch (SQLException ex) {
- ConsoleLogger.showError(ex.getMessage());
- ConsoleLogger.writeStackTrace(ex);
+ ConsoleLogger.logException("Error getting password:", ex);
} finally {
close(rs);
close(pst);
diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java
index 2e365e93..bae29ab7 100644
--- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java
+++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java
@@ -108,6 +108,9 @@ public class AuthMePlayerListener implements Listener {
if (Settings.useEssentialsMotd && cmd.equals("/motd")) {
return;
}
+ if(!Settings.isForcedRegistrationEnabled && Settings.allowAllCommandsIfRegIsOptional) {
+ return;
+ }
if (Settings.allowCommands.contains(cmd)) {
return;
}
diff --git a/src/main/java/fr/xephi/authme/modules/ModuleManager.java b/src/main/java/fr/xephi/authme/modules/ModuleManager.java
index 23aa37a8..6228091c 100644
--- a/src/main/java/fr/xephi/authme/modules/ModuleManager.java
+++ b/src/main/java/fr/xephi/authme/modules/ModuleManager.java
@@ -135,8 +135,7 @@ public class ModuleManager {
}
} catch (Exception ex) {
- ConsoleLogger.writeStackTrace(ex);
- ConsoleLogger.showError("Cannot load " + pathToJar.getName() + " jar file !");
+ ConsoleLogger.logException("Cannot load " + pathToJar.getName() + " jar file!", ex);
} finally {
try {
if (jarFile != null) {
diff --git a/src/main/java/fr/xephi/authme/process/logout/ProcessSyncronousPlayerLogout.java b/src/main/java/fr/xephi/authme/process/logout/ProcessSyncronousPlayerLogout.java
index 236c8cd4..5a8133b7 100644
--- a/src/main/java/fr/xephi/authme/process/logout/ProcessSyncronousPlayerLogout.java
+++ b/src/main/java/fr/xephi/authme/process/logout/ProcessSyncronousPlayerLogout.java
@@ -49,6 +49,13 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
}
+ protected void restoreSpeedEffect() {
+ if (Settings.isRemoveSpeedEnabled) {
+ player.setWalkSpeed(0.0F);
+ player.setFlySpeed(0.0F);
+ }
+ }
+
/**
* Method run.
*
@@ -77,6 +84,7 @@ public class ProcessSyncronousPlayerLogout implements Runnable {
if (Settings.applyBlindEffect)
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
player.setOp(false);
+ restoreSpeedEffect();
// Player is now logout... Time to fire event !
Bukkit.getServer().getPluginManager().callEvent(new LogoutEvent(player));
if (Settings.bungee)
diff --git a/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java b/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java
index 60d3da15..16c469e5 100644
--- a/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java
+++ b/src/main/java/fr/xephi/authme/process/register/AsyncRegister.java
@@ -85,8 +85,7 @@ public class AsyncRegister {
passwordRegister();
}
} catch (Exception e) {
- ConsoleLogger.showError(e.getMessage());
- ConsoleLogger.writeStackTrace(e);
+ ConsoleLogger.logException("Error during async register process", e);
m.send(player, MessageKey.ERROR);
}
}
diff --git a/src/main/java/fr/xephi/authme/settings/CustomConfiguration.java b/src/main/java/fr/xephi/authme/settings/CustomConfiguration.java
index cb1719cb..ee164525 100644
--- a/src/main/java/fr/xephi/authme/settings/CustomConfiguration.java
+++ b/src/main/java/fr/xephi/authme/settings/CustomConfiguration.java
@@ -77,8 +77,7 @@ public abstract class CustomConfiguration extends YamlConfiguration {
return true;
}
} catch (Exception e) {
- ConsoleLogger.writeStackTrace(e);
- ConsoleLogger.showError("Failed to load config from JAR");
+ ConsoleLogger.logException("Failed to load config from JAR", e);
}
}
return false;
diff --git a/src/main/java/fr/xephi/authme/settings/NewSetting.java b/src/main/java/fr/xephi/authme/settings/NewSetting.java
index 1361f227..85ae6505 100644
--- a/src/main/java/fr/xephi/authme/settings/NewSetting.java
+++ b/src/main/java/fr/xephi/authme/settings/NewSetting.java
@@ -181,8 +181,7 @@ public class NewSetting {
writer.flush();
writer.close();
} catch (IOException e) {
- ConsoleLogger.showError("Could not save config file - " + StringUtils.formatException(e));
- ConsoleLogger.writeStackTrace(e);
+ ConsoleLogger.logException("Could not save config file:", e);
}
}
diff --git a/src/main/java/fr/xephi/authme/settings/Settings.java b/src/main/java/fr/xephi/authme/settings/Settings.java
index c745cf84..96d15d12 100644
--- a/src/main/java/fr/xephi/authme/settings/Settings.java
+++ b/src/main/java/fr/xephi/authme/settings/Settings.java
@@ -65,7 +65,7 @@ public final class Settings {
enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
broadcastWelcomeMessage, forceRegKick, forceRegLogin,
checkVeryGames, delayJoinLeaveMessages, noTeleport, applyBlindEffect,
- kickPlayersBeforeStopping,
+ kickPlayersBeforeStopping, allowAllCommandsIfRegIsOptional,
customAttributes, generateImage, isRemoveSpeedEnabled, preventOtherCase;
public static String getNickRegex, getUnloggedinGroup, getMySQLHost,
getMySQLPort, getMySQLUsername, getMySQLPassword, getMySQLDatabase,
@@ -189,6 +189,7 @@ public final class Settings {
isStopEnabled = configFile.getBoolean("Security.SQLProblem.stopServer", true);
reloadSupport = configFile.getBoolean("Security.ReloadCommand.useReloadCommandSupport", true);
+ allowAllCommandsIfRegIsOptional = configFile.getBoolean("settings.restrictions.allowAllCommandsIfRegistrationIsOptional", false);
allowCommands = new ArrayList<>();
allowCommands.addAll(Arrays.asList("/login", "/l", "/register", "/reg", "/email", "/captcha"));
for (String cmd : configFile.getStringList("settings.restrictions.allowCommands")) {
diff --git a/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java b/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java
index a14285fd..386e130c 100644
--- a/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java
+++ b/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java
@@ -18,13 +18,19 @@ public class RestrictionSettings implements SettingsClass {
public static final Property ALLOW_CHAT =
newProperty("settings.restrictions.allowChat", false);
+ @Comment({
+ "Allow unlogged users to use all the commands if registration is not forced!",
+ "WARNING: use this only if you need it!)"})
+ public static final Property ALLOW_ALL_COMMANDS_IF_REGISTRATION_IS_OPTIONAL =
+ newProperty("settings.restrictions.allowAllCommandsIfRegistrationIsOptional", false);
+
@Comment("Allowed commands for unauthenticated players")
public static final Property> ALLOW_COMMANDS =
newProperty(PropertyType.STRING_LIST, "settings.restrictions.allowCommands",
"login", "register", "l", "reg", "email", "captcha");
@Comment("Max number of allowed registrations per IP")
- // TODO ljacqu 20160109: If 0 == unlimited, add this fact ot the comment
+ // TODO ljacqu 20160109: If 0 == unlimited, add this fact to the comment
public static final Property MAX_REGISTRATION_PER_IP =
newProperty("settings.restrictions.maxRegPerIp", 1);
diff --git a/src/main/java/fr/xephi/authme/util/GeoLiteAPI.java b/src/main/java/fr/xephi/authme/util/GeoLiteAPI.java
index ebd0deb3..7f519a77 100644
--- a/src/main/java/fr/xephi/authme/util/GeoLiteAPI.java
+++ b/src/main/java/fr/xephi/authme/util/GeoLiteAPI.java
@@ -36,7 +36,7 @@ public class GeoLiteAPI {
plugin.getLogger().info(LICENSE);
return true;
} catch (IOException e) {
- // TODO ljacqu 20151123: Log the exception instead of just swallowing it
+ ConsoleLogger.logException("Could not find/download GeoLiteAPI", e);
return false;
}
}
@@ -63,7 +63,7 @@ public class GeoLiteAPI {
output.close();
input.close();
} catch (IOException e) {
- ConsoleLogger.writeStackTrace(e);
+ ConsoleLogger.logException("Could not download GeoLiteAPI", e);
}
}
});
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 0bc81202..c9cdbfe6 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -67,6 +67,9 @@ settings:
# Care that this feature blocks also all the commands not
# listed in the list below.
allowChat: false
+ # WARNING: use this only if you need it!
+ # Allow unlogged users to use all the commands if registration is not forced!
+ allowAllCommandsIfRegistrationIsOptional: false
# Commands allowed when a player is not authenticated
allowCommands:
- /login
diff --git a/src/main/resources/messages/messages_hu.yml b/src/main/resources/messages/messages_hu.yml
index f52e4f2b..099179f8 100644
--- a/src/main/resources/messages/messages_hu.yml
+++ b/src/main/resources/messages/messages_hu.yml
@@ -4,56 +4,56 @@ registered: '&aSikeres regisztráció. Üdvözöllek!'
user_regged: '&cJátékosnév már regisztrálva'
login_msg: '&cKérlek jelentkezz be: "/login jelszó"'
not_logged_in: '&cNem vagy bejelentkezve!'
-logout: '&cSikeresen kijelentkeztél'
-usage_log: '&cBejelentkezés: /login jelszó'
-unknown_user: User is not in database
-reg_voluntarily: Regisztrálhatod beceneved a szerveren a következö parancsal "/register jelszó jelszó"
-reg_disabled: '&cRegisztráció letiltva'
-no_perm: '&cNincs engedélyed'
-usage_reg: '&cHasználat: /register jelszó jelszóújra'
-password_error_nick: '&fYou can''t use your name as password'
-password_error_unsafe: '&fYou can''t use unsafe passwords'
+logout: '&cSikeresen kijelentkeztél!'
+usage_log: '&cBejelentkezés: /login '
+unknown_user: '&cA kért felhasználó nem telálható az adatbázisban!'
+reg_voluntarily: Regisztrálhatod magad a szerveren a következö parancsal "/register "
+reg_disabled: '&cRegisztráció letiltva!'
+no_perm: '&cNincs jogod ehhez!'
+usage_reg: '&cHasználat: /register '
+password_error_nick: '&cNem használhatod a felhasználóneved jelszónak, kérlek válassz másikat...'
+password_error_unsafe: '&cA választott jelszó nem biztonságos, kérlek válassz másikat...'
unregistered: '&cRegisztráció sikeresen törölve!'
-same_nick: Ezen a játékosnéven már játszanak
-valid_session: '&cSession login'
+same_nick: 'Ezzel a játékosnévvel már játszanak a szerveren.'
+valid_session: '&2A hálózati kapcsolat újraépítése megtörtént.'
pwd_changed: '&cJelszó cserélve!'
-reload: Beálítások és adatbázis újratöltve!
-timeout: Bejelentkezési idötúllépés
-error: Hiba lépett fel; Lépj kapcsolatba a tulajjal'
+reload: 'Beálítások és adatbázis újratöltve!'
+timeout: 'Bejelentkezési időtúllépés!'
+error: 'Hiba lépett fel; Lépj kapcsolatba a tulajjal'
logged_in: '&cMár be vagy jelentkezve!'
-login: '&aSikeresen Beléptél! Üdvözöllek!!!'
-wrong_pwd: '&4Hibás jelszó'
-user_unknown: '&cJátékosnév nem regisztrált'
+login: '&aSikeresen beléptél!'
+wrong_pwd: '&4Hibás jelszó!'
+user_unknown: '&cEz a felhasználó nincs regisztrálva!'
reg_msg: '&cKérlek Regisztrálj: "/register jelszó jelszóújra"'
-reg_email_msg: '&cPlease register with "/register "'
-unsafe_spawn: A kilépési helyzeted nem biztonságos, teleportálás a kezdö Spawnra.
-max_reg: Csak egy karakterrel Registrálhatsz!!!
-password_error: A jelszó nem illik össze
-invalid_session: Session Dataes doesnt corrispond Plaese wait the end of session
-pass_len: A jelszavad nem éri el a minimális hosszat
-vb_nonActiv: Your Account isent Activated yet check your Emails!
-usage_changepassword: 'használat: /changepassword régiJelszó újJelszó'
-name_len: '&cYour nickname is too Short or too long'
-regex: '&cYour nickname contains illegal characters. Allowed chars: REG_EX'
-add_email: '&cPlease add your email with : /email add yourEmail confirmEmail'
-recovery_email: '&cForgot your password? Please use /email recovery '
-usage_captcha: '&cUsage: /captcha '
-wrong_captcha: '&cWrong Captcha, please use : /captcha THE_CAPTCHA'
-valid_captcha: '&cYour captcha is valid !'
-kick_forvip: '&cA VIP Player join the full server!'
-kick_fullserver: '&cThe server is actually full, Sorry!'
-usage_email_add: '&fUsage: /email add '
-usage_email_change: '&fUsage: /email change '
-usage_email_recovery: '&fUsage: /email recovery '
-new_email_invalid: '[AuthMe] New email invalid!'
-old_email_invalid: '[AuthMe] Old email invalid!'
-email_invalid: '[AuthMe] Invalid Email'
-email_added: '[AuthMe] Email Added !'
-email_confirm: '[AuthMe] Confirm your Email !'
-email_changed: '[AuthMe] Email Change !'
-email_send: '[AuthMe] Recovery Email Send !'
-country_banned: 'Your country is banned from this server'
-antibot_auto_enabled: '[AuthMe] AntiBotMod automatically enabled due to massive connections!'
-antibot_auto_disabled: '[AuthMe] AntiBotMod automatically disabled after %m Minutes, hope invasion stopped'
-kick_antibot: 'AntiBot protection mode is enabled! You have to wait some minutes before joining the server.'
-email_exists: '&cA recovery email was already sent! You can discard it and send a new one using the command below:'
+reg_email_msg: '&cKérlek regisztrálj: "/register "'
+unsafe_spawn: 'A kilépési helyzeted nem biztonságos, teleportálás a Spawnra.'
+max_reg: 'Csak egy karakterrel registrálhatsz!'
+password_error: 'A két jelszó nem egyezik!'
+invalid_session: '&cAz IP címed megváltozott és a hálózati kapcsolatod lejárt. Kapcsolódj újra.'
+pass_len: 'A jelszavad nem éri el a minimális hosszúságot!'
+vb_nonActiv: '&cA felhasználód aktiválása még nem történt meg, ellenőrizd a leveleid!'
+usage_changepassword: 'Használat: /changepassword <új Jelszó>'
+name_len: '&4A felhasználó neved túl hosszú, vagy túl rövid! Válassz másikat!'
+regex: '&4A felhasználóneved nem használható karaktereket tartalmaz. Elfogadott karakterek: REG_EX'
+add_email: '&3Kérlek add hozzá a felhasználódhoz az email címedet "/email add "'
+recovery_email: '&3Ha elfelejtetted a jelszavad, használd az: "/email recovery "'
+usage_captcha: '&3A bejelentkezéshez CAPTCHA szükséges, kérem használd a következő parancsot "/captcha "'
+wrong_captcha: '&cHibás captcha, kérlek írd be a következő parancsot "/captcha THE_CAPTCHA" a chat-be!'
+valid_captcha: '&2Captcha sikeresen feloldva!'
+kick_forvip: '&3VIP játékos csatlakozott a szerverhez!'
+kick_fullserver: '&4A szerver megtelt, próbálj csatlakozni később!'
+usage_email_add: '&cHasználat: /email add '
+usage_email_change: '&cHasználat: /email change <új Email>'
+usage_email_recovery: '&cHasználat: /email recovery '
+new_email_invalid: '&cHibás az új email cím, próbáld újra!'
+old_email_invalid: '&cHibás a régi email cím, próbáld újra!'
+email_invalid: '&cHibás az email cím, próbáld újra!'
+email_added: '&2Az email címed rögzítése sikeresen megtörtént!'
+email_confirm: '&cKérlek ellenőrízd az email címedet!'
+email_changed: '&2Az email cím cseréje sikeresen megtörtént!'
+email_send: '&2A jelszó visszaállításhoz szükséges emailt elküldtük! Ellenőrízd a leveleidet!'
+email_exists: '&cA visszaállító emailt elküldtük! Hiba esetén újkérheted az alábbi parancs segítségével:'
+country_banned: '&4Az országod tiltólistán van ezen a szerveren!'
+antibot_auto_enabled: '&4[AntiBot] Az AntiBot védelem bekapcsolt a nagy számú hálózati kapcsolat miatt!'
+antibot_auto_disabled: '&2[AntiBot] Az AntiBot kikapcsol %m múlva!'
+kick_antibot: 'Az AntiBot védelem bekapcsolva! Kérünk várj pár másodpercet a csatlakozáshoz.'