*Added socket function (not tested, but should work)

This commit is contained in:
Lukas
2015-01-06 19:03:52 +01:00
parent c373f3b971
commit 315f4493e7

View File

@@ -42,7 +42,7 @@ public class VotifierListener implements Listener, PluginMessageListener {
System.out.println("Got vote from " + vote.getServiceName() + " Username: " + vote.getUsername() + " with Adress: " + vote.getAddress() + "@" + vote.getTimeStamp()); System.out.println("Got vote from " + vote.getServiceName() + " Username: " + vote.getUsername() + " with Adress: " + vote.getAddress() + "@" + vote.getTimeStamp());
try { try {
ResultSet rs1 = Core.getMySql().querySelect("SELECT * FROM `players` WHERE name = '" + vote.getUsername() + "'"); ResultSet rs1 = Core.getMySql().querySelect("SELECT id FROM `players` WHERE name = '" + vote.getUsername() + "'");
if (!rs1.next()) { if (!rs1.next()) {
System.out.println("Database doesn't contain player!"); System.out.println("Database doesn't contain player!");
return; return;
@@ -65,7 +65,7 @@ public class VotifierListener implements Listener, PluginMessageListener {
} }
Core.getMySql().queryUpdate("UPDATE `voteUsers` SET `dateOfLastVote`=" + timestampInt + ",`votesInARow`=" + votesInRow + " WHERE playerId=" + playerId); Core.getMySql().queryUpdate("UPDATE `voteUsers` SET `dateOfLastVote`=" + timestampInt + ",`votesInARow`=" + votesInRow + " WHERE playerId=" + playerId);
} else { } else {
Core.getMySql().queryUpdate("INSERT INTO `voteUsers`(`playerId`, `dateOfLastVote`, `votesInARow`) VALUES (" + playerId + "," + timestampInt + ",1)"); Core.getMySql().queryUpdate("INSERT INTO `voteUsers`(`playerId`, `dateOfLastVote`, `votesInARow`) VALUES (SELECT id FROM `players` WHERE name = '" + vote.getUsername() + "'," + timestampInt + ",1)");
} }
} catch (SQLException ex) { } catch (SQLException ex) {
Errors.reportException(ex); Errors.reportException(ex);