Skip to content

Commit

Permalink
MySQL Bugfixes
Browse files Browse the repository at this point in the history
So, that's all the bugs I've been able to find on my own. =/

I feel really dirty about releasing it in this state. But it works, and
I haven't been able to throw any bugs through my light testing. But I'm
hardly a stress tester. I'm sure someone will find something.

Because it's a MySQL release, and pretty massive, I'll be upping to
3.1.0 after this.
  • Loading branch information
FerusGrim committed May 2, 2014
1 parent bea3f23 commit 58f98bb
Showing 1 changed file with 12 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,11 @@ private void setupLogTable() {
executeUpdate("CREATE TABLE IF NOT EXISTS `uselogs` (" +
"`vicUuid` varchar(36) NOT NULL, " +
"`vicName` varchar(16) NOT NULL, " +
"`command` varchar(6) NOT NULL, " +
"`arguments` varchar(64) NOT NULL, " +
"`command` varchar(64) NOT NULL, " +
"`exUuid` varchar(36) NOT NULL, " +
"`exName` varchar(16) NOT NULL, " +
"`datePerformed` varchar(19) NOT NULL, " +
"`commandNumber` int(9) NOT NULL DEFAULT '0', " +
"`commandNumber` int(9) NOT NULL AUTO_INCREMENT, " +
"PRIMARY KEY (`commandNumber`)" +
") ENGINE=InnoDB DEFAULT CHARSET=latin1;");
}
Expand Down Expand Up @@ -184,9 +183,9 @@ public void alterRecordOnLogin(String uuid, String name, String address){
}
}

public void addCommandLog(String vicUuid, String vicName, String command, String exUuid, String exName){
public void addCommandLog(String vicName, String vicUuid, String command, String exUuid, String exName){
SimpleDateFormat fDate = new SimpleDateFormat("MM.dd.yyyy-HH:mm:ss");
String sql = "INSERT INTO `" + database + ("`.`uselogs` (`vicUuid`, `vicName`, `command`, `exUuid`, `exName`, `datePerformed`, `commandNumber`) VALUES {" +
String sql = "INSERT INTO `" + database + ("`.`uselogs` (`vicUuid`, `vicName`, `command`, `exUuid`, `exName`, `datePerformed`, `commandNumber`) VALUES (" +
"'[VICUUID]', '[VICNAME]', '[COMMAND]', '[EXUUID]', '[EXNAME]', '[DATE]', NULL);")
.replace("[VICUUID]", vicUuid)
.replace("[VICNAME]", vicName)
Expand Down Expand Up @@ -301,21 +300,19 @@ public boolean isFirstLoginSet(String uuid) {
}

public boolean isNameAPreviousName(String uuid, String name) {
List<String> usernames = new ArrayList<>();
Connection conn = null;
PreparedStatement ps = null;
try {
conn = sqlConnection();
ps = conn.prepareStatement("SELECT `usernames` FROM `" + database + "`.`previoususernames` WHERE `uuid` = ?;");
ps.setString(1, uuid);
ResultSet rs = ps.executeQuery();
int i = 1;
while (rs.next()) {
usernames.add(rs.getString(i));
i++;
if (rs.getString(1).equalsIgnoreCase(name)) {
clean(conn, ps);
return true;
}
}
clean(conn, ps);
return usernames.contains(name);
} catch (SQLException e) {
e.printStackTrace();
}
Expand All @@ -324,21 +321,19 @@ public boolean isNameAPreviousName(String uuid, String name) {
}

public boolean isAddressAPreviousAddress(String uuid, String address) {
List<String> addresses = new ArrayList<>();
Connection conn = null;
PreparedStatement ps = null;
try {
conn = sqlConnection();
ps = conn.prepareStatement("SELECT `addresses` FROM `" + database + "`.`previousaddresses` WHERE `uuid` = ?;");
ps.setString(1, uuid);
ResultSet rs = ps.executeQuery();
int i = 1;
while (rs.next()) {
addresses.add(rs.getString(i));
i++;
if (rs.getString(1).equalsIgnoreCase(address)) {
clean(conn, ps);
return true;
}
}
clean(conn, ps);
return addresses.contains(address);
} catch (SQLException e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -453,7 +448,6 @@ public void doViewPlayer(CommandSender sender, String uuid) {
}
String isWhitelisted = playerData.get(1);
String lastUsername = playerData.get(2);
String lastAddress = playerData.get(3);
String firstLogin = playerData.get(4);
String lastLogin = playerData.get(5);
String loginCount = playerData.get(6);
Expand Down

0 comments on commit 58f98bb

Please sign in to comment.