diff --git a/src/de/anura/core/events/VotifierListener.java b/src/de/anura/core/events/VotifierListener.java index fa2e8d3..4631e30 100644 --- a/src/de/anura/core/events/VotifierListener.java +++ b/src/de/anura/core/events/VotifierListener.java @@ -26,34 +26,30 @@ import org.bukkit.plugin.messaging.PluginMessageListener; public class VotifierListener implements Listener, PluginMessageListener { - private int timestampInt; - private int votesInRow; - private int playerId; - @EventHandler public void onVotifierEvent(VotifierEvent event) { Vote vote = event.getVote(); String timestamp = vote.getTimeStamp(); + int timestampInt; try { timestampInt = Integer.parseInt(timestamp); } catch (NumberFormatException ex) { timestampInt = (int) (System.currentTimeMillis() / 1000); } - System.out.println("Got vote from " + vote.getServiceName() + " Username: " + vote.getUsername() + " with Adress: " + vote.getAddress() + " @ " + vote.getTimeStamp()); try { ResultSet rs1 = Core.getMySql().querySelect("SELECT id FROM `players` WHERE name = '" + vote.getUsername() + "'"); if (!rs1.next()) { - System.out.println("Database doesn't contain player!"); return; } - System.out.println("Found Player in Database!"); addPlayerMoney(25, vote); + int playerId; playerId = rs1.getInt("id"); ResultSet rs2 = Core.getMySql().querySelect("SELECT * FROM `voteUsers` WHERE playerId = '" + playerId + "'"); if (rs2.first()) { int lastVoteDate = rs2.getInt("dateOfLastVote"); + int votesInRow; votesInRow = rs2.getInt("votesInARow"); - if (lastVoteDate > ((System.currentTimeMillis() / 1000) - 86400)) { + if (lastVoteDate > ((System.currentTimeMillis() / 1000) - (60*60*24))) { votesInRow++; if (votesInRow == 10) { addPlayerMoney(50, vote);