Documentation
¶
Index ¶
- Constants
- Variables
- func AddUpdater(updater Updater)
- func ComponentToFriendlyName(component string) string
- func FetchMavenVersionFiltered(url string, friendlyName string, ...) func(mcVersion string) ([]string, string, error)
- func FetchMavenVersionList(url string) func(mcVersion string) ([]string, string, error)
- func FetchMavenVersionPrefixedList(url string, friendlyName string) func(mcVersion string) ([]string, string, error)
- func FetchMavenVersionPrefixedListStrip(url string, friendlyName string) func(mcVersion string) ([]string, string, error)
- func FetchMavenWithNeoForgeStyleVersions(url string, friendlyName string) func(mcVersion string) ([]string, string, error)
- func FetchNeoForge() func(mcVersion string) ([]string, string, error)
- func GetForgeRecommended(mcVersion string) string
- func GetWithUA(url string, contentType string) (resp *http.Response, err error)
- func HighestSliceIndex(slice []string, values []string) int
- func ReEncodeURL(u string) (string, error)
- func SlugifyName(name string) string
- func SortAndDedupeVersions(versions []string)
- func UpdateAllMods(pack Pack) error
- func UpdateSingleMod(pack Pack, mod *Mod) error
- func ValidatePack(pack *PackToml) error
- type ForgeRecommended
- type HashStringer
- type HashableObject
- type IndexFS
- func (in *IndexFS) FindMod(modName string) (string, bool)
- func (in *IndexFS) GetAllMods() []string
- func (in *IndexFS) GetFilePath() string
- func (in *IndexFS) GetHash() string
- func (in *IndexFS) GetHashFormat() string
- func (in *IndexFS) GetPackRoot() string
- func (in *IndexFS) RelIndexPath(p string) (string, error)
- func (in *IndexFS) RemoveFile(path string) error
- func (in *IndexFS) ResolveIndexPath(p string) string
- func (in *IndexFS) ToWritable() IndexTomlRepresentation
- func (in *IndexFS) UpdateFileHashGiven(path, format, hash string, markAsMetaFile bool) error
- type IndexFile
- type IndexFiles
- type IndexFilesTomlRepresentation
- type IndexPathHolder
- type IndexTomlRepresentation
- func (it *IndexTomlRepresentation) GetFilePath() string
- func (it *IndexTomlRepresentation) GetHashFormat() string
- func (it *IndexTomlRepresentation) Marshal() (MarshalResult, error)
- func (it *IndexTomlRepresentation) SetFilePath(path string)
- func (it *IndexTomlRepresentation) UpdateHash(format, hash string)
- type LengthHasher
- type LoaderInfo
- type ManualDownload
- type MarshalResult
- type MavenMetadata
- type MetaDownloader
- type MetaDownloaderData
- type Mod
- type ModDownload
- type ModLoaderComponent
- type ModOption
- type ModSide
- type ModSourceData
- type ModToml
- func (m *ModToml) AppendUpdateData(key string, value interface{})
- func (m *ModToml) GetDestFilePath() string
- func (m *ModToml) GetFilePath() string
- func (m *ModToml) GetHashFormat() string
- func (m *ModToml) GetHashInfo() (string, string)
- func (m *ModToml) GetMetaFolder() string
- func (m *ModToml) GetMetaRelativePath() string
- func (m *ModToml) GetParsedUpdateData(updaterName string) (interface{}, bool)
- func (m *ModToml) GetSlug() string
- func (m *ModToml) GetUpdater() (Updater, error)
- func (m *ModToml) IsMetaFile() bool
- func (m *ModToml) Marshal() (MarshalResult, error)
- func (m *ModToml) ReflectUpdateData() error
- func (m *ModToml) SetMetaFolder(value string)
- func (m *ModToml) SetMetaPath(metaFile string) string
- func (m *ModToml) SetSlug(value string)
- func (m *ModToml) UpdateHash(_ string, hash string)
- type ModUpdate
- type Pack
- func (p *Pack) AsIndexMeta() (IndexFS, error)
- func (p *Pack) AsIndexToml() (string, string, error)
- func (p *Pack) AsModToml(modSlug string) (string, error)
- func (p *Pack) AsPackToml() (string, error)
- func (p *Pack) GetAcceptableGameVersions() []string
- func (p *Pack) GetCompatibleLoaders() (loaders []string)
- func (p *Pack) GetExportName() string
- func (p *Pack) GetMCVersion() (string, error)
- func (p *Pack) GetModsList() []*Mod
- func (p *Pack) GetSupportedMCVersions() ([]string, error)
- func (p *Pack) SetAcceptableGameVersions(versions []string)
- func (p *Pack) SetMod(mod *Mod)
- func (p *Pack) ToPackMeta() (PackToml, error)
- func (p *Pack) Update(modSlug string) error
- func (p *Pack) UpdateAll() error
- type PackToml
- func (pack *PackToml) GetAcceptableGameVersions() []string
- func (pack *PackToml) GetCompatibleLoaders() (loaders []string)
- func (pack *PackToml) GetFilePath() string
- func (pack *PackToml) GetLoaders() (loaders []string)
- func (pack *PackToml) GetMCVersion() (string, error)
- func (pack *PackToml) GetPackDir() string
- func (pack *PackToml) GetPackName() string
- func (pack *PackToml) GetSupportedMCVersions() ([]string, error)
- func (pack *PackToml) Marshal() (MarshalResult, error)
- func (pack *PackToml) RefreshIndexHash(index IndexFS)
- func (pack *PackToml) SetAcceptableGameVersions(versions []string)
- func (pack *PackToml) SetFilePath(path string)
- func (pack *PackToml) UpdateHash(_, _ string)
- type PackTomlIndex
- type UpdateCheck
- type UpdateData
- type UpdateDataList
- type UpdateSourceMap
- type Updater
Constants ¶
const ( ModeURL string = "url" ModeCF string = "metadata:curseforge" )
const CurrentPackFormat = "packwiz:1.1.0"
const MetaExtension = ".pw.toml"
MetaExtension is the file extension of the mod metadata files Note that this is currently not required; it will only be used for new files.
const MetaExtensionOld = ".toml"
const UserAgent = "packwiz/packwiz"
Variables ¶
var MetaDownloaders = make(map[string]MetaDownloader)
MetaDownloaders stores all the metadata-based installers that packwiz can use. Add your own downloaders to this map, keyed by the source name.
var ModLoaders = map[string]ModLoaderComponent{ "fabric": { Name: "fabric", FriendlyName: "Fabric loader", VersionListGetter: FetchMavenVersionList("https://maven.fabricmc.net/net/fabricmc/fabric-loader/maven-metadata.xml"), }, "forge": { Name: "forge", FriendlyName: "Forge", VersionListGetter: FetchMavenVersionPrefixedListStrip("https://files.minecraftforge.net/maven/net/minecraftforge/forge/maven-metadata.xml", "Forge"), }, "liteloader": { Name: "liteloader", FriendlyName: "LiteLoader", VersionListGetter: FetchMavenVersionPrefixedList("https://repo.mumfrey.com/content/repositories/snapshots/com/mumfrey/liteloader/maven-metadata.xml", "LiteLoader"), }, "quilt": { Name: "quilt", FriendlyName: "Quilt loader", VersionListGetter: FetchMavenVersionList("https://maven.quiltmc.org/repository/release/org/quiltmc/quilt-loader/maven-metadata.xml"), }, "neoforge": { Name: "neoforge", FriendlyName: "NeoForge", VersionListGetter: FetchNeoForge(), }, }
var PackFormatConstraintAccepted = mustParseConstraint("~1")
var PackFormatConstraintSuggestUpgrade = mustParseConstraint("~1.1")
var PreferredHashList = []string{
"murmur2",
"md5",
"sha1",
"sha256",
"sha512",
}
Functions ¶
func AddUpdater ¶
func AddUpdater(updater Updater)
func ComponentToFriendlyName ¶
func FetchMavenVersionList ¶
func GetForgeRecommended ¶
GetForgeRecommended gets the recommended version of Forge for the given Minecraft version
func HighestSliceIndex ¶
HighestSliceIndex returns the highest index of the given values in the slice (-1 if no value is found in the slice)
func ReEncodeURL ¶
ReEncodeURL re-encodes URLs for RFC3986 compliance; as CurseForge URLs aren't properly encoded
func SlugifyName ¶
func SortAndDedupeVersions ¶
func SortAndDedupeVersions(versions []string)
func UpdateAllMods ¶
func UpdateSingleMod ¶
func ValidatePack ¶
ValidatePack run some basic validation and migrate the pack if possible.
Types ¶
type ForgeRecommended ¶
type HashStringer ¶
func GetHashImpl ¶
func GetHashImpl(hashType string) (HashStringer, error)
GetHashImpl gets an implementation of hash.Hash for the given hash type string
type HashableObject ¶
type HashableObject interface {
Marshal() (MarshalResult, error)
}
type IndexFS ¶
type IndexFS struct { DefaultModHashFormat string Files IndexFiles // contains filtered or unexported fields }
IndexFS is a representation of the index.toml file for referencing all the files in a pack.
func NewIndexFromTomlRepr ¶
func NewIndexFromTomlRepr(rep IndexTomlRepresentation) IndexFS
func (*IndexFS) FindMod ¶
FindMod finds a mod in the index and returns its path and whether it has been found
func (*IndexFS) GetAllMods ¶
GetAllMods finds paths to every metadata file (ModToml) in the index
func (*IndexFS) GetFilePath ¶
func (*IndexFS) GetHashFormat ¶
func (*IndexFS) GetPackRoot ¶
func (*IndexFS) RelIndexPath ¶
RelIndexPath turns a file path on disk into a path from the index
func (*IndexFS) RemoveFile ¶
RemoveFile removes a file from the index, given a file path
func (*IndexFS) ResolveIndexPath ¶
ResolveIndexPath turns a path from the index into a file path on disk
func (*IndexFS) ToWritable ¶
func (in *IndexFS) ToWritable() IndexTomlRepresentation
type IndexFile ¶
type IndexFile struct { // Files are stored in forward-slash format relative to the index file File string `toml:"file"` Hash string `toml:"hash,omitempty"` HashFormat string `toml:"hash-format,omitempty"` Alias string `toml:"alias,omitempty"` MetaFile bool `toml:"metafile,omitempty"` // True when it is a .toml metadata file Preserve bool `toml:"preserve,omitempty"` // Don't overwrite the file when updating // contains filtered or unexported fields }
IndexFile is a file in the index
func (*IndexFile) IsMetaFile ¶
func (*IndexFile) MarkedFound ¶
type IndexFiles ¶
type IndexFiles map[string]IndexPathHolder
IndexFiles are stored as a map of path -> (indexFile or alias -> indexFile) The latter is used for multiple copies with the same path but different alias
type IndexFilesTomlRepresentation ¶
type IndexFilesTomlRepresentation []IndexFile
type IndexPathHolder ¶
type IndexTomlRepresentation ¶
type IndexTomlRepresentation struct { DefaultModHashFormat string `toml:"hash-format"` Files IndexFilesTomlRepresentation `toml:"files"` // contains filtered or unexported fields }
IndexTomlRepresentation is the TOML representation of IndexFS (Files must be converted)
func (*IndexTomlRepresentation) GetFilePath ¶
func (it *IndexTomlRepresentation) GetFilePath() string
func (*IndexTomlRepresentation) GetHashFormat ¶
func (it *IndexTomlRepresentation) GetHashFormat() string
func (*IndexTomlRepresentation) Marshal ¶
func (it *IndexTomlRepresentation) Marshal() (MarshalResult, error)
func (*IndexTomlRepresentation) SetFilePath ¶
func (it *IndexTomlRepresentation) SetFilePath(path string)
func (*IndexTomlRepresentation) UpdateHash ¶
func (it *IndexTomlRepresentation) UpdateHash(format, hash string)
type LengthHasher ¶
type LengthHasher struct {
// contains filtered or unexported fields
}
func (*LengthHasher) BlockSize ¶
func (h *LengthHasher) BlockSize() int
func (*LengthHasher) Reset ¶
func (h *LengthHasher) Reset()
func (*LengthHasher) Size ¶
func (h *LengthHasher) Size() int
func (*LengthHasher) Sum ¶
func (h *LengthHasher) Sum(b []byte) []byte
type LoaderInfo ¶
type ManualDownload ¶
type MarshalResult ¶
func (MarshalResult) String ¶
func (m MarshalResult) String() string
type MavenMetadata ¶
type MavenMetadata struct { XMLName xml.Name `xml:"metadata"` GroupID string `xml:"groupId"` ArtifactID string `xml:"artifactId"` Versioning struct { Release string `xml:"release"` Latest string `xml:"latest"` Versions struct { Version []string `xml:"version"` } `xml:"versions"` LastUpdated string `xml:"lastUpdated"` } `xml:"versioning"` }
type MetaDownloader ¶
type MetaDownloader interface {
GetFilesMetadata([]*Mod) ([]MetaDownloaderData, error)
}
MetaDownloader specifies a downloader for a Mod using a "metadata:source" mode The calling code should handle caching and hash validation.
type MetaDownloaderData ¶
type MetaDownloaderData interface { GetManualDownload() (bool, ManualDownload) DownloadFile() (io.ReadCloser, error) }
MetaDownloaderData specifies the per-ModToml metadata retrieved for downloading
type Mod ¶
type Mod struct { Name string FileName string Side ModSide Pin bool Download ModDownload Update ModUpdate Option *ModOption // for index Slug string ModType string // mods, shaders, resourcepacks, etc. HashFormat string Alias string Preserve bool }
func FromModMeta ¶
func (*Mod) DecodeNamedModSourceData ¶
func (*Mod) GetRelDownloadPath ¶
func (*Mod) GetRelMetaPath ¶
func (*Mod) GetUpdater ¶
type ModDownload ¶
type ModDownload struct { URL string `toml:"url,omitempty"` HashFormat string `toml:"hash-format"` Hash string `toml:"hash"` // Mode defaults to modeURL (i.e. use URL when omitted or empty) Mode string `toml:"mode,omitempty"` }
ModDownload specifies how to download the mod file
type ModLoaderComponent ¶
type ModOption ¶
type ModOption struct { Optional bool `toml:"optional"` Description string `toml:"description,omitempty"` Default bool `toml:"default,omitempty"` }
ModOption specifies optional metadata for this mod file
type ModSourceData ¶
type ModSourceData map[string]interface{}
type ModToml ¶
type ModToml struct { Name string `toml:"name"` FileName string `toml:"filename"` Side ModSide `toml:"side,omitempty"` Pin bool `toml:"pin,omitempty"` Download ModDownload `toml:"download"` // Update is a map of maps, of stuff, so you can store arbitrary values on // string keys to define updating Update ModUpdate `toml:"update"` Option *ModOption `toml:"option,omitempty"` // contains filtered or unexported fields }
ModToml stores metadata about a mod. This is written to a TOML file for each mod.
func (*ModToml) AppendUpdateData ¶
func (*ModToml) GetDestFilePath ¶
GetDestFilePath returns the path of the destination file of the mod
func (*ModToml) GetFilePath ¶
GetFilePath is a clumsy hack that I made because ModToml already stores it's path anyway
func (*ModToml) GetHashFormat ¶
func (*ModToml) GetHashInfo ¶
func (*ModToml) GetMetaFolder ¶
func (*ModToml) GetMetaRelativePath ¶
func (*ModToml) GetParsedUpdateData ¶
GetParsedUpdateData can be used to retrieve updater-specific information after parsing a mod file
func (*ModToml) GetUpdater ¶
func (*ModToml) IsMetaFile ¶
func (*ModToml) Marshal ¶
func (m *ModToml) Marshal() (MarshalResult, error)
func (*ModToml) ReflectUpdateData ¶
func (*ModToml) SetMetaFolder ¶
func (*ModToml) SetMetaPath ¶
SetMetaPath sets the file path of a metadata file
func (*ModToml) UpdateHash ¶
UpdateHash updates the hash of a mod file, used with ModWriter
type ModUpdate ¶
type ModUpdate map[string]ModSourceData
type Pack ¶
type Pack struct { Name string Author string Version string Description string PackFormat string Versions map[string]string Export map[string]map[string]interface{} Options map[string]interface{} Mods map[string]*Mod }
func FromPackAndModsMeta ¶
func (*Pack) AsIndexMeta ¶
func (*Pack) AsPackToml ¶
func (*Pack) GetAcceptableGameVersions ¶
func (*Pack) GetCompatibleLoaders ¶
func (*Pack) GetExportName ¶
func (*Pack) GetMCVersion ¶
GetMCVersion gets the version of Minecraft this pack uses, if it has been correctly specified
func (*Pack) GetModsList ¶
func (*Pack) GetSupportedMCVersions ¶
GetSupportedMCVersions gets the versions of Minecraft this pack allows in downloaded mods, ordered by preference (highest = most desirable)
func (*Pack) SetAcceptableGameVersions ¶
func (*Pack) ToPackMeta ¶
type PackToml ¶
type PackToml struct { Name string `toml:"name"` Author string `toml:"author,omitempty"` Version string `toml:"version,omitempty"` Description string `toml:"description,omitempty"` PackFormat string `toml:"pack-format"` Index PackTomlIndex `toml:"index"` Versions map[string]string `toml:"versions"` Export map[string]map[string]interface{} `toml:"export"` Options map[string]interface{} `toml:"options"` // contains filtered or unexported fields }
PackToml stores the modpack metadata, usually in pack.toml
func CreatePackToml ¶
func (*PackToml) GetAcceptableGameVersions ¶
func (*PackToml) GetCompatibleLoaders ¶
func (*PackToml) GetFilePath ¶
func (*PackToml) GetLoaders ¶
func (*PackToml) GetMCVersion ¶
GetMCVersion gets the version of Minecraft this pack uses, if it has been correctly specified
func (*PackToml) GetPackDir ¶
func (*PackToml) GetPackName ¶
func (*PackToml) GetSupportedMCVersions ¶
GetSupportedMCVersions gets the versions of Minecraft this pack allows in downloaded mods, ordered by preference (highest = most desirable)
func (*PackToml) Marshal ¶
func (pack *PackToml) Marshal() (MarshalResult, error)
func (*PackToml) RefreshIndexHash ¶
func (*PackToml) SetAcceptableGameVersions ¶
func (*PackToml) SetFilePath ¶
func (*PackToml) UpdateHash ¶
type PackTomlIndex ¶
type UpdateCheck ¶
type UpdateCheck struct { // UpdateAvailable is true if an update is available for this mod UpdateAvailable bool // UpdateString is a string that details the update in some way to the user. Usually this will be in the form of // a version change (1.0.0 -> 1.0.1), or a file name change (thanos-skin-1.0.0.jar -> thanos-skin-1.0.1.jar). UpdateString string // CachedState can be used to preserve per-mod state between CheckUpdate and DoUpdate (e.g. file metadata) CachedState interface{} // Error stores an error for this specific mod // Errors can also be returned from CheckUpdate directly, if the whole operation failed completely (so only 1 error is printed) // If an error is returned for a mod, or from CheckUpdate, DoUpdate is not called on that mod / at all Error error }
UpdateCheck represents the data returned from CheckUpdate for each mod
type UpdateData ¶
type UpdateData struct { Mods []*Mod CachedState []interface{} }
type UpdateDataList ¶
type UpdateDataList map[string]UpdateData
func GetUpdatableMods ¶
func GetUpdatableMods(pack Pack) (UpdateDataList, error)
func (UpdateDataList) Append ¶
func (ud UpdateDataList) Append(source string, mod *Mod, cachedState interface{})
type UpdateSourceMap ¶
named update source to mod list
func BuildUpdateMap ¶
func BuildUpdateMap(mods []*Mod) UpdateSourceMap
type Updater ¶
type Updater interface { GetName() string // ParseUpdate takes an unparsed interface{} (as a map[string]interface{}), and returns an Updater for a mod file. // This can be done using the mapstructure library or your own parsing methods. ParseUpdate(map[string]interface{}) (interface{}, error) // CheckUpdate checks whether there is an update for each of the mods in the given slice, // called for all of the mods that this updater handles CheckUpdate([]*Mod, Pack) ([]UpdateCheck, error) // DoUpdate carries out the update previously queried in CheckUpdate, on each ModToml's metadata, // given pointers to Mods and the value of CachedState for each mod DoUpdate([]*Mod, []interface{}) error }
Updater is used to process updates on mods