@@ -37,30 +37,41 @@ class LoaderVersionController(
3737 override fun getReleaseMode (): ReleaseMode = ConfigManager .config.loaderReleaseMode
3838
3939 /* *
40- * Get the current loader version from the manifest or build properties .
40+ * Get the current loader version from the Fabric mod metadata .
4141 * This can be used to check if an update is available.
4242 */
4343 fun getCurrentLoaderVersion (): String? {
4444 return try {
45- // Try to read version from package implementation version
45+ // Try to read from Fabric mod container
46+ val fabricLoader = net.fabricmc.loader.api.FabricLoader .getInstance()
47+ val loaderMod = fabricLoader.getModContainer(" lambda-loader" )
48+
49+ if (loaderMod.isPresent) {
50+ val version = loaderMod.get().metadata.version.friendlyString
51+ if (com.lambda.loader.config.ConfigManager .config.debug) {
52+ logger.info(" Current loader version: $version " )
53+ }
54+ return version
55+ }
56+
57+ // Fallback: try package implementation version
4658 val version = this ::class .java.`package`?.implementationVersion
4759 if (version != null ) {
48- logger.info(" Current loader version: $version " )
60+ if (ConfigManager .config.debug) {
61+ logger.info(" Current loader version (from package): $version " )
62+ }
4963 return version
5064 }
5165
52- // Alternative: read from a properties file
53- val props = this ::class .java.classLoader.getResourceAsStream(" loader.properties" )
54- if (props != null ) {
55- val properties = java.util.Properties ()
56- properties.load(props)
57- return properties.getProperty(" version" )
66+ if (ConfigManager .config.debug) {
67+ logger.warning(" Could not determine current loader version" )
5868 }
59-
60- logger.warning(" Could not determine current loader version" )
6169 null
6270 } catch (e: Exception ) {
63- logger.warning(" Error reading loader version: ${e.message} " )
71+ if (ConfigManager .config.debug) {
72+ logger.warning(" Error reading loader version: ${e.message} " )
73+ e.printStackTrace()
74+ }
6475 null
6576 }
6677 }
0 commit comments