Advertisement
MystoGan64

L2Topzone Vote Reward 15 6 2016

Jun 14th, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.58 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 Topzone extends VoteSystem
  30. {
  31.        public Topzone(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.TOPZONE_SERVER_LINK).openConnection();
  51.                         con.addRequestProperty("User-Agent", "L2TopZone");
  52.                         isr = new InputStreamReader(con.getInputStream());
  53.                         br = new BufferedReader(isr);
  54.  
  55.                         String line;
  56.                         while ((line = br.readLine()) != null)
  57.                         {
  58.                                
  59.                                         int votes = Integer.valueOf(line);
  60.                                         return votes;
  61.                              
  62.                         }
  63.                      
  64.                         br.close();
  65.                         isr.close();
  66.                 }
  67.                catch (Exception e)
  68.                {
  69.                        e.printStackTrace();
  70.                        System.out.println("Error while getting server vote count from "+getSiteName()+".");
  71.                }
  72.              
  73.                return -1;
  74.        }
  75.  
  76.        @Override
  77.        public String getSiteName()
  78.        {
  79.                return "Topzone";
  80.        }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement