aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLorenz <lo.scherf@gmail.com>2022-08-02 09:24:32 +0200
committerLorenz <lo.scherf@gmail.com>2022-08-02 09:24:32 +0200
commit283a986d3d0f84afc5c38fb4c8465abc5de0d2b2 (patch)
treea9add543a5d796e001b91d72853afafbed848be1 /src
parent5303eae494b7411c28b736a30ed6b632edd1a20f (diff)
downloadskyhanni-283a986d3d0f84afc5c38fb4c8465abc5de0d2b2.tar.gz
skyhanni-283a986d3d0f84afc5c38fb4c8465abc5de0d2b2.tar.bz2
skyhanni-283a986d3d0f84afc5c38fb4c8465abc5de0d2b2.zip
adding debug for mod init phase
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java49
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;