summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mc-resources.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/mc-resources.py b/mc-resources.py
index cf5dc10..746705e 100644
--- a/mc-resources.py
+++ b/mc-resources.py
@@ -3,6 +3,7 @@ import itertools
import graphlib
import zipfile
import json
+import sys
import os
def ask_from_list(prompt, mapping):
@@ -28,9 +29,19 @@ def join_with_and(list):
return list[0] + ' and ' + list[1]
return ', '.join(list[:-1]) + ', and ' + list[-1]
+def guess_minecraft_directory():
+ if sys.platform.startswith('linux'):
+ return os.path.join(os.path.expanduser('~'), '.minecraft')
+ if sys.platform in ['win32', 'cygwin']:
+ return os.path.join(os.getenv('APPDATA'), '.minecraft')
+ return '.'
+
if not os.path.exists('from-jar'):
- print('please enter the path to the .minecraft folder:')
- versions_dir = os.path.join(input('> '), 'versions')
+ versions_dir = os.path.join(guess_minecraft_directory(), 'versions')
+
+ while not os.path.exists(versions_dir):
+ print('please enter the path to the .minecraft directory:')
+ versions_dir = os.path.join(input('> '), 'versions')
versions = {}