1
0
mirror of https://github.com/moparisthebest/xAuth synced 2024-12-21 22:58:51 -05:00
2. Account activation fixed for servers using web registration
3. Error when a MySQL DATETIME field is 0000-00-00 00:00:00 fixed
This commit is contained in:
Zach Iverson 2011-06-20 01:28:20 -04:00
parent 79ef31afff
commit 78e827eade
3 changed files with 23 additions and 3 deletions

View File

@ -47,7 +47,8 @@ public class LoginCommand implements CommandExecutor {
xAuthMessages.send("loginErrPassword", player);
return true;
} else if (xAuthSettings.activation && account.getActive() == 0) {
//} else if (xAuthSettings.activation && account.getActive() == 0) {
} else if (xAuthSettings.activation && plugin.getDataManager().getActive(player.getName()) == 0) {
xAuthMessages.send("loginErrActivate", player);
return true;
}

View File

@ -38,7 +38,7 @@ public class DataManager {
try {
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mysql://" + xAuthSettings.mysqlHost + ":" + xAuthSettings.mysqlPort + "/" +
xAuthSettings.mysqlDb, xAuthSettings.mysqlUser, xAuthSettings.mysqlPass);
xAuthSettings.mysqlDb + "?zeroDateTimeBehavior=convertToNull", xAuthSettings.mysqlUser, xAuthSettings.mysqlPass);
stmt = connection.createStatement();
xAuthLog.info("Connection to MySQL server established!");
} catch (ClassNotFoundException e) {
@ -190,6 +190,25 @@ public class DataManager {
return xPlayer;
}
public int getActive(String playerName) {
try {
prepStmt = connection.prepareStatement(
"SELECT `active`" +
" FROM `" + xAuthSettings.tblAccount + "`" +
" WHERE playername = ?"
);
prepStmt.setString(1, playerName);
rs = prepStmt.executeQuery();
if (rs.next())
return rs.getInt("active");
} catch (SQLException e) {
xAuthLog.severe("Could not check active status of player: " + playerName, e);
}
return 0;
}
public void saveAccount(Account account) {
if (account.getId() == 0)
insertAccount(account);

View File

@ -46,7 +46,7 @@ public class xAuthEntityListener extends EntityListener {
Entity damager = edbeEvent.getDamager();
if (damager instanceof Player) {
xAuthPlayer xPlayer = plugin.getDataManager().getPlayerByName(((Player)entity).getName());
xAuthPlayer xPlayer = plugin.getDataManager().getPlayerByName(((Player)damager).getName());
//if (!xAuthSettings.rstrDmgGiven && !xPlayer.isRegistered())
//return;