Jump to content

Recommended Posts

Posted (edited)

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
Posted


@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;

}

Posted

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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock