Merge pull request #1 from Xephi/master

Up
This commit is contained in:
Gabriele C. 2015-06-21 20:27:32 +02:00
commit 1fcf019b2b
4 changed files with 1745 additions and 1745 deletions

14
pom.xml
View File

@ -203,14 +203,14 @@
<!-- Multi World plugin, http://www.spigotmc.org/resources/multiverse-core.390/ --> <!-- Multi World plugin, http://www.spigotmc.org/resources/multiverse-core.390/ -->
<dependency> <dependency>
<groupId>com.onarandombox.multiversecore</groupId> <groupId>com.onarandombox.multiversecore</groupId>
<artifactId>Multiverse-Core</artifactId> <artifactId>Multiverse-Core</artifactId>
<version>2.5</version> <version>2.5</version>
<type>jar</type> <type>jar</type>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- Essentials plugin--> <!-- Essentials plugin -->
<dependency> <dependency>
<groupId>net.ess3</groupId> <groupId>net.ess3</groupId>
<artifactId>Essentials</artifactId> <artifactId>Essentials</artifactId>

View File

@ -3,8 +3,8 @@ package fr.xephi.authme;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.Date; import java.util.Date;
import java.util.Properties; import java.util.Properties;
import javax.mail.Message; import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication; import javax.mail.PasswordAuthentication;
import javax.mail.Session; import javax.mail.Session;
import javax.mail.Transport; import javax.mail.Transport;
@ -44,13 +44,13 @@ public class SendMailSSL {
props.put("mail.smtp.auth", "true"); props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", String.valueOf(Settings.getMailPort)); props.put("mail.smtp.port", String.valueOf(Settings.getMailPort));
Session session = Session.getInstance(props, new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(Settings.getmailAccount, Settings.getmailPassword);
}
});
try { try {
Session session = Session.getInstance(props, new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(Settings.getmailAccount, Settings.getmailPassword);
}
});
final Message message = new MimeMessage(session); final Message message = new MimeMessage(session);
try { try {
message.setFrom(new InternetAddress(Settings.getmailAccount, sendername)); message.setFrom(new InternetAddress(Settings.getmailAccount, sendername));
@ -66,19 +66,20 @@ public class SendMailSSL {
text = text.replace("<generatedpass>", newPass); text = text.replace("<generatedpass>", newPass);
message.setContent(text, "text/html"); message.setContent(text, "text/html");
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
Transport.send(message); Transport.send(message);
} catch (MessagingException e) { } catch (Exception e) {
e.printStackTrace(); ConsoleLogger.showError("Some error appears while trying to send mail to " + auth.getEmail());
} }
} }
}); });
if (!Settings.noConsoleSpam) if (!Settings.noConsoleSpam)
ConsoleLogger.info("Email sent to : " + auth.getNickname()); ConsoleLogger.info("Email sent to : " + auth.getNickname());
} catch (MessagingException e) { } catch (Exception e) {
throw new RuntimeException(e); ConsoleLogger.showError("Some error appears while trying to send mail to " + auth.getEmail());
} }
} }
} }

View File

@ -118,7 +118,7 @@ public class MySQLThread extends Thread implements DataSource {
try { try {
con = makeSureConnectionIsReady(); con = makeSureConnectionIsReady();
st = con.createStatement(); st = con.createStatement();
st.executeUpdate("CREATE TABLE IF NOT EXISTS " + tableName + " (" + columnID + " INTEGER AUTO_INCREMENT," + columnName + " VARCHAR(255) NOT NULL UNIQUE," + columnPassword + " VARCHAR(255) NOT NULL," + columnIp + " VARCHAR(40) NOT NULL DEFAULT '127.0.0.1'," + columnLastLogin + " BIGINT NOT NULL DEFAULT '" + System.currentTimeMillis() + "'," + lastlocX + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocY + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocWorld + " VARCHAR(255) DEFAULT 'world'," + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com'," + columnLogged + " SMALLINT NOT NULL DEFAULT '0'," + "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));"); st.executeUpdate("CREATE TABLE IF NOT EXISTS " + tableName + " (" + columnID + " INTEGER AUTO_INCREMENT," + columnName + " VARCHAR(255) NOT NULL UNIQUE," + columnPassword + " VARCHAR(255) NOT NULL," + columnIp + " VARCHAR(40) NOT NULL DEFAULT '127.0.0.1'," + columnLastLogin + " BIGINT NOT NULL DEFAULT '" + System.currentTimeMillis() + "'," + lastlocX + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocY + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocWorld + " VARCHAR(255) NOT NULL DEFAULT " + Settings.defaultWorld + "," + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com'," + columnLogged + " SMALLINT NOT NULL DEFAULT '0'," + "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));");
rs = con.getMetaData().getColumns(null, null, tableName, columnPassword); rs = con.getMetaData().getColumns(null, null, tableName, columnPassword);
if (!rs.next()) { if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnPassword + " VARCHAR(255) NOT NULL;"); st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnPassword + " VARCHAR(255) NOT NULL;");
@ -190,7 +190,7 @@ public class MySQLThread extends Thread implements DataSource {
} }
@SuppressWarnings("resource") @SuppressWarnings("resource")
@Override @Override
public synchronized PlayerAuth getAuth(String user) { public synchronized PlayerAuth getAuth(String user) {
Connection con = null; Connection con = null;
PreparedStatement pst = null; PreparedStatement pst = null;
@ -975,23 +975,22 @@ public class MySQLThread extends Thread implements DataSource {
Connection con = null; Connection con = null;
PreparedStatement pst = null; PreparedStatement pst = null;
if (user != null) if (user != null)
try { try {
con = makeSureConnectionIsReady(); con = makeSureConnectionIsReady();
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE LOWER(" + columnName + ")=?;"); pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE LOWER(" + columnName + ")=?;");
pst.setInt(1, 0); pst.setInt(1, 0);
pst.setString(2, user); pst.setString(2, user);
pst.executeUpdate(); pst.executeUpdate();
} catch (SQLException ex) { } catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.showError(ex.getMessage());
return; return;
} catch (TimeoutException ex) { } catch (TimeoutException ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.showError(ex.getMessage());
return; return;
} } finally {
finally { close(pst);
close(pst); close(con);
close(con); }
}
return; return;
} }

View File

@ -88,7 +88,7 @@ public class SQLiteThread extends Thread implements DataSource {
ResultSet rs = null; ResultSet rs = null;
try { try {
st = con.createStatement(); st = con.createStatement();
st.executeUpdate("CREATE TABLE IF NOT EXISTS " + tableName + " (" + columnID + " INTEGER AUTO_INCREMENT," + columnName + " VARCHAR(255) NOT NULL UNIQUE," + columnPassword + " VARCHAR(255) NOT NULL," + columnIp + " VARCHAR(40) NOT NULL," + columnLastLogin + " BIGINT," + lastlocX + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocY + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocWorld + " VARCHAR(255) DEFAULT 'world'," + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com'," + "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));"); st.executeUpdate("CREATE TABLE IF NOT EXISTS " + tableName + " (" + columnID + " INTEGER AUTO_INCREMENT," + columnName + " VARCHAR(255) NOT NULL UNIQUE," + columnPassword + " VARCHAR(255) NOT NULL," + columnIp + " VARCHAR(40) NOT NULL," + columnLastLogin + " BIGINT," + lastlocX + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocY + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0'," + lastlocWorld + " VARCHAR(255) NOT NULL DEFAULT " + Settings.defaultWorld + "," + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com'," + "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));");
rs = con.getMetaData().getColumns(null, null, tableName, columnPassword); rs = con.getMetaData().getColumns(null, null, tableName, columnPassword);
if (!rs.next()) { if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnPassword + " VARCHAR(255) NOT NULL;"); st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnPassword + " VARCHAR(255) NOT NULL;");