Guest User

Untitled

a guest
Apr 7th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. if (playerCommand.startsWith("auth") && playerCommand.length() > 5) {
  2. //if (!Config.MYSQL_ACTIVE) {
  3. // c.sendMessage("Sorry this is currently disabled.");
  4. // return;
  5. //} else {
  6. try {
  7. //PreparedStatement ps =
  8. java.sql.Connection con = DriverManager.getConnection("jdbc:mysql://zionscape.com:3306/zionscap_vote", "zionscap_votsusr", "livinlarge12");
  9. PreparedStatement ps = con
  10. .prepareStatement(
  11. "SELECT * FROM votes WHERE username = ? AND used = '1' LIMIT 1");
  12. ps.setString(1, c.playerName);
  13. ResultSet results = ps.executeQuery();
  14. if (results.next()) {
  15. c.sendMessage("You have already voted once today.");
  16. } else {
  17. ps.close();
  18. ps = con
  19. .prepareStatement(
  20. "SELECT * FROM votes WHERE authcode = ? AND used = '0' LIMIT 1");
  21. ps.setString(1, playerCommand.substring(5));
  22. results = ps.executeQuery();
  23. if (results.next()) {
  24. ps.close();
  25. ps = con.prepareStatement(
  26. "UPDATE votes SET used = '1' WHERE authcode = ?");
  27. ps.setString(1, playerCommand.substring(5));
  28. ps.executeUpdate();
  29. c.votePoints += 1;
  30. c.sendMessage("Thank you for voting.");
  31. c.sendMessage("You now have @red@" + c.votePoints
  32. + "@bla@ vote points");
  33. } else {
  34. c.sendMessage("The auth code is not valid!");
  35. }
  36. }
  37. ps.close();//what about that ps? this code is ugly n 'shit ol
  38. } catch (Exception e) {
  39. e.printStackTrace();
  40. }
  41. return;
  42. }
Add Comment
Please, Sign In to add comment