diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java | 49 |
1 files changed, 44 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 5c7d11070..179f24faa 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -23,8 +23,6 @@ import at.hannibal2.skyhanni.repo.RepoManager; import at.hannibal2.skyhanni.test.LorenzTest; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import java.io.*; -import java.nio.charset.StandardCharsets; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.common.MinecraftForge; @@ -34,6 +32,9 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; +import java.io.*; +import java.nio.charset.StandardCharsets; + @Mod(modid = SkyHanniMod.MODID, version = SkyHanniMod.VERSION) public class SkyHanniMod { @@ -50,7 +51,11 @@ public class SkyHanniMod { @EventHandler public void preInit(FMLPreInitializationEvent event) { + loading("BazaarApi"); new BazaarApi(); + doneLoading(); + + loading("MinecraftForge.EVENT_BUS"); MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(new ChatManager()); MinecraftForge.EVENT_BUS.register(new HypixelData()); @@ -79,34 +84,67 @@ public class SkyHanniMod { MinecraftForge.EVENT_BUS.register(new BazaarBestSellMethod()); MinecraftForge.EVENT_BUS.register(new AnvilCombineHelper()); MinecraftForge.EVENT_BUS.register(new SeaCreatureMessageShortener()); + doneLoading(); + loading("Commands.init"); Commands.init(); + doneLoading(); + loading("more MinecraftForge.EVENT_BUS"); MinecraftForge.EVENT_BUS.register(new LorenzTest()); MinecraftForge.EVENT_BUS.register(new ButtonOnPause()); + doneLoading(); + loading("config"); configDirectory = new File("config/skyhanni"); try { //noinspection ResultOfMethodCallIgnored configDirectory.mkdir(); - } catch (Exception ignored) {} + } catch (Exception ignored) { + } configFile = new File(configDirectory, "config.json"); if (configFile.exists()) { try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8))) { feature = gson.fromJson(reader, Features.class); - } catch (Exception ignored) {} + } catch (Exception ignored) { + } } + doneLoading(); + loading("features"); if (feature == null) { feature = new Features(); saveConfig(); } + doneLoading(); + + loading("addShutdownHook"); Runtime.getRuntime().addShutdownHook(new Thread(this::saveConfig)); + doneLoading(); + loading("Repo"); repo = new RepoManager(configDirectory); repo.loadRepoInformation(); + doneLoading(); + } + + private long startLoadTime = 0; + + private String lastLoad = ""; + + private void loading(String text) { + lastLoad = text; + System.out.println(" "); + System.out.println("SkyHanni starts loading '" + lastLoad + "'"); + startLoadTime = System.currentTimeMillis(); + } + + private void doneLoading() { + long duration = System.currentTimeMillis() - startLoadTime; + System.out.println("Done (took " + duration + " ms)"); + System.out.println(" "); } public void saveConfig() { @@ -117,7 +155,8 @@ public class SkyHanniMod { try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(configFile), StandardCharsets.UTF_8))) { writer.write(gson.toJson(feature)); } - } catch (IOException ignored) {} + } catch (IOException ignored) { + } } public static GuiScreen screenToOpen = null; |