mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-12 11:10:29 +00:00
Improve UX when a resource mount cannot be found
- Add a full example of the docs. Hopefully is a little more explicit. - Print a warning when the mount is empty. Closes #762
This commit is contained in:
parent
058d63e77f
commit
8494ba8ce2
@ -98,7 +98,9 @@ public final class ComputerCraftAPI
|
|||||||
* resource folder onto a computer's file system.
|
* resource folder onto a computer's file system.
|
||||||
*
|
*
|
||||||
* The files in this mount will be a combination of files in all mod jar, and data packs that contain
|
* The files in this mount will be a combination of files in all mod jar, and data packs that contain
|
||||||
* resources with the same domain and path.
|
* resources with the same domain and path. For instance, ComputerCraft's resources are stored in
|
||||||
|
* "/data/computercraft/lua/rom". We construct a mount for that with
|
||||||
|
* {@code createResourceMount("computercraft", "lua/rom")}.
|
||||||
*
|
*
|
||||||
* @param domain The domain under which to look for resources. eg: "mymod".
|
* @param domain The domain under which to look for resources. eg: "mymod".
|
||||||
* @param subPath The subPath under which to look for resources. eg: "lua/myfiles".
|
* @param subPath The subPath under which to look for resources. eg: "lua/myfiles".
|
||||||
|
@ -103,9 +103,13 @@ public final class ResourceMount implements IMount
|
|||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
boolean hasAny = false;
|
boolean hasAny = false;
|
||||||
|
String existingNamespace = null;
|
||||||
|
|
||||||
FileEntry newRoot = new FileEntry( new ResourceLocation( namespace, subPath ) );
|
FileEntry newRoot = new FileEntry( new ResourceLocation( namespace, subPath ) );
|
||||||
for( ResourceLocation file : manager.listResources( subPath, s -> true ) )
|
for( ResourceLocation file : manager.listResources( subPath, s -> true ) )
|
||||||
{
|
{
|
||||||
|
existingNamespace = file.getNamespace();
|
||||||
|
|
||||||
if( !file.getNamespace().equals( namespace ) ) continue;
|
if( !file.getNamespace().equals( namespace ) ) continue;
|
||||||
|
|
||||||
String localPath = FileSystem.toLocal( file.getPath(), subPath );
|
String localPath = FileSystem.toLocal( file.getPath(), subPath );
|
||||||
@ -114,6 +118,15 @@ public final class ResourceMount implements IMount
|
|||||||
}
|
}
|
||||||
|
|
||||||
root = hasAny ? newRoot : null;
|
root = hasAny ? newRoot : null;
|
||||||
|
|
||||||
|
if( !hasAny )
|
||||||
|
{
|
||||||
|
ComputerCraft.log.warn("Cannot find any files under /data/{}/{} for resource mount.", namespace, subPath);
|
||||||
|
if( newRoot != null )
|
||||||
|
{
|
||||||
|
ComputerCraft.log.warn("There are files under /data/{}/{} though. Did you get the wrong namespace?", existingNamespace, subPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private FileEntry get( String path )
|
private FileEntry get( String path )
|
||||||
|
Loading…
Reference in New Issue
Block a user