From 78e827eade19c8bf19d7b9f74ee8ee9f004f63f1 Mon Sep 17 00:00:00 2001 From: Zach Iverson Date: Mon, 20 Jun 2011 01:28:20 -0400 Subject: [PATCH] 1. Fixed ENTITY_DAMAGE ClassCastException (http://forums.bukkit.org/threads/sec-xauth-v2-0-beta-1-offline-mode-security-suite-689-860.8712/page-18#post-397808) 2. Account activation fixed for servers using web registration 3. Error when a MySQL DATETIME field is 0000-00-00 00:00:00 fixed --- .../cypherx/xauth/commands/LoginCommand.java | 3 ++- .../xauth/datamanager/DataManager.java | 21 ++++++++++++++++++- .../xauth/listeners/xAuthEntityListener.java | 2 +- 3 files changed, 23 insertions(+), 3 deletions(-) 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;