Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.skyvox.hmod.events;
- import java.io.BufferedReader;
- import java.io.DataOutputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- import java.net.HttpURLConnection;
- import java.net.URL;
- import org.json.JSONObject;
- import me.skyvox.hmod.SkyHMod;
- import me.skyvox.hmod.script.HypixelMultithreading;
- import me.skyvox.hmod.script.HypixelMultithreadingScript;
- import me.skyvox.hmod.utils.CheckServer;
- import me.skyvox.hmod.utils.chat.ChatUtil;
- import me.skyvox.hmod.utils.hypixelgeneralutil.AutoTip;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.entity.EntityPlayerSP;
- import net.minecraft.util.ChatComponentText;
- import net.minecraftforge.common.MinecraftForge;
- import net.minecraftforge.event.entity.EntityJoinWorldEvent;
- import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
- public class JoinListener {
- public static final JoinListener INSTANCE = new JoinListener();
- private SkyHMod skyhmod;
- @SubscribeEvent
- public void PlayerJoin(EntityJoinWorldEvent event) {
- if (event.entity instanceof EntityPlayerSP) {
- EntityPlayerSP player = (EntityPlayerSP) event.entity;
- CheckServer.check();
- if (CheckServer.isHypixel()) {
- player.addChatMessage(new ChatComponentText(ChatUtil.messageWithPre("\u00A72" + "You are on Hypixel network!")));
- this.onJoin();
- String raw = pullPlayerProfile(player.getName());
- JSONObject a = new JSONObject(raw);
- player.addChatMessage(new ChatComponentText("Suas vitorias sao: " + this.get(a, "player#stats#Paintball#wins")));
- player.addChatMessage(new ChatComponentText("Suas kills sao: " + this.get(a, "player#stats#Paintball#kills")));
- } else {
- player.addChatMessage(new ChatComponentText(ChatUtil.messageWithPre("\u00A74" + "You are not on Hypixel network, Some functions of this mod will not work.")));
- }
- }
- MinecraftForge.EVENT_BUS.unregister(this);
- }
- private void onJoin() {
- AutoTip.isAutoTip = true;
- AutoTip.autoTip();
- /*HypixelMultithreading.runAsync(() -> {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("1"));
- try {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("2"));
- do {
- /*try {
- if (Minecraft.getMinecraft().thePlayer.getName() != null) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("5"));
- break;
- }
- } catch (Exception e) {
- }
- try {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("3"));
- Thread.sleep(50);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- } while (CheckServer.isHypixel() == true);
- pullPlayerProfile(Minecraft.getMinecraft().thePlayer.getName());
- startScript();
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Started"));
- } catch (Exception e) {
- Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("4"));
- }
- });
- */
- }
- private HypixelMultithreadingScript script;
- public void startScript() {
- HypixelMultithreading.runAsync(() -> {
- if (this.script != null) {
- this.script.stop();
- }
- this.script = new HypixelMultithreadingScript(skyhmod);
- this.script.run();
- });
- }
- public static String rawExpectJson(String url) {
- try {
- URL u = new URL(url);
- HttpURLConnection connection = (HttpURLConnection)u.openConnection();
- connection.setRequestMethod("GET");
- connection.addRequestProperty("User-Agent", "Mozilla/4.76");
- connection.setUseCaches(true);
- connection.setReadTimeout(2500);
- connection.setConnectTimeout(2500);
- connection.setDoInput(true);
- connection.setDoOutput(true);
- InputStream is = connection.getInputStream();
- BufferedReader reader = new BufferedReader(new InputStreamReader(is));
- String line = reader.readLine();
- if (line != null) {
- StringBuilder builder = new StringBuilder(line);
- while (line != null) {
- line = reader.readLine();
- if (line == null) continue;
- builder.append(line);
- }
- reader.close();
- return builder.toString();
- }
- return "{}";
- }
- catch (Exception e) {
- return "{}";
- }
- }
- public static String pullPlayerProfile(String name) {
- JSONObject gen_key = new JSONObject(rawExpectJson("http://sk1er.club/genkey?name=" + Minecraft.getMinecraft().thePlayer.getName() + "&uuid=" + Minecraft.getMinecraft().thePlayer.getUniqueID() + "&mcver=" + Minecraft.getMinecraft().getVersion() + "&modver=" + "1.1-Beta" + "&mod=PUBLIC_PRIVATE_MOD"));
- String aaaa = gen_key.getString("key");
- return rawExpectJson("http://sk1er.club/data/" + name + "/" + aaaa);
- }
- public static int get(JSONObject tmp, String path)
- {
- try
- {
- if (path.contains("#"))
- {
- int max = path.split("#").length;
- int cur = 0;
- JSONObject curent = tmp;
- for (String s : path.split("#"))
- {
- if (cur >= max - 1) {
- return curent.has(s) ? curent.getInt(s) : 0;
- }
- curent = curent.has(s) ? curent.getJSONObject(s) : new JSONObject();
- cur++;
- }
- }
- else
- {
- return tmp.has(path) ? tmp.getInt(path) : 0;
- }
- return 0;
- }
- catch (Exception e) {}
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement