From 1c2cc959cc7b20d7ffbe2f38f1a7e371fb5fcf44 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sun, 8 Nov 2015 14:51:46 +0100 Subject: [PATCH 01/12] cleanup --- pom.xml | 39 ++++++++++++++--------------------- src/main/resources/plugin.yml | 12 +++++------ 2 files changed, 22 insertions(+), 29 deletions(-) diff --git a/pom.xml b/pom.xml index 451aed586..485f9f5c7 100644 --- a/pom.xml +++ b/pom.xml @@ -2,57 +2,61 @@ 4.0.0 - + fr.xephi authme 5.1-SNAPSHOT jar - + AuthMeReloaded Authentication plugin for CraftBukkit/Spigot! 2013 http://dev.bukkit.org/bukkit-plugins/authme-reloaded/ - + AuthMe-Team https://github.com/AuthMe-Team - + scm:git:https://github.com/Xephi/AuthMeReloaded.git scm:git:git@github.com:Xephi/AuthMeReloaded.git http://github.com/Xephi/AuthMeReloaded - - + jenkins http://ci.xephi.fr/job/AuthMeReloaded/ - + GitHub https://github.com/Xephi/AuthMeReloaded/issues - + The GNU General Public Licence version 3 (GPLv3) http://www.gnu.org/licenses/gpl-3.0.html - + + UTF-8 + fr.xephi.authme.AuthMe + CustomBuild + [Xephi, sgdc3, DNx5, timvisee, games647] + 1.7 - + 1.8.8-R0.1-SNAPSHOT - AuthMe-${project.version} + ${project.name} . @@ -112,7 +116,6 @@ - spigot-repo @@ -155,23 +158,14 @@ http://repo.luricos.de/content/repositories/releases - + xephi-repo http://ci.xephi.fr/plugin/repository/everything/ - - - - com.zaxxer @@ -511,6 +505,5 @@ compile true - diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 276773ca5..65b1321c5 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,10 +1,10 @@ -name: AuthMe -author: Xephi59 -website: http://dev.bukkit.org/bukkit-plugins/authme-reloaded/ -description: AuthMe prevents people, which aren't logged in, from doing stuff like placing blocks, moving, typing commands or seeing the inventory of the player. -main: fr.xephi.authme.AuthMe +name: ${project.name} +authors: ${pluginAuthors} +website: ${project.url} +description: ${project.description} +main: ${mainClass} version: ${project.version} -softdepend: [Vault, ChestShop, Multiverse-Core, Citizens, CombatTag, Essentials, EssentialsSpawn, PerWorldInventories, ProtocolLib] +softdepend: [Vault, Multiverse-Core, Essentials, EssentialsSpawn, ProtocolLib] commands: register: description: Register an account From 0828bcc3da2326b8ef58360ac9a041bd20dff734 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sun, 8 Nov 2015 17:53:17 +0100 Subject: [PATCH 02/12] Update circle.yml --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index 6da929d44..1b08b3a99 100644 --- a/circle.yml +++ b/circle.yml @@ -3,7 +3,7 @@ machine: version: oraclejdk7 general: artifacts: - - "target/AuthMe-*.jar" + - "target/AuthMeReloaded.jar" test: override: - mvn clean install -B From 6bff45f0ed62f3fa388bc33b1edf1f6a6ecf355c Mon Sep 17 00:00:00 2001 From: Xephi59 Date: Sun, 8 Nov 2015 19:31:44 +0100 Subject: [PATCH 03/12] Fix Mail Recovery --- pom.xml | 9 +----- .../java/fr/xephi/authme/SendMailSSL.java | 30 +++++++++++-------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/pom.xml b/pom.xml index 451aed586..4953a82d2 100644 --- a/pom.xml +++ b/pom.xml @@ -87,7 +87,7 @@ 2.4.2 false - true + false org.mcstats @@ -212,13 +212,6 @@ compile true - - javax.mail - javax.mail-api - 1.5.4 - provided - true - diff --git a/src/main/java/fr/xephi/authme/SendMailSSL.java b/src/main/java/fr/xephi/authme/SendMailSSL.java index 2239f0db6..4af471f98 100644 --- a/src/main/java/fr/xephi/authme/SendMailSSL.java +++ b/src/main/java/fr/xephi/authme/SendMailSSL.java @@ -12,6 +12,7 @@ import javax.imageio.ImageIO; import javax.mail.BodyPart; import javax.mail.Message; import javax.mail.Multipart; +import javax.mail.PasswordAuthentication; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; @@ -62,8 +63,16 @@ public class SendMailSSL { props.put("mail.smtp.host", smtp); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.port", port); + props.put("mail.smtp.socketFactory.port", port); + props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); props.put("mail.smtp.starttls.enable", true); - Session session = Session.getInstance(props, null); + props.put("mail.smtp.socketFactory.fallback", false); + Session session = Session.getInstance(props, new javax.mail.Authenticator() { + + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(acc, password); + } + }); Message message = new MimeMessage(session); try { @@ -71,7 +80,7 @@ public class SendMailSSL { } catch (UnsupportedEncodingException uee) { message.setFrom(new InternetAddress(acc)); } - message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(mail)); + message.addRecipient(Message.RecipientType.TO, new InternetAddress(mail)); message.setSubject(subject); message.setSentDate(new Date()); BodyPart messageBodyPart = new MimeBodyPart(); @@ -96,23 +105,20 @@ public class SendMailSSL { } } - Transport transport = session.getTransport("smtp"); message.setContent(multipart); - try { - transport.connect(smtp, acc, password); + Transport transport = session.getTransport("smtp"); + transport.connect(smtp, Integer.parseInt(port), acc, password); + transport.sendMessage(message, message.getAllRecipients()); + transport.close(); } catch (Exception e) { - ConsoleLogger.showError("Can't connect to your SMTP server! Aborting! Can't send recovery email to " + mail); - if (file != null) - file.delete(); - return; + e.printStackTrace(); + ConsoleLogger.showError("Cannot send email to " + mail + ", an error occured!"); } - transport.sendMessage(message, message.getAllRecipients()); - if (file != null) file.delete(); - } catch(Exception e) { + } catch (Exception e) { // Print the stack trace e.printStackTrace(); ConsoleLogger.showError("Some error occurred while trying to send a email to " + mail); From 7f4db3a85b24b573c3c6fc80914c6bb7214a5013 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Tue, 10 Nov 2015 18:37:53 +0100 Subject: [PATCH 04/12] cleanup --- src/main/java/fr/xephi/authme/AuthMe.java | 6 +++--- .../java/fr/xephi/authme/listener/AuthMePlayerListener.java | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java index 43d6a7100..a9302bb57 100644 --- a/src/main/java/fr/xephi/authme/AuthMe.java +++ b/src/main/java/fr/xephi/authme/AuthMe.java @@ -74,7 +74,7 @@ public class AuthMe extends JavaPlugin { /** 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 AuthMe plugin; private static Server server; private Logger authmeLogger; @@ -122,7 +122,7 @@ public class AuthMe extends JavaPlugin { } public static AuthMe getInstance() { - return authme; + return plugin; } public Settings getSettings() { @@ -142,7 +142,7 @@ public class AuthMe extends JavaPlugin { // Set the Instance server = getServer(); authmeLogger = Logger.getLogger("AuthMe"); - authme = this; + plugin = this; // Set up and initialize the command handler this.commandHandler = new CommandHandler(false); diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java index fda2caa7a..c393e5099 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java @@ -227,6 +227,7 @@ public class AuthMePlayerListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST) public void onPreLogin(AsyncPlayerPreLoginEvent event) { final String name = event.getName().toLowerCase(); + @SuppressWarnings("deprecation") final Player player = plugin.getServer().getPlayer(name); if (player == null) return; From 2c45cece003dbe6450942d0ff4de50e242b9e842 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Tue, 10 Nov 2015 18:43:24 +0100 Subject: [PATCH 05/12] fix plugin name (i'm an idiot -_-) --- circle.yml | 2 +- pom.xml | 2 +- src/main/resources/plugin.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/circle.yml b/circle.yml index 1b08b3a99..6da929d44 100644 --- a/circle.yml +++ b/circle.yml @@ -3,7 +3,7 @@ machine: version: oraclejdk7 general: artifacts: - - "target/AuthMeReloaded.jar" + - "target/AuthMe-*.jar" test: override: - mvn clean install -B diff --git a/pom.xml b/pom.xml index aaf0da14e..a41fa0173 100644 --- a/pom.xml +++ b/pom.xml @@ -56,7 +56,7 @@ - ${project.name} + AuthMe-${project.version} . diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 65b1321c5..574596388 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,4 +1,4 @@ -name: ${project.name} +name: AuthMe authors: ${pluginAuthors} website: ${project.url} description: ${project.description} From 8a4f2c5ef81926307dc3cec05145dbc4eaa1716e Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Tue, 10 Nov 2015 19:28:17 +0100 Subject: [PATCH 06/12] I love to clean code and stuff --- pom.xml | 34 + src/main/java/fr/xephi/authme/AuthMe.java | 4 +- .../xephi/authme/commands/AdminCommand.java | 610 ------------------ .../xephi/authme/commands/CaptchaCommand.java | 78 --- .../commands/ChangePasswordCommand.java | 69 -- .../authme/commands/ConverterCommand.java | 114 ---- .../xephi/authme/commands/EmailCommand.java | 116 ---- .../xephi/authme/commands/LoginCommand.java | 41 -- .../xephi/authme/commands/LogoutCommand.java | 37 -- .../authme/commands/RegisterCommand.java | 65 -- .../authme/commands/UnregisterCommand.java | 49 -- .../manager => hooks}/BungeeCordMessage.java | 2 +- .../{plugin/manager => hooks}/EssSpawn.java | 2 +- src/main/java/fr/xephi/authme/util/Utils.java | 11 - 14 files changed, 38 insertions(+), 1194 deletions(-) delete mode 100644 src/main/java/fr/xephi/authme/commands/AdminCommand.java delete mode 100644 src/main/java/fr/xephi/authme/commands/CaptchaCommand.java delete mode 100644 src/main/java/fr/xephi/authme/commands/ChangePasswordCommand.java delete mode 100644 src/main/java/fr/xephi/authme/commands/ConverterCommand.java delete mode 100644 src/main/java/fr/xephi/authme/commands/EmailCommand.java delete mode 100644 src/main/java/fr/xephi/authme/commands/LoginCommand.java delete mode 100644 src/main/java/fr/xephi/authme/commands/LogoutCommand.java delete mode 100644 src/main/java/fr/xephi/authme/commands/RegisterCommand.java delete mode 100644 src/main/java/fr/xephi/authme/commands/UnregisterCommand.java rename src/main/java/fr/xephi/authme/{plugin/manager => hooks}/BungeeCordMessage.java (96%) rename src/main/java/fr/xephi/authme/{plugin/manager => hooks}/EssSpawn.java (97%) diff --git a/pom.xml b/pom.xml index a41fa0173..62a4d4f8d 100644 --- a/pom.xml +++ b/pom.xml @@ -51,6 +51,7 @@ 1.7 + 1.8.8-R0.1-SNAPSHOT @@ -92,6 +93,7 @@ false false + org.mcstats @@ -101,6 +103,38 @@ com.google.gson fr.xephi.authme.libs.gson + + com.zaxxer.hikari + fr.xephi.authme.libs.hikari + + + org.slf4j + fr.xephi.authme.libs.slf4j + + + javax.mail + fr.xephi.authme.libs.mail + + + javax.activation + fr.xephi.authme.libs.mail.activation + + + com.sun.activation + fr.xephi.authme.libs.mail.activation + + + com.sun.mail + fr.xephi.authme.libs.mail + + + com.maxmind.geoip + fr.xephi.authme.libs.geoip + + + net.ricecode.similarity + fr.xephi.authme.libs.similarity + diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java index a9302bb57..893814ac6 100644 --- a/src/main/java/fr/xephi/authme/AuthMe.java +++ b/src/main/java/fr/xephi/authme/AuthMe.java @@ -45,6 +45,8 @@ import fr.xephi.authme.datasource.DatabaseCalls; import fr.xephi.authme.datasource.FlatFile; import fr.xephi.authme.datasource.MySQL; import fr.xephi.authme.datasource.SQLite; +import fr.xephi.authme.hooks.BungeeCordMessage; +import fr.xephi.authme.hooks.EssSpawn; import fr.xephi.authme.listener.AuthMeBlockListener; import fr.xephi.authme.listener.AuthMeEntityListener; import fr.xephi.authme.listener.AuthMeInventoryPacketAdapter; @@ -53,8 +55,6 @@ import fr.xephi.authme.listener.AuthMePlayerListener16; import fr.xephi.authme.listener.AuthMePlayerListener18; import fr.xephi.authme.listener.AuthMeServerListener; import fr.xephi.authme.modules.ModuleManager; -import fr.xephi.authme.plugin.manager.BungeeCordMessage; -import fr.xephi.authme.plugin.manager.EssSpawn; import fr.xephi.authme.process.Management; import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.OtherAccounts; diff --git a/src/main/java/fr/xephi/authme/commands/AdminCommand.java b/src/main/java/fr/xephi/authme/commands/AdminCommand.java deleted file mode 100644 index 78b054827..000000000 --- a/src/main/java/fr/xephi/authme/commands/AdminCommand.java +++ /dev/null @@ -1,610 +0,0 @@ -package fr.xephi.authme.commands; - -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.List; - -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.OfflinePlayer; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; -import org.bukkit.scheduler.BukkitScheduler; -import org.bukkit.scheduler.BukkitTask; - -import fr.xephi.authme.AuthMe; -import fr.xephi.authme.ConsoleLogger; -import fr.xephi.authme.cache.auth.PlayerAuth; -import fr.xephi.authme.cache.auth.PlayerCache; -import fr.xephi.authme.cache.limbo.LimboCache; -import fr.xephi.authme.events.SpawnTeleportEvent; -import fr.xephi.authme.security.PasswordSecurity; -import fr.xephi.authme.settings.Messages; -import fr.xephi.authme.settings.Settings; -import fr.xephi.authme.settings.Spawn; -import fr.xephi.authme.task.MessageTask; -import fr.xephi.authme.task.TimeoutTask; -import fr.xephi.authme.util.Utils; -import fr.xephi.authme.util.Utils.GroupType; - -public class AdminCommand implements CommandExecutor { - - public AuthMe plugin; - private Messages m = Messages.getInstance(); - - public AdminCommand(AuthMe plugin) { - this.plugin = plugin; - } - - @Override - public boolean onCommand(final CommandSender sender, Command cmnd, - String label, String[] args) { - if (args.length == 0) { - sender.sendMessage("Usage:"); - sender.sendMessage("/authme reload - Reload the config"); - sender.sendMessage("/authme version - Get AuthMe version info"); - sender.sendMessage("/authme register - Register a player"); - sender.sendMessage("/authme unregister - Unregister a player"); - sender.sendMessage("/authme changepassword - Change a player's password"); - sender.sendMessage("/authme chgemail - Change a player's email"); - sender.sendMessage("/authme getemail - Get a player's email"); - sender.sendMessage("/authme getip - Display a player's IP if he's online"); - sender.sendMessage("/authme lastlogin - Display the date of a player's last login"); - sender.sendMessage("/authme accounts - Display all player's accounts"); - sender.sendMessage("/authme purge - Purge database"); - sender.sendMessage("/authme purgebannedplayers - Purge database from banned players"); - sender.sendMessage("/authme purgelastpos - Purge last position infos for a player"); - sender.sendMessage("/authme setspawn - Set player's spawn to your current position"); - sender.sendMessage("/authme setfirstspawn - Set player's first spawn to your current position"); - sender.sendMessage("/authme spawn - Teleport yourself to the spawn point"); - sender.sendMessage("/authme firstspawn - Teleport yourself to the first spawn point"); - sender.sendMessage("/authme switchantibot on/off - Enable/Disable AntiBot feature"); - sender.sendMessage("/authme forcelogin - Enforce the login of a connected player"); - return true; - } - - if (!plugin.authmePermissible(sender, "authme.admin." + args[0].toLowerCase())) { - m.send(sender, "no_perm"); - return true; - } - - if (args[0].equalsIgnoreCase("version")) { - sender.sendMessage("AuthMe Version: " + AuthMe.getInstance().getDescription().getVersion()); - return true; - } - - if (args[0].equalsIgnoreCase("purge")) { - if (args.length != 2) { - sender.sendMessage("Usage: /authme purge "); - return true; - } - if (Integer.parseInt(args[1]) < 30) { - sender.sendMessage("You can only purge data older than 30 days"); - return true; - } - try { - Calendar calendar = Calendar.getInstance(); - calendar.add(Calendar.DATE, -(Integer.parseInt(args[1]))); - long until = calendar.getTimeInMillis(); - List purged = plugin.database.autoPurgeDatabase(until); - sender.sendMessage("Deleted " + purged.size() + " user accounts"); - if (Settings.purgeEssentialsFile && plugin.ess != null) - plugin.dataManager.purgeEssentials(purged); - if (Settings.purgePlayerDat) - plugin.dataManager.purgeDat(purged); - if (Settings.purgeLimitedCreative) - plugin.dataManager.purgeLimitedCreative(purged); - if (Settings.purgeAntiXray) - plugin.dataManager.purgeAntiXray(purged); - sender.sendMessage("[AuthMe] Database has been purged correctly"); - return true; - } catch (NumberFormatException e) { - sender.sendMessage("Usage: /authme purge "); - return true; - } - } else if (args[0].equalsIgnoreCase("reload")) { - try { - Settings.reload(); - plugin.getModuleManager().reloadModules(); - m.reloadMessages(); - plugin.setupDatabase(); - } catch (Exception e) { - ConsoleLogger.showError("Fatal error occurred! Authme instance ABORTED!"); - ConsoleLogger.writeStackTrace(e); - plugin.stopOrUnload(); - return false; - } - m.send(sender, "reload"); - } else if (args[0].equalsIgnoreCase("lastlogin")) { - if (args.length != 2) { - sender.sendMessage("Usage: /authme lastlogin "); - return true; - } - PlayerAuth auth; - try { - auth = plugin.database.getAuth(args[1].toLowerCase()); - } catch (NullPointerException e) { - m.send(sender, "unknown_user"); - return true; - } - if (auth == null) { - m.send(sender, "user_unknown"); - return true; - } - long lastLogin = auth.getLastLogin(); - Date d = new Date(lastLogin); - final long diff = System.currentTimeMillis() - lastLogin; - final String msg = (int) (diff / 86400000) + " days " + (int) (diff / 3600000 % 24) + " hours " + (int) (diff / 60000 % 60) + " mins " + (int) (diff / 1000 % 60) + " secs."; - String lastIP = auth.getIp(); - sender.sendMessage("[AuthMe] " + args[1] + " lastlogin : " + d.toString()); - sender.sendMessage("[AuthMe] The player " + auth.getNickname() + " is unlogged since " + msg); - sender.sendMessage("[AuthMe] Last Player's IP: " + lastIP); - } else if (args[0].equalsIgnoreCase("accounts")) { - if (args.length != 2) { - sender.sendMessage("Usage: /authme accounts "); - sender.sendMessage("Or: /authme accounts "); - return true; - } - if (!args[1].contains(".")) { - final String[] arguments = args; - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { - - @Override - public void run() { - PlayerAuth auth; - StringBuilder message = new StringBuilder("[AuthMe] "); - try { - auth = plugin.database.getAuth(arguments[1].toLowerCase()); - } catch (NullPointerException npe) { - m.send(sender, "unknown_user"); - return; - } - if (auth == null) { - m.send(sender, "unknown_user"); - return; - } - List accountList = plugin.database.getAllAuthsByName(auth); - if (accountList == null || accountList.isEmpty()) { - m.send(sender, "user_unknown"); - return; - } - if (accountList.size() == 1) { - sender.sendMessage("[AuthMe] " + arguments[1] + " is a single account player"); - return; - } - int i = 0; - for (String account : accountList) { - i++; - message.append(account); - if (i != accountList.size()) { - message.append(", "); - } else { - message.append("."); - } - } - sender.sendMessage("[AuthMe] " + arguments[1] + " has " + String.valueOf(accountList.size()) + " accounts"); - sender.sendMessage(message.toString()); - } - }); - return true; - } else { - final String[] arguments = args; - Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { - - @Override - public void run() { - StringBuilder message = new StringBuilder("[AuthMe] "); - if (arguments[1] == null) { - sender.sendMessage("[AuthMe] Please put a valid IP"); - return; - } - List accountList = null; - try { - accountList = plugin.database.getAllAuthsByIp(arguments[1]); - } catch (Exception e) { - ConsoleLogger.showError(e.getMessage()); - ConsoleLogger.writeStackTrace(e); - m.send(sender, "error"); - return; - } - if (accountList == null || accountList.isEmpty()) { - sender.sendMessage("[AuthMe] This IP does not exist in the database"); - return; - } - if (accountList.size() == 1) { - sender.sendMessage("[AuthMe] " + arguments[1] + " is a single account player"); - return; - } - int i = 0; - for (String account : accountList) { - i++; - message.append(account); - if (i != accountList.size()) { - message.append(", "); - } else { - message.append("."); - } - } - sender.sendMessage("[AuthMe] " + arguments[1] + " has " + String.valueOf(accountList.size()) + " accounts"); - sender.sendMessage(message.toString()); - } - }); - return true; - } - } else if (args[0].equalsIgnoreCase("register") || args[0].equalsIgnoreCase("reg")) { - if (args.length != 3) { - sender.sendMessage("Usage: /authme register "); - return true; - } - final String name = args[1].toLowerCase(); - final String realName = args[1]; - final String lowpass = args[2].toLowerCase(); - if (lowpass.contains("delete") || lowpass.contains("where") || lowpass.contains("insert") || lowpass.contains("modify") || lowpass.contains("from") || lowpass.contains("select") || lowpass.contains(";") || lowpass.contains("null") || !lowpass.matches(Settings.getPassRegex)) { - m.send(sender, "password_error"); - return true; - } - if (lowpass.equalsIgnoreCase(args[1])) { - m.send(sender, "password_error_nick"); - return true; - } - if (lowpass.length() < Settings.getPasswordMinLen || lowpass.length() > Settings.passwordMaxLength) { - m.send(sender, "pass_len"); - return true; - } - if (!Settings.unsafePasswords.isEmpty()) { - if (Settings.unsafePasswords.contains(lowpass)) { - m.send(sender, "password_error_unsafe"); - return true; - } - } - plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() { - - @SuppressWarnings("deprecation") - @Override - public void run() { - try { - if (plugin.database.isAuthAvailable(name)) { - m.send(sender, "user_regged"); - return; - } - String hash = PasswordSecurity.getHash(Settings.getPasswordHash, lowpass, name); - PlayerAuth auth = new PlayerAuth(name, hash, "192.168.0.1", 0L, "your@email.com", realName); - if (PasswordSecurity.userSalt.containsKey(name) && PasswordSecurity.userSalt.get(name) != null) - auth.setSalt(PasswordSecurity.userSalt.get(name)); - else auth.setSalt(""); - if (!plugin.database.saveAuth(auth)) { - m.send(sender, "error"); - return; - } - plugin.database.setUnlogged(name); - if (Bukkit.getPlayerExact(realName) != null) - Bukkit.getPlayerExact(realName).kickPlayer("An admin just registered you, please log again"); - m.send(sender, "registered"); - ConsoleLogger.info(name + " registered"); - } catch (NoSuchAlgorithmException ex) { - ConsoleLogger.showError(ex.getMessage()); - m.send(sender, "error"); - } - - } - }); - return true; - } else if (args[0].equalsIgnoreCase("getemail")) { - if (args.length != 2) { - sender.sendMessage("Usage: /authme getemail "); - return true; - } - String playername = args[1].toLowerCase(); - PlayerAuth auth = plugin.database.getAuth(playername); - if (auth == null) { - m.send(sender, "unknown_user"); - return true; - } - sender.sendMessage("[AuthMe] " + args[1] + "'s email: " + auth.getEmail()); - return true; - } else if (args[0].equalsIgnoreCase("chgemail")) { - if (args.length != 3) { - sender.sendMessage("Usage: /authme chgemail "); - return true; - } - if (!Settings.isEmailCorrect(args[2])) { - m.send(sender, "email_invalid"); - return true; - } - String playername = args[1].toLowerCase(); - PlayerAuth auth = plugin.database.getAuth(playername); - if (auth == null) { - m.send(sender, "unknown_user"); - return true; - } - auth.setEmail(args[2]); - if (!plugin.database.updateEmail(auth)) { - m.send(sender, "error"); - return true; - } - if (PlayerCache.getInstance().getAuth(playername) != null) - PlayerCache.getInstance().updatePlayer(auth); - m.send(sender, "email_changed"); - return true; - } else if (args[0].equalsIgnoreCase("setspawn")) { - try { - if (sender instanceof Player) { - if (Spawn.getInstance().setSpawn(((Player) sender).getLocation())) { - sender.sendMessage("[AuthMe] Correctly defined new spawn point"); - } else { - sender.sendMessage("[AuthMe] SetSpawn has failed, please retry"); - } - } else { - sender.sendMessage("[AuthMe] Please use that command in game"); - } - } catch (NullPointerException ex) { - ConsoleLogger.showError(ex.getMessage()); - } - return true; - } else if (args[0].equalsIgnoreCase("setfirstspawn")) { - try { - if (sender instanceof Player) { - if (Spawn.getInstance().setFirstSpawn(((Player) sender).getLocation())) - sender.sendMessage("[AuthMe] Correctly defined new first spawn point"); - else sender.sendMessage("[AuthMe] SetFirstSpawn has failed, please retry"); - } else { - sender.sendMessage("[AuthMe] Please use that command in game"); - } - } catch (NullPointerException ex) { - ConsoleLogger.showError(ex.getMessage()); - } - return true; - } else if (args[0].equalsIgnoreCase("purgebannedplayers")) { - List bannedPlayers = new ArrayList<>(); - for (OfflinePlayer off : plugin.getServer().getBannedPlayers()) { - bannedPlayers.add(off.getName().toLowerCase()); - } - plugin.database.purgeBanned(bannedPlayers); - if (Settings.purgeEssentialsFile && plugin.ess != null) - plugin.dataManager.purgeEssentials(bannedPlayers); - if (Settings.purgePlayerDat) - plugin.dataManager.purgeDat(bannedPlayers); - if (Settings.purgeLimitedCreative) - plugin.dataManager.purgeLimitedCreative(bannedPlayers); - if (Settings.purgeAntiXray) - plugin.dataManager.purgeAntiXray(bannedPlayers); - sender.sendMessage("[AuthMe] Database has been purged correctly"); - return true; - } else if (args[0].equalsIgnoreCase("spawn")) { - try { - if (sender instanceof Player) { - if (Spawn.getInstance().getSpawn() != null) - ((Player) sender).teleport(Spawn.getInstance().getSpawn()); - else sender.sendMessage("[AuthMe] Spawn has failed, please try to define the spawn"); - } else { - sender.sendMessage("[AuthMe] Please use that command in game"); - } - } catch (NullPointerException ex) { - ConsoleLogger.showError(ex.getMessage()); - } - return true; - } else if (args[0].equalsIgnoreCase("firstspawn")) { - try { - if (sender instanceof Player) { - if (Spawn.getInstance().getFirstSpawn() != null) - ((Player) sender).teleport(Spawn.getInstance().getFirstSpawn()); - else sender.sendMessage("[AuthMe] First spawn has failed, please try to define the first spawn"); - } else { - sender.sendMessage("[AuthMe] Please use that command in game"); - } - } catch (NullPointerException ex) { - ConsoleLogger.showError(ex.getMessage()); - } - return true; - } else if (args[0].equalsIgnoreCase("changepassword") || args[0].equalsIgnoreCase("cp")) { - if (args.length != 3) { - sender.sendMessage("Usage: /authme changepassword "); - return true; - } - String lowpass = args[2].toLowerCase(); - if (lowpass.contains("delete") || lowpass.contains("where") || lowpass.contains("insert") || lowpass.contains("modify") || lowpass.contains("from") || lowpass.contains("select") || lowpass.contains(";") || lowpass.contains("null") || !lowpass.matches(Settings.getPassRegex)) { - m.send(sender, "password_error"); - return true; - } - if (lowpass.equalsIgnoreCase(args[1])) { - m.send(sender, "password_error_nick"); - return true; - } - if (lowpass.length() < Settings.getPasswordMinLen || lowpass.length() > Settings.passwordMaxLength) { - m.send(sender, "pass_len"); - return true; - } - if (!Settings.unsafePasswords.isEmpty()) { - if (Settings.unsafePasswords.contains(lowpass)) { - m.send(sender, "password_error_unsafe"); - return true; - } - } - final String name = args[1].toLowerCase(); - final String raw = args[2]; - Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { - - @Override - public void run() { - String hash; - try { - hash = PasswordSecurity.getHash(Settings.getPasswordHash, raw, name); - } catch (NoSuchAlgorithmException e) { - m.send(sender, "error"); - return; - } - PlayerAuth auth = null; - if (PlayerCache.getInstance().isAuthenticated(name)) { - auth = PlayerCache.getInstance().getAuth(name); - } else if (plugin.database.isAuthAvailable(name)) { - auth = plugin.database.getAuth(name); - } - if (auth == null) { - m.send(sender, "unknown_user"); - return; - } - auth.setHash(hash); - if (PasswordSecurity.userSalt.containsKey(name)) { - auth.setSalt(PasswordSecurity.userSalt.get(name)); - plugin.database.updateSalt(auth); - } - if (!plugin.database.updatePassword(auth)) { - m.send(sender, "error"); - return; - } - sender.sendMessage("pwd_changed"); - ConsoleLogger.info(name + "'s password changed"); - } - - }); - return true; - } else if (args[0].equalsIgnoreCase("unregister") || args[0].equalsIgnoreCase("unreg") || args[0].equalsIgnoreCase("del")) { - if (args.length != 2) { - sender.sendMessage("Usage: /authme unregister "); - return true; - } - String name = args[1].toLowerCase(); - if (!plugin.database.isAuthAvailable(name)) { - m.send(sender, "user_unknown"); - return true; - } - if (!plugin.database.removeAuth(name)) { - m.send(sender, "error"); - return true; - } - @SuppressWarnings("deprecation") - Player target = Bukkit.getPlayer(name); - PlayerCache.getInstance().removePlayer(name); - Utils.setGroup(target, GroupType.UNREGISTERED); - if (target != null && target.isOnline()) { - if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) { - Location spawn = plugin.getSpawnLocation(target); - SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(target, target.getLocation(), spawn, false); - plugin.getServer().getPluginManager().callEvent(tpEvent); - if (!tpEvent.isCancelled() && tpEvent.getTo() != null) { - target.teleport(tpEvent.getTo()); - } - } - LimboCache.getInstance().addLimboPlayer(target); - int delay = Settings.getRegistrationTimeout * 20; - int interval = Settings.getWarnMessageInterval; - BukkitScheduler sched = sender.getServer().getScheduler(); - if (delay != 0) { - BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, target), delay); - LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id); - } - LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("reg_msg"), interval))); - if (Settings.applyBlindEffect) - target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2)); - if (!Settings.isMovementAllowed && Settings.isRemoveSpeedEnabled) { - target.setWalkSpeed(0.0f); - target.setFlySpeed(0.0f); - } - m.send(target, "unregistered"); - - } - m.send(sender, "unregistered"); - ConsoleLogger.info(args[1] + " unregistered"); - return true; - } else if (args[0].equalsIgnoreCase("purgelastpos") || args[0].equalsIgnoreCase("resetposition")) { - if (args.length != 2) { - sender.sendMessage("Usage: /authme purgelastpos "); - return true; - } - try { - String name = args[1].toLowerCase(); - PlayerAuth auth = plugin.database.getAuth(name); - if (auth == null) { - m.send(sender, "unknown_user"); - return true; - } - auth.setQuitLocX(0D); - auth.setQuitLocY(0D); - auth.setQuitLocZ(0D); - auth.setWorld("world"); - plugin.database.updateQuitLoc(auth); - sender.sendMessage(name + "'s last position location is now reset"); - } catch (Exception e) { - ConsoleLogger.showError("An error occured while trying to reset location or player do not exist, please see below: "); - ConsoleLogger.showError(e.getMessage()); - if (sender instanceof Player) - sender.sendMessage("An error occured while trying to reset location or player do not exist, please see logs"); - } - return true; - } else if (args[0].equalsIgnoreCase("switchantibot")) { - if (args.length != 2) { - sender.sendMessage("Usage: /authme switchantibot on/off"); - return true; - } - if (args[1].equalsIgnoreCase("on")) { - plugin.switchAntiBotMod(true); - sender.sendMessage("[AuthMe] AntiBotMod enabled"); - return true; - } - if (args[1].equalsIgnoreCase("off")) { - plugin.switchAntiBotMod(false); - sender.sendMessage("[AuthMe] AntiBotMod disabled"); - return true; - } - sender.sendMessage("Usage: /authme switchantibot on/off"); - return true; - } else if (args[0].equalsIgnoreCase("getip")) { - if (args.length < 2) { - sender.sendMessage("Usage: /authme getip "); - return true; - } - @SuppressWarnings("deprecation") - Player player = Bukkit.getPlayer(args[1]); - if (player == null) { - sender.sendMessage("This player is not actually online"); - sender.sendMessage("Usage: /authme getip "); - return true; - } - sender.sendMessage(player.getName() + "'s actual IP is : " + player.getAddress().getAddress().getHostAddress() + ":" + player.getAddress().getPort()); - sender.sendMessage(player.getName() + "'s real IP is : " + plugin.getIP(player)); - return true; - } else if (args[0].equalsIgnoreCase("forcelogin")) { - if (args.length < 2) { - sender.sendMessage("Usage: /authme forcelogin "); - return true; - } - try { - @SuppressWarnings("deprecation") - Player player = Bukkit.getPlayer(args[1]); - if (player == null || !player.isOnline()) { - sender.sendMessage("Player needs to be online!"); - return true; - } - if (!plugin.authmePermissible(player, "authme.canbeforced")) { - sender.sendMessage("You cannot force login for this player!"); - return true; - } - plugin.management.performLogin(player, "dontneed", true); - sender.sendMessage("Force Login performed!"); - } catch (Exception e) { - sender.sendMessage("An error occured while trying to get that player!"); - } - } else if (args[0].equalsIgnoreCase("resetname")) { - Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { - - @Override - public void run() { - List auths = plugin.database.getAllAuths(); - for (PlayerAuth auth : auths) { - auth.setRealName("Player"); - plugin.database.updateSession(auth); - } - } - }); - } else { - sender.sendMessage("Usage: /authme reload|register playername password|changepassword playername password|unregister playername"); - } - return true; - } -} diff --git a/src/main/java/fr/xephi/authme/commands/CaptchaCommand.java b/src/main/java/fr/xephi/authme/commands/CaptchaCommand.java deleted file mode 100644 index 0c0e242ae..000000000 --- a/src/main/java/fr/xephi/authme/commands/CaptchaCommand.java +++ /dev/null @@ -1,78 +0,0 @@ -package fr.xephi.authme.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import fr.xephi.authme.AuthMe; -import fr.xephi.authme.cache.auth.PlayerCache; -import fr.xephi.authme.security.RandomString; -import fr.xephi.authme.settings.Messages; -import fr.xephi.authme.settings.Settings; - -public class CaptchaCommand implements CommandExecutor { - - public AuthMe plugin; - private Messages m = Messages.getInstance(); - public static RandomString rdm = new RandomString(Settings.captchaLength); - - public CaptchaCommand(AuthMe plugin) { - this.plugin = plugin; - } - - @Override - public boolean onCommand(CommandSender sender, Command cmnd, String label, - String[] args) { - - if (!(sender instanceof Player)) { - return true; - } - - Player player = (Player) sender; - String name = player.getName().toLowerCase(); - - if (args.length == 0) { - m.send(player, "usage_captcha"); - return true; - } - - if (PlayerCache.getInstance().isAuthenticated(name)) { - m.send(player, "logged_in"); - return true; - } - - if (!plugin.authmePermissible(player, "authme." + label.toLowerCase())) { - m.send(player, "no_perm"); - return true; - } - - if (!Settings.useCaptcha) { - m.send(player, "usage_log"); - return true; - } - - if (!plugin.cap.containsKey(name)) { - m.send(player, "usage_log"); - return true; - } - - if (Settings.useCaptcha && !args[0].equals(plugin.cap.get(name))) { - plugin.cap.remove(name); - plugin.cap.put(name, rdm.nextString()); - for (String s : m.send("wrong_captcha")) { - player.sendMessage(s.replace("THE_CAPTCHA", plugin.cap.get(name))); - } - return true; - } - try { - plugin.captcha.remove(name); - plugin.cap.remove(name); - } catch (NullPointerException npe) { - } - m.send(player, "valid_captcha"); - m.send(player, "login_msg"); - return true; - } - -} diff --git a/src/main/java/fr/xephi/authme/commands/ChangePasswordCommand.java b/src/main/java/fr/xephi/authme/commands/ChangePasswordCommand.java deleted file mode 100644 index 4a668bfea..000000000 --- a/src/main/java/fr/xephi/authme/commands/ChangePasswordCommand.java +++ /dev/null @@ -1,69 +0,0 @@ -package fr.xephi.authme.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import fr.xephi.authme.AuthMe; -import fr.xephi.authme.cache.auth.PlayerCache; -import fr.xephi.authme.settings.Messages; -import fr.xephi.authme.settings.Settings; -import fr.xephi.authme.task.ChangePasswordTask; - -public class ChangePasswordCommand implements CommandExecutor { - - private Messages m = Messages.getInstance(); - public AuthMe plugin; - - public ChangePasswordCommand(AuthMe plugin) { - this.plugin = plugin; - } - - @Override - public boolean onCommand(CommandSender sender, Command cmnd, String label, - String[] args) { - if (!(sender instanceof Player)) { - return true; - } - - if (!plugin.authmePermissible(sender, "authme." + label.toLowerCase())) { - m.send(sender, "no_perm"); - return true; - } - - Player player = (Player) sender; - String name = player.getName().toLowerCase(); - if (!PlayerCache.getInstance().isAuthenticated(name)) { - m.send(player, "not_logged_in"); - return true; - } - - if (args.length != 2) { - m.send(player, "usage_changepassword"); - return true; - } - - String lowpass = args[1].toLowerCase(); - if (lowpass.contains("delete") || lowpass.contains("where") || lowpass.contains("insert") || lowpass.contains("modify") || lowpass.contains("from") || lowpass.contains("select") || lowpass.contains(";") || lowpass.contains("null") || !lowpass.matches(Settings.getPassRegex)) { - m.send(player, "password_error"); - return true; - } - if (lowpass.equalsIgnoreCase(name)) { - m.send(player, "password_error_nick"); - return true; - } - if (lowpass.length() < Settings.getPasswordMinLen || lowpass.length() > Settings.passwordMaxLength) { - m.send(player, "pass_len"); - return true; - } - if (!Settings.unsafePasswords.isEmpty()) { - if (Settings.unsafePasswords.contains(lowpass)) { - m.send(player, "password_error_unsafe"); - return true; - } - } - plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new ChangePasswordTask(plugin, player, args[0], args[1])); - return true; - } -} diff --git a/src/main/java/fr/xephi/authme/commands/ConverterCommand.java b/src/main/java/fr/xephi/authme/commands/ConverterCommand.java deleted file mode 100644 index 56deecdf3..000000000 --- a/src/main/java/fr/xephi/authme/commands/ConverterCommand.java +++ /dev/null @@ -1,114 +0,0 @@ -package fr.xephi.authme.commands; - -import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; - -import fr.xephi.authme.AuthMe; -import fr.xephi.authme.converter.Converter; -import fr.xephi.authme.converter.CrazyLoginConverter; -import fr.xephi.authme.converter.FlatToSql; -import fr.xephi.authme.converter.FlatToSqlite; -import fr.xephi.authme.converter.RakamakConverter; -import fr.xephi.authme.converter.RoyalAuthConverter; -import fr.xephi.authme.converter.SqlToFlat; -import fr.xephi.authme.converter.vAuthConverter; -import fr.xephi.authme.converter.xAuthConverter; -import fr.xephi.authme.settings.Messages; - -public class ConverterCommand implements CommandExecutor { - - private AuthMe plugin; - private Messages m = Messages.getInstance(); - - public ConverterCommand(AuthMe plugin) { - this.plugin = plugin; - } - - @Override - public boolean onCommand(CommandSender sender, Command cmnd, String label, - final String[] args) { - if (!plugin.authmePermissible(sender, "authme.admin.converter")) { - m.send(sender, "no_perm"); - return true; - } - - if (args.length == 0) { - sender.sendMessage("Usage : /converter flattosql | flattosqlite | xauth | crazylogin | rakamak | royalauth | vauth | sqltoflat"); - return true; - } - - ConvertType type = ConvertType.fromName(args[0]); - if (type == null) { - m.send(sender, "error"); - return true; - } - Converter converter = null; - switch (type) { - case ftsql: - converter = new FlatToSql(); - break; - case ftsqlite: - converter = new FlatToSqlite(sender); - break; - case xauth: - converter = new xAuthConverter(plugin, sender); - break; - case crazylogin: - converter = new CrazyLoginConverter(plugin, sender); - break; - case rakamak: - converter = new RakamakConverter(plugin, sender); - break; - case royalauth: - converter = new RoyalAuthConverter(plugin); - break; - case vauth: - converter = new vAuthConverter(plugin, sender); - break; - case sqltoflat: - converter = new SqlToFlat(plugin, sender); - break; - default: - break; - } - if (converter == null) { - m.send(sender, "error"); - return true; - } - Bukkit.getScheduler().runTaskAsynchronously(plugin, converter); - sender.sendMessage("[AuthMe] Successfully converted from " + args[0]); - return true; - } - - public enum ConvertType { - - ftsql("flattosql"), - ftsqlite("flattosqlite"), - xauth("xauth"), - crazylogin("crazylogin"), - rakamak("rakamak"), - royalauth("royalauth"), - vauth("vauth"), - sqltoflat("sqltoflat"); - - String name; - - ConvertType(String name) { - this.name = name; - } - - String getName() { - return this.name; - } - - public static ConvertType fromName(String name) { - for (ConvertType type : ConvertType.values()) { - if (type.getName().equalsIgnoreCase(name)) - return type; - } - return null; - } - } -} diff --git a/src/main/java/fr/xephi/authme/commands/EmailCommand.java b/src/main/java/fr/xephi/authme/commands/EmailCommand.java deleted file mode 100644 index 5f11ae259..000000000 --- a/src/main/java/fr/xephi/authme/commands/EmailCommand.java +++ /dev/null @@ -1,116 +0,0 @@ -package fr.xephi.authme.commands; - -import java.security.NoSuchAlgorithmException; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import fr.xephi.authme.AuthMe; -import fr.xephi.authme.ConsoleLogger; -import fr.xephi.authme.cache.auth.PlayerAuth; -import fr.xephi.authme.cache.auth.PlayerCache; -import fr.xephi.authme.security.PasswordSecurity; -import fr.xephi.authme.security.RandomString; -import fr.xephi.authme.settings.Messages; -import fr.xephi.authme.settings.Settings; - -/** - * @author Xephi59 - */ -public class EmailCommand implements CommandExecutor { - - public AuthMe plugin; - private Messages m = Messages.getInstance(); - - public EmailCommand(AuthMe plugin) { - this.plugin = plugin; - } - - @Override - public boolean onCommand(CommandSender sender, Command cmnd, String label, - String[] args) { - if (!(sender instanceof Player)) { - return true; - } - - if (!plugin.authmePermissible(sender, "authme." + label.toLowerCase())) { - m.send(sender, "no_perm"); - return true; - } - - Player player = (Player) sender; - String name = player.getName(); - - if (args.length == 0) { - m.send(player, "usage_email_add"); - m.send(player, "usage_email_change"); - m.send(player, "usage_email_recovery"); - return true; - } - - if (args[0].equalsIgnoreCase("add")) { - if (args.length != 3) { - m.send(player, "usage_email_add"); - return true; - } - plugin.management.performAddEmail(player, args[1], args[2]); - } else if (args[0].equalsIgnoreCase("change")) { - if (args.length != 3) { - m.send(player, "usage_email_change"); - return true; - } - plugin.management.performChangeEmail(player, args[1], args[2]); - } - if (args[0].equalsIgnoreCase("recovery")) { - if (args.length != 2) { - m.send(player, "usage_email_recovery"); - return true; - } - if (plugin.mail == null) { - m.send(player, "error"); - return true; - } - if (plugin.database.isAuthAvailable(name)) { - if (PlayerCache.getInstance().isAuthenticated(name)) { - m.send(player, "logged_in"); - return true; - } - try { - RandomString rand = new RandomString(Settings.getRecoveryPassLength); - String thePass = rand.nextString(); - String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, thePass, name); - PlayerAuth auth; - if (PlayerCache.getInstance().isAuthenticated(name)) { - auth = PlayerCache.getInstance().getAuth(name); - } else if (plugin.database.isAuthAvailable(name)) { - auth = plugin.database.getAuth(name); - } else { - m.send(player, "unknown_user"); - return true; - } - if (Settings.getmailAccount.equals("") || Settings.getmailAccount.isEmpty()) { - m.send(player, "error"); - return true; - } - - if (!args[1].equalsIgnoreCase(auth.getEmail()) || args[1].equalsIgnoreCase("your@email.com") || auth.getEmail().equalsIgnoreCase("your@email.com")) { - m.send(player, "email_invalid"); - return true; - } - auth.setHash(hashnew); - plugin.database.updatePassword(auth); - plugin.mail.main(auth, thePass); - m.send(player, "email_send"); - } catch (NoSuchAlgorithmException | NoClassDefFoundError ex) { - ConsoleLogger.showError(ex.getMessage()); - m.send(sender, "error"); - } - } else { - m.send(player, "reg_email_msg"); - } - } - return true; - } -} diff --git a/src/main/java/fr/xephi/authme/commands/LoginCommand.java b/src/main/java/fr/xephi/authme/commands/LoginCommand.java deleted file mode 100644 index b8730929a..000000000 --- a/src/main/java/fr/xephi/authme/commands/LoginCommand.java +++ /dev/null @@ -1,41 +0,0 @@ -package fr.xephi.authme.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import fr.xephi.authme.AuthMe; -import fr.xephi.authme.settings.Messages; - -public class LoginCommand implements CommandExecutor { - - private AuthMe plugin; - private Messages m = Messages.getInstance(); - - public LoginCommand(AuthMe plugin) { - this.plugin = plugin; - } - - @Override - public boolean onCommand(CommandSender sender, Command cmnd, String label, - final String[] args) { - if (!(sender instanceof Player)) { - return true; - } - - final Player player = (Player) sender; - - if (args.length == 0) { - m.send(player, "usage_log"); - return true; - } - - if (!plugin.authmePermissible(player, "authme." + label.toLowerCase())) { - m.send(player, "no_perm"); - return true; - } - plugin.management.performLogin(player, args[0], false); - return true; - } -} diff --git a/src/main/java/fr/xephi/authme/commands/LogoutCommand.java b/src/main/java/fr/xephi/authme/commands/LogoutCommand.java deleted file mode 100644 index 4c21f7f66..000000000 --- a/src/main/java/fr/xephi/authme/commands/LogoutCommand.java +++ /dev/null @@ -1,37 +0,0 @@ -package fr.xephi.authme.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import fr.xephi.authme.AuthMe; -import fr.xephi.authme.settings.Messages; - -public class LogoutCommand implements CommandExecutor { - - private Messages m = Messages.getInstance(); - private AuthMe plugin; - - public LogoutCommand(AuthMe plugin) { - this.plugin = plugin; - } - - @Override - public boolean onCommand(CommandSender sender, Command cmnd, String label, - String[] args) { - if (!(sender instanceof Player)) { - return true; - } - - if (!plugin.authmePermissible(sender, "authme." + label.toLowerCase())) { - m.send(sender, "no_perm"); - return true; - } - - final Player player = (Player) sender; - plugin.management.performLogout(player); - return true; - } - -} diff --git a/src/main/java/fr/xephi/authme/commands/RegisterCommand.java b/src/main/java/fr/xephi/authme/commands/RegisterCommand.java deleted file mode 100644 index 0707ee789..000000000 --- a/src/main/java/fr/xephi/authme/commands/RegisterCommand.java +++ /dev/null @@ -1,65 +0,0 @@ -package fr.xephi.authme.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import fr.xephi.authme.AuthMe; -import fr.xephi.authme.cache.auth.PlayerAuth; -import fr.xephi.authme.security.RandomString; -import fr.xephi.authme.settings.Messages; -import fr.xephi.authme.settings.Settings; - -public class RegisterCommand implements CommandExecutor { - - private Messages m = Messages.getInstance(); - public PlayerAuth auth; - public AuthMe plugin; - - public RegisterCommand(AuthMe plugin) { - this.plugin = plugin; - } - - @Override - public boolean onCommand(CommandSender sender, Command cmnd, String label, - String[] args) { - if (!(sender instanceof Player)) { - sender.sendMessage("Player Only! Use 'authme register ' instead"); - return true; - } - final Player player = (Player) sender; - if (args.length == 0 || (Settings.getEnablePasswordVerifier && args.length < 2)) { - m.send(player, "usage_reg"); - return true; - } - if (!plugin.authmePermissible(player, "authme." + label.toLowerCase())) { - m.send(player, "no_perm"); - return true; - } - if (Settings.emailRegistration && !Settings.getmailAccount.isEmpty()) { - if (Settings.doubleEmailCheck) { - if (args.length < 2 || !args[0].equals(args[1])) { - m.send(player, "usage_reg"); - return true; - } - } - final String email = args[0]; - if (!Settings.isEmailCorrect(email)) { - m.send(player, "email_invalid"); - return true; - } - RandomString rand = new RandomString(Settings.getRecoveryPassLength); - final String thePass = rand.nextString(); - plugin.management.performRegister(player, thePass, email); - return true; - } - if (args.length > 1 && Settings.getEnablePasswordVerifier) - if (!args[0].equals(args[1])) { - m.send(player, "password_error"); - return true; - } - plugin.management.performRegister(player, args[0], ""); - return true; - } -} diff --git a/src/main/java/fr/xephi/authme/commands/UnregisterCommand.java b/src/main/java/fr/xephi/authme/commands/UnregisterCommand.java deleted file mode 100644 index 4a879f1b1..000000000 --- a/src/main/java/fr/xephi/authme/commands/UnregisterCommand.java +++ /dev/null @@ -1,49 +0,0 @@ -package fr.xephi.authme.commands; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import fr.xephi.authme.AuthMe; -import fr.xephi.authme.cache.auth.PlayerCache; -import fr.xephi.authme.settings.Messages; - -public class UnregisterCommand implements CommandExecutor { - - private Messages m = Messages.getInstance(); - public AuthMe plugin; - - public UnregisterCommand(AuthMe plugin) { - this.plugin = plugin; - } - - @Override - public boolean onCommand(final CommandSender sender, Command cmnd, String label, - final String[] args) { - if (!(sender instanceof Player)) { - return true; - } - - if (!plugin.authmePermissible(sender, "authme." + label.toLowerCase())) { - m.send(sender, "no_perm"); - return true; - } - - final Player player = (Player) sender; - final String name = player.getName().toLowerCase(); - - if (!PlayerCache.getInstance().isAuthenticated(name)) { - m.send(player, "not_logged_in"); - return true; - } - - if (args.length != 1) { - m.send(player, "usage_unreg"); - return true; - } - - plugin.management.performUnregister(player, args[0], false); - return true; - } -} diff --git a/src/main/java/fr/xephi/authme/plugin/manager/BungeeCordMessage.java b/src/main/java/fr/xephi/authme/hooks/BungeeCordMessage.java similarity index 96% rename from src/main/java/fr/xephi/authme/plugin/manager/BungeeCordMessage.java rename to src/main/java/fr/xephi/authme/hooks/BungeeCordMessage.java index a81745e70..feff2ccab 100644 --- a/src/main/java/fr/xephi/authme/plugin/manager/BungeeCordMessage.java +++ b/src/main/java/fr/xephi/authme/hooks/BungeeCordMessage.java @@ -1,4 +1,4 @@ -package fr.xephi.authme.plugin.manager; +package fr.xephi.authme.hooks; import org.bukkit.entity.Player; import org.bukkit.plugin.messaging.PluginMessageListener; diff --git a/src/main/java/fr/xephi/authme/plugin/manager/EssSpawn.java b/src/main/java/fr/xephi/authme/hooks/EssSpawn.java similarity index 97% rename from src/main/java/fr/xephi/authme/plugin/manager/EssSpawn.java rename to src/main/java/fr/xephi/authme/hooks/EssSpawn.java index cd422b48c..b47b644d3 100644 --- a/src/main/java/fr/xephi/authme/plugin/manager/EssSpawn.java +++ b/src/main/java/fr/xephi/authme/hooks/EssSpawn.java @@ -1,4 +1,4 @@ -package fr.xephi.authme.plugin.manager; +package fr.xephi.authme.hooks; import java.io.File; diff --git a/src/main/java/fr/xephi/authme/util/Utils.java b/src/main/java/fr/xephi/authme/util/Utils.java index fd73baf73..938a03580 100644 --- a/src/main/java/fr/xephi/authme/util/Utils.java +++ b/src/main/java/fr/xephi/authme/util/Utils.java @@ -163,17 +163,6 @@ public class Utils { return false; } - // TODO: remove if not needed - public static void hasPermOnJoin(Player player) { - if (plugin.permission == null) - return; - for (String permission : Settings.getJoinPermissions) { - if (plugin.permission.playerHas(player, permission)) { - plugin.permission.playerAddTransient(player, permission); - } - } - } - // TODO: Move to a Manager public static boolean checkAuth(Player player) { if (player == null || Utils.isUnrestricted(player)) { From 604f2f3ee918ce0ba2ef04351777c16b45bf098c Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Tue, 10 Nov 2015 20:20:43 +0100 Subject: [PATCH 07/12] reduce size of the email api --- pom.xml | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 62a4d4f8d..ef80d41d8 100644 --- a/pom.xml +++ b/pom.xml @@ -94,6 +94,11 @@ false false + + + com.sun:* + + org.mcstats @@ -119,14 +124,14 @@ javax.activation fr.xephi.authme.libs.mail.activation - - com.sun.activation - fr.xephi.authme.libs.mail.activation - com.sun.mail fr.xephi.authme.libs.mail + + com.sun.activation + fr.xephi.authme.libs.mail.activation + com.maxmind.geoip fr.xephi.authme.libs.geoip @@ -235,7 +240,14 @@ com.sun.mail - javax.mail + mailapi + 1.5.4 + compile + true + + + com.sun.mail + smtp 1.5.4 compile true From 10606a22e6485253061b5accd85ecb2c69d63008 Mon Sep 17 00:00:00 2001 From: Xephi59 Date: Wed, 11 Nov 2015 01:28:04 +0100 Subject: [PATCH 08/12] Change default mail api to apache one --- pom.xml | 50 ++----------- src/main/java/fr/xephi/authme/AuthMe.java | 72 +++++++++++-------- .../java/fr/xephi/authme/SendMailSSL.java | 72 +++++-------------- 3 files changed, 65 insertions(+), 129 deletions(-) diff --git a/pom.xml b/pom.xml index ef80d41d8..8c8a2148f 100644 --- a/pom.xml +++ b/pom.xml @@ -51,13 +51,12 @@ 1.7 - 1.8.8-R0.1-SNAPSHOT - AuthMe-${project.version} + ${project.name} . @@ -93,12 +92,6 @@ false false - - - - com.sun:* - - org.mcstats @@ -108,38 +101,6 @@ com.google.gson fr.xephi.authme.libs.gson - - com.zaxxer.hikari - fr.xephi.authme.libs.hikari - - - org.slf4j - fr.xephi.authme.libs.slf4j - - - javax.mail - fr.xephi.authme.libs.mail - - - javax.activation - fr.xephi.authme.libs.mail.activation - - - com.sun.mail - fr.xephi.authme.libs.mail - - - com.sun.activation - fr.xephi.authme.libs.mail.activation - - - com.maxmind.geoip - fr.xephi.authme.libs.geoip - - - net.ricecode.similarity - fr.xephi.authme.libs.similarity - @@ -240,19 +201,18 @@ com.sun.mail - mailapi + javax.mail 1.5.4 compile true - com.sun.mail - smtp - 1.5.4 + org.apache.commons + commons-email + 1.4 compile true - com.google.code.gson diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java index 893814ac6..d8d80afca 100644 --- a/src/main/java/fr/xephi/authme/AuthMe.java +++ b/src/main/java/fr/xephi/authme/AuthMe.java @@ -72,7 +72,9 @@ public class AuthMe extends JavaPlugin { /** 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 final int PLUGIN_VERSION_CODE = 100; // Increase this number + // by one when an update + // is released private static AuthMe plugin; private static Server server; @@ -114,14 +116,14 @@ public class AuthMe extends JavaPlugin { private boolean canConnect = true; public boolean canConnect() { - return canConnect; - } + return canConnect; + } - public void setCanConnect(boolean canConnect) { - this.canConnect = canConnect; - } + public void setCanConnect(boolean canConnect) { + this.canConnect = canConnect; + } - public static AuthMe getInstance() { + public static AuthMe getInstance() { return plugin; } @@ -186,18 +188,20 @@ public class AuthMe extends JavaPlugin { Graph databaseBackend = metrics.createGraph("Database backend"); // Custom graphs - if(Settings.messageFile.exists()) { + if (Settings.messageFile.exists()) { messagesLanguage.addPlotter(new Metrics.Plotter(Settings.messagesLanguage) { + @Override public int getValue() { - return 1; + return 1; } }); } databaseBackend.addPlotter(new Metrics.Plotter(Settings.getDataSource.toString()) { + @Override public int getValue() { - return 1; + return 1; } }); @@ -335,17 +339,19 @@ 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 + // 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(); @@ -419,7 +425,8 @@ public class AuthMe extends JavaPlugin { // Initialize and setup the database public void setupDatabase() throws Exception { - if (database != null) database.close(); + if (database != null) + database.close(); // Backend MYSQL - FILE - SQLITE - SQLITEHIKARI boolean isSQLite = false; switch (Settings.getDataSource) { @@ -830,18 +837,23 @@ public class AuthMe extends JavaPlugin { /** * 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). + * @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) { + 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) + if (commandHandler == null) return false; // Handle the command, return the result @@ -851,7 +863,8 @@ public class AuthMe extends JavaPlugin { /** * Get the current installed AuthMeReloaded version name. * - * @return The version name of the currently installed AuthMeReloaded instance. + * @return The version name of the currently installed AuthMeReloaded + * instance. */ public static String getVersionName() { return PLUGIN_VERSION_NAME; @@ -860,7 +873,8 @@ public class AuthMe extends JavaPlugin { /** * Get the current installed AuthMeReloaded version code. * - * @return The version code of the currently installed AuthMeReloaded instance. + * @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 4af471f98..7fab50785 100644 --- a/src/main/java/fr/xephi/authme/SendMailSSL.java +++ b/src/main/java/fr/xephi/authme/SendMailSSL.java @@ -1,25 +1,12 @@ package fr.xephi.authme; import java.io.File; -import java.io.UnsupportedEncodingException; -import java.util.Date; -import java.util.Properties; -import javax.activation.DataHandler; import javax.activation.DataSource; import javax.activation.FileDataSource; import javax.imageio.ImageIO; -import javax.mail.BodyPart; -import javax.mail.Message; -import javax.mail.Multipart; -import javax.mail.PasswordAuthentication; -import javax.mail.Session; -import javax.mail.Transport; -import javax.mail.internet.InternetAddress; -import javax.mail.internet.MimeBodyPart; -import javax.mail.internet.MimeMessage; -import javax.mail.internet.MimeMultipart; +import org.apache.commons.mail.HtmlEmail; import org.bukkit.Bukkit; import fr.xephi.authme.cache.auth.PlayerAuth; @@ -47,7 +34,7 @@ public class SendMailSSL { } final String sender = sendername; - final String port = String.valueOf(Settings.getMailPort); + final int port = Settings.getMailPort; final String acc = Settings.getmailAccount; final String subject = Settings.getMailSubject; final String smtp = Settings.getmailSMTP; @@ -59,35 +46,18 @@ public class SendMailSSL { @Override public void run() { try { - Properties props = new Properties(); - props.put("mail.smtp.host", smtp); - props.put("mail.smtp.auth", "true"); - props.put("mail.smtp.port", port); - props.put("mail.smtp.socketFactory.port", port); - props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); - props.put("mail.smtp.starttls.enable", true); - props.put("mail.smtp.socketFactory.fallback", false); - Session session = Session.getInstance(props, new javax.mail.Authenticator() { - - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(acc, password); - } - }); - - Message message = new MimeMessage(session); - try { - message.setFrom(new InternetAddress(acc, sender)); - } catch (UnsupportedEncodingException uee) { - message.setFrom(new InternetAddress(acc)); - } - message.addRecipient(Message.RecipientType.TO, new InternetAddress(mail)); - message.setSubject(subject); - message.setSentDate(new Date()); - BodyPart messageBodyPart = new MimeBodyPart(); - messageBodyPart.setContent(mailText, "text/html"); - Multipart multipart = new MimeMultipart(); - multipart.addBodyPart(messageBodyPart); - + Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); + HtmlEmail email = new HtmlEmail(); + email.setSmtpPort(port); + email.setHostName(smtp); + email.addTo(mail); + email.setFrom(acc, sender); + email.setSubject(subject); + email.setHtmlMsg(mailText); + email.setAuthentication(acc, password); + email.setStartTLSEnabled(true); + email.setStartTLSRequired(true); + email.setSSLCheckServerIdentity(true); // Generate an image ? File file = null; if (Settings.generateImage) { @@ -95,25 +65,17 @@ public class SendMailSSL { ImageGenerator gen = new ImageGenerator(newPass); file = new File(plugin.getDataFolder() + File.separator + auth.getNickname() + "_new_pass.jpg"); ImageIO.write(gen.generateImage(), "jpg", file); - messageBodyPart = new MimeBodyPart(); DataSource source = new FileDataSource(file); - messageBodyPart.setDataHandler(new DataHandler(source)); - messageBodyPart.setFileName(auth.getNickname() + "_new_pass.jpg"); - multipart.addBodyPart(messageBodyPart); + email.embed(source, auth.getNickname() + "_new_pass.jpg"); } catch (Exception e) { ConsoleLogger.showError("Unable to send new password as image! Using normal text! Dest: " + mail); } } - - message.setContent(multipart); try { - Transport transport = session.getTransport("smtp"); - transport.connect(smtp, Integer.parseInt(port), acc, password); - transport.sendMessage(message, message.getAllRecipients()); - transport.close(); + email.send(); } catch (Exception e) { e.printStackTrace(); - ConsoleLogger.showError("Cannot send email to " + mail + ", an error occured!"); + ConsoleLogger.showError("Fail to send a mail to " + mail); } if (file != null) file.delete(); From a9a057c278305e3b6dd9af10d523ff0605d9ad1a Mon Sep 17 00:00:00 2001 From: Xephi59 Date: Wed, 11 Nov 2015 01:42:19 +0100 Subject: [PATCH 09/12] Fix Pom --- pom.xml | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 8c8a2148f..afcb2bfb1 100644 --- a/pom.xml +++ b/pom.xml @@ -51,12 +51,13 @@ 1.7 + 1.8.8-R0.1-SNAPSHOT - ${project.name} + AuthMe-${project.version} . @@ -92,6 +93,12 @@ false false + + + + com.sun:* + + org.mcstats @@ -101,6 +108,22 @@ com.google.gson fr.xephi.authme.libs.gson + + com.zaxxer.hikari + fr.xephi.authme.libs.hikari + + + org.slf4j + fr.xephi.authme.libs.slf4j + + + com.maxmind.geoip + fr.xephi.authme.libs.geoip + + + net.ricecode.similarity + fr.xephi.authme.libs.similarity + @@ -201,7 +224,14 @@ com.sun.mail - javax.mail + mailapi + 1.5.4 + compile + true + + + com.sun.mail + smtp 1.5.4 compile true @@ -213,6 +243,7 @@ compile true + com.google.code.gson From 46d39c786458e0cdbef4f6f2d5b4ab26f41ea1b9 Mon Sep 17 00:00:00 2001 From: Xephi59 Date: Wed, 11 Nov 2015 01:49:15 +0100 Subject: [PATCH 10/12] Fix attachment --- src/main/java/fr/xephi/authme/SendMailSSL.java | 6 ++++-- src/main/resources/config.yml | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/fr/xephi/authme/SendMailSSL.java b/src/main/java/fr/xephi/authme/SendMailSSL.java index 7fab50785..2a6083e75 100644 --- a/src/main/java/fr/xephi/authme/SendMailSSL.java +++ b/src/main/java/fr/xephi/authme/SendMailSSL.java @@ -53,11 +53,11 @@ public class SendMailSSL { email.addTo(mail); email.setFrom(acc, sender); email.setSubject(subject); - email.setHtmlMsg(mailText); email.setAuthentication(acc, password); email.setStartTLSEnabled(true); email.setStartTLSRequired(true); email.setSSLCheckServerIdentity(true); + String content = mailText; // Generate an image ? File file = null; if (Settings.generateImage) { @@ -66,11 +66,13 @@ public class SendMailSSL { file = new File(plugin.getDataFolder() + File.separator + auth.getNickname() + "_new_pass.jpg"); ImageIO.write(gen.generateImage(), "jpg", file); DataSource source = new FileDataSource(file); - email.embed(source, auth.getNickname() + "_new_pass.jpg"); + String tag = email.embed(source, auth.getNickname() + "_new_pass.jpg"); + content = content.replace("", ""); } catch (Exception e) { ConsoleLogger.showError("Unable to send new password as image! Using normal text! Dest: " + mail); } } + email.setHtmlMsg(content); try { email.send(); } catch (Exception e) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 084b9cff9..cbf62dcb2 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -340,7 +340,7 @@ Email: # Email subject of password get mailSubject: 'Your new AuthMe Password' # Email text here - mailText: 'Dear ,

