Jump to content

Hopzone/topzone/network Vote Reward [Re-Share]


An4rchy

Recommended Posts

Not all only the lines replace yours with this is just the same

String line;
           while ((line = in.readLine()) != null)
           {
               if (line.contains("Total Votes") )
               {
                   String inputLine = line.split(">")[2].replace("</span", "");
                   votes = Integer.parseInt(inputLine);
                   break;
Edited by Reborn12
Link to comment
Share on other sites


@Override

public int getVotes()

{

int votes = -1;

try

{

final URL obj = new URL(Config.VOTES_SITE_HOPZONE_URL);

final HttpURLConnection con = (HttpURLConnection) obj.openConnection();

con.addRequestProperty("User-Agent", "L2Hopzone");

con.setConnectTimeout(5000);

 

final int responseCode = con.getResponseCode();

if (responseCode == 200)

{

try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())))

{

String line;

while ((line = in.readLine()) != null)

{

if (line.contains("Total Votes") )

{

String inputLine = line.split(">")[2].replace("</span", "");

votes = Integer.parseInt(inputLine);

break;

}

}

}

}

}

catch (Exception e)

{

e.printStackTrace();

System.out.println("Error while getting server vote count from "+getSiteName()+".");

}

 

return votes;

}

Link to comment
Share on other sites

Since hopzone has an API to get the total votes you should use that. I used the old way in this vote system by reading the votes from the server information page.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




×
×
  • Create New...