Selaa lähdekoodia

Add Platform#getFilePaths (#268)

Signed-off-by: Max <maxh2709@gmail.com>
(cherry picked from commit 517205efdc5a8c7791b3eae088420221a9b4f1a6)
(cherry picked from commit d1d491dad25f82d24b769e8d15e04e36c99d6e73)
(cherry picked from commit f4e828d4eb3aed7317766c50959f23cd5e467e7a)
Max 3 vuotta sitten
vanhempi
sitoutus
7ba233f867

+ 14 - 0
common/src/main/java/me/shedaniel/architectury/platform/Mod.java

@@ -26,6 +26,7 @@ import org.jetbrains.annotations.Nullable;
 
 import java.nio.file.Path;
 import java.util.Collection;
+import java.util.List;
 import java.util.Optional;
 
 public interface Mod {
@@ -45,6 +46,19 @@ public interface Mod {
      */
     Optional<String> getLogoFile(int preferredSize);
     
+    /**
+     * Gets a list of all possible root paths for the mod.
+     * This is especially relevant on Fabric, as a single mod may have multiple source sets
+     * (such as client / server-specific ones), each corresponding to one root path.
+     *
+     * @return A list of root paths belonging to the mod
+     */
+    List<Path> getFilePaths();
+    
+    /**
+     * @deprecated Use {@link #getFilePaths()} instead
+     */
+    @Deprecated(forRemoval = true)
     Path getFilePath();
     
     Collection<String> getAuthors();

+ 7 - 1
fabric/src/main/java/me/shedaniel/architectury/platform/fabric/PlatformImpl.java

@@ -31,6 +31,7 @@ import org.jetbrains.annotations.Nullable;
 
 import java.nio.file.Path;
 import java.util.Collection;
+import java.util.List;
 import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.Optional;
@@ -123,7 +124,12 @@ public class PlatformImpl {
         public @NotNull Optional<String> getLogoFile(int preferredSize) {
             return metadata.getIconPath(preferredSize);
         }
-        
+    
+        @Override
+        public List<Path> getFilePaths() {
+            return container.getRootPaths();
+        }
+    
         @Override
         public @NotNull Path getFilePath() {
             return container.getRootPath();

+ 6 - 1
forge/src/main/java/me/shedaniel/architectury/platform/forge/PlatformImpl.java

@@ -126,7 +126,12 @@ public class PlatformImpl {
         public @NotNull Optional<String> getLogoFile(int i) {
             return this.info.getLogoFile();
         }
-        
+    
+        @Override
+        public List<Path> getFilePaths() {
+            return Collections.singletonList(getFilePath());
+        }
+    
         @Override
         public @NotNull Path getFilePath() {
             return this.info.getOwningFile().getFile().getFilePath();