Search in sources :

Example 1 with CommandNickHider

use of cc.hyperium.mods.nickhider.command.CommandNickHider 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)

Aggregations

CommandNickHider (cc.hyperium.mods.nickhider.command.CommandNickHider)1 NickHiderConfig (cc.hyperium.mods.nickhider.config.NickHiderConfig)1 Sk1erMod (cc.hyperium.mods.sk1ercommon.Sk1erMod)1 Gson (com.google.gson.Gson)1 File (java.io.File)1