SHARE
TWEET

iTopZ Vote reward

a guest Feb 21st, 2020 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.BufferedReader;
  2. import java.io.InputStreamReader;
  3. import java.net.URL;
  4. import java.net.URLConnection;
  5. import java.util.Collection;
  6. import java.util.HashMap;
  7.  
  8. public class Main
  9. {
  10.     private int votes;
  11.     private int rank;
  12.     private int wanted_votes;
  13.     private int next_rank;
  14.     private String iTopZ = "https://itopz.com/check/";
  15.     private String Json = "?json=true";
  16.     private String ApiKey;
  17.     private int ServerId;
  18.     private boolean UseJson;
  19.    
  20.     public void main()
  21.     {
  22.         ApiKey = "elYhDvMxrH-DSeQCXVR2kGyGsKrHB03"; // Config.ITOPZ_API_KEY
  23.         ServerId = 4; // Config.ITOPZ_SERVER_ID
  24.         UseJson = true; // Config.ITOPZ_READ_FORMAT
  25.         getVotes();
  26.         System.out.println("Votes: " + votes);
  27.         System.out.println("Ranking: " + rank);
  28.         System.out.println("Next rank votes needed: " + wanted_votes);
  29.         System.out.println("Next rank will be: " + next_rank);
  30.     }
  31.    
  32.     private int getVotes()
  33.     {
  34.         String iTopZurl = iTopZ + ApiKey + "/" + ServerId + "/" + (UseJson == true ? Json : null);
  35.         URLConnection con = null;
  36.         try
  37.         {
  38.             con = new URL(iTopZurl).openConnection();
  39.             con.addRequestProperty("User-Agent", "Mozilla/4.76");
  40.             try (BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream())))
  41.             {
  42.                 String line;
  43.                 while ((line = br.readLine()) != null)
  44.                 {
  45.                     if (line.contains("server_votes"))
  46.                     {
  47.                         votes = Integer.valueOf(line.replaceAll("[^\\d]", ""));
  48.                     }
  49.                     if (line.contains("server_rank"))
  50.                     {
  51.                         rank = Integer.valueOf(line.replaceAll("[^\\d]", ""));
  52.                     }
  53.                     if (line.contains("next_rank_votes"))
  54.                     {
  55.                         wanted_votes = Integer.valueOf(line.replaceAll("[^\\d]", ""));
  56.                     }
  57.                     if (line.contains("next_rank"))
  58.                     {
  59.                         next_rank = Integer.valueOf(line.replaceAll("[^\\d]", ""));
  60.                     }
  61.                 }
  62.             }
  63.         }
  64.         catch(Exception e)
  65.         {
  66.             System.out.println(e);
  67.             System.out.println("Error while getting iTopZ server info.");
  68.         }
  69.         return -1;
  70.     }
  71. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top