From 84f45ebb48ecefac19b3ec6e2e0f406113f227f3 Mon Sep 17 00:00:00 2001 From: Logan Darklock Date: Sat, 31 Aug 2019 07:55:24 -0700 Subject: [PATCH] Fix file tab completion in production environments --- .../api/utils/command/datatypes/RelativeFile.java | 12 ++++++++++++ .../utils/command/defaults/ExploreFilterCommand.java | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/api/java/baritone/api/utils/command/datatypes/RelativeFile.java b/src/api/java/baritone/api/utils/command/datatypes/RelativeFile.java index 41b6ff55..b612e342 100644 --- a/src/api/java/baritone/api/utils/command/datatypes/RelativeFile.java +++ b/src/api/java/baritone/api/utils/command/datatypes/RelativeFile.java @@ -11,6 +11,8 @@ import java.util.Locale; import java.util.Objects; import java.util.stream.Stream; +import static baritone.api.utils.Helper.HELPER; + public class RelativeFile implements IDatatypePost { private final Path path; @@ -48,4 +50,14 @@ public class RelativeFile implements IDatatypePost { public File apply(File original) { return original.toPath().resolve(path).toFile(); } + + public static File gameDir() { + File gameDir = HELPER.mc.gameDir.getAbsoluteFile(); + + if (gameDir.getName().equals(".")) { + return gameDir.getParentFile(); + } + + return gameDir; + } } diff --git a/src/api/java/baritone/api/utils/command/defaults/ExploreFilterCommand.java b/src/api/java/baritone/api/utils/command/defaults/ExploreFilterCommand.java index 6b257012..1dd48512 100644 --- a/src/api/java/baritone/api/utils/command/defaults/ExploreFilterCommand.java +++ b/src/api/java/baritone/api/utils/command/defaults/ExploreFilterCommand.java @@ -67,7 +67,7 @@ public class ExploreFilterCommand extends Command { @Override protected Stream tabCompleted(String label, ArgConsumer args, Settings settings) { if (args.hasExactlyOne()) { - return RelativeFile.tabComplete(args, MC.gameDir.getAbsoluteFile().getParentFile()); + return RelativeFile.tabComplete(args, RelativeFile.gameDir()); } return Stream.empty();