This is your new AuthMe password for the server

:



Do not forget to change password after login!
/changepassword newPassword' + mailText: 'Dear ,

This is your new AuthMe password for the server

:



Do not forget to change password after login!
/changepassword newPassword' # Like maxRegPerIp but with email maxRegPerEmail: 1 # Recall players to add an email ? From 3b802d03b1ee021e96968a39d5636ef182ebd4a7 Mon Sep 17 00:00:00 2001 From: Xephi59 Date: Wed, 11 Nov 2015 01:50:23 +0100 Subject: [PATCH 11/12] Add non html content --- src/main/java/fr/xephi/authme/SendMailSSL.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/fr/xephi/authme/SendMailSSL.java b/src/main/java/fr/xephi/authme/SendMailSSL.java index 2a6083e75..eb4c2b8ee 100644 --- a/src/main/java/fr/xephi/authme/SendMailSSL.java +++ b/src/main/java/fr/xephi/authme/SendMailSSL.java @@ -73,6 +73,7 @@ public class SendMailSSL { } } email.setHtmlMsg(content); + email.setTextMsg(content); try { email.send(); } catch (Exception e) { From 8dadcbd7dd141024b8ff91a8791e8ba93e2f4899 Mon Sep 17 00:00:00 2001 From: Xephi59 Date: Wed, 11 Nov 2015 01:52:45 +0100 Subject: [PATCH 12/12] Remove useless Exclusion --- pom.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pom.xml b/pom.xml index afcb2bfb1..7547c90bd 100644 --- a/pom.xml +++ b/pom.xml @@ -93,12 +93,6 @@ false false - - - - com.sun:* - - org.mcstats