Jump to content

Topzone Get Votes


Lioy

Recommended Posts

Since topzone changed again , you need to change the code. Use this one to solve your problem.

Just the getTopZoneVotes() method      (just changed Frozen's one)

protected int getTopZoneVotes()
	{
		int votes = -1;
		URL url = null;
		URLConnection con = null;
		InputStream is = null;
		InputStreamReader isr = null;
		BufferedReader in = null;
		
		try
		{
			url = new URL(PowerPakConfig.VOTES_SITE_TOPZONE_URL);
			con = url.openConnection();
			con.addRequestProperty("User-Agent", "L2TopZone");
			is = con.getInputStream();
			isr = new InputStreamReader(is);
			in = new BufferedReader(isr);
			String inputLine;
			while ((inputLine = in.readLine()) != null)
			{
				if (inputLine.contains("thumbs-up"))
				{
					int startPosition = inputLine.indexOf("</i>") + "</i>".length();
					int endPosition = inputLine.indexOf("</span>", startPosition);
					String ss = inputLine.substring(startPosition, endPosition);
					votes = Integer.valueOf(ss);
					break;
				}
			}
		}
		catch (final Exception e)
		{
			LOGGER.warn("[AutoVoteReward] Server TOPZONE is offline or something is wrong in link");
			Announcements.getInstance().gameAnnounceToAll("[AutoVoteReward] TOPZONE is offline. We will check reward as it will be online again");
			// e.printStackTrace();
		}
		finally
		{
			if (in != null)
				try
				{
					in.close();
				}
				catch (final IOException e1)
				{
					e1.printStackTrace();
				}
			if (isr != null)
				try
				{
					isr.close();
				}
				catch (final IOException e1)
				{
					e1.printStackTrace();
				}
			if (is != null)
				try
				{
					is.close();
				}
				catch (final IOException e1)
				{
					e1.printStackTrace();
				}
		}
		return votes;
	}
Edited by PonyRider❤
Link to comment
Share on other sites

Link to comment
Share on other sites

 

Never seen that before xD ,  but I think it changed again and code needs to be edited (not like my version ofc, there are too many ways) since code doesn't fit. I mean there were some <span> html tags in old topzone vote site's source code and now there aren't (and code was based on these spans , in Frozen's version at least).

Edited by PonyRider❤
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...