Skip to content
This repository has been archived by the owner on Jun 3, 2022. It is now read-only.

Commit

Permalink
feat: allow ignoring mods for server (unifies manifests)
Browse files Browse the repository at this point in the history
  • Loading branch information
ViRb3 committed Nov 22, 2020
1 parent fec3e8a commit 3f233d6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion cmd/manifest/lint/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func execute() error {
break
}
}
manifestFile.Metadata = curseforge.CornMetadata{
manifestFile.Metadata = curseforge.Metadata{
ProjectName: addon.Name,
FileName: fileName,
Summary: addon.Summary,
Expand Down
19 changes: 9 additions & 10 deletions curseforge/corn_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ type CornManifest struct {
}
type CornFile struct {
File
Metadata CornMetadata `json:"_metadata"`
Metadata Metadata `json:"_metadata"`
ServerIgnored bool `json:"_serverIgnored"`
}
type CornMetadata struct {
type Metadata struct {
ProjectName string `json:"projectName"`
FileName string `json:"fileName"`
Summary string `json:"summary"`
Expand All @@ -21,12 +22,10 @@ type ExtractConfig struct {
Unwrap bool `json:"unwrap"`
}
type ExternalFile struct {
Name string `json:"name"`
Url string `json:"url"`
// Can be a file path or directory path.
// In the case of a directory path, the file name will be inferred.
// See: grab.Request#Filename
InstallPath string `json:"installPath"`
Required bool `json:"required"`
Extract ExtractConfig `json:"extract"`
Name string `json:"name"`
Url string `json:"url"`
InstallPath string `json:"installPath"`
Required bool `json:"required"`
Extract ExtractConfig `json:"extract"`
ServerIgnored bool `json:"serverIgnored"`
}
24 changes: 17 additions & 7 deletions curseforge/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ func (i *ModpackInstaller) Install() error {
if err := json.Unmarshal(manifestBytes, &manifest); err != nil {
return e.S(err)
}
if i.TargetType != TargetServer {
if err := i.processOverrides(&manifest, i.DestPath); err != nil {
return e.S(err)
}
if err := i.processOverrides(&manifest, i.DestPath); err != nil {
return e.S(err)
}
if i.TargetType == TargetMultiMC {
if err := i.ensureInstanceConfig(&manifest, i.DestPath); err != nil {
Expand Down Expand Up @@ -165,8 +163,12 @@ func (i *ModpackInstaller) processMods(manifest *CornManifest, destPath string)
}

var source []interface{}
for i := range manifest.Files {
source = append(source, &manifest.Files[i])
for i2 := range manifest.Files {
file := &manifest.Files[i2]
if i.TargetType == TargetServer && file.ServerIgnored {
continue
}
source = append(source, file)
}

type OpResult struct {
Expand Down Expand Up @@ -210,6 +212,9 @@ func (i *ModpackInstaller) processMods(manifest *CornManifest, destPath string)
}

for _, file := range manifest.ExternalFiles {
if i.TargetType == TargetServer && file.ServerIgnored {
continue
}
var downloadPath string
if file.Extract.Enable {
tempFile, err := ioutil.TempFile(os.TempDir(), "cornstone")
Expand Down Expand Up @@ -336,7 +341,12 @@ func (i *ModpackInstaller) getForgeVersion(manifest *CornManifest) string {
func (i *ModpackInstaller) processOverrides(manifest *CornManifest, stagingPath string) error {
if manifest.Overrides != "" {
overridePath := util.SafeJoin(stagingPath, manifest.Overrides)
minecraftPath := filepath.Join(stagingPath, "minecraft")
var minecraftPath string
if i.TargetType == TargetServer {
minecraftPath = stagingPath
} else {
minecraftPath = filepath.Join(stagingPath, "minecraft")
}
if _, err := os.Stat(minecraftPath); err == nil {
return util.MergePaths(overridePath, minecraftPath)
} else if os.IsNotExist(err) {
Expand Down

0 comments on commit 3f233d6

Please sign in to comment.