Skip to content

Commit 4867f8f

Browse files
committed
Merge branch 'dev'
2 parents 3e4dacc + e26cf6d commit 4867f8f

File tree

14 files changed

+84
-69
lines changed

14 files changed

+84
-69
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ out/
99
.git-old/
1010

1111
post-body.json
12+
13+
refactor.md

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/hashicorp/go-version v1.8.0
88
github.com/minio/selfupdate v0.6.0
99
github.com/pterm/pterm v0.12.82
10-
golang.org/x/term v0.38.0
10+
golang.org/x/term v0.39.0
1111
)
1212

1313
require (
@@ -21,12 +21,12 @@ require (
2121
github.com/gookit/color v1.6.0 // indirect
2222
github.com/h2non/filetype v1.1.3 // indirect
2323
github.com/juju/errors v1.0.0 // indirect
24-
github.com/klauspost/compress v1.18.2 // indirect
24+
github.com/klauspost/compress v1.18.3 // indirect
2525
github.com/lithammer/fuzzysearch v1.1.8 // indirect
2626
github.com/mattn/go-runewidth v0.0.19 // indirect
2727
github.com/ulikunitz/xz v0.5.15 // indirect
2828
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
29-
golang.org/x/crypto v0.46.0 // indirect
30-
golang.org/x/sys v0.39.0 // indirect
31-
golang.org/x/text v0.32.0 // indirect
29+
golang.org/x/crypto v0.47.0 // indirect
30+
golang.org/x/sys v0.40.0 // indirect
31+
golang.org/x/text v0.33.0 // indirect
3232
)

go.sum

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,12 @@ github.com/gookit/color v1.6.0 h1:JjJXBTk1ETNyqyilJhkTXJYYigHG24TM9Xa2M1xAhRA=
4141
github.com/gookit/color v1.6.0/go.mod h1:9ACFc7/1IpHGBW8RwuDm/0YEnhg3dwwXpoMsmtyHfjs=
4242
github.com/h2non/filetype v1.1.3 h1:FKkx9QbD7HR/zjK1Ia5XiBsq9zdLi5Kf3zGyFTAFkGg=
4343
github.com/h2non/filetype v1.1.3/go.mod h1:319b3zT68BvV+WRj7cwy856M2ehB3HqNOt6sy1HndBY=
44-
github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY=
45-
github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
4644
github.com/hashicorp/go-version v1.8.0 h1:KAkNb1HAiZd1ukkxDFGmokVZe1Xy9HG6NUp+bPle2i4=
4745
github.com/hashicorp/go-version v1.8.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
4846
github.com/juju/errors v1.0.0 h1:yiq7kjCLll1BiaRuNY53MGI0+EQ3rF6GB+wvboZDefM=
4947
github.com/juju/errors v1.0.0/go.mod h1:B5x9thDqx0wIMH3+aLIMP9HjItInYWObRovoCFM5Qe8=
50-
github.com/klauspost/compress v1.18.1 h1:bcSGx7UbpBqMChDtsF28Lw6v/G94LPrrbMbdC3JH2co=
51-
github.com/klauspost/compress v1.18.1/go.mod h1:ZQFFVG+MdnR0P+l6wpXgIL4NTtwiKIdBnrBd8Nrxr+0=
52-
github.com/klauspost/compress v1.18.2 h1:iiPHWW0YrcFgpBYhsA6D1+fqHssJscY/Tm/y2Uqnapk=
53-
github.com/klauspost/compress v1.18.2/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4=
48+
github.com/klauspost/compress v1.18.3 h1:9PJRvfbmTabkOX8moIpXPbMMbYN60bWImDDU7L+/6zw=
49+
github.com/klauspost/compress v1.18.3/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4=
5450
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
5551
github.com/klauspost/cpuid/v2 v2.0.10/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c=
5652
github.com/klauspost/cpuid/v2 v2.0.12/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c=
@@ -100,10 +96,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
10096
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
10197
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
10298
golang.org/x/crypto v0.0.0-20211209193657-4570a0811e8b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
103-
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
104-
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
105-
golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU=
106-
golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0=
99+
golang.org/x/crypto v0.47.0 h1:V6e3FRj+n4dbpw86FJ8Fv7XVOql7TEwpHapKoMJ/GO8=
100+
golang.org/x/crypto v0.47.0/go.mod h1:ff3Y9VzzKbwSSEzWqJsJVBnWmRwRSHt/6Op5n9bQc4A=
107101
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E=
108102
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
109103
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
@@ -131,30 +125,24 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
131125
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
132126
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
133127
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
134-
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
135-
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
136-
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
137-
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
128+
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
129+
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
138130
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
139131
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
140132
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
141133
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
142134
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
143135
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
144-
golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU=
145-
golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254=
146-
golang.org/x/term v0.38.0 h1:PQ5pkm/rLO6HnxFR7N2lJHOZX6Kez5Y1gDSJla6jo7Q=
147-
golang.org/x/term v0.38.0/go.mod h1:bSEAKrOT1W+VSu9TSCMtoGEOUcKxOKgl3LE5QEF/xVg=
136+
golang.org/x/term v0.39.0 h1:RclSuaJf32jOqZz74CkPA9qFuVTX7vhLlpfj/IGWlqY=
137+
golang.org/x/term v0.39.0/go.mod h1:yxzUCTP/U+FzoxfdKmLaA0RV1WgE0VY7hXBwKtY/4ww=
148138
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
149139
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
150140
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
151141
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
152142
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
153143
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
154-
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
155-
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
156-
golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
157-
golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
144+
golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE=
145+
golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8=
158146
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
159147
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
160148
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=

main.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ func main() {
203203

204204
var filesToDownload []structs.File
205205

206+
if selectedProvider == nil {
207+
pterm.Fatal.Println("No provider selected")
208+
return
209+
}
210+
206211
// Get modpack details from the provider
207212
modpack, err := selectedProvider.GetModpack()
208213
if err != nil {
@@ -242,7 +247,7 @@ func main() {
242247
Files: modpackVersion.Files,
243248
}
244249

245-
// Check if the install location exists, if it doesnt, ask if they want to create the folder(s)
250+
// Check if the install location exists, if it doesn't, ask if they want to create the folder(s)
246251
exists, err := util.PathExists(installDir)
247252
if err != nil {
248253
selectedProvider.FailedInstall()
@@ -300,8 +305,8 @@ func main() {
300305
}
301306

302307
/*
303-
Check the manifest to see if its the same modpack installed, if its not the same modpack then ask the user
304-
if they intened to install a different modpack and the issues that can arrise for it.
308+
Check the manifest to see if it's the same modpack installed, if it's not the same modpack then ask the user
309+
if they intend to install a different modpack and the issues that can arise for it.
305310
If auto is specified but not the force flag show a warning and exit
306311
*/
307312
isSamePack := isSameModpack(existingManifest, manifest)
@@ -388,7 +393,7 @@ func main() {
388393
jreAlreadyExists = true
389394
}
390395

391-
// If noJava is set or we already have java downloaded, we skip the java download
396+
// If noJava is set, or we already have java downloaded, we skip the java download
392397
if !noJava && !auto && !jreAlreadyExists {
393398
noJava = !util.ConfirmYN("Do you want to download java?", true, pterm.Info.MessageStyle)
394399
}
@@ -430,7 +435,7 @@ func main() {
430435
}
431436
}
432437

433-
// Remove unchanged files from filesToDownload, we dont want to r edownload unchanged files
438+
// Remove unchanged files from filesToDownload, we don't want to re-download unchanged files
434439
for _, f := range unchangedFiles {
435440
for i, v := range filesToDownload {
436441
if v.Name == f.Name && v.Path == f.Path {
@@ -480,7 +485,7 @@ func main() {
480485
selectedProvider.FailedInstall()
481486
pterm.Fatal.Println("Error extracting java archive:", err.Error())
482487
}
483-
javaFile.Close()
488+
_ = javaFile.Close()
484489
err = os.Remove(filepath.Join(installDir, java.Name))
485490
if err != nil {
486491
pterm.Warning.Println("Error removing java archive:", err.Error())
@@ -638,6 +643,9 @@ func doDownload(file structs.File) error {
638643
continue
639644
}
640645
}
646+
if dl == nil {
647+
return errors.New(fmt.Sprintf("download object is nil for file %s", file.Name))
648+
}
641649
if file.Hash != "" {
642650
hexHash, _ := hex.DecodeString(file.Hash)
643651
switch file.HashType {

modloaders/fabric.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import (
55
"fmt"
66
"ftb-server-downloader/structs"
77
"ftb-server-downloader/util"
8-
"github.com/pterm/pterm"
98
"os"
109
"os/exec"
1110
"path/filepath"
1211
"runtime"
12+
13+
"github.com/pterm/pterm"
1314
)
1415

1516
const fabricMeta = "https://meta.fabricmc.net"

modloaders/forge.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func (s Forge) Install(useOwnJava bool) error {
113113
return err
114114
}
115115
if pathExists {
116-
os.Remove(filepath.Join(s.InstallDir, fmt.Sprintf("minecraft_server.%s.jar", s.Targets.McVersion)))
116+
_ = os.Remove(filepath.Join(s.InstallDir, fmt.Sprintf("minecraft_server.%s.jar", s.Targets.McVersion)))
117117
}
118118
vanilla, err := GetVanilla(s.Targets, s.InstallDir)
119119
if err != nil {
@@ -137,7 +137,7 @@ func (s Forge) Install(useOwnJava bool) error {
137137
if err != nil {
138138
return err
139139
}
140-
os.Remove(filepath.Join(s.InstallDir, jarName))
140+
_ = os.Remove(filepath.Join(s.InstallDir, jarName))
141141
}
142142

143143
err = s.startScript(useOwnJava)
@@ -149,10 +149,11 @@ func (s Forge) Install(useOwnJava bool) error {
149149
}
150150

151151
func doesForgeExist(url string) bool {
152-
_, err := util.DoHead(url)
152+
resp, err := util.DoHead(url)
153153
if err != nil {
154154
return false
155155
}
156+
defer resp.Body.Close()
156157
return true
157158
}
158159

@@ -239,7 +240,7 @@ func (s Forge) startScript(ownJava bool) error {
239240
lines = append(lines, line)
240241
}
241242

242-
file.Close()
243+
_ = file.Close()
243244

244245
// Rewrite the file with our changes
245246
file, _ = os.Create(runScriptPath)

modloaders/neoforge.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func (s NeoForge) startScript(ownJava bool) error {
190190
lines = append(lines, line)
191191
}
192192

193-
file.Close()
193+
_ = file.Close()
194194

195195
// Rewrite the file with our changes
196196
file, _ = os.Create(runScriptPath)

modloaders/util.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package modloaders
33
import (
44
"fmt"
55
"ftb-server-downloader/util"
6-
semVer "github.com/hashicorp/go-version"
7-
"github.com/pterm/pterm"
86
"io"
97
"os"
108
"path/filepath"
9+
10+
semVer "github.com/hashicorp/go-version"
11+
"github.com/pterm/pterm"
1112
)
1213

1314
func Log4JFixer(installDir string, mcVersion string) (string, error) {

modloaders/vanilla.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (v Vanilla) GetDownload() ([]structs.File, error) {
7474
return mlFiles, nil
7575
}
7676

77-
func (v Vanilla) Install(useOwnJava bool) error {
77+
func (v Vanilla) Install(bool) error {
7878
return nil
7979
}
8080

repos/curseforge.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package repos
22

33
import (
44
"ftb-server-downloader/structs"
5+
56
"github.com/pterm/pterm"
67
)
78

@@ -14,6 +15,7 @@ type CurseForge struct {
1415
VersionId int
1516
}
1617

18+
//goland:noinspection GoUnusedExportedFunction
1719
func GetCurseForge(packId, versionId int) *CurseForge {
1820
return &CurseForge{
1921
PackId: packId,
@@ -35,10 +37,10 @@ func (v *CurseForge) SetVersionId(versionId int) {
3537
v.VersionId = versionId
3638
}
3739

38-
func (m *CurseForge) SuccessfulInstall() {
40+
func (v *CurseForge) SuccessfulInstall() {
3941
return
4042
}
4143

42-
func (m *CurseForge) FailedInstall() {
44+
func (v *CurseForge) FailedInstall() {
4345
return
4446
}

0 commit comments

Comments
 (0)