This repository has been archived by the owner on Jul 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4dm-resource-picker.sh
executable file
·105 lines (96 loc) · 3.65 KB
/
4dm-resource-picker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
gamefolder=$(cat gamepath)
helptext='4D Miner Texture Manger CLI
Flags:
-c Change game path
-d Display detailed 4d meta info
-h Display this help text
-l List folder names'
while getopts "cdhl" option; do
case $option in
c)
read -rp "Enter new directory: " gamefolder
echo "$gamefolder" > gamepath
exit;;
d)
table="Folder | Name | Description | Author"
for i in "$gamefolder"/texturepacks/*
do
if [ -a "$i"/pack.4dmeta ]
then
name=$(grep 'name:' "$i"/pack.4dmeta)
desc=$(grep 'description:' "$i"/pack.4dmeta)
autr=$(grep 'author:' "$i"/pack.4dmeta)
if [ -z "$name" ]; then name="Name not specified"; fi
if [ -z "$desc" ]; then desc="Description not specified"; fi
if [ -z "$autr" ]; then autr="Author not specified"; fi
table=$table"\n""$(basename "$i") | ${name:5} | ${desc:12} | ${autr:7}"
else
table=$table"\n""$(basename "$i") | No pack.4dmeta"
fi
done
echo -e "$table" | column -t -s'|' -o'|'
exit;;
l)
ls -N --format=single-column "$gamefolder/texturepacks/"
exit;;
h)
echo -e "$helptext"
exit;;
*)
echo -e "Invalid flag!"
echo -e "$helptext"
exit;;
esac
done
read -rp "Enter name of folder: " txtrpack
# --------------------
# If Someone's reading this I'm so sorry for this code I wrote
# --------------------
if [ -d "$gamefolder/texturepacks/$txtrpack/" ]
then
if [ -d "$gamefolder/texturepacks/$txtrpack/audio" ]
then
ln -sTf "$gamefolder/texturepacks/$txtrpack/audio" "$gamefolder/assets/audio"
else
ln -sTf "$gamefolder/texturepacks/Vanilla/audio" "$gamefolder/assets/audio"
fi
if [ -d "$gamefolder/texturepacks/$txtrpack/shaders" ]
then
ln -sTf "$gamefolder/texturepacks/$txtrpack/shaders" "$gamefolder/assets/shaders"
else
ln -sTf "$gamefolder/texturepacks/Vanilla/shaders" "$gamefolder/assets/shaders"
fi
if [ -d "$gamefolder/texturepacks/$txtrpack/textures" ]
then
ln -sTf "$gamefolder/texturepacks/$txtrpack/textures" "$gamefolder/assets/textures"
else
ln -sTf "$gamefolder/texturepacks/Vanilla/textures" "$gamefolder/assets/textures"
fi
if [ -a "$gamefolder/texturepacks/$txtrpack/itemInfo.json" ]
then
ln -sTf "$gamefolder/texturepacks/$txtrpack/itemInfo.json" "$gamefolder/itemInfo.json"
else
ln -sTf "$gamefolder/texturepacks/Vanilla/itemInfo.json" "$gamefolder/itemInfo.json"
fi
if [ -a "$gamefolder/texturepacks/$txtrpack/music.json" ]
then
ln -sTf "$gamefolder/texturepacks/$txtrpack/music.json" "$gamefolder/music.json"
else
ln -sTf "$gamefolder/texturepacks/Vanilla/music.json" "$gamefolder/music.json"
fi
if [ -a "$gamefolder/texturepacks/$txtrpack/recipes.json" ]
then
ln -sTf "$gamefolder/texturepacks/$txtrpack/recipes.json" "$gamefolder/recipes.json"
else
ln -sTf "$gamefolder/texturepacks/Vanilla/recipes.json" "$gamefolder/recipes.json"
fi
if [ -a "$gamefolder/texturepacks/$txtrpack/shaderList.json" ]
then
ln -sTf "$gamefolder/texturepacks/$txtrpack/shaderList.json" "$gamefolder/shaderList.json"
else
ln -sTf "$gamefolder/texturepacks/Vanilla/shaderList.json" "$gamefolder/shaderList.json"
fi
else
echo "Invalid texture pack! (input is case-sensitive!)"
fi