fix: correctly resolve file if extension is given (#2857)

* fix: correctly resolve file if extension is given

* Adjust error if ClipboardFormats#findByFile null
This commit is contained in:
Jordan 2024-07-31 21:08:06 +02:00 committed by GitHub
parent 638344d815
commit f93ad596c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 2 deletions

View File

@ -712,6 +712,12 @@ public class MainUtil {
return file;
}
}
if (filename.matches(".*\\.[\\w].*")) {
File file = MainUtil.resolveRelative(new File(dir, filename));
if (file.exists()) {
return file;
}
}
for (ClipboardFormat f : ClipboardFormats.getAll()) {
File file = MainUtil.resolveRelative(new File(dir, filename + "." + f.getPrimaryFileExtension()));
if (file.exists()) {

View File

@ -401,7 +401,11 @@ public class SchematicCommands {
if (format == null) {
format = ClipboardFormats.findByFile(file);
if (format == null) {
if (noExplicitFormat) {
actor.print(Caption.of("fawe.worldedit.schematic.schematic.load-failure", TextComponent.of(file.getName())));
} else {
actor.print(Caption.of("worldedit.schematic.unknown-format", TextComponent.of(formatName)));
}
return;
}
}

View File

@ -208,7 +208,6 @@ public class ClipboardFormats {
}
}
return null;
}
public static MultiClipboardHolder loadAllFromInput(