Little changes (look comments)

This commit is contained in:
Lukas
2015-01-08 21:32:38 +01:00
parent 5c70ba6926
commit a2d91f0bd2

View File

@@ -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);