Skip to content

Commit

Permalink
improve mod detection logging
Browse files Browse the repository at this point in the history
  • Loading branch information
mist475 committed Apr 17, 2024
1 parent e5ab619 commit 8329a4f
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public static void register() {
ModuleRegistrar.instance().registerHeadProvider(new HUDHandlerBCTanks(), TileTank);
ModuleRegistrar.instance().registerBodyProvider(new HUDHandlerBCTanks(), TileTank);

} catch (ClassNotFoundException e) {
Waila.log.log(Level.WARN, "[BC] Class not found. " + e);
} catch (NoSuchMethodException e) {
Waila.log.log(Level.WARN, "[BC] Method not found." + e);
} catch (ClassNotFoundException | NoSuchMethodException e) {
Waila.log.log(Level.INFO, "[BC] Buildcraft mod not found.");
return;
}
Waila.log.log(Level.INFO, "Buildcraft mod found.");

}

Expand Down
8 changes: 7 additions & 1 deletion src/main/java/mcp/mobius/waila/addons/ic2/IC2Module.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,14 @@ public static void register() {
ModuleRegistrar.instance().addConfigRemote("IndustrialCraft2", "ic2.outputeu");

} catch (Exception e) {
Waila.log.log(Level.WARN, "[IndustrialCraft 2] Error while loading generator hooks." + e);
if (e instanceof ClassNotFoundException || e instanceof NoSuchFieldException) {
Waila.log.log(Level.INFO, "[IndustrialCraft 2] IndustrialCraft 2 mod not found.");
} else {
Waila.log.log(Level.WARN, "[IndustrialCraft 2] Error while loading generator hooks." + e);
}
return;
}
Waila.log.log(Level.INFO, "IndustrialCraft 2 mod found.");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ public static void register() {
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerIAspectContainer(), TileAlchemyFurnace);

} catch (ClassNotFoundException e) {
Waila.log.log(Level.WARN, "[Thaumcraft] Class not found. " + e);
Waila.log.log(Level.INFO, "[Thaumcraft] Thaumcraft mod not found.");
return;
} catch (Exception e) {
Waila.log.log(Level.WARN, "[Thaumcraft] Unhandled exception." + e);
Waila.log.log(Level.WARN, "[Thaumcraft] Unhandled exception. {}", e);
return;
}
Waila.log.log(Level.INFO, "Thaumcraft mod found.");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@ public static void register() {
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerDuct(), TileFluidDuct);

} catch (Exception e) {
Waila.log.log(Level.WARN, "[Thermal Dynamics] Error while loading FluidDuct hooks." + e);
if (e instanceof ClassNotFoundException) {
Waila.log.log(Level.INFO, "[Thermal Dynamics] Thermal Dynamics mod not found.");
} else {
Waila.log.log(Level.WARN, "[Thermal Dynamics] Error while loading FluidDuct hooks. {}", e);
}
return;
}
Waila.log.log(Level.INFO, "Thermal Dynamics mod found.");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class ThermalExpansionModule {
public static Method IBlockInfo_getBlockInfo = null;

public static void register() {
boolean printedThermalExpansionNotFound = false;
// XXX : We register the Energy interface first
try {
IEnergyProvider = Class.forName("cofh.api.energy.IEnergyProvider");
Expand All @@ -74,7 +75,12 @@ public static void register() {
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerIEnergyHandler(), IEnergyInfo);

} catch (Exception e) {
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Energy hooks." + e);
if (e instanceof ClassNotFoundException) {
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
printedThermalExpansionNotFound = true;
} else {
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Energy hooks. {}", e);
}
}

// XXX : We register the energy cell
Expand All @@ -88,7 +94,14 @@ public static void register() {
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerEnergyCell(), TileEnergyCell);

} catch (Exception e) {
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Energy Cell hooks." + e);
if (e instanceof ClassNotFoundException || e instanceof NoSuchFieldException) {
if (!printedThermalExpansionNotFound) {
printedThermalExpansionNotFound = true;
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
}
} else {
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Energy Cell hooks. {}", e);
}
}

// XXX : We register the Tank interface
Expand All @@ -107,7 +120,14 @@ public static void register() {
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerTank(), TileTank);

} catch (Exception e) {
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Tank hooks." + e);
if (e instanceof ClassNotFoundException || e instanceof NoSuchFieldException) {
if (!printedThermalExpansionNotFound) {
printedThermalExpansionNotFound = true;
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
}
} else {
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Tank hooks. {}", e);
}
}

// XXX : We register the Tesseract interface
Expand All @@ -123,7 +143,14 @@ public static void register() {
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerTesseract(), TileTesseract);

} catch (Exception e) {
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Tesseract hooks." + e);
if (e instanceof ClassNotFoundException || e instanceof NoSuchFieldException) {
if (!printedThermalExpansionNotFound) {
printedThermalExpansionNotFound = true;
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
}
} else {
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Tesseract hooks. {}", e);
}
}

// XXX : We register the ISecureTile interface
Expand All @@ -137,7 +164,14 @@ public static void register() {
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerISecureTile(), ISecureTile);

} catch (Exception e) {
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading ISecureTile hooks." + e);
if (e instanceof ClassNotFoundException) {
if (!printedThermalExpansionNotFound) {
printedThermalExpansionNotFound = true;
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
}
} else {
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading ISecureTile hooks. {}", e);
}
}

// XXX : We register the Cache interface
Expand All @@ -153,7 +187,17 @@ public static void register() {
ModuleRegistrar.instance().registerNBTProvider(new HUDHandlerCache(), TileCache);

} catch (Exception e) {
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Tesseract hooks." + e);
if (e instanceof ClassNotFoundException) {
if (!printedThermalExpansionNotFound) {
printedThermalExpansionNotFound = true;
Waila.log.log(Level.INFO, "[Thermal Expansion] Thermal Expansion mod not found.");
}
} else {
Waila.log.log(Level.WARN, "[Thermal Expansion] Error while loading Tesseract hooks. {}", e);
}
}
if (!printedThermalExpansionNotFound) {
Waila.log.log(Level.INFO, "Thermal Expansion mod found.");
}
}

Expand Down

0 comments on commit 8329a4f

Please sign in to comment.