Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.kirdow.enhancewynn;
- import java.io.DataOutputStream;
- import java.net.HttpURLConnection;
- public class PlayerList
- {
- public PlayerList() {}
- public static boolean testPlayer(String tag)
- {
- try
- {
- return postRequest(tag).equals("true");
- }
- catch (java.io.IOException localIOException) {}
- return false;
- }
- private static String postRequest(String tag) throws java.io.IOException {
- String url = "http://kirdow.com/WynncraftEnhanced/playerlist.php";
- java.net.URL obj = new java.net.URL(url);
- HttpURLConnection con = (HttpURLConnection)obj.openConnection();
- con.setRequestMethod("POST");
- con.setRequestProperty("User-Agent", System.getProperty("java.version"));
- String urlParameters = "tag=" + tag;
- System.out.println(urlParameters);
- con.setDoOutput(true);
- con.setDoInput(true);
- DataOutputStream wr = new DataOutputStream(con.getOutputStream());
- wr.writeBytes(urlParameters);
- wr.flush();
- wr.close();
- int responseCode = con.getResponseCode();
- if (responseCode != 200) { return "false";
- }
- java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(con.getInputStream()));
- StringBuffer response = new StringBuffer();
- String inputLine;
- while ((inputLine = in.readLine()) != null) {
- response.append(inputLine);
- }
- in.close();
- String ret = response.toString().trim();
- System.out.println(ret.length() + ":" + ret);
- return ret;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment