Fix file tab completion in production environments

This commit is contained in:
Logan Darklock 2019-08-31 07:55:24 -07:00
parent 90fb17b89f
commit 84f45ebb48
No known key found for this signature in database
GPG Key ID: B8C37CEDE1AC60EA
2 changed files with 13 additions and 1 deletions

View File

@ -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<File, File> {
private final Path path;
@ -48,4 +50,14 @@ public class RelativeFile implements IDatatypePost<File, File> {
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;
}
}

View File

@ -67,7 +67,7 @@ public class ExploreFilterCommand extends Command {
@Override
protected Stream<String> 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();