blob: 7f0882a353deda73f5977060766cb4cb9064899d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
package cc.polyfrost.oneconfig.internal;
import cc.polyfrost.oneconfig.internal.config.ConfigCore;
import cc.polyfrost.oneconfig.config.data.Mod;
import cc.polyfrost.oneconfig.config.data.ModType;
import cc.polyfrost.oneconfig.events.EventManager;
import cc.polyfrost.oneconfig.internal.hud.HudCore;
import cc.polyfrost.oneconfig.internal.config.OneConfigConfig;
import cc.polyfrost.oneconfig.internal.command.OneConfigCommand;
import cc.polyfrost.oneconfig.internal.gui.BlurHandler;
import cc.polyfrost.oneconfig.test.TestCommand;
import cc.polyfrost.oneconfig.test.TestConfig;
import cc.polyfrost.oneconfig.utils.gui.GuiUtils;
import cc.polyfrost.oneconfig.utils.commands.CommandManager;
import cc.polyfrost.oneconfig.utils.hypixel.HypixelUtils;
import net.minecraftforge.fml.common.DummyModContainer;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.ModContainer;
import net.minecraftforge.fml.common.ModMetadata;
import java.io.File;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
/**
* The main class of OneConfig.
*/
@net.minecraftforge.fml.common.Mod(modid = "@ID@", name = "@NAME@", version = "@VER@")
public class OneConfig {
public static final File oneConfigDir = new File("./OneConfig");
public static final List<Mod> loadedMods = new ArrayList<>();
public static final List<ModMetadata> loadedOtherMods = new ArrayList<>();
public static OneConfigConfig config;
public static TestConfig testConfig;
private static boolean preLaunched = false;
private static boolean initialized = false;
/**
* Called before mods are loaded.
* <p><b>SHOULD NOT BE CALLED!</b></p>
*/
public static void preLaunch() {
if (preLaunched) return;
if (!net.minecraft.launchwrapper.Launch.blackboard.containsKey("oneconfig.initialized")) {
throw new RuntimeException("OneConfig has not been initialized! Please add the OneConfig tweaker or call OneConfigInit via an ITweaker or a FMLLoadingPlugin!");
}
oneConfigDir.mkdirs();
new File(oneConfigDir, "profiles").mkdirs();
config = new OneConfigConfig();
preLaunched = true;
}
/**
* Called after mods are loaded.
* <p><b>SHOULD NOT BE CALLED!</b></p>
*/
@SuppressWarnings("ResultOfMethodCallIgnored")
public static void init() {
if (initialized) return;
GuiUtils.getDeltaTime(); // called to make sure static initializer is called
BlurHandler.INSTANCE.load();
testConfig = new TestConfig();
CommandManager.INSTANCE.registerCommand(OneConfigCommand.class);
CommandManager.INSTANCE.registerCommand(TestCommand.class);
EventManager.INSTANCE.register(new HudCore());
EventManager.INSTANCE.register(HypixelUtils.INSTANCE);
reloadModsList();
initialized = true;
}
public static void reloadModsList() {
loadedMods.addAll(ConfigCore.oneConfigMods);
LinkedHashSet<Mod> modData = new LinkedHashSet<>(ConfigCore.oneConfigMods);
for (ModContainer mod : Loader.instance().getActiveModList()) {
ModMetadata metadata = mod.getMetadata();
loadedOtherMods.add(metadata);
String imageName = Loader.instance().activeModContainer() == null || Loader.instance().activeModContainer().getMetadata().logoFile.trim().equals("") ? null : "/" + Loader.instance().activeModContainer().getMetadata().logoFile;
Mod newMod = new Mod(metadata.name, ModType.THIRD_PARTY, imageName);
newMod.isShortCut = true;
if (mod instanceof DummyModContainer || newMod.name.equals("OneConfig")) continue;
if (modData.add(newMod)) loadedMods.add(newMod);
}
}
}
|