Jump to content
  • 0

Frozen Hopzone Reward


Question

Posted
protected int getHopZoneVotes()
{
int votes = -1;


try
{
final WebClient webClient = new WebClient(BrowserVersion.CHROME);
webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.getOptions().setPrintContentOnFailingStatusCode(false);


final HtmlPage page = webClient.getPage(PowerPakConfig.VOTES_SITE_HOPZONE_URL);


final String fullPage = page.asXml();
final int constrainA = fullPage.indexOf("rank anonymous tooltip") + 24;
String voteSection = fullPage.substring(constrainA);
final int constrainB = voteSection.indexOf("span") - 2;
voteSection = voteSection.substring(0, constrainB).trim();
votes = Integer.parseInt(voteSection);


// Try to free all the freaking resources
page.cleanUp();
webClient.getJavaScriptEngine().shutdown();
webClient.closeAllWindows();
}
catch (final Exception e)
{
LOGGER.warn("[AutoVoteReward] Server HOPZONE is offline or something is wrong in link", e);
Announcements.getInstance().gameAnnounceToAll("[AutoVoteReward] HOPZONE is offline. We will check reward as it will be online again");
}


return votes;
}

Maybe anyone have fixed that auto vote reward script? This is from frozen, Hopzone.

2 answers to this question

Recommended Posts

  • 0
Posted
  protected static int getHopZoneVotes()
  {
      int votes = -1;
     
      try
      {
      final URL obj = new URL(PowerPakConfig.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") || line.contains("rank tooltip") || line.contains("no steal make love") || line.contains("no votes here") || line.contains("bang, you don't have votes") || line.contains("la vita e bella") || line.contains("rank anonymous tooltip"))
                      {
                          String inputLine = line.split(">")[2].replace("</span", "");
                          votes = Integer.parseInt(inputLine);
                          break;
                      }
                  }
              }
         }
      }
catch (final Exception e)
{
LOGGER.warn("[AutoVoteReward] Server HOPZONE is offline or something is wrong in link", e);
Announcements.getInstance().gameAnnounceToAll("[AutoVoteReward] HOPZONE is offline. We will check reward as it will be online again");
}


return votes;
}

Fixed. Lock it.

Guest
This topic is now closed to further replies.
×
×
  • Create New...