Jump to content
  • 0

L2Top Brasil Some Help

Crytek ™


private boolean isVotedInSite(String ip, VoteSite site)
            // Make URL with vote site link with player IP address
            final URL url = new URL(site.getLink(ip));
            // Open connection
            final HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
            // Set User-Agent
            httpURLConnection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36");
            // Get response code and if everything is OK try to get answer
            final int response = httpURLConnection.getResponseCode();
            if (response == HTTP_OK)
                // Get input stream from vote sites
                try (BufferedReader br = new BufferedReader(new InputStreamReader(httpURLConnection.getInputStream())))
                    // Get answer from vote site which returns true/false
                    switch (site)
                        case L2HOPZONE:
                            return br.readLine().contains("true");
                        case L2TOPZONE:
                            return br.readLine().equals("TRUE");
                        case L2NETWORK:
                            return br.readLine().equals("1");
                        case L2TOP:
                            return br.readLine().equals("TRUE");
                        case L2BR:
                            return br.readLine().equals("1");    (if is correct or request correct read)

exampe of check is




have to get check of status. there is 1 (then player not voted is 0)





<date>2017-04-24 19:34:07</date>



Edited by Crytek
Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Try change to 

return br.readLine().equals("<status>1</status>");


return br.readLine().contains("<status>1</status>");

The return is a simple xml, may you can read it using DOM XML Parser



Edited by Grundor
Link to comment
Share on other sites

  • 0

Optionally you can change the way you call.



By node: 


Or change to json output: 

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.

Answer this question...

×   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...

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