mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-29 04:09: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)
|
@Deprecated(forRemoval = true)
|
||||||
Path getFilePath();
|
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();
|
Collection<String> getAuthors();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -132,7 +132,12 @@ public class PlatformImpl {
|
|||||||
public Path getFilePath() {
|
public Path getFilePath() {
|
||||||
return container.getRootPath();
|
return container.getRootPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Path> findResource(String... path) {
|
||||||
|
return container.findPath(String.join("/", path));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> getAuthors() {
|
public Collection<String> getAuthors() {
|
||||||
return metadata.getAuthors().stream()
|
return metadata.getAuthors().stream()
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@@ -126,15 +127,20 @@ public class PlatformImpl {
|
|||||||
public Optional<String> getLogoFile(int i) {
|
public Optional<String> getLogoFile(int i) {
|
||||||
return this.info.getLogoFile();
|
return this.info.getLogoFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Path> getFilePaths() {
|
public List<Path> getFilePaths() {
|
||||||
return List.of(getFilePath());
|
return List.of(getFilePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Path getFilePath() {
|
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
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user