Search in sources :

Example 1 with Sk1erMod

use of cc.hyperium.mods.sk1ercommon.Sk1erMod 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 Sk1erMod

use of cc.hyperium.mods.sk1ercommon.Sk1erMod in project Hyperium by HyperiumClient.

the class NickHider method init.

@Override
public AbstractMod init() {
    instance = this;
    Sk1erMod sk1erMod = new Sk1erMod("nick_hider", VERSION, object -> {
        if (!object.optBoolean("enabled"))
            forceDown = true;
        if (object.optBoolean("extended"))
            extendedUse = true;
    });
    Multithreading.runAsync(() -> {
        String s = sk1erMod.rawWithAgent("https://sk1er.club/words.txt?uuid=" + Minecraft.getMinecraft().getSession().getProfile().getId());
        namesDatabase.addAll(Arrays.asList(s.split("\n")));
    });
    sk1erMod.checkStatus();
    configFile = new File(Hyperium.folder, "nickhider.json");
    if (configFile.exists()) {
        try {
            String s = FileUtils.readFileToString(configFile, StandardCharsets.UTF_8);
            nickHiderConfig = new Gson().fromJson(s, NickHiderConfig.class);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    if (nickHiderConfig == null)
        nickHiderConfig = new NickHiderConfig();
    EventBus.INSTANCE.register(this);
    Hyperium.INSTANCE.getHandlers().getCommandHandler().registerCommand(new CommandNickHider());
    Runtime.getRuntime().addShutdownHook(new Thread(() -> {
        String s = new Gson().toJson(nickHiderConfig);
        try {
            FileUtils.write(configFile, s, StandardCharsets.UTF_8);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }));
    return this;
}
Also used : Sk1erMod(cc.hyperium.mods.sk1ercommon.Sk1erMod) NickHiderConfig(cc.hyperium.mods.nickhider.config.NickHiderConfig) Gson(com.google.gson.Gson) CommandNickHider(cc.hyperium.mods.nickhider.command.CommandNickHider) File(java.io.File)

Example 3 with Sk1erMod

use of cc.hyperium.mods.sk1ercommon.Sk1erMod in project Hyperium by HyperiumClient.

the class KeystrokesMod method init.

/**
 * Init method, loads configs and events for the KeystrokesMod
 *
 * @return this mods instance
 */
@Override
public AbstractMod init() {
    config = new KeystrokesSettings(this, Hyperium.folder);
    config.load();
    new Sk1erMod("keystrokesmod", VERSION).checkStatus();
    renderer = new KeystrokesRenderer(this);
    EventBus.INSTANCE.register(renderer);
    Hyperium.INSTANCE.getHandlers().getHyperiumCommandHandler().registerCommand(new CommandKeystrokes(this));
    return this;
}
Also used : KeystrokesSettings(cc.hyperium.mods.keystrokes.config.KeystrokesSettings) Sk1erMod(cc.hyperium.mods.sk1ercommon.Sk1erMod) KeystrokesRenderer(cc.hyperium.mods.keystrokes.render.KeystrokesRenderer)

Example 4 with Sk1erMod

use of cc.hyperium.mods.sk1ercommon.Sk1erMod in project Hyperium by HyperiumClient.

the class Hyperium method acceptTos.

/**
 * Create the lock file
 */
public void acceptTos() {
    acceptedTos = true;
    if (sk1erMod == null) {
        sk1erMod = new Sk1erMod("hyperium", Metadata.getVersion());
        sk1erMod.checkStatus();
    }
    try {
        new File(folder.getAbsolutePath() + "/accounts/" + Minecraft.getMinecraft().getSession().getPlayerID() + ".lck").createNewFile();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : Sk1erMod(cc.hyperium.mods.sk1ercommon.Sk1erMod)

Example 5 with Sk1erMod

use of cc.hyperium.mods.sk1ercommon.Sk1erMod in project Hyperium by HyperiumClient.

the class Hyperium method init.

/**
 * Initialize all local variables
 * <p>
 * Create / check for important things that need to be loaded
 * before the client officially allows the player to use it.
 *
 * @param event Fired on startup, after screen is displayed {@link InitializationEvent}
 */
@InvokeEvent(priority = Priority.HIGH)
public void init(InitializationEvent event) {
    try {
        // Create the network handler, register it in config, then check for a LoginReply
        Multithreading.runAsync(() -> {
            networkHandler = new NetworkHandler();
            CONFIG.register(networkHandler);
            this.client = new NettyClient(networkHandler);
            UniversalNetty.getInstance().getPacketManager().register(new LoginReplyHandler());
        });
        // Initialize notifications
        notification = new NotificationCenter();
        // Get the build id
        createBuildId();
        Hyperium.LOGGER.info("Hyperium Build ID: {}", BUILD_ID);
        // Check for if the user is in a developers environment
        checkForDevEnvironment();
        // Initialize cosmetics
        cosmetics = new HyperiumCosmetics();
        // If it's the users first launch, create a folder to store their lock file in
        firstLaunch = new File(folder.getAbsolutePath() + "/accounts").mkdirs();
        // Determine if the users ever charge backed, if they have, they won't be allowed to launch
        new ChargebackStopper();
        // Create a lock file if the user accepts the TOS
        this.acceptedTos = new File(folder.getAbsolutePath() + "/accounts/" + Minecraft.getMinecraft().getSession().getPlayerID() + ".lck").exists();
        SplashProgress.setProgress(5, I18n.format("splashprogress.loadinghandlers"));
        // Initialize handlers
        handlers = new HyperiumHandlers();
        handlers.postInit();
        SplashProgress.setProgress(6, I18n.format("splashprogress.registeringlisteners"));
        // Register events
        EventBus.INSTANCE.register(new ToggleSprintContainer());
        EventBus.INSTANCE.register(notification);
        EventBus.INSTANCE.register(CompactChat.getInstance());
        EventBus.INSTANCE.register(CONFIG.register(FPSLimiter.getInstance()));
        EventBus.INSTANCE.register(confirmation);
        EventBus.INSTANCE.register(statTrack);
        CONFIG.register(statTrack);
        CONFIG.register(new ToggleSprintContainer());
        SplashProgress.setProgress(7, I18n.format("splashprogress.startinghyperium"));
        LOGGER.info("[Hyperium] Started!");
        // Set the window title
        Display.setTitle("Hyperium " + Metadata.getVersion());
        SplashProgress.setProgress(8, I18n.format("splashprogress.registeringconfiguration"));
        // Register the settings
        Settings.register();
        CONFIG.register(new ColourOptions());
        SplashProgress.setProgress(9, I18n.format("splashprogress.registeringcommands"));
        // Register all the default commands
        registerCommands();
        // Initialize the Purchase API
        EventBus.INSTANCE.register(PurchaseApi.getInstance());
        SplashProgress.setProgress(10, I18n.format("splashprogress.loadingintegrations"));
        // Register mods & addons
        modIntegration = new HyperiumModIntegration();
        internalAddons = new InternalAddons();
        // Fetch Hyperium staff members
        fetchStaffMembers();
        // Add a thread for shutdowns
        Runtime.getRuntime().addShutdownHook(new Thread(this::shutdown));
        // Load
        richPresenceManager.load();
        // Check if the user has accepted the TOS, if they have, check the Hyperium status
        if (acceptedTos) {
            sk1erMod = new Sk1erMod("hyperium", Metadata.getVersion(), object -> {
                if (object.has("enabled") && !object.optBoolean("enabled")) {
                    handlers.getHyperiumCommandHandler().clear();
                }
            });
            sk1erMod.checkStatus();
        }
        SplashProgress.setProgress(11, I18n.format("splashprogress.finishing"));
        // Load the previous chat session
        loadPreviousChatFile();
        // Fetch the current version
        fetchVersion();
        // Check if the user is running Optifine
        if (AddonCheckerUtil.isUsingOptifine()) {
            // 🦀
            optifineInstalled = true;
        }
        // Print every loaded addon
        collectAddons();
        LOGGER.info("Hyperium loaded in {} seconds", (System.currentTimeMillis() - launchTime) / 1000F);
    } catch (Throwable t) {
        // If an issue is caught, crash the game
        Minecraft.getMinecraft().crashed(new CrashReport("Hyperium Startup Failure", t));
    }
}
Also used : StaffUtils(cc.hyperium.utils.StaffUtils) PreInitializationEvent(cc.hyperium.event.client.PreInitializationEvent) FPSLimiter(cc.hyperium.utils.mods.FPSLimiter) InternalAddons(cc.hyperium.addons.InternalAddons) I18n(net.minecraft.client.resources.I18n) CallbackInfo(org.spongepowered.asm.mixin.injection.callback.CallbackInfo) cc.hyperium.commands.defaults(cc.hyperium.commands.defaults) AutoGG(cc.hyperium.mods.autogg.AutoGG) Multithreading(cc.hyperium.mods.sk1ercommon.Multithreading) AddonMinecraftBootstrap(cc.hyperium.internal.addons.AddonMinecraftBootstrap) UniversalNetty(cc.hyperium.netty.UniversalNetty) HyperiumLocale(cc.hyperium.mixinsimp.client.resources.HyperiumLocale) LoginReplyHandler(cc.hyperium.network.LoginReplyHandler) InvokeEvent(cc.hyperium.event.InvokeEvent) Display(org.lwjgl.opengl.Display) HyperiumHandlers(cc.hyperium.handlers.HyperiumHandlers) HyperiumCommandHandler(cc.hyperium.commands.HyperiumCommandHandler) List(java.util.List) Logger(org.apache.logging.log4j.Logger) ChargebackStopper(cc.hyperium.handlers.handlers.purchase.ChargebackStopper) GameShutDownEvent(cc.hyperium.event.client.GameShutDownEvent) NotificationCenter(cc.hyperium.gui.NotificationCenter) DefaultConfig(cc.hyperium.config.DefaultConfig) MixinMinecraft(cc.hyperium.mixins.client.MixinMinecraft) CustomLevelheadCommand(cc.hyperium.mods.levelhead.command.CustomLevelheadCommand) CompactChat(cc.hyperium.utils.mods.CompactChat) GeneralStatisticsTracking(cc.hyperium.mods.statistics.GeneralStatisticsTracking) NetworkHandler(cc.hyperium.network.NetworkHandler) AddonBootstrap(cc.hyperium.internal.addons.AddonBootstrap) ToggleSprintContainer(cc.hyperium.mods.common.ToggleSprintContainer) Minecraft(net.minecraft.client.Minecraft) Sk1erMod(cc.hyperium.mods.sk1ercommon.Sk1erMod) DiscordPresence(cc.hyperium.mods.discord.DiscordPresence) Settings(cc.hyperium.config.Settings) ConfirmationPopup(cc.hyperium.gui.ConfirmationPopup) EventBus(cc.hyperium.event.EventBus) HyperiumModIntegration(cc.hyperium.mods.HyperiumModIntegration) HyperiumCosmetics(cc.hyperium.cosmetics.HyperiumCosmetics) ColourOptions(cc.hyperium.gui.ColourOptions) UpdateUtils(cc.hyperium.utils.UpdateUtils) NettyClient(cc.hyperium.netty.NettyClient) InitializationEvent(cc.hyperium.event.client.InitializationEvent) CrashReport(net.minecraft.crash.CrashReport) AddonCheckerUtil(cc.hyperium.utils.mods.AddonCheckerUtil) java.io(java.io) AddonManifest(cc.hyperium.internal.addons.AddonManifest) Priority(cc.hyperium.event.Priority) PurchaseApi(cc.hyperium.purchases.PurchaseApi) LogManager(org.apache.logging.log4j.LogManager) ToggleSprintContainer(cc.hyperium.mods.common.ToggleSprintContainer) ColourOptions(cc.hyperium.gui.ColourOptions) Sk1erMod(cc.hyperium.mods.sk1ercommon.Sk1erMod) LoginReplyHandler(cc.hyperium.network.LoginReplyHandler) CrashReport(net.minecraft.crash.CrashReport) NotificationCenter(cc.hyperium.gui.NotificationCenter) ChargebackStopper(cc.hyperium.handlers.handlers.purchase.ChargebackStopper) HyperiumModIntegration(cc.hyperium.mods.HyperiumModIntegration) NettyClient(cc.hyperium.netty.NettyClient) HyperiumHandlers(cc.hyperium.handlers.HyperiumHandlers) NetworkHandler(cc.hyperium.network.NetworkHandler) HyperiumCosmetics(cc.hyperium.cosmetics.HyperiumCosmetics) InternalAddons(cc.hyperium.addons.InternalAddons) InvokeEvent(cc.hyperium.event.InvokeEvent)

Aggregations

Sk1erMod (cc.hyperium.mods.sk1ercommon.Sk1erMod)5 CustomLevelheadCommand (cc.hyperium.mods.levelhead.command.CustomLevelheadCommand)2 File (java.io.File)2 InternalAddons (cc.hyperium.addons.InternalAddons)1 HyperiumCommandHandler (cc.hyperium.commands.HyperiumCommandHandler)1 cc.hyperium.commands.defaults (cc.hyperium.commands.defaults)1 DefaultConfig (cc.hyperium.config.DefaultConfig)1 Settings (cc.hyperium.config.Settings)1 HyperiumCosmetics (cc.hyperium.cosmetics.HyperiumCosmetics)1 EventBus (cc.hyperium.event.EventBus)1 InvokeEvent (cc.hyperium.event.InvokeEvent)1 Priority (cc.hyperium.event.Priority)1 GameShutDownEvent (cc.hyperium.event.client.GameShutDownEvent)1 InitializationEvent (cc.hyperium.event.client.InitializationEvent)1 PreInitializationEvent (cc.hyperium.event.client.PreInitializationEvent)1 ColourOptions (cc.hyperium.gui.ColourOptions)1 ConfirmationPopup (cc.hyperium.gui.ConfirmationPopup)1 NotificationCenter (cc.hyperium.gui.NotificationCenter)1 HyperiumHandlers (cc.hyperium.handlers.HyperiumHandlers)1 ChargebackStopper (cc.hyperium.handlers.handlers.purchase.ChargebackStopper)1