Guest User

Untitled

a guest
Dec 11th, 2016
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package net.sf.l2j.gameserver.votereward;
  16.  
  17. import java.io.BufferedReader;
  18. import java.io.InputStreamReader;
  19. import java.net.URL;
  20. import java.net.URLConnection;
  21. import java.util.Map;
  22.  
  23. import net.sf.l2j.Config;
  24.  
  25. /**
  26. * @author Anarchy
  27. *
  28. */
  29. public class Hopzone extends VoteSystem
  30. {
  31. public Hopzone(int votesDiff, boolean allowReport, int boxes, Map<Integer, Integer> rewards, int checkMins)
  32. {
  33. super(votesDiff, allowReport, boxes, rewards, checkMins);
  34. }
  35.  
  36. @Override
  37. public void run()
  38. {
  39. reward();
  40. }
  41.  
  42. @Override
  43. public int getVotes()
  44. {
  45. InputStreamReader isr = null;
  46. BufferedReader br = null;
  47.  
  48. try
  49. {
  50. URLConnection con = new URL(Config.HOPZONE_SERVER_LINK).openConnection();
  51. con.addRequestProperty("User-Agent", "L2Hopzone");
  52. isr = new InputStreamReader(con.getInputStream());
  53. br = new BufferedReader(isr);
  54.  
  55. String line;
  56. while ((line = in.readLine()) != null)
  57. {
  58. if (line.contains("Total Votes") )
  59. {
  60. String inputLine = line.split(">")[2].replace("</span", "");
  61. votes = Integer.parseInt(inputLine);
  62. break;
  63. }
  64. }
  65.  
  66. br.close();
  67. isr.close();
  68. }
  69. catch (Exception e)
  70. {
  71. e.printStackTrace();
  72. System.out.println("Error while getting server vote count from "+getSiteName()+".");
  73. }
  74.  
  75. return -1;
  76. }
  77.  
  78. @Override
  79. public String getSiteName()
  80. {
  81. return "Hopzone";
  82. }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment