mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-28 03:56:59 -05:00
Fix Platform#getFilePath not returning the *root* file path on Forge (#269)
* Platform#getFilePath now actually returns the *root* path on forge Signed-off-by: Max <maxh2709@gmail.com> * Add Mod#findResource (please stop yelling at me now kthx) Signed-off-by: Max <maxh2709@gmail.com>
This commit is contained in:
@@ -61,6 +61,15 @@ public interface Mod {
|
||||
@Deprecated(forRemoval = true)
|
||||
Path getFilePath();
|
||||
|
||||
/**
|
||||
* Gets an NIO Path to the given resource contained within the mod file / folder.
|
||||
* The path is verified to exist, and an empty optional is returned if it doesn't.
|
||||
*
|
||||
* @param path The resource to search for
|
||||
* @return The path of the resource if it exists, or {@link Optional#empty()} if it doesn't
|
||||
*/
|
||||
Optional<Path> findResource(String... path);
|
||||
|
||||
Collection<String> getAuthors();
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -132,7 +132,12 @@ public class PlatformImpl {
|
||||
public Path getFilePath() {
|
||||
return container.getRootPath();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Optional<Path> findResource(String... path) {
|
||||
return container.findPath(String.join("/", path));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getAuthors() {
|
||||
return metadata.getAuthors().stream()
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -126,15 +127,20 @@ 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();
|
||||
return this.info.getOwningFile().getFile().getSecureJar().getRootPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Path> findResource(String... path) {
|
||||
return Optional.of(this.info.getOwningFile().getFile().findResource(path)).filter(Files::exists);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user