Search in sources :

Example 51 with JsonHolder

use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.

the class Sk1erMod method rawWithAgent.

public String rawWithAgent(String url) {
    Hyperium.LOGGER.info("[Sk1erMod] Fetching " + url);
    if (!Hyperium.INSTANCE.isAcceptedTos()) {
        return new JsonHolder().put("success", false).put("cause", "TOS_NOT_ACCEPTED").toString();
    }
    url = url.replace(" ", "%20");
    HttpURLConnection connection = null;
    try {
        URL u = new URL(url);
        connection = (HttpURLConnection) u.openConnection();
        connection.setRequestMethod("GET");
        connection.setUseCaches(true);
        connection.addRequestProperty("User-Agent", "Mozilla/4.76 (" + modid + " V" + version + ") via Hyperium ");
        connection.setReadTimeout(15000);
        connection.setConnectTimeout(15000);
        connection.setDoOutput(true);
        InputStream is = connection.getInputStream();
        return IOUtils.toString(is, StandardCharsets.UTF_8);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (connection != null)
            connection.disconnect();
    }
    JsonObject object = new JsonObject();
    object.addProperty("success", false);
    object.addProperty("cause", "Exception");
    return object.toString();
}
Also used : JsonHolder(cc.hyperium.utils.JsonHolder) HttpURLConnection(java.net.HttpURLConnection) InputStream(java.io.InputStream) JsonObject(com.google.gson.JsonObject) URL(java.net.URL)

Example 52 with JsonHolder

use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.

the class Sk1erMod method checkStatus.

public void checkStatus() {
    if (Minecraft.getMinecraft().gameSettings.snooperEnabled) {
        Multithreading.schedule(() -> {
            en = new JsonHolder(rawWithAgent("https://sk1er.club/genkey?name=" + Minecraft.getMinecraft().getSession().getProfile().getName() + "&uuid=" + Minecraft.getMinecraft().getSession().getPlayerID().replace("-", "") + "&mcver=" + Minecraft.getMinecraft().getVersion() + "&modver=" + version + "&mod=" + modid));
            if (callback != null)
                callback.call(en);
            en.optBoolean("enabled");
            apiKey = en.optString("key");
        }, 0, 5, TimeUnit.MINUTES);
    }
}
Also used : JsonHolder(cc.hyperium.utils.JsonHolder)

Example 53 with JsonHolder

use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.

the class HypixelApiGuild method getCustomRanks.

public List<GuildRank> getCustomRanks() {
    if (ranks == null) {
        ranks = new ArrayList<>();
        ranks.add(new GuildRank("GUILDMASTER", Integer.MAX_VALUE));
        ranks.add(new GuildRank("OFFICER", 4));
        ranks.add(new GuildRank("MEMBER", 3));
        for (JsonElement element : getRoot().optJSONArray("ranks")) {
            JsonHolder holder = new JsonHolder(element.getAsJsonObject());
            ranks.add(new GuildRank(holder.optString("name"), holder.optInt("priority")));
        }
    }
    return ranks;
}
Also used : JsonHolder(cc.hyperium.utils.JsonHolder) JsonElement(com.google.gson.JsonElement)

Example 54 with JsonHolder

use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.

the class PurchaseApi method getPackageSync.

public HyperiumPurchase getPackageSync(UUID uuid) {
    if (uuid == null)
        return null;
    return purchasePlayers.computeIfAbsent(uuid, uuid1 -> {
        String s = uuid.toString().replace("-", "");
        if (s.length() == 32 && s.charAt(12) != '4') {
            HyperiumPurchase non_player = new HyperiumPurchase(uuid, new JsonHolder().put("non_player", true));
            EventBus.INSTANCE.post(new PurchaseLoadEvent(uuid, non_player, false));
            return non_player;
        }
        HyperiumPurchase hyperiumPurchase = new HyperiumPurchase(uuid, get(url + uuid.toString()));
        EventBus.INSTANCE.post(new PurchaseLoadEvent(uuid, hyperiumPurchase, uuid.equals(UUIDUtil.getClientUUID())));
        return hyperiumPurchase;
    });
}
Also used : JsonHolder(cc.hyperium.utils.JsonHolder) PurchaseLoadEvent(cc.hyperium.event.network.PurchaseLoadEvent)

