diff --git a/README.md b/README.md
index 056700d3..220a2ced 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,10 @@

The most used authentication plugin for CraftBukkit/Spigot!
+
+####Development history:
+[](https://www.youtube.com/watch?v=hJRzNfYyd9k)
+
#####Development tools:
- DEVELOPMENT TEAM REPO (please send PRs here!): Github Development Page
diff --git a/pom.xml b/pom.xml
index dcd0d36f..ecb05302 100644
--- a/pom.xml
+++ b/pom.xml
@@ -210,12 +210,13 @@
javax.mail
1.5.4
compile
-
-
- activation
- javax.activation
-
-
+ true
+
+
+ javax.mail
+ javax.mail-api
+ 1.5.4
+ compile
true
@@ -502,5 +503,12 @@
true
+
+
+ net.ricecode
+ string-similarity
+ 1.0.0
+
+
diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java
index aae74c27..dbf99b6c 100644
--- a/src/main/java/fr/xephi/authme/AuthMe.java
+++ b/src/main/java/fr/xephi/authme/AuthMe.java
@@ -16,6 +16,7 @@ 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;
@@ -35,15 +36,7 @@ import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.backup.JsonCache;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.cache.limbo.LimboPlayer;
-import fr.xephi.authme.commands.AdminCommand;
-import fr.xephi.authme.commands.CaptchaCommand;
-import fr.xephi.authme.commands.ChangePasswordCommand;
-import fr.xephi.authme.commands.ConverterCommand;
-import fr.xephi.authme.commands.EmailCommand;
-import fr.xephi.authme.commands.LoginCommand;
-import fr.xephi.authme.commands.LogoutCommand;
-import fr.xephi.authme.commands.RegisterCommand;
-import fr.xephi.authme.commands.UnregisterCommand;
+import fr.xephi.authme.command.CommandHandler;
import fr.xephi.authme.converter.Converter;
import fr.xephi.authme.converter.ForceFlatToSqlite;
import fr.xephi.authme.datasource.CacheDataSource;
@@ -68,15 +61,27 @@ import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.OtherAccounts;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.Spawn;
+import fr.xephi.authme.util.Utils;
import net.milkbowl.vault.permission.Permission;
import net.minelink.ctplus.CombatTagPlus;
public class AuthMe extends JavaPlugin {
+ /** Defines the name of the plugin. */
+ // TODO: Create a getter method for this constant, and make it private
+ public static final String PLUGIN_NAME = "AuthMeReloaded";
+ /** Defines the current AuthMeReloaded version name. */
+ private static final String PLUGIN_VERSION_NAME = "5.1-SNAPSHOT";
+ /** Defines the current AuthMeReloaded version code. */
+ private static final int PLUGIN_VERSION_CODE = 100; // Increase this number by one when an update is released
+
private static AuthMe authme;
private static Server server;
private Logger authmeLogger;
+ // TODO: Move this to a better place! -- timvisee
+ private CommandHandler commandHandler = null;
+
public Management management;
public NewAPI api;
public SendMailSSL mail;
@@ -109,7 +114,7 @@ public class AuthMe extends JavaPlugin {
// In case we need to cache PlayerAuths, prevent connection before it's done
private boolean canConnect = true;
- public boolean isCanConnect() {
+ public boolean canConnect() {
return canConnect;
}
@@ -140,6 +145,10 @@ public class AuthMe extends JavaPlugin {
authmeLogger = Logger.getLogger("AuthMe");
authme = this;
+ // Set up and initialize the command handler
+ this.commandHandler = new CommandHandler(false);
+ this.commandHandler.init();
+
// TODO: split the plugin in more modules
moduleManager = new ModuleManager(this);
@SuppressWarnings("unused")
@@ -327,16 +336,17 @@ public class AuthMe extends JavaPlugin {
pm.registerEvents(new AuthMeEntityListener(this), this);
pm.registerEvents(new AuthMeServerListener(this), this);
+ // TODO: This is moved to CommandManager.registerCommands() handled by AuthMe.onCommand() -- timvisee
// Register commands
- getCommand("authme").setExecutor(new AdminCommand(this));
- getCommand("register").setExecutor(new RegisterCommand(this));
- getCommand("login").setExecutor(new LoginCommand(this));
- getCommand("changepassword").setExecutor(new ChangePasswordCommand(this));
- getCommand("logout").setExecutor(new LogoutCommand(this));
- getCommand("unregister").setExecutor(new UnregisterCommand(this));
- getCommand("email").setExecutor(new EmailCommand(this));
- getCommand("captcha").setExecutor(new CaptchaCommand(this));
- getCommand("converter").setExecutor(new ConverterCommand(this));
+ //getCommand("authme").setExecutor(new AdminCommand(this));
+ //getCommand("register").setExecutor(new RegisterCommand(this));
+ //getCommand("login").setExecutor(new LoginCommand(this));
+ //getCommand("changepassword").setExecutor(new ChangePasswordCommand(this));
+ //getCommand("logout").setExecutor(new LogoutCommand(this));
+ //getCommand("unregister").setExecutor(new UnregisterCommand(this));
+ //getCommand("email").setExecutor(new EmailCommand(this));
+ //getCommand("captcha").setExecutor(new CaptchaCommand(this));
+ //getCommand("converter").setExecutor(new ConverterCommand(this));
// Purge on start if enabled
autoPurge();
@@ -703,6 +713,10 @@ public class AuthMe extends JavaPlugin {
Settings.switchAntiBotMod(mode);
}
+ public boolean getAntiBotModMode() {
+ return this.antibotMod;
+ }
+
private void recallEmail() {
if (!Settings.recallEmail)
return;
@@ -808,4 +822,52 @@ public class AuthMe extends JavaPlugin {
public String getCountryName(String ip) {
return Utils.getCountryName(ip);
}
+
+ /**
+ * Get the command handler instance.
+ *
+ * @return Command handler.
+ */
+ public CommandHandler getCommandHandler() {
+ return this.commandHandler;
+ }
+
+ /**
+ * Handle Bukkit commands.
+ *
+ * @param sender The command sender (Bukkit).
+ * @param cmd The command (Bukkit).
+ * @param commandLabel The command label (Bukkit).
+ * @param args The command arguments (Bukkit).
+ *
+ * @return True if the command was executed, false otherwise.
+ */
+ @Override
+ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
+ // Get the command handler, and make sure it's valid
+ CommandHandler commandHandler = this.getCommandHandler();
+ if(commandHandler == null)
+ return false;
+
+ // Handle the command, return the result
+ return commandHandler.onCommand(sender, cmd, commandLabel, args);
+ }
+
+ /**
+ * Get the current installed AuthMeReloaded version name.
+ *
+ * @return The version name of the currently installed AuthMeReloaded instance.
+ */
+ public static String getVersionName() {
+ return PLUGIN_VERSION_NAME;
+ }
+
+ /**
+ * Get the current installed AuthMeReloaded version code.
+ *
+ * @return The version code of the currently installed AuthMeReloaded instance.
+ */
+ public static int getVersionCode() {
+ return PLUGIN_VERSION_CODE;
+ }
}
diff --git a/src/main/java/fr/xephi/authme/ConsoleLogger.java b/src/main/java/fr/xephi/authme/ConsoleLogger.java
index b7e75790..e791e352 100644
--- a/src/main/java/fr/xephi/authme/ConsoleLogger.java
+++ b/src/main/java/fr/xephi/authme/ConsoleLogger.java
@@ -1,5 +1,9 @@
package fr.xephi.authme;
+import com.google.common.base.Throwables;
+import fr.xephi.authme.api.NewAPI;
+import fr.xephi.authme.settings.Settings;
+
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;
@@ -8,39 +12,30 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Logger;
-import com.google.common.base.Throwables;
-
-import fr.xephi.authme.api.NewAPI;
-import fr.xephi.authme.settings.Settings;
-
public class ConsoleLogger {
private static final Logger log = AuthMe.getInstance().getLogger();
private static final DateFormat df = new SimpleDateFormat("[MM-dd HH:mm:ss]");
public static void info(String message) {
- if (AuthMe.getInstance().isEnabled()) {
- log.info("[AuthMe] " + message);
- if (Settings.useLogging) {
- String dateTime;
- synchronized (df) {
- dateTime = df.format(new Date());
- }
- writeLog(dateTime + " " + message);
+ log.info("[AuthMe] " + message);
+ if (Settings.useLogging) {
+ String dateTime;
+ synchronized (df) {
+ dateTime = df.format(new Date());
}
+ writeLog(dateTime + " " + message);
}
}
public static void showError(String message) {
- if (AuthMe.getInstance().isEnabled()) {
- log.warning("[AuthMe] " + message);
- if (Settings.useLogging) {
- String dateTime;
- synchronized (df) {
- dateTime = df.format(new Date());
- }
- writeLog(dateTime + " ERROR: " + message);
+ log.warning("[AuthMe] " + message);
+ if (Settings.useLogging) {
+ String dateTime;
+ synchronized (df) {
+ dateTime = df.format(new Date());
}
+ writeLog(dateTime + " ERROR: " + message);
}
}
@@ -54,10 +49,12 @@ public class ConsoleLogger {
}
public static void writeStackTrace(Exception ex) {
- String dateTime;
- synchronized (df) {
- dateTime = df.format(new Date());
+ if (Settings.useLogging) {
+ String dateTime;
+ synchronized (df) {
+ dateTime = df.format(new Date());
+ }
+ writeLog(dateTime + " " + Throwables.getStackTraceAsString(ex));
}
- writeLog(dateTime + " " + Throwables.getStackTraceAsString(ex));
}
}
diff --git a/src/main/java/fr/xephi/authme/DataManager.java b/src/main/java/fr/xephi/authme/DataManager.java
index 2d08489d..95a9ab53 100644
--- a/src/main/java/fr/xephi/authme/DataManager.java
+++ b/src/main/java/fr/xephi/authme/DataManager.java
@@ -12,6 +12,7 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import fr.xephi.authme.settings.Settings;
+import fr.xephi.authme.util.Utils;
import net.milkbowl.vault.permission.Permission;
public class DataManager {
diff --git a/src/main/java/fr/xephi/authme/SendMailSSL.java b/src/main/java/fr/xephi/authme/SendMailSSL.java
index baac1955..2239f0db 100644
--- a/src/main/java/fr/xephi/authme/SendMailSSL.java
+++ b/src/main/java/fr/xephi/authme/SendMailSSL.java
@@ -112,10 +112,10 @@ public class SendMailSSL {
if (file != null)
file.delete();
- } catch (RuntimeException e) {
- ConsoleLogger.showError("Some error occured while trying to send a email to " + mail);
- } catch (Exception e) {
- ConsoleLogger.showError("Some error occured while trying to send a email to " + mail);
+ } catch(Exception e) {
+ // Print the stack trace
+ e.printStackTrace();
+ ConsoleLogger.showError("Some error occurred while trying to send a email to " + mail);
}
}
diff --git a/src/main/java/fr/xephi/authme/api/API.java b/src/main/java/fr/xephi/authme/api/API.java
index 79eaeaff..96dcc2a6 100644
--- a/src/main/java/fr/xephi/authme/api/API.java
+++ b/src/main/java/fr/xephi/authme/api/API.java
@@ -9,11 +9,11 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import fr.xephi.authme.AuthMe;
-import fr.xephi.authme.Utils;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.settings.Settings;
+import fr.xephi.authme.util.Utils;
public class API {
diff --git a/src/main/java/fr/xephi/authme/api/NewAPI.java b/src/main/java/fr/xephi/authme/api/NewAPI.java
index e1426f6f..6c48286a 100644
--- a/src/main/java/fr/xephi/authme/api/NewAPI.java
+++ b/src/main/java/fr/xephi/authme/api/NewAPI.java
@@ -9,11 +9,11 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import fr.xephi.authme.AuthMe;
-import fr.xephi.authme.Utils;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.settings.Settings;
+import fr.xephi.authme.util.Utils;
public class NewAPI {
diff --git a/src/main/java/fr/xephi/authme/cache/backup/JsonCache.java b/src/main/java/fr/xephi/authme/cache/backup/JsonCache.java
index 837bf45a..31c647cb 100644
--- a/src/main/java/fr/xephi/authme/cache/backup/JsonCache.java
+++ b/src/main/java/fr/xephi/authme/cache/backup/JsonCache.java
@@ -19,8 +19,8 @@ import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import fr.xephi.authme.ConsoleLogger;
-import fr.xephi.authme.Utils;
import fr.xephi.authme.settings.Settings;
+import fr.xephi.authme.util.Utils;
public class JsonCache {
diff --git a/src/main/java/fr/xephi/authme/command/CommandArgumentDescription.java b/src/main/java/fr/xephi/authme/command/CommandArgumentDescription.java
new file mode 100644
index 00000000..a5ea63d0
--- /dev/null
+++ b/src/main/java/fr/xephi/authme/command/CommandArgumentDescription.java
@@ -0,0 +1,90 @@
+package fr.xephi.authme.command;
+
+public class CommandArgumentDescription {
+
+ // TODO: Allow argument to consist of infinite parts.