Search in sources :

Example 1 with DisplayManager

use of cc.hyperium.mods.levelhead.display.DisplayManager in project Hyperium by HyperiumClient.

the class Levelhead method init.

@Override
public AbstractMod init() {
    instance = this;
    LevelheadJsonHolder jsonHolder = new LevelheadJsonHolder();
    try {
        jsonHolder = new LevelheadJsonHolder(FileUtils.readFileToString(new File(Hyperium.folder, "levelhead.json")));
    } catch (Exception e) {
        e.printStackTrace();
    }
    displayManager = new DisplayManager(jsonHolder, new File(Hyperium.folder, "levelhead.json"));
    Multithreading.runAsync(() -> types = new LevelheadJsonHolder(rawWithAgent("https://api.sk1er.club/levelhead_config")));
    Sk1erMod sk1erMod = new Sk1erMod("LEVEL_HEAD", VERSION, object -> {
        count = object.optInt("count");
        wait = object.optInt("wait", Integer.MAX_VALUE);
        if (count == 0 || wait == Integer.MAX_VALUE) {
            Hyperium.LOGGER.warn("An error occurred whilst loading loading internal Levelhead info.");
        }
    });
    sk1erMod.checkStatus();
    auth = new MojangAuth();
    Multithreading.runAsync(() -> {
        auth.auth();
        if (auth.isFailed()) {
            Hyperium.LOGGER.warn("Failed to authenticate with Levelhead: {}", auth.getFailedMessage());
        }
    });
    userUuid = Minecraft.getMinecraft().getSession().getProfile().getId();
    Hyperium.INSTANCE.getHandlers().getCommandHandler().registerCommand(new LevelheadCommand());
    Hyperium.INSTANCE.getHandlers().getCommandHandler().registerCommand(new CustomLevelheadCommand());
    LevelheadChatRenderer levelheadChatRenderer = new LevelheadChatRenderer(this);
    EventBus.INSTANCE.register(this);
    EventBus.INSTANCE.register(levelheadChatRenderer);
    EventBus.INSTANCE.register(new AboveHeadRenderer(this));
    Multithreading.runAsync(this::refreshPurchaseStates);
    Multithreading.runAsync(this::refreshRawPurchases);
    Multithreading.runAsync(this::refreshPaidData);
    return this;
}
Also used : Sk1erMod(cc.hyperium.mods.sk1ercommon.Sk1erMod) AboveHeadRenderer(cc.hyperium.mods.levelhead.renderer.AboveHeadRenderer) MojangAuth(cc.hyperium.mods.levelhead.auth.MojangAuth) CustomLevelheadCommand(cc.hyperium.mods.levelhead.command.CustomLevelheadCommand) LevelheadCommand(cc.hyperium.mods.levelhead.command.LevelheadCommand) DisplayManager(cc.hyperium.mods.levelhead.display.DisplayManager) LevelheadChatRenderer(cc.hyperium.mods.levelhead.renderer.LevelheadChatRenderer) LevelheadJsonHolder(cc.hyperium.mods.levelhead.util.LevelheadJsonHolder) File(java.io.File) CustomLevelheadCommand(cc.hyperium.mods.levelhead.command.CustomLevelheadCommand)

Example 2 with DisplayManager

use of cc.hyperium.mods.levelhead.display.DisplayManager in project Hyperium by HyperiumClient.

the class Levelhead method refreshPurchaseStates.

public synchronized void refreshPurchaseStates() {
    purchaseStatus = new LevelheadJsonHolder(rawWithAgent("https://api.sk1er.club/levelhead_purchase_status/" + Minecraft.getMinecraft().getSession().getProfile().getId().toString()));
    levelheadPurchaseStates.setChat(purchaseStatus.optBoolean("chat"));
    levelheadPurchaseStates.setTab(purchaseStatus.optBoolean("tab"));
    levelheadPurchaseStates.setExtraHead(purchaseStatus.optInt("head"));
    DisplayManager displayManager = this.displayManager;
    while (displayManager.getAboveHead().size() <= levelheadPurchaseStates.getExtraHead()) {
        displayManager.getAboveHead().add(new AboveHeadDisplay(new DisplayConfig()));
    }
    displayManager.adjustIndexes();
}
Also used : DisplayManager(cc.hyperium.mods.levelhead.display.DisplayManager) LevelheadJsonHolder(cc.hyperium.mods.levelhead.util.LevelheadJsonHolder) DisplayConfig(cc.hyperium.mods.levelhead.display.DisplayConfig) AboveHeadDisplay(cc.hyperium.mods.levelhead.display.AboveHeadDisplay)

Aggregations

DisplayManager (cc.hyperium.mods.levelhead.display.DisplayManager)2 LevelheadJsonHolder (cc.hyperium.mods.levelhead.util.LevelheadJsonHolder)2 MojangAuth (cc.hyperium.mods.levelhead.auth.MojangAuth)1 CustomLevelheadCommand (cc.hyperium.mods.levelhead.command.CustomLevelheadCommand)1 LevelheadCommand (cc.hyperium.mods.levelhead.command.LevelheadCommand)1 AboveHeadDisplay (cc.hyperium.mods.levelhead.display.AboveHeadDisplay)1 DisplayConfig (cc.hyperium.mods.levelhead.display.DisplayConfig)1 AboveHeadRenderer (cc.hyperium.mods.levelhead.renderer.AboveHeadRenderer)1 LevelheadChatRenderer (cc.hyperium.mods.levelhead.renderer.LevelheadChatRenderer)1 Sk1erMod (cc.hyperium.mods.sk1ercommon.Sk1erMod)1 File (java.io.File)1