Search in sources :

Example 11 with LevelheadJsonHolder

use of cc.hyperium.mods.levelhead.util.LevelheadJsonHolder in project Hyperium by HyperiumClient.

the class DisplayManager method save.

public void save() {
    LevelheadJsonHolder jsonHolder = new LevelheadJsonHolder();
    jsonHolder.put("master", new LevelheadJsonHolder(GSON.toJson(config)));
    if (tab != null)
        jsonHolder.put("tab", new LevelheadJsonHolder(GSON.toJson(tab.getConfig())));
    if (chat != null)
        jsonHolder.put("chat", new LevelheadJsonHolder(GSON.toJson(chat.getConfig())));
    JsonArray head = new JsonArray();
    aboveHead.stream().map(aboveHeadDisplay -> new LevelheadJsonHolder(GSON.toJson(aboveHeadDisplay.getConfig())).getObject()).forEach(head::add);
    jsonHolder.put("head", head);
    try {
        FileUtils.writeStringToFile(file, jsonHolder.toString());
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : JsonArray(com.google.gson.JsonArray) JsonElement(com.google.gson.JsonElement) JsonArray(com.google.gson.JsonArray) List(java.util.List) LevelheadJsonHolder(cc.hyperium.mods.levelhead.util.LevelheadJsonHolder) Gson(com.google.gson.Gson) ChatColor(cc.hyperium.utils.ChatColor) Hyperium(cc.hyperium.Hyperium) MasterConfig(cc.hyperium.mods.levelhead.config.MasterConfig) FileUtils(org.apache.commons.io.FileUtils) IOException(java.io.IOException) File(java.io.File) ArrayList(java.util.ArrayList) LevelheadJsonHolder(cc.hyperium.mods.levelhead.util.LevelheadJsonHolder) IOException(java.io.IOException)

Example 12 with LevelheadJsonHolder

use of cc.hyperium.mods.levelhead.util.LevelheadJsonHolder in project Hyperium by HyperiumClient.

the class LevelheadDisplay method getFooterConfig.

public LevelheadJsonHolder getFooterConfig() {
    LevelheadJsonHolder holder = new LevelheadJsonHolder();
    holder.put("chroma", config.isFooterChroma());
    holder.put("rgb", config.isFooterRgb());
    holder.put("red", config.getFooterRed());
    holder.put("green", config.getFooterGreen());
    holder.put("blue", config.getFooterBlue());
    holder.put("alpha", config.getFooterAlpha());
    holder.put("color", config.getFooterColor());
    return holder;
}
Also used : LevelheadJsonHolder(cc.hyperium.mods.levelhead.util.LevelheadJsonHolder)

Example 13 with LevelheadJsonHolder

use of cc.hyperium.mods.levelhead.util.LevelheadJsonHolder in project Hyperium by HyperiumClient.

the class CustomLevelheadConfigurer method refresh.

private void refresh() {
    Multithreading.runAsync(() -> {
        LevelheadJsonHolder jsonHolder = new LevelheadJsonHolder(Sk1erMod.getInstance().rawWithAgent("https://sk1er.club/newlevel/" + mc.getSession().getProfile().getId().toString().replace("-", "")));
        header.setText(jsonHolder.optString("header"));
        level.setText(jsonHolder.optString("true_footer"));
    });
    Multithreading.runAsync(() -> levelheadPropose = new LevelheadJsonHolder(Sk1erMod.getInstance().rawWithAgent("https://api.hyperium.cc/levelhead_propose" + mc.getSession().getProfile().getId().toString().replace("-", ""))));
}
Also used : LevelheadJsonHolder(cc.hyperium.mods.levelhead.util.LevelheadJsonHolder)

Example 14 with LevelheadJsonHolder

use of cc.hyperium.mods.levelhead.util.LevelheadJsonHolder in project Hyperium by HyperiumClient.

the class CustomLevelheadConfigurer method initGui.

@Override
public void initGui() {
    super.initGui();
    header = new GuiTextField(nextId(), fontRendererObj, width / 2 - 205, 30, 200, 20);
    level = new GuiTextField(nextId(), fontRendererObj, width / 2 + 5, 30, 200, 20);
    header.setMaxStringLength(50);
    level.setMaxStringLength(50);
    Multithreading.runAsync(() -> {
        LevelheadJsonHolder jsonHolder = new LevelheadJsonHolder(Sk1erMod.getInstance().rawWithAgent("https://sk1er.club/newlevel/" + mc.getSession().getProfile().getId().toString().replace("-", "")));
        header.setText(jsonHolder.optString("header"));
        level.setText(jsonHolder.optString("true_footer"));
    });
    Multithreading.runAsync(() -> levelheadPropose = new LevelheadJsonHolder(Sk1erMod.getInstance().rawWithAgent("https://api.hyperium.cc/levelhead_propose" + mc.getSession().getProfile().getId().toString().replace("-", ""))));
    Multithreading.runAsync(() -> {
        LevelheadJsonHolder jsonHolder = new LevelheadJsonHolder(Sk1erMod.getInstance().rawWithAgent("https://api.sk1er.club/levelheadv5/" + mc.getSession().getProfile().getId().toString().replace("-", "") + "/LEVEL"));
        if (!jsonHolder.has("uuid")) {
            if (mc.currentScreen instanceof CustomLevelheadConfigurer) {
                mc.displayGuiScreen(null);
                Hyperium.INSTANCE.getHandlers().getGeneralChatHandler().sendMessage("You must purchase Custom Levelhead to use this!");
            }
        }
    });
    refresh();
    reg(new GuiButton(nextId(), width / 2 - 205, 55, 200, 20, "Reset to default"), button -> {
        Sk1erMod.getInstance().rawWithAgent("https://api.sk1er.club/customlevelhead/reset?hash=" + Levelhead.getInstance().getAuth().getHash() + "&level=default&header=default");
        refresh();
    });
    reg(new GuiButton(nextId(), width / 2 + 5, 55, 200, 20, "Send for review"), button -> {
        Sk1erMod.getInstance().rawWithAgent("https://api.sk1er.club/customlevelhead/propose?hash=" + Levelhead.getInstance().getAuth().getHash() + "&footer=" + URLEncoder.encode(level.getText()) + "&header=" + URLEncoder.encode(header.getText()));
        refresh();
    });
    reg(new GuiButton(nextId(), width / 2 - 50, 80, 100, 20, "Refresh"), button -> refresh());
}
Also used : GuiButton(net.minecraft.client.gui.GuiButton) LevelheadJsonHolder(cc.hyperium.mods.levelhead.util.LevelheadJsonHolder) GuiTextField(net.minecraft.client.gui.GuiTextField)

Example 15 with LevelheadJsonHolder

use of cc.hyperium.mods.levelhead.util.LevelheadJsonHolder in project Hyperium by HyperiumClient.

the class LevelheadTag method build.

private LevelheadComponent build(LevelheadJsonHolder holder, boolean isHeader) {
    String seek = isHeader ? "header" : "footer";
    LevelheadJsonHolder json = holder.optJsonObject(seek);
    LevelheadComponent component = new LevelheadComponent(json.optString(seek, "Big problem, report to Sk1er."));
    boolean custom = json.optBoolean("custom");
    component.setCustom(custom);
    if (custom && isHeader && !holder.optBoolean("exclude")) {
        component.setValue(component.getValue() + ": ");
    }
    if (json.optBoolean("chroma")) {
        component.setChroma(true);
    } else if (json.optBoolean("rgb")) {
        component.setRgb(true);
        component.setAlpha(json.optInt("alpha"));
        component.setRed(json.optInt("red"));
        component.setGreen(json.optInt("green"));
        component.setBlue(json.optInt("blue"));
    } else {
        component.setColor(json.optString("color"));
    }
    return component;
}
Also used : LevelheadJsonHolder(cc.hyperium.mods.levelhead.util.LevelheadJsonHolder)

Aggregations

LevelheadJsonHolder (cc.hyperium.mods.levelhead.util.LevelheadJsonHolder)15 ChatColor (cc.hyperium.utils.ChatColor)4 Hyperium (cc.hyperium.Hyperium)3 Levelhead (cc.hyperium.mods.levelhead.Levelhead)3 DisplayManager (cc.hyperium.mods.levelhead.display.DisplayManager)3 LevelheadChatRenderer (cc.hyperium.mods.levelhead.renderer.LevelheadChatRenderer)3 LevelheadTag (cc.hyperium.mods.levelhead.renderer.LevelheadTag)3 NullLevelheadTag (cc.hyperium.mods.levelhead.renderer.NullLevelheadTag)3 Sk1erMod (cc.hyperium.mods.sk1ercommon.Sk1erMod)3 File (java.io.File)3 IOException (java.io.IOException)3 List (java.util.List)3 MojangAuth (cc.hyperium.mods.levelhead.auth.MojangAuth)2 CustomLevelheadCommand (cc.hyperium.mods.levelhead.command.CustomLevelheadCommand)2 LevelheadCommand (cc.hyperium.mods.levelhead.command.LevelheadCommand)2 AboveHeadDisplay (cc.hyperium.mods.levelhead.display.AboveHeadDisplay)2 DisplayConfig (cc.hyperium.mods.levelhead.display.DisplayConfig)2 LevelheadPurchaseStates (cc.hyperium.mods.levelhead.purchases.LevelheadPurchaseStates)2 AboveHeadRenderer (cc.hyperium.mods.levelhead.renderer.AboveHeadRenderer)2 Multithreading (cc.hyperium.mods.sk1ercommon.Multithreading)2