AMP automation

This commit is contained in:
Seth
2020-08-07 22:51:09 -07:00
parent 075299dbd9
commit 2ecde80b5f
15 changed files with 355 additions and 55 deletions

View File

@ -223,7 +223,7 @@ public class FUtil
List<String> headers = new ArrayList<>();
headers.add("Accept:application/json");
headers.add("Content-Type:application/json");
String response = postRequestToEndpoint("https://api.mojang.com/profiles/minecraft", "POST", headers, json.toString());
String response = sendRequest("https://api.mojang.com/profiles/minecraft", "POST", headers, json.toString());
// Don't care how stupid this looks, couldn't find anything to parse a json string to something readable in java with something not horrendously huge, maybe im just retarded
Pattern pattern = Pattern.compile("(?<=\"id\":\")[a-f0-9].{31}");
Matcher matcher = pattern.matcher(response);
@ -240,7 +240,7 @@ public class FUtil
return null;
}
public static String postRequestToEndpoint(String endpoint, String method, List<String>headers, String body) throws IOException
public static String sendRequest(String endpoint, String method, List<String>headers, String body) throws IOException
{
URL url = new URL(endpoint);
HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();
@ -639,12 +639,26 @@ public class FUtil
}
public static String randomString(int length)
{
String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvxyz0123456789-_=+[]{};:,.<>~";
String randomString = "";
for (int i = 0; i < length; i++)
{
int selectedCharacter = randomInteger(1, characters.length()) - 1;
randomString += characters.charAt(selectedCharacter);
}
return randomString;
}
public static String randomAlphanumericString(int length)
{
String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvxyz0123456789";
String randomString = "";
for (int i = 0; i < length; i++)
{
int selectedCharacter = randomInteger(1, characters.length()) - 1;
randomString += characters.charAt(selectedCharacter);