diff --git a/src/main/java/com/cypherx/xauth/commands/LoginCommand.java b/src/main/java/com/cypherx/xauth/commands/LoginCommand.java index d74d7d5..f05ebe0 100644 --- a/src/main/java/com/cypherx/xauth/commands/LoginCommand.java +++ b/src/main/java/com/cypherx/xauth/commands/LoginCommand.java @@ -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; } diff --git a/src/main/java/com/cypherx/xauth/datamanager/DataManager.java b/src/main/java/com/cypherx/xauth/datamanager/DataManager.java index 65f7341..fa1721d 100644 --- a/src/main/java/com/cypherx/xauth/datamanager/DataManager.java +++ b/src/main/java/com/cypherx/xauth/datamanager/DataManager.java @@ -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); diff --git a/src/main/java/com/cypherx/xauth/listeners/xAuthEntityListener.java b/src/main/java/com/cypherx/xauth/listeners/xAuthEntityListener.java index c7ea63a..bd0f1a8 100644 --- a/src/main/java/com/cypherx/xauth/listeners/xAuthEntityListener.java +++ b/src/main/java/com/cypherx/xauth/listeners/xAuthEntityListener.java @@ -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;