mirror of
https://github.com/refactorinqq/SLC-1.8.9.git
synced 2024-11-10 07:01:32 +01:00
Requests Library
This commit is contained in:
parent
fe11ce847b
commit
afeb9e3e6d
@ -11,9 +11,12 @@ import net.silentclient.client.cosmetics.Cosmetics;
|
||||
import net.silentclient.client.event.EventManager;
|
||||
import net.silentclient.client.event.EventTarget;
|
||||
import net.silentclient.client.event.impl.ClientTickEvent;
|
||||
import net.silentclient.client.event.impl.ConnectToServerEvent;
|
||||
import net.silentclient.client.event.impl.RenderEvent;
|
||||
import net.silentclient.client.gui.GuiError;
|
||||
import net.silentclient.client.gui.clickgui.ClickGUI;
|
||||
import net.silentclient.client.gui.font.SilentFontRenderer;
|
||||
import net.silentclient.client.gui.notification.NotificationManager;
|
||||
import net.silentclient.client.gui.util.BackgroundPanorama;
|
||||
import net.silentclient.client.keybinds.KeyBindManager;
|
||||
import net.silentclient.client.mods.ModInstances;
|
||||
@ -28,6 +31,7 @@ import net.silentclient.client.utils.culling.EntityCulling;
|
||||
import net.silentclient.client.utils.types.*;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.json.JSONObject;
|
||||
import org.lwjgl.opengl.GLContext;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
@ -198,7 +202,7 @@ public class Client {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation(mod.getIcon()));
|
||||
}
|
||||
});
|
||||
logger.info("STARTING > friends");
|
||||
logger.info("STARTING > servers");
|
||||
FeaturedServersResponse servers = FeaturedServers.get();
|
||||
featuredServers.clear();
|
||||
if(servers != null && servers.getServers() != null) {
|
||||
@ -207,6 +211,7 @@ public class Client {
|
||||
});
|
||||
}
|
||||
|
||||
logger.info("STARTING > friends");
|
||||
this.updateFriendsList();
|
||||
|
||||
if(Client.getInstance().getAccount() == null) {
|
||||
@ -242,6 +247,9 @@ public class Client {
|
||||
Minecraft.getMinecraft().displayGuiScreen(new PremiumCosmeticsGui(premiumCosmetics));
|
||||
}
|
||||
}
|
||||
|
||||
Client.logger.info("STARTING > launching-detector");
|
||||
Requests.post("https://api.silentclient.net/_next/launch_v2", new JSONObject().put("branch", getBuildData().getBranch()).toString());
|
||||
} catch(Exception err) {
|
||||
logger.info("STARTING > ERROR: " + err.getMessage());
|
||||
throw err;
|
||||
@ -392,6 +400,20 @@ public class Client {
|
||||
}
|
||||
}
|
||||
|
||||
@EventTarget
|
||||
public void renderNotification(RenderEvent event) {
|
||||
NotificationManager.render();
|
||||
}
|
||||
|
||||
@EventTarget
|
||||
public void onServerConnect(ConnectToServerEvent event) {
|
||||
ping = 0;
|
||||
playersCount = 0;
|
||||
nextPing = 10;
|
||||
this.updateUserInformation();
|
||||
silentSocket.getSocket().emit("update_information", (Minecraft.getMinecraft().getCurrentServerData() != null ? Minecraft.getMinecraft().getCurrentServerData().serverIP : ""));
|
||||
}
|
||||
|
||||
// Instances
|
||||
public FriendsResponse getFriends() {
|
||||
return friends;
|
||||
|
@ -1,17 +1,7 @@
|
||||
package net.silentclient.client.cosmetics;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@ -21,10 +11,15 @@ import net.silentclient.client.cosmetics.model.ModelBuffer;
|
||||
import net.silentclient.client.mixin.ducks.AbstractClientPlayerExt;
|
||||
import net.silentclient.client.mods.settings.CosmeticsMod;
|
||||
import net.silentclient.client.utils.Players;
|
||||
import net.silentclient.client.utils.Requests;
|
||||
import net.silentclient.client.utils.types.CosmeticsResponse;
|
||||
import net.silentclient.client.utils.types.PlayerResponse;
|
||||
import net.silentclient.client.utils.types.PlayerResponse.Account.Cosmetics.CosmeticItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Cosmetics {
|
||||
public Map<Number, AnimatedResourceLocation> capes = new HashMap<>();
|
||||
public Map<Number, StaticResourceLocation> capesShoulders = new HashMap<>();
|
||||
@ -226,26 +221,13 @@ public class Cosmetics {
|
||||
|
||||
public static CosmeticsResponse getAllCosmetics() {
|
||||
try {
|
||||
URL url = new URL("https://api.silentclient.net/_next/get_cosmetics");
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
Client.logger.info("STARTING > cosmeitcs > response: " + content.toString());
|
||||
in.close();
|
||||
con.disconnect();
|
||||
String content = Requests.get("https://api.silentclient.net/_next/get_cosmetics");
|
||||
GsonBuilder builder = new GsonBuilder();
|
||||
Gson gson = builder.create();
|
||||
|
||||
CosmeticsResponse response = gson.fromJson(content.toString(), CosmeticsResponse.class);
|
||||
return response;
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
@ -253,26 +235,13 @@ public class Cosmetics {
|
||||
|
||||
public static PlayerResponse getCosmetics() {
|
||||
try {
|
||||
URL url = new URL("https://api.silentclient.net/account");
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
con.setRequestProperty("Authorization", "Bearer " + Client.getInstance().getUserData().getAccessToken());
|
||||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
con.disconnect();
|
||||
String content = Requests.get("https://api.silentclient.net/account");
|
||||
GsonBuilder builder = new GsonBuilder();
|
||||
Gson gson = builder.create();
|
||||
|
||||
PlayerResponse response = gson.fromJson(content.toString(), PlayerResponse.class);
|
||||
return response;
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
@ -1,23 +1,11 @@
|
||||
package net.silentclient.client.gui.friends;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import net.silentclient.client.gui.SilentScreen;
|
||||
import net.silentclient.client.utils.MenuBlurUtils;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.silentclient.client.Client;
|
||||
import net.silentclient.client.gui.SilentScreen;
|
||||
import net.silentclient.client.gui.clickgui.utils.RenderUtils;
|
||||
import net.silentclient.client.gui.elements.Button;
|
||||
import net.silentclient.client.gui.elements.IconButton;
|
||||
@ -25,8 +13,12 @@ import net.silentclient.client.gui.elements.Input;
|
||||
import net.silentclient.client.gui.font.SilentFontRenderer;
|
||||
import net.silentclient.client.gui.notification.NotificationManager;
|
||||
import net.silentclient.client.gui.theme.Theme;
|
||||
import net.silentclient.client.mods.settings.GeneralMod;
|
||||
import net.silentclient.client.utils.MenuBlurUtils;
|
||||
import net.silentclient.client.utils.NotificationUtils;
|
||||
import net.silentclient.client.utils.Requests;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class AddFriendModal extends SilentScreen {
|
||||
private final GuiScreen parentScreen;
|
||||
@ -59,32 +51,11 @@ public class AddFriendModal extends SilentScreen {
|
||||
break;
|
||||
case 2:
|
||||
if(this.silentInputs.get(0).getValue().length() != 0) {
|
||||
try {
|
||||
URL url = new URL("https://api.silentclient.net/friends/send_request");
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
con.setRequestProperty("Authorization", "Bearer " + Client.getInstance().getUserData().getAccessToken());
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
con.setRequestProperty("Accept", "application/json");
|
||||
con.setDoOutput(true);
|
||||
String jsonInputString = "{\"username\": \"" + this.silentInputs.get(0).getValue() + "\"}";
|
||||
try(OutputStream os = con.getOutputStream()) {
|
||||
byte[] input = jsonInputString.getBytes("utf-8");
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
con.disconnect();
|
||||
String content = Requests.get("https://api.silentclient.net/friends/send_request");
|
||||
if(content != null) {
|
||||
Client.getInstance().updateFriendsList();
|
||||
mc.displayGuiScreen(parentScreen);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} else {
|
||||
NotificationUtils.showNotification("Error", "User not found or you have already added him as a friend");
|
||||
}
|
||||
} else {
|
||||
|
@ -1,42 +1,20 @@
|
||||
package net.silentclient.client.premium;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.silentclient.client.Client;
|
||||
import net.silentclient.client.utils.Requests;
|
||||
import net.silentclient.client.utils.types.PremiumCosmeticsResponse;
|
||||
|
||||
public class PremiumUtils {
|
||||
public static PremiumCosmeticsResponse getPremiumCosmetics() {
|
||||
try {
|
||||
URL url = new URL("https://api.silentclient.net/premium_cosmetics");
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
con.setRequestProperty("Authorization", "Bearer " + Client.getInstance().getUserData().getAccessToken());
|
||||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
con.disconnect();
|
||||
String content = Requests.get("https://api.silentclient.net/premium_cosmetics");
|
||||
GsonBuilder builder = new GsonBuilder();
|
||||
Gson gson = builder.create();
|
||||
|
||||
PremiumCosmeticsResponse response = gson.fromJson(content.toString(), PremiumCosmeticsResponse.class);
|
||||
PremiumCosmeticsResponse response = gson.fromJson(content, PremiumCosmeticsResponse.class);
|
||||
return response;
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
@ -1,42 +1,19 @@
|
||||
package net.silentclient.client.utils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import net.silentclient.client.Client;
|
||||
import net.silentclient.client.utils.types.FeaturedServersResponse;
|
||||
|
||||
public class FeaturedServers {
|
||||
public static FeaturedServersResponse get() {
|
||||
try {
|
||||
URL url = new URL("https://api.silentclient.net/_next/servers.json");
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
Client.logger.info("Loaded servers: " + content.toString());
|
||||
in.close();
|
||||
con.disconnect();
|
||||
String content = Requests.get("https://api.silentclient.net/_next/servers.json");
|
||||
GsonBuilder builder = new GsonBuilder();
|
||||
Gson gson = builder.create();
|
||||
|
||||
FeaturedServersResponse response = gson.fromJson(content.toString(), FeaturedServersResponse.class);
|
||||
return response;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +1,15 @@
|
||||
package net.silentclient.client.utils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.silentclient.client.Client;
|
||||
import net.silentclient.client.utils.types.HypixelProxyResponse;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class HypixelUtils {
|
||||
private static final Map<UUID, String> levelCache = new HashMap<>();
|
||||
public static boolean isLoading = false;
|
||||
@ -38,23 +31,11 @@ public class HypixelUtils {
|
||||
(new Thread() {
|
||||
public void run() {
|
||||
try {
|
||||
URL url = new URL("https://hypixel.silentclient.net/uuid/" + id.toString() + ".json");
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
con.disconnect();
|
||||
String content = Requests.get("https://hypixel.silentclient.net/uuid/" + id.toString() + ".json");
|
||||
GsonBuilder builder = new GsonBuilder();
|
||||
Gson gson = builder.create();
|
||||
|
||||
HypixelProxyResponse response = gson.fromJson(content.toString(), HypixelProxyResponse.class);
|
||||
HypixelProxyResponse response = gson.fromJson(content, HypixelProxyResponse.class);
|
||||
|
||||
if(response != null && !response.error) {
|
||||
levelCache.put(id, Integer.toString(response.level));
|
||||
@ -67,7 +48,7 @@ public class HypixelUtils {
|
||||
Client.logger.catching(e);
|
||||
}
|
||||
HypixelUtils.isLoading = false;
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
Client.logger.catching(e);
|
||||
levelCache.put(id, "null");
|
||||
}
|
||||
|
@ -11,12 +11,6 @@ import net.silentclient.client.mixin.ducks.AbstractClientPlayerExt;
|
||||
import net.silentclient.client.mods.settings.CosmeticsMod;
|
||||
import net.silentclient.client.utils.types.PlayerResponse;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@ -131,90 +125,15 @@ public class Players {
|
||||
|
||||
public static PlayerResponse getAccount(String name) {
|
||||
try {
|
||||
URL url = new URL("https://api.silentclient.net/account/"+name);
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
con.disconnect();
|
||||
String content = Requests.get("https://api.silentclient.net/account/"+name);
|
||||
GsonBuilder builder = new GsonBuilder();
|
||||
Gson gson = builder.create();
|
||||
|
||||
PlayerResponse response = gson.fromJson(content.toString(), PlayerResponse.class);
|
||||
PlayerResponse response = gson.fromJson(content, PlayerResponse.class);
|
||||
return response;
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
Client.logger.catching(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
try {
|
||||
URL url = new URL("https://api.silentclient.net/account/set_online");
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
con.setRequestProperty("Authorization", "Bearer " + Client.getInstance().getUserData().getAccessToken());
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
con.setRequestProperty("Accept", "application/json");
|
||||
con.setDoOutput(true);
|
||||
String jsonInputString = "{\"online\": " + true + "}";
|
||||
try(OutputStream os = con.getOutputStream()) {
|
||||
byte[] input = jsonInputString.getBytes("utf-8");
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
|
||||
Client.logger.info("STARTING > registering-player > response: " + content.toString());
|
||||
|
||||
in.close();
|
||||
con.disconnect();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Client.logger.info("STARTING > registering-player > ERROR: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static void unregister() {
|
||||
try {
|
||||
URL url = new URL("https://api.silentclient.net/account/set_online");
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
con.setRequestProperty("Authorization", "Bearer " + Client.getInstance().getUserData().getAccessToken());
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
con.setRequestProperty("Accept", "application/json");
|
||||
con.setDoOutput(true);
|
||||
String jsonInputString = "{\"online\": " + false + "}";
|
||||
try(OutputStream os = con.getOutputStream()) {
|
||||
byte[] input = jsonInputString.getBytes("utf-8");
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
|
||||
Client.logger.info("STOPPING > unregistering-player > response: " + content.toString());
|
||||
|
||||
in.close();
|
||||
con.disconnect();
|
||||
} catch (IOException e) {
|
||||
Client.logger.error("STOPPING > unregistering-player > ERROR: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
57
src/main/java/net/silentclient/client/utils/Requests.java
Normal file
57
src/main/java/net/silentclient/client/utils/Requests.java
Normal file
@ -0,0 +1,57 @@
|
||||
package net.silentclient.client.utils;
|
||||
|
||||
import net.silentclient.client.Client;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
|
||||
public class Requests {
|
||||
public static String get(String url) {
|
||||
return request("GET", url, null);
|
||||
}
|
||||
|
||||
public static String post(String url, String data) {
|
||||
return request("POST", url, data);
|
||||
}
|
||||
|
||||
public static String post(String url) {
|
||||
return request("POST", url, null);
|
||||
}
|
||||
|
||||
public static String request(String method, String urlOriginal, String data) {
|
||||
try {
|
||||
Client.logger.info("Sending a " + method + " Request to a URL: " + urlOriginal + " with data: " + data);
|
||||
URL url = new URL(urlOriginal);
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod(method);
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
con.setRequestProperty("Authorization", "Bearer " + Client.getInstance().getUserData().getAccessToken());
|
||||
if(data != null) {
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
con.setRequestProperty("Accept", "application/json");
|
||||
con.setDoOutput(true);
|
||||
try(OutputStream os = con.getOutputStream()) {
|
||||
byte[] input = data.getBytes("utf-8");
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
}
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
con.disconnect();
|
||||
Client.logger.info(method + " Request ("+ urlOriginal +") Response: " + content.toString());
|
||||
return content.toString();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,28 +1,22 @@
|
||||
package net.silentclient.client.utils.types;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigInteger;
|
||||
import java.net.URL;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.silentclient.client.Client;
|
||||
import net.silentclient.client.mixin.ducks.AbstractClientPlayerExt;
|
||||
import net.silentclient.client.utils.Players;
|
||||
import net.silentclient.client.utils.Requests;
|
||||
import net.silentclient.client.utils.reply.AbstractReply;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class PlayerResponse extends AbstractReply {
|
||||
public boolean errors;
|
||||
public Account account;
|
||||
|
||||
public Account getAccount() {
|
||||
@ -92,36 +86,7 @@ public class PlayerResponse extends AbstractReply {
|
||||
public Cosmetics cosmetics;
|
||||
|
||||
public void setPlusIconColor(int plus_icon_color) {
|
||||
try {
|
||||
URL url = new URL("https://api.silentclient.net/plus/set_icon_color");
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
con.setRequestProperty("Authorization", "Bearer " + Client.getInstance().getUserData().getAccessToken());
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
con.setRequestProperty("Accept", "application/json");
|
||||
con.setDoOutput(true);
|
||||
String jsonInputString = "{\"color\": " + plus_icon_color + "}";
|
||||
try(OutputStream os = con.getOutputStream()) {
|
||||
byte[] input = jsonInputString.getBytes("utf-8");
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
con.disconnect();
|
||||
this.plus_icon_color = plus_icon_color;
|
||||
Players.reload();
|
||||
if(Minecraft.getMinecraft().thePlayer != null) {
|
||||
Players.getPlayerStatus(false, ((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getNameClear(), EntityPlayer.getUUID(Minecraft.getMinecraft().thePlayer.getGameProfile()), Minecraft.getMinecraft().thePlayer);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int getSelectedMask() {
|
||||
@ -136,31 +101,7 @@ public class PlayerResponse extends AbstractReply {
|
||||
Players.handleAccount(this);
|
||||
(new Thread("updateFavorite") {
|
||||
public void run() {
|
||||
try {
|
||||
URL url = new URL("https://api.silentclient.net/account/update_favorite_cosmetics");
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
con.setRequestProperty("Authorization", "Bearer " + Client.getInstance().getUserData().getAccessToken());
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
con.setRequestProperty("Accept", "application/json");
|
||||
con.setDoOutput(true);
|
||||
String jsonInputString = "{\"id\": " + id + ", \"type\": \"" + type + "\"}";
|
||||
try(OutputStream os = con.getOutputStream()) {
|
||||
byte[] input = jsonInputString.getBytes("utf-8");
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
con.disconnect();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Requests.post("https://api.silentclient.net/account/update_favorite_cosmetics", new JSONObject().put("id", id).put("type", type).toString());
|
||||
Client.getInstance().updateUserInformation();
|
||||
}
|
||||
}).start();
|
||||
@ -171,32 +112,8 @@ public class PlayerResponse extends AbstractReply {
|
||||
Players.handleAccount(this);
|
||||
(new Thread() {
|
||||
public void run() {
|
||||
try {
|
||||
URL url = new URL("https://api.silentclient.net/plus/set_bandana_color");
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
con.setRequestProperty("Authorization", "Bearer " + Client.getInstance().getUserData().getAccessToken());
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
con.setRequestProperty("Accept", "application/json");
|
||||
con.setDoOutput(true);
|
||||
String jsonInputString = "{\"color\": " + color + "}";
|
||||
try(OutputStream os = con.getOutputStream()) {
|
||||
byte[] input = jsonInputString.getBytes("utf-8");
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
con.disconnect();
|
||||
Client.getInstance().updateUserInformation();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Requests.post("https://api.silentclient.net/plus/set_bandana_color", new JSONObject().put("color", color).toString());
|
||||
Client.getInstance().updateUserInformation();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
@ -230,27 +147,7 @@ public class PlayerResponse extends AbstractReply {
|
||||
}
|
||||
|
||||
public void claimPremiumCosmetics() {
|
||||
try {
|
||||
URL url = new URL("https://api.silentclient.net/plus/claim_premium_cosmetics");
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
con.setRequestProperty("Authorization", "Bearer " + Client.getInstance().getUserData().getAccessToken());
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
|
||||
Client.logger.info("claim-premium-cosmetics > response: " + content.toString());
|
||||
|
||||
in.close();
|
||||
con.disconnect();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Client.logger.error("claim-premium-cosmetics > ERROR: " + e.getMessage());
|
||||
}
|
||||
Requests.post("https://api.silentclient.net/plus/claim_premium_cosmetics");
|
||||
}
|
||||
|
||||
public void setShowNametagMessage(boolean show) {
|
||||
@ -258,32 +155,8 @@ public class PlayerResponse extends AbstractReply {
|
||||
Players.handleAccount(this);
|
||||
(new Thread("setShowNametagMessage") {
|
||||
public void run() {
|
||||
try {
|
||||
URL url = new URL("https://api.silentclient.net/plus/set_nametag_message");
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
con.setRequestProperty("Authorization", "Bearer " + Client.getInstance().getUserData().getAccessToken());
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
con.setRequestProperty("Accept", "application/json");
|
||||
con.setDoOutput(true);
|
||||
String jsonInputString = "{\"enabled\": " + show + "}";
|
||||
try(OutputStream os = con.getOutputStream()) {
|
||||
byte[] input = jsonInputString.getBytes("utf-8");
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
con.disconnect();
|
||||
Client.getInstance().updateUserInformation();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Requests.post("https://api.silentclient.net/plus/set_nametag_message", new JSONObject().put("enabled", show).toString());
|
||||
Client.getInstance().updateUserInformation();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
@ -293,32 +166,8 @@ public class PlayerResponse extends AbstractReply {
|
||||
Players.handleAccount(this);
|
||||
(new Thread("setShowNametagMessage") {
|
||||
public void run() {
|
||||
try {
|
||||
URL url = new URL("https://api.silentclient.net/plus/set_nametag_message");
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
con.setRequestProperty("Authorization", "Bearer " + Client.getInstance().getUserData().getAccessToken());
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
con.setRequestProperty("Accept", "application/json");
|
||||
con.setDoOutput(true);
|
||||
String jsonInputString = "{\"message\": \"" + message + "\"}";
|
||||
try(OutputStream os = con.getOutputStream()) {
|
||||
byte[] input = jsonInputString.getBytes("utf-8");
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
con.disconnect();
|
||||
Client.getInstance().updateUserInformation();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Requests.post("https://api.silentclient.net/plus/set_nametag_message", new JSONObject().put("message", message).toString());
|
||||
Client.getInstance().updateUserInformation();
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
@ -335,31 +184,7 @@ public class PlayerResponse extends AbstractReply {
|
||||
}
|
||||
(new Thread("setShoulders") {
|
||||
public void run() {
|
||||
try {
|
||||
URL url = new URL("https://api.silentclient.net/account/set_cape_shoulders");
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
con.setRequestProperty("Authorization", "Bearer " + Client.getInstance().getUserData().getAccessToken());
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
con.setRequestProperty("Accept", "application/json");
|
||||
con.setDoOutput(true);
|
||||
String jsonInputString = "{\"enabled\": " + shoulders + "}";
|
||||
try(OutputStream os = con.getOutputStream()) {
|
||||
byte[] input = jsonInputString.getBytes("utf-8");
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
con.disconnect();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Requests.post("https://api.silentclient.net/account/set_cape_shoulders", new JSONObject().put("enabled", shoulders).toString());
|
||||
Client.getInstance().updateUserInformation();
|
||||
}
|
||||
}).start();
|
||||
@ -372,31 +197,7 @@ public class PlayerResponse extends AbstractReply {
|
||||
Players.handleAccount(this);
|
||||
(new Thread("setCapeType") {
|
||||
public void run() {
|
||||
try {
|
||||
URL url = new URL("https://api.silentclient.net/account/set_cape_type");
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
con.setRequestProperty("Authorization", "Bearer " + Client.getInstance().getUserData().getAccessToken());
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
con.setRequestProperty("Accept", "application/json");
|
||||
con.setDoOutput(true);
|
||||
String jsonInputString = "{\"type\": \"" + type + "\"}";
|
||||
try(OutputStream os = con.getOutputStream()) {
|
||||
byte[] input = jsonInputString.getBytes("utf-8");
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
con.disconnect();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Requests.post("https://api.silentclient.net/account/set_cape_type", new JSONObject().put("enabled", type).toString());
|
||||
Client.getInstance().updateUserInformation();
|
||||
}
|
||||
}).start();
|
||||
@ -478,76 +279,6 @@ public class PlayerResponse extends AbstractReply {
|
||||
return (isPlus() && custom_cape == 1) ? true : false;
|
||||
}
|
||||
|
||||
public void setCustomCape(boolean custom_cape) {
|
||||
this.custom_cape = custom_cape ? 1 : 0;
|
||||
Players.handleAccount(this);
|
||||
(new Thread("setCustomCapeRequest") {
|
||||
public void run() {
|
||||
try {
|
||||
URL url = new URL("https://api.silentclient.net/plus/set_custom_cape");
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
con.setRequestProperty("Authorization", "Bearer " + Client.getInstance().getUserData().getAccessToken());
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
con.setRequestProperty("Accept", "application/json");
|
||||
con.setDoOutput(true);
|
||||
String jsonInputString = "{\"enabled\": " + custom_cape + "}";
|
||||
try(OutputStream os = con.getOutputStream()) {
|
||||
byte[] input = jsonInputString.getBytes("utf-8");
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
con.disconnect();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void setPlusIcon(boolean plus_icon) {
|
||||
this.plus_icon = plus_icon ? 1 : 0;
|
||||
Players.handleAccount(this);
|
||||
(new Thread("setPlusIconRequest") {
|
||||
public void run() {
|
||||
try {
|
||||
URL url = new URL("https://api.silentclient.net/plus/set_icon");
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
con.setRequestProperty("Authorization", "Bearer " + Client.getInstance().getUserData().getAccessToken());
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
con.setRequestProperty("Accept", "application/json");
|
||||
con.setDoOutput(true);
|
||||
String jsonInputString = "{\"enabled\": " + plus_icon + "}";
|
||||
try(OutputStream os = con.getOutputStream()) {
|
||||
byte[] input = jsonInputString.getBytes("utf-8");
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
con.disconnect();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Client.getInstance().updateUserInformation();
|
||||
}
|
||||
}).start();
|
||||
|
||||
}
|
||||
|
||||
public int getSelectedBandana() {
|
||||
return selected_bandana;
|
||||
}
|
||||
@ -558,31 +289,7 @@ public class PlayerResponse extends AbstractReply {
|
||||
Players.handleAccount(this);
|
||||
(new Thread("setBandana") {
|
||||
public void run() {
|
||||
try {
|
||||
URL url = new URL("https://api.silentclient.net/account/select_bandana");
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
con.setRequestProperty("Authorization", "Bearer " + Client.getInstance().getUserData().getAccessToken());
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
con.setRequestProperty("Accept", "application/json");
|
||||
con.setDoOutput(true);
|
||||
String jsonInputString = "{\"id\": " + bandanaId + "}";
|
||||
try(OutputStream os = con.getOutputStream()) {
|
||||
byte[] input = jsonInputString.getBytes("utf-8");
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
con.disconnect();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Requests.post("https://api.silentclient.net/account/select_bandana", new JSONObject().put("id", bandanaId).toString());
|
||||
Client.getInstance().updateUserInformation();
|
||||
}
|
||||
}).start();
|
||||
@ -609,31 +316,7 @@ public class PlayerResponse extends AbstractReply {
|
||||
Players.handleAccount(this);
|
||||
(new Thread("setHat") {
|
||||
public void run() {
|
||||
try {
|
||||
URL url = new URL("https://api.silentclient.net/account/select_hat");
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
con.setRequestProperty("Authorization", "Bearer " + Client.getInstance().getUserData().getAccessToken());
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
con.setRequestProperty("Accept", "application/json");
|
||||
con.setDoOutput(true);
|
||||
String jsonInputString = "{\"id\": " + cid + ", \"type\": \""+ type +"\"}";
|
||||
try(OutputStream os = con.getOutputStream()) {
|
||||
byte[] input = jsonInputString.getBytes("utf-8");
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
con.disconnect();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Requests.post("https://api.silentclient.net/account/select_hat", new JSONObject().put("id", cid).put("type", type).toString());
|
||||
Client.getInstance().updateUserInformation();
|
||||
}
|
||||
}).start();
|
||||
@ -644,33 +327,9 @@ public class PlayerResponse extends AbstractReply {
|
||||
final int hatId = id == this.selected_shield ? 0 : id;
|
||||
this.selected_shield = hatId;
|
||||
Players.handleAccount(this);
|
||||
(new Thread("setCapeRequest") {
|
||||
(new Thread("setShield") {
|
||||
public void run() {
|
||||
try {
|
||||
URL url = new URL("https://api.silentclient.net/account/select_shield");
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
con.setRequestProperty("Authorization", "Bearer " + Client.getInstance().getUserData().getAccessToken());
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
con.setRequestProperty("Accept", "application/json");
|
||||
con.setDoOutput(true);
|
||||
String jsonInputString = "{\"id\": " + hatId + "}";
|
||||
try(OutputStream os = con.getOutputStream()) {
|
||||
byte[] input = jsonInputString.getBytes("utf-8");
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
con.disconnect();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Requests.post("https://api.silentclient.net/account/select_shield", new JSONObject().put("id", hatId).toString());
|
||||
Client.getInstance().updateUserInformation();
|
||||
}
|
||||
}).start();
|
||||
@ -687,31 +346,7 @@ public class PlayerResponse extends AbstractReply {
|
||||
Players.handleAccount(this);
|
||||
(new Thread("setCapeRequest") {
|
||||
public void run() {
|
||||
try {
|
||||
URL url = new URL("https://api.silentclient.net/account/select_cape");
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
con.setRequestProperty("Authorization", "Bearer " + Client.getInstance().getUserData().getAccessToken());
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
con.setRequestProperty("Accept", "application/json");
|
||||
con.setDoOutput(true);
|
||||
String jsonInputString = "{\"id\": " + capeId + "}";
|
||||
try(OutputStream os = con.getOutputStream()) {
|
||||
byte[] input = jsonInputString.getBytes("utf-8");
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
con.disconnect();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Requests.post("https://api.silentclient.net/account/select_cape", new JSONObject().put("id", capeId).toString());
|
||||
Client.getInstance().updateUserInformation();
|
||||
}
|
||||
}).start();
|
||||
@ -728,31 +363,7 @@ public class PlayerResponse extends AbstractReply {
|
||||
Players.handleAccount(this);
|
||||
(new Thread("setWingsRequest") {
|
||||
public void run() {
|
||||
try {
|
||||
URL url = new URL("https://api.silentclient.net/account/select_wings");
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
con.setRequestProperty("Authorization", "Bearer " + Client.getInstance().getUserData().getAccessToken());
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
con.setRequestProperty("Accept", "application/json");
|
||||
con.setDoOutput(true);
|
||||
String jsonInputString = "{\"id\": " + wingsId + "}";
|
||||
try(OutputStream os = con.getOutputStream()) {
|
||||
byte[] input = jsonInputString.getBytes("utf-8");
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
con.disconnect();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Requests.post("https://api.silentclient.net/account/select_wings", new JSONObject().put("id", wingsId).toString());
|
||||
Client.getInstance().updateUserInformation();
|
||||
}
|
||||
}).start();
|
||||
@ -769,31 +380,7 @@ public class PlayerResponse extends AbstractReply {
|
||||
Players.handleAccount(this);
|
||||
(new Thread("setIconRequest") {
|
||||
public void run() {
|
||||
try {
|
||||
URL url = new URL("https://api.silentclient.net/account/select_icon");
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("User-Agent", "SilentClient");
|
||||
con.setRequestProperty("Authorization", "Bearer " + Client.getInstance().getUserData().getAccessToken());
|
||||
con.setRequestProperty("Content-Type", "application/json");
|
||||
con.setRequestProperty("Accept", "application/json");
|
||||
con.setDoOutput(true);
|
||||
String jsonInputString = "{\"id\": " + iconId + "}";
|
||||
try(OutputStream os = con.getOutputStream()) {
|
||||
byte[] input = jsonInputString.getBytes("utf-8");
|
||||
os.write(input, 0, input.length);
|
||||
}
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String inputLine;
|
||||
StringBuffer content = new StringBuffer();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
content.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
con.disconnect();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Requests.post("https://api.silentclient.net/account/select_icon", new JSONObject().put("id", iconId).toString());
|
||||
Client.getInstance().updateUserInformation();
|
||||
}
|
||||
}).start();
|
||||
|
Loading…
Reference in New Issue
Block a user