Example 55 with JsonHolder

use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.

the class CommandDebug method get.

public static String get() {
    StringBuilder builder = new StringBuilder();
    PurchaseApi api = PurchaseApi.getInstance();
    if (api == null)
        return "";
    builder.append("\n\n");
    Multithreading.runAsync(CommandDebug::checkUUID);
    if (isPremium) {
        builder.append("Premium: True, ").append("UUID is ").append(Minecraft.getMinecraft().thePlayer.getGameProfile().getId());
    } else {
        builder.append("Premium: False, user doesn't have a UUID");
    }
    builder.append("\n\n");
    HyperiumPurchase self = PurchaseApi.getInstance().getSelf();
    builder.append("Purchase callback: ");
    if (self != null) {
        JsonHolder response = self.getResponse();
        if (response != null)
            builder.append(printer.toJson(response.getObject()));
    }
    builder.append("\n\n");
    HypixelDetector instance = HypixelDetector.getInstance();
    if (instance != null)
        builder.append("Hypixel: ").append(instance.isHypixel());
    builder.append("\n\n\n\n");
    NetworkHandler networkHandler = Hyperium.INSTANCE.getNetworkHandler();
    if (networkHandler != null) {
        List<String> verboseLogs = networkHandler.getVerboseLogs();
        verboseLogs.forEach(verboseLog -> {
            builder.append(verboseLog);
            builder.append("\n");
        });
        builder.append(verboseLogs);
        builder.append("\n");
    }
    tryConfig(builder);
    builder.append("\n\n");
    tryChromaHUD(builder);
    builder.append("\n\n");
    tryKeybinds(builder);
    builder.append("\n\n");
    tryLevelhead(builder);
    builder.append("\n\n");
    builder.append("Levelhead");
    builder.append("\n");
    return builder.toString();
}
Also used : JsonHolder(cc.hyperium.utils.JsonHolder) HypixelDetector(cc.hyperium.handlers.handlers.HypixelDetector) HyperiumPurchase(cc.hyperium.purchases.HyperiumPurchase) NetworkHandler(cc.hyperium.network.NetworkHandler) PurchaseApi(cc.hyperium.purchases.PurchaseApi)

Aggregations

JsonHolder (cc.hyperium.utils.JsonHolder)81 DisplayLine (cc.hyperium.handlers.handlers.stats.display.DisplayLine)42 StatsDisplayItem (cc.hyperium.handlers.handlers.stats.display.StatsDisplayItem)42 ArrayList (java.util.ArrayList)34 NettyClient (cc.hyperium.netty.NettyClient)13 DisplayTable (cc.hyperium.handlers.handlers.stats.display.DisplayTable)10 JsonArray (com.google.gson.JsonArray)9 JsonElement (com.google.gson.JsonElement)8 HyperiumPurchase (cc.hyperium.purchases.HyperiumPurchase)5 JsonObject (com.google.gson.JsonObject)5 URL (java.net.URL)5 UUID (java.util.UUID)5 HashMap (java.util.HashMap)4 InvokeEvent (cc.hyperium.event.InvokeEvent)3 PurchaseLoadEvent (cc.hyperium.event.network.PurchaseLoadEvent)3 AbstractAnimationHandler (cc.hyperium.handlers.handlers.animation.AbstractAnimationHandler)3 DisplayItem (cc.hyperium.mods.chromahud.api.DisplayItem)3 IOException (java.io.IOException)3 ExecutionException (java.util.concurrent.ExecutionException)3 GuiButton (net.minecraft.client.gui.GuiButton)3