Merge pull request #266 from AuthMe-Team/master

Rewrite Email system
This commit is contained in:
Alexandre Vanhecke 2015-11-11 01:54:16 +01:00
commit e509766be8
18 changed files with 123 additions and 1310 deletions

55
pom.xml
View File

@ -25,7 +25,6 @@
<url>http://github.com/Xephi/AuthMeReloaded</url>
</scm>
<!-- Official Build Server -->
<ciManagement>
<system>jenkins</system>
<url>http://ci.xephi.fr/job/AuthMeReloaded/</url>
@ -44,10 +43,16 @@
</licenses>
<properties>
<!-- Project Properties -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mainClass>fr.xephi.authme.AuthMe</mainClass>
<buildNumber>CustomBuild</buildNumber>
<pluginAuthors>[Xephi, sgdc3, DNx5, timvisee, games647]</pluginAuthors>
<!-- Change Compiler Version (JDK) HERE! -->
<javaVersion>1.7</javaVersion>
<!-- Change MC Version HERE! -->
<!-- Change Bukkit Version HERE! -->
<bukkitVersion>1.8.8-R0.1-SNAPSHOT</bukkitVersion>
</properties>
@ -87,7 +92,7 @@
<version>2.4.2</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<minimizeJar>true</minimizeJar>
<minimizeJar>false</minimizeJar>
<relocations>
<relocation>
<pattern>org.mcstats</pattern>
@ -97,6 +102,22 @@
<pattern>com.google.gson</pattern>
<shadedPattern>fr.xephi.authme.libs.gson</shadedPattern>
</relocation>
<relocation>
<pattern>com.zaxxer.hikari</pattern>
<shadedPattern>fr.xephi.authme.libs.hikari</shadedPattern>
</relocation>
<relocation>
<pattern>org.slf4j</pattern>
<shadedPattern>fr.xephi.authme.libs.slf4j</shadedPattern>
</relocation>
<relocation>
<pattern>com.maxmind.geoip</pattern>
<shadedPattern>fr.xephi.authme.libs.geoip</shadedPattern>
</relocation>
<relocation>
<pattern>net.ricecode.similarity</pattern>
<shadedPattern>fr.xephi.authme.libs.similarity</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
@ -112,7 +133,6 @@
</build>
<repositories>
<!-- SpigotMC Repo (Bukkit and SpigotAPI) -->
<repository>
<id>spigot-repo</id>
@ -155,23 +175,14 @@
<url>http://repo.luricos.de/content/repositories/releases</url>
</repository>
<!-- Xephi Repo (Metrics)-->
<!-- Xephi Repo -->
<repository>
<id>xephi-repo</id>
<url>http://ci.xephi.fr/plugin/repository/everything/</url>
</repository>
<!-- Metrics Snapshots Repo (Always offline! 60% UPTIME)
<repository>
<id>mcstats-snapshots</id>
<url>http://repo.mcstats.org/content/repositories/snapshots/</url>
</repository>
-->
</repositories>
<dependencies>
<!-- Database Connection Pool -->
<dependency>
<groupId>com.zaxxer</groupId>
@ -207,16 +218,23 @@
<!-- Java Email Implementation -->
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<artifactId>mailapi</artifactId>
<version>1.5.4</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
<groupId>com.sun.mail</groupId>
<artifactId>smtp</artifactId>
<version>1.5.4</version>
<scope>provided</scope>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-email</artifactId>
<version>1.4</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
@ -511,6 +529,5 @@
<scope>compile</scope>
<optional>true</optional>
</dependency>
</dependencies>
</project>

View File

