From c1da022471698907fe427da8a282de591d7b57b2 Mon Sep 17 00:00:00 2001 From: Matyrobbrt Date: Sat, 13 Jan 2024 17:41:54 +0200 Subject: [PATCH] A few defaults --- .../neoforgespi/locating/IModFile.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/spi/src/main/java/net/neoforged/neoforgespi/locating/IModFile.java b/spi/src/main/java/net/neoforged/neoforgespi/locating/IModFile.java index 5d7e75031..fbcc13b46 100644 --- a/spi/src/main/java/net/neoforged/neoforgespi/locating/IModFile.java +++ b/spi/src/main/java/net/neoforged/neoforgespi/locating/IModFile.java @@ -13,8 +13,10 @@ import net.neoforged.neoforgespi.language.IModLanguageProvider; import net.neoforged.neoforgespi.language.ModFileScanData; import org.apache.maven.artifact.versioning.ArtifactVersion; +import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.jetbrains.annotations.ApiStatus; +import java.lang.module.ModuleDescriptor; import java.nio.file.Path; import java.util.List; import java.util.Map; @@ -122,17 +124,23 @@ public interface IModFile { /** * {@return the coremods contained in this file} */ - List getCoreMods(); + default List getCoreMods() { + return List.of(); + } /** * {@return the names of the Mixin configs of this file} */ - List getMixinConfigs(); + default List getMixinConfigs() { + return List.of(); + } /** * {@return the paths to the access transformer files contained in this file} */ - List getAccessTransformers(); + default List getAccessTransformers() { + return List.of(); + } /** * {@return the controller of this file} @@ -147,7 +155,9 @@ public interface IModFile { * Usually this is the version in the jar's manifest. * @apiNote This version may not be accurate, when possible, use the version of the mods contained in the file. */ - ArtifactVersion getVersion(); + default ArtifactVersion getVersion() { + return new DefaultArtifactVersion(getSecureJar().moduleDataProvider().descriptor().version().map(ModuleDescriptor.Version::toString).orElse("0.0NONE")); + } /** * The type of file.