Advertisement
Guest User

Untitled

a guest
Jun 29th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. tMan.register(new Runnable() {
  2. @Override
  3. public void run() {
  4. try {
  5. PreparedStatement ps = null;
  6. ResultSet rs = null;
  7. for (Channel ch : Server.getInstance().getAllChannels())
  8. for (MapleCharacter player : ch.getPlayerStorage().getAllCharacters()) {
  9. int sites = 3; // Add up the sum of the site IDs and subtract to get which site is leftover (only works if there are 2 voting sites)
  10. ps = DatabaseConnection.getConnection().prepareStatement("SELECT siteid,account,date from votingrecords WHERE account = ?");
  11. ps.setString(1, player.getClient().getAccountName());
  12. rs = ps.executeQuery();
  13.  
  14. if (!rs.next()) {
  15. player.dropMessage("You can vote for the first time!");
  16. continue;
  17. } do {
  18. long lastvote = rs.getInt("date");
  19. int siteid = rs.getInt("siteid");
  20.  
  21. if (siteid == 1 && player.canVoteGTOP(lastvote))
  22. player.dropMessage("You can now vote for GTOP100!");
  23. else if (siteid == 2 && player.canVoteUltimate(lastvote))
  24. player.dropMessage("You can now vote for UltimatePrivateServers!");
  25. sites -= siteid;
  26. } while (rs.next());
  27.  
  28. if (sites > 0)
  29. player.dropMessage("You can now vote for " + (sites == 1 ? "GTOP100" : "UltimatePrivateServers") + "!");
  30. }
  31. ps.close();
  32. rs.close();
  33. } catch (Exception e) {
  34. System.out.println("Vote checker failed");
  35. }
  36. }
  37. }, 60000, 10000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement