mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-09-01 01:57:55 +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:
@@ -619,3 +619,9 @@ b90611b4b4c176ec1c80df002cc4ac36aa0c4dc8
|
|||||||
Preserve registration order of upgrades
|
Preserve registration order of upgrades
|
||||||
```
|
```
|
||||||
Again, a huge diff because of code style changes.
|
Again, a huge diff because of code style changes.
|
||||||
|
|
||||||
|
```
|
||||||
|
8494ba8ce29cd8d7b9105eef497fe3fe3f89d350
|
||||||
|
|
||||||
|
Improve UX when a resource mount cannot be found
|
||||||
|
```
|
||||||
|
@@ -108,7 +108,10 @@ public final class ComputerCraftAPI {
|
|||||||
* Use in conjunction with {@link IComputerAccess#mount} or {@link IComputerAccess#mountWritable} to mount a resource folder onto a computer's file
|
* Use in conjunction with {@link IComputerAccess#mount} or {@link IComputerAccess#mountWritable} to mount a resource folder onto a computer's file
|
||||||
* system.
|
* system.
|
||||||
*
|
*
|
||||||
* 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.
|
* 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. 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".
|
||||||
|
@@ -90,19 +90,30 @@ public final class ResourceMount implements IMount {
|
|||||||
|
|
||||||
private void load() {
|
private void load() {
|
||||||
boolean hasAny = false;
|
boolean hasAny = false;
|
||||||
FileEntry newRoot = new FileEntry(new Identifier(this.namespace, this.subPath));
|
String existingNamespace = null;
|
||||||
for (Identifier file : this.manager.findResources(this.subPath, s -> true)) {
|
|
||||||
if (!file.getNamespace()
|
FileEntry newRoot = new FileEntry( new Identifier( namespace, subPath ) );
|
||||||
.equals(this.namespace)) {
|
for( Identifier file : manager.findResources( subPath, s -> true ) )
|
||||||
continue;
|
{
|
||||||
}
|
existingNamespace = file.getNamespace();
|
||||||
|
|
||||||
|
if( !file.getNamespace().equals( namespace ) ) continue;
|
||||||
|
|
||||||
String localPath = FileSystem.toLocal(file.getPath(), this.subPath);
|
String localPath = FileSystem.toLocal(file.getPath(), this.subPath);
|
||||||
this.create(newRoot, localPath);
|
this.create(newRoot, localPath);
|
||||||
hasAny = true;
|
hasAny = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.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 void create(FileEntry lastEntry, String path) {
|
private void create(FileEntry lastEntry, String path) {
|
||||||
|
Reference in New Issue
Block a user