@ -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;
@ -72,9 +72,11 @@ 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 authme;
private static AuthMe plugin;
private static Server server;
private Logger authmeLogger;
@ -122,7 +124,7 @@ public class AuthMe extends JavaPlugin {
}
public static AuthMe getInstance() {
return authme;
return plugin;
}
public Settings getSettings() {
@ -142,7 +144,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);
@ -186,8 +188,9 @@ 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;
@ -195,6 +198,7 @@ public class AuthMe extends JavaPlugin {
});
}
databaseBackend.addPlotter(new Metrics.Plotter(Settings.getDataSource.toString()) {
@Override
public int getValue() {
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;

View File

@ -1,24 +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.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;
@ -46,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;
@ -58,27 +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.starttls.enable", true);
Session session = Session.getInstance(props, null);
Message message = new MimeMessage(session);
try {
message.setFrom(new InternetAddress(acc, sender));
} catch (UnsupportedEncodingException uee) {
message.setFrom(new InternetAddress(acc));
}
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(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.setAuthentication(acc, password);
email.setStartTLSEnabled(true);
email.setStartTLSRequired(true);
email.setSSLCheckServerIdentity(true);
String content = mailText;
// Generate an image ?
File file = null;
if (Settings.generateImage) {
@ -86,33 +65,25 @@ 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);
String tag = email.embed(source, auth.getNickname() + "_new_pass.jpg");
content = content.replace("<image>", "<img src=\"cid:" + tag + "\">");
} catch (Exception e) {
ConsoleLogger.showError("Unable to send new password as image! Using normal text! Dest: " + mail);
}
}
Transport transport = session.getTransport("smtp");
message.setContent(multipart);
email.setHtmlMsg(content);
email.setTextMsg(content);
try {
transport.connect(smtp, acc, password);
email.send();
} 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("Fail to send a mail to " + mail);
}
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);

View File

@ -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 <playername> <password> - Register a player");
sender.sendMessage("/authme unregister <playername> - Unregister a player");
sender.sendMessage("/authme changepassword <playername> <password> - Change a player's password");
sender.sendMessage("/authme chgemail <playername> <email> - Change a player's email");
sender.sendMessage("/authme getemail <playername> - Get a player's email");
sender.sendMessage("/authme getip <onlineplayername> - Display a player's IP if he's online");
sender.sendMessage("/authme lastlogin <playername> - Display the date of a player's last login");
sender.sendMessage("/authme accounts <playername> - Display all player's accounts");
sender.sendMessage("/authme purge <days> - Purge database");
sender.sendMessage("/authme purgebannedplayers - Purge database from banned players");
sender.sendMessage("/authme purgelastpos <playername> - 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 <playername> - 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 <days>");
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<String> 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 <days>");
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 <playername>");
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 <playername>");
sender.sendMessage("Or: /authme accounts <ip>");
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<String> 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<String> 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 <playername> <password>");
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 <playername>");
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 <playername> <email>");
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<String> 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 <playername> <newpassword>");
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 <playername>");
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 <playername>");
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 <onlineplayername>");
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 <onlineplayername>");
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 <playername>");
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<PlayerAuth> 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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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 <playername> <password>' 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;
}
}

View File

@ -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;
}
}

View File

@ -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;

View File

@ -1,4 +1,4 @@
package fr.xephi.authme.plugin.manager;
package fr.xephi.authme.hooks;
import java.io.File;

View File

@ -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;

View File

@ -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)) {

View File

@ -340,7 +340,7 @@ Email:
# Email subject of password get
mailSubject: 'Your new AuthMe Password'
# Email text here
mailText: 'Dear <playername>, <br /><br /> This is your new AuthMe password for the server <br /><br /> <servername> : <br /><br /> <generatedpass><br /><br />Do not forget to change password after login! <br /> /changepassword <generatedpass> newPassword'
mailText: 'Dear <playername>, <br /><br /> This is your new AuthMe password for the server <br /><br /> <servername> : <br /><br /> <generatedpass><br /><image><br />Do not forget to change password after login! <br /> /changepassword <generatedpass> newPassword'
# Like maxRegPerIp but with email
maxRegPerEmail: 1
# Recall players to add an email ?

View File

@ -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
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