summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/check-tree.py105
-rwxr-xr-xscripts/create-mrpack.sh5
-rw-r--r--scripts/emote-convert.py55
-rw-r--r--scripts/jarscanner-1.1-SNAPSHOT.jarbin0 -> 190123 bytes
-rwxr-xr-xscripts/rename-emotes.py52
-rwxr-xr-xscripts/write-tree.sh2
6 files changed, 219 insertions, 0 deletions
diff --git a/scripts/check-tree.py b/scripts/check-tree.py
new file mode 100755
index 0000000..e37110a
--- /dev/null
+++ b/scripts/check-tree.py
@@ -0,0 +1,105 @@
+#! /usr/bin/env python3
+
+import os
+import sys
+
+if len(sys.argv) < 3:
+ print(f'usage: {sys.argv[0]} [directory] mods.txt config.txt')
+ sys.exit(1)
+
+tree = sys.argv[1]
+if not os.path.isdir(tree):
+ print(f'{tree} is not a valid path')
+ sys.exit(1)
+
+mod_paths = {
+ 'c': 'client-overrides/mods',
+ 'r': 'client-overrides/resourcepacks',
+ 'sh': 'client-overrides/shaderpacks',
+ 'c,s': 'overrides/mods',
+ 's': 'server-overrides/mods',
+ 'd': 'server-overrides/datapacks'
+}
+
+all_files = ['modrinth.index.json']
+any_error = False
+
+def invalid_line(n, line):
+ print(f'err: Invalid line.\n\t{n + 1}: {line}')
+
+def parse_line(line, paths):
+ close = line.rfind(']')
+ if close < 0:
+ invalid_line(n, line)
+ return None, None
+ side = line[close + 1:]
+ if side not in mod_paths.keys():
+ invalid_line(n, line)
+ return None, None
+ open = line[:close].rfind('[')
+ if open < 0:
+ invalid_line(n, line)
+ return None, None
+ key = line[open + 1:close]
+ return side, key
+
+# mods.txt
+with open(sys.argv[2], 'r', encoding='utf-8') as f:
+ for n, line in enumerate(f.read().splitlines()):
+ if len(line) == 0:
+ continue
+ if line[0] not in ['-', '*']:
+ continue
+ side, filename = parse_line(line, mod_paths)
+ if not side:
+ continue
+ listed_disabled = line[2:4] == 'x|'
+ if filename.endswith('.disabled') and not listed_disabled:
+ print(f'err: Mod file named disabled but not listed as disabled.\n\t{n + 1}: {line}')
+ any_error = True
+ continue
+ if listed_disabled and side not in ('r', 'd'):
+ filename += '.disabled'
+ all_files.append(filename)
+ target = f'{tree}/{mod_paths[side]}/{filename}'
+ if not os.path.isfile(target):
+ print(f'err: Mod not found in the specified directory.\n\t{target}')
+ any_error = True
+
+for i, file in enumerate(all_files):
+ if file in all_files[i + 1:]:
+ print(f'err: Duplicate entry.\n\t{file}')
+ any_error = True
+
+config_paths = {
+ 'c': 'client-overrides',
+ 'c,s': 'overrides',
+ 's': 'server-overrides'
+}
+
+# config.txt
+with open(sys.argv[3], 'r', encoding='utf-8') as f:
+ for n, line in enumerate(f.read().splitlines()):
+ if len(line) == 0:
+ continue
+ if line[0] != '[':
+ continue
+ side, path = parse_line(line, config_paths)
+ if not side:
+ continue
+ all_files.append(path.split('/')[-1])
+ target = f'{tree}/{config_paths[side]}/{path}'
+ if not os.path.isfile(target):
+ print(f'err: Config file not found in specified directory.\n\t{target}')
+ any_error = True
+
+for subdir, dirs, files in os.walk(tree):
+ for file in files:
+ if not (subdir.endswith('mods') or subdir.endswith('resourcepacks') or subdir.endswith('datapacks')):
+ continue
+ if file not in all_files:
+ print(f'err: Erroneous file in tree.\n\t{os.path.join(subdir, file)}')
+ any_error = True
+
+if not any_error:
+ print('success: The modpack tree is intact.')
diff --git a/scripts/create-mrpack.sh b/scripts/create-mrpack.sh
new file mode 100755
index 0000000..ded348f
--- /dev/null
+++ b/scripts/create-mrpack.sh
@@ -0,0 +1,5 @@
+#! /usr/bin/env sh
+set -e
+cd tree
+7za a -tzip ../../website/static/mrpacks/$1.mrpack *
+cd ..
diff --git a/scripts/emote-convert.py b/scripts/emote-convert.py
new file mode 100644
index 0000000..41fac5c
--- /dev/null
+++ b/scripts/emote-convert.py
@@ -0,0 +1,55 @@
+#! /usr/bin/env python3
+
+import json
+import sys
+
+if len(sys.argv) < 3:
+ print(f'usage: {sys.argv[0]} BROKEN_EMOTE.json OUTPUT.json')
+ sys.exit(1)
+
+with open(sys.argv[1], 'r', encoding='utf-8') as f0:
+ j = json.loads(f0.read())
+ frames = {}
+ inner_keys = []
+ max_tick = 0
+ for m in j['emote']['moves']:
+ if m['tick'] < 0:
+ m['tick'] = 0
+ if m['tick'] not in frames:
+ frames[m['tick']] = {}
+ key = ''
+ for k in m:
+ if k != 'tick' and k != 'easing' and k != 'turn':
+ key += k + str(list(m[k].keys())[0])
+ if key not in inner_keys:
+ inner_keys.append(key)
+ frames[m['tick']][key] = m.copy()
+ if m['tick'] > max_tick:
+ max_tick = m['tick']
+ if j['emote']['returnTick'] > max_tick:
+ j['emote']['returnTick'] = max_tick
+ if max_tick > j['emote']['stopTick']:
+ j['emote']['endTick'] = max_tick
+ j['emote']['stopTick'] = max_tick + 1
+ j['emote']['beginTick'] = 0
+ composite = frames.copy()
+ keys = sorted(list(frames.keys()))
+ if len(keys) > 1:
+ for i in range(1, len(keys)):
+ if keys[i] != max_tick:
+ continue
+ for k in inner_keys:
+ if k in frames[keys[i]]:
+ continue
+ for rk in reversed(keys):
+ if k in frames[rk]:
+ val = frames[rk][k].copy()
+ val['tick'] = keys[i]
+ composite[keys[i]][k] = val
+ break
+ j['emote']['moves'] = []
+ for k, v in sorted(composite.items()):
+ for p, m in sorted(v.items()):
+ j['emote']['moves'].append(m)
+ with open(sys.argv[2], 'w+', encoding='utf-8') as f1:
+ json.dump(j, f1, ensure_ascii=False, indent=4)
diff --git a/scripts/jarscanner-1.1-SNAPSHOT.jar b/scripts/jarscanner-1.1-SNAPSHOT.jar
new file mode 100644
index 0000000..52249f0
--- /dev/null
+++ b/scripts/jarscanner-1.1-SNAPSHOT.jar
Binary files differ
diff --git a/scripts/rename-emotes.py b/scripts/rename-emotes.py
new file mode 100755
index 0000000..85f16db
--- /dev/null
+++ b/scripts/rename-emotes.py
@@ -0,0 +1,52 @@
+#! /usr/bin/env python3
+
+import re
+import os
+import sys
+import json
+import argostranslate.package
+import argostranslate.translate
+
+from_code = "ru"
+to_code = "en"
+
+# https://github.com/argosopentech/argos-translate?tab=readme-ov-file#python
+argostranslate.package.update_package_index()
+available_packages = argostranslate.package.get_available_packages()
+package_to_install = next(
+ filter(lambda x: x.from_code == from_code and x.to_code == to_code, available_packages)
+)
+argostranslate.package.install_from_path(package_to_install.download())
+
+def has_cyrillic(text):
+ return bool(re.search('[\u0400-\u04FF]', text))
+
+target = sys.argv[1]
+output = './emotes_output'
+
+if not os.path.isdir(output):
+ os.mkdir(output)
+
+for file in os.listdir(sys.argv[1]):
+ print(file)
+ if file.split('.')[1] != 'json':
+ continue
+ with open(f"{target}/{file}", 'r') as f:
+ j = json.loads(f.read())
+ if file.startswith('SPE_'):
+ file = file.replace('SPE_', '')
+ j['name'] = file.split('.')[0].replace('_', ' ')
+ else:
+ if has_cyrillic(j['name']):
+ j['name'] = file.split('.')[0].replace('_', ' ')
+ j['name'] = re.sub('ยง[a-zA-Z0-9]', '', j['name'])
+ if j['name'].startswith('[18+] '):
+ j['name'] = j['name'].replace('[18+] ', '')
+ if has_cyrillic(j['description']):
+ j['description'] = argostranslate.translate.translate(j['description'], from_code, to_code)
+ file = file.replace(' ', '_')
+ file = file.replace('\'', '-')
+ file = file.lower()
+ path = f"{output}/{file}"
+ with open(path, 'w') as fo:
+ fo.write(json.dumps(j, indent=4))
diff --git a/scripts/write-tree.sh b/scripts/write-tree.sh
new file mode 100755
index 0000000..3e5ef31
--- /dev/null
+++ b/scripts/write-tree.sh
@@ -0,0 +1,2 @@
+#! /usr/bin/env sh
+find tree -type f | sort > tree.txt