Add Platform#getFilePaths (#268)

Signed-off-by: Max <maxh2709@gmail.com>
This commit is contained in:
Max
2022-05-27 17:31:05 +02:00
committed by GitHub
parent 42684fd87a
commit 517205efdc
3 changed files with 27 additions and 2 deletions

View File

@@ -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();

View File

@@ -30,6 +30,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.Optional;
import java.util.concurrent.ConcurrentHashMap;
@@ -121,7 +122,12 @@ public class PlatformImpl {
public Optional<String> getLogoFile(int preferredSize) {
return metadata.getIconPath(preferredSize);
}
@Override
public List<Path> getFilePaths() {
return container.getRootPaths();
}
@Override
public Path getFilePath() {
return container.getRootPath();

View File

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