diff --git a/pom.xml b/pom.xml
index dcd0d36f..47b6bb2a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -502,5 +502,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 8371bbb4..1bceb5a5 100644
--- a/src/main/java/fr/xephi/authme/AuthMe.java
+++ b/src/main/java/fr/xephi/authme/AuthMe.java
@@ -11,11 +11,13 @@ import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
+import fr.xephi.authme.command.CommandHandler;
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;
@@ -73,10 +75,21 @@ 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;
@@ -140,6 +153,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 +344,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 +721,10 @@ public class AuthMe extends JavaPlugin {
Settings.switchAntiBotMod(mode);
}
+ public boolean getAntiBotModMode() {
+ return this.antibotMod;
+ }
+
private void recallEmail() {
if (!Settings.recallEmail)
return;
@@ -808,4 +830,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/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/command/CommandArgumentDescription.java b/src/main/java/fr/xephi/authme/command/CommandArgumentDescription.java
new file mode 100644
index 00000000..7efede29
--- /dev/null
+++ b/src/main/java/fr/xephi/authme/command/CommandArgumentDescription.java
@@ -0,0 +1,91 @@
+package fr.xephi.authme.command;
+
+public class CommandArgumentDescription {
+
+ // TODO: Allow argument to consist of infinite parts.