Guest User

Untitled

a guest
Dec 6th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. // Authorises a vote
  2. if (command.startsWith("auth") || command.startsWith("redeem")) {
  3. String[] parameters = command.split("-");
  4. String authorisation = parameters[1];
  5.  
  6. if (!player.getLastVoteClaim().elapsed(10000)) {
  7. player.write(new SendMessage("Please wait 5 seconds before trying vote again."));
  8. return;
  9. }
  10. Result valid;
  11. try {
  12. valid = motivote.redeem(SearchField.AUTH_CODE, authorisation);
  13.  
  14. if (valid.success()) {
  15. player.getItems().addItem(20935, 1);
  16. player.write(new SendMessage("Authorisation code redeemed, thanks for your support."));
  17. player.getLastVoteClaim().reset();
  18. CommunityVotes.contributeVote(player);
  19.  
  20. Result r3 = motivote.redeem(SearchField.IP_ADDRESS, player.ipAddress);
  21.  
  22. if (r3.success()) {
  23. int total = r3.votes().size();
  24. player.write(new SendMessage(
  25. "We Found " + total + " Auths Linked to your IpAddress, Issuing those rewards now."));
  26. if (player.getItems().freeSlots() < total) {
  27. player.getBank().addItemToBankSky(20935, total);
  28. System.out.println("Player " + player.username + " just recieved Vote books x =" + total);
  29. for (int i = 0; i < total; i++) {
  30. CommunityVotes.contributeVote(player);
  31. }
  32. } else {
  33. player.getItems().addItem(20935, total);
  34. for (int i = 0; i < total; i++) {
  35. CommunityVotes.contributeVote(player);
  36. }
  37. }
  38. } else {
  39. player.msg("Attempted to find any other Auths connected to your IpAddress");
  40. player.msg("The result wasn't positive");
  41. }
  42. } else {
  43. player.write(new SendMessage(
  44. "The authorisation [" + authorisation + "] supplied was invalid, try again!"));
  45. player.getLastVoteClaim().reset();
  46. }
  47. } catch (Exception e) {
  48. // TODO Auto-generated catch block
  49. e.printStackTrace();
  50. }
  51. }
Add Comment
Please, Sign In to add comment