diff --git a/src/api/java/baritone/api/Settings.java b/src/api/java/baritone/api/Settings.java index bf077f1a..69bcabcb 100644 --- a/src/api/java/baritone/api/Settings.java +++ b/src/api/java/baritone/api/Settings.java @@ -811,6 +811,12 @@ public final class Settings { */ public final Setting schematicOrientationZ = new Setting<>(false); + /** + * The fallback used by the build command when no extension is specified. This may be useful if schematics of a + * particular format are used often, and the user does not wish to have to specify the extension with every usage. + */ + public final Setting schematicFallbackExtension = new Setting<>("schematic"); + /** * Distance to scan every tick for updates. Expanding this beyond player reach distance (i.e. setting it to 6 or above) * is only necessary in very large schematics where rescanning the whole thing is costly. diff --git a/src/main/java/baritone/command/defaults/BuildCommand.java b/src/main/java/baritone/command/defaults/BuildCommand.java index 39bf0d3f..3d549587 100644 --- a/src/main/java/baritone/command/defaults/BuildCommand.java +++ b/src/main/java/baritone/command/defaults/BuildCommand.java @@ -17,6 +17,7 @@ package baritone.command.defaults; +import baritone.Baritone; import baritone.api.IBaritone; import baritone.api.utils.BetterBlockPos; import baritone.api.command.Command; @@ -26,11 +27,11 @@ import baritone.api.command.exception.CommandException; import baritone.api.command.exception.CommandInvalidStateException; import baritone.api.command.argument.IArgConsumer; import net.minecraft.client.Minecraft; +import org.apache.commons.io.FilenameUtils; import java.io.File; import java.util.Arrays; import java.util.List; -import java.util.Locale; import java.util.stream.Stream; public class BuildCommand extends Command { @@ -44,8 +45,8 @@ public class BuildCommand extends Command { @Override public void execute(String label, IArgConsumer args) throws CommandException { File file = args.getDatatypePost(RelativeFile.INSTANCE, schematicsDir).getAbsoluteFile(); - if (!file.getName().toLowerCase(Locale.US).endsWith(".schematic")) { - file = new File(file.getAbsolutePath() + ".schematic"); + if (FilenameUtils.getExtension(file.getAbsolutePath()).isEmpty()) { + file = new File(file.getAbsolutePath() + "." + Baritone.settings().schematicFallbackExtension); } BetterBlockPos origin = ctx.playerFeet(); BetterBlockPos buildOrigin; diff --git a/src/main/java/baritone/utils/schematic/format/SchematicFormat.java b/src/main/java/baritone/utils/schematic/format/SchematicFormat.java index 5f103d9a..6c84273e 100644 --- a/src/main/java/baritone/utils/schematic/format/SchematicFormat.java +++ b/src/main/java/baritone/utils/schematic/format/SchematicFormat.java @@ -65,6 +65,6 @@ public enum SchematicFormat { public static Optional getByExtension(String extension) { return extension == null || extension.isEmpty() ? Optional.empty() - : Stream.of(values()).filter(format -> format.extension.equals(extension)).findFirst(); + : Stream.of(values()).filter(format -> format.extension.equalsIgnoreCase(extension)).findFirst(); } }