Documentation ¶
Index ¶
- Constants
- Variables
- func ComponentToFriendlyName(component string) string
- 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 GetForgeRecommended(mcVersion string) string
- func GetPackwizCache() (string, error)
- func GetPackwizInstallBinFile() (string, error)
- func GetPackwizInstallBinPath() (string, error)
- func GetPackwizLocalCache() (string, error)
- func GetPackwizLocalStore() (string, error)
- 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
- type CacheIndex
- func (c *CacheIndex) GetHandleFromHash(hashFormat string, hash string) *CacheIndexHandle
- func (c *CacheIndex) GetHandleFromHashForce(hashFormat string, hash string) (*CacheIndexHandle, error)
- func (c *CacheIndex) MoveImportFiles() error
- func (c *CacheIndex) NewHandleFromHashes(hashes map[string]string) (*CacheIndexHandle, bool)
- type CacheIndexHandle
- func (h *CacheIndexHandle) CreateFromTemp(temp *os.File) (*os.File, error)
- func (h *CacheIndexHandle) GetRemainingHashes(hashesToObtain []string) []string
- func (h *CacheIndexHandle) Open() (*os.File, error)
- func (h *CacheIndexHandle) Path() string
- func (h *CacheIndexHandle) Remove()
- func (h *CacheIndexHandle) UpdateIndex() (warnings []error)
- type CompletedDownload
- type DownloadSession
- type ForgeRecommended
- type HashStringer
- type Index
- func (in Index) FindMod(modName string) (string, bool)
- func (in Index) LoadAllMods() ([]*Mod, error)
- func (in *Index) Refresh() error
- func (in *Index) RefreshFileWithHash(path, format, hash string, markAsMetaFile bool) error
- func (in Index) RelIndexPath(p string) (string, error)
- func (in *Index) RemoveFile(path string) error
- func (in Index) ResolveIndexPath(p string) string
- func (in Index) Write() error
- type IndexFiles
- type IndexPathHolder
- type LengthHasher
- type ManualDownload
- type MavenMetadata
- type MetaDownloader
- type MetaDownloaderData
- type Mod
- type ModDownload
- type ModLoaderComponent
- type ModOption
- type Pack
- func (pack Pack) GetCompatibleLoaders() (loaders []string)
- func (pack Pack) GetLoaders() (loaders []string)
- func (pack Pack) GetMCVersion() (string, error)
- func (pack Pack) GetPackName() string
- func (pack Pack) GetSupportedMCVersions() ([]string, error)
- func (pack Pack) LoadIndex() (Index, error)
- func (pack *Pack) UpdateIndexHash() error
- func (pack Pack) Write() error
- type UpdateCheck
- type Updater
Constants ¶
const ( ModeURL string = "url" ModeCF string = "metadata:curseforge" )
const ( ServerSide = "server" ClientSide = "client" UniversalSide = "both" EmptySide = "" )
The four possible values of Side (the side that the mod is on) are "server", "client", "both", and "" (equivalent to "both")
const CurrentPackFormat = "packwiz:1.1.0"
const DownloadCacheImportFolder = "import"
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: FetchMavenVersionPrefixedListStrip("https://maven.neoforged.net/releases/net/neoforged/forge/maven-metadata.xml", "NeoForge"), }, }
var PackFormatConstraintAccepted = mustParseConstraint("~1")
var PackFormatConstraintSuggestUpgrade = mustParseConstraint("~1.1")
var Updaters = make(map[string]Updater)
Updaters stores all the updaters that packwiz can use. Add your own update systems to this map, keyed by the configuration name.
Functions ¶
func ComponentToFriendlyName ¶
func FetchMavenVersionList ¶
func GetForgeRecommended ¶
GetForgeRecommended gets the recommended version of Forge for the given Minecraft version
func GetPackwizCache ¶
func GetPackwizLocalCache ¶
func GetPackwizLocalStore ¶
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 ¶
Types ¶
type CacheIndex ¶
type CacheIndex struct { Version uint32 Hashes map[string][]string // contains filtered or unexported fields }
func (*CacheIndex) GetHandleFromHash ¶
func (c *CacheIndex) GetHandleFromHash(hashFormat string, hash string) *CacheIndexHandle
func (*CacheIndex) GetHandleFromHashForce ¶
func (c *CacheIndex) GetHandleFromHashForce(hashFormat string, hash string) (*CacheIndexHandle, error)
GetHandleFromHashForce looks up the given hash in the index; but will rehash any file without this hash format to obtain the necessary hash. Only use this for manually downloaded files, as it can rehash every file in the cache, which can be more time-consuming than just redownloading the file and noticing it is already in the index!
func (*CacheIndex) MoveImportFiles ¶
func (c *CacheIndex) MoveImportFiles() error
func (*CacheIndex) NewHandleFromHashes ¶
func (c *CacheIndex) NewHandleFromHashes(hashes map[string]string) (*CacheIndexHandle, bool)
type CacheIndexHandle ¶
func (*CacheIndexHandle) CreateFromTemp ¶
func (*CacheIndexHandle) GetRemainingHashes ¶
func (h *CacheIndexHandle) GetRemainingHashes(hashesToObtain []string) []string
func (*CacheIndexHandle) Path ¶
func (h *CacheIndexHandle) Path() string
func (*CacheIndexHandle) Remove ¶
func (h *CacheIndexHandle) Remove()
func (*CacheIndexHandle) UpdateIndex ¶
func (h *CacheIndexHandle) UpdateIndex() (warnings []error)
type CompletedDownload ¶
type CompletedDownload struct { // File is only populated when the download is successful; points to the opened cache file File *os.File Mod *Mod // Hashes is only populated when the download is successful; contains all stored hashes of the file Hashes map[string]string // Error indicates if/why downloading this file failed Error error // Warnings indicates messages to show to the user regarding this file (download was successful, but had a problem) Warnings []error }
type DownloadSession ¶
type DownloadSession interface { GetManualDownloads() []ManualDownload StartDownloads() chan CompletedDownload SaveIndex() error }
func CreateDownloadSession ¶
func CreateDownloadSession(mods []*Mod, hashesToObtain []string) (DownloadSession, error)
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 Index ¶
type Index struct { HashFormat string Files IndexFiles // contains filtered or unexported fields }
Index is a representation of the index.toml file for referencing all the files in a pack.
func (Index) FindMod ¶
FindMod finds a mod in the index and returns its path and whether it has been found
func (Index) LoadAllMods ¶
LoadAllMods reads all metadata files into Mod structs
func (*Index) Refresh ¶
Refresh updates the hashes of all the files in the index, and adds new files to the index
func (*Index) RefreshFileWithHash ¶
RefreshFileWithHash updates a file in the index, given a file hash and whether it should be marked as metafile or not
func (Index) RelIndexPath ¶
RelIndexPath turns a file path on disk into a path from the index
func (*Index) RemoveFile ¶
RemoveFile removes a file from the index, given a file path
func (Index) ResolveIndexPath ¶
ResolveIndexPath turns a path from the index into a file path on disk
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 IndexPathHolder ¶
type IndexPathHolder interface { IsMetaFile() bool // contains filtered or unexported methods }
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 ManualDownload ¶
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-Mod metadata retrieved for downloading
type Mod ¶
type Mod struct { Name string `toml:"name"` FileName string `toml:"filename"` Side string `toml:"side,omitempty"` Pin bool `toml:"pin,omitempty"` Download ModDownload `toml:"download"` // Update is a map of map of stuff, so you can store arbitrary values on string keys to define updating Update map[string]map[string]interface{} `toml:"update"` Option *ModOption `toml:"option,omitempty"` // contains filtered or unexported fields }
Mod stores metadata about a mod. This is written to a TOML file for each mod.
func (Mod) GetDestFilePath ¶
GetDestFilePath returns the path of the destination file of the mod
func (Mod) GetFilePath ¶
GetFilePath is a clumsy hack that I made because Mod already stores it's path anyway
func (Mod) GetParsedUpdateData ¶
GetParsedUpdateData can be used to retrieve updater-specific information after parsing a mod file
func (*Mod) SetMetaPath ¶
SetMetaPath sets the file path of a metadata file
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 Pack ¶
type Pack 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 struct { // Path is stored in forward slash format relative to pack.toml File string `toml:"file"` HashFormat string `toml:"hash-format"` Hash string `toml:"hash,omitempty"` } `toml:"index"` Versions map[string]string `toml:"versions"` Export map[string]map[string]interface{} `toml:"export"` Options map[string]interface{} `toml:"options"` }
Pack stores the modpack metadata, usually in pack.toml
func (Pack) GetCompatibleLoaders ¶
func (Pack) GetLoaders ¶
func (Pack) GetMCVersion ¶
GetMCVersion gets the version of Minecraft this pack uses, if it has been correctly specified
func (Pack) GetPackName ¶
func (Pack) GetSupportedMCVersions ¶
GetSupportedMCVersions gets the versions of Minecraft this pack allows in downloaded mods, ordered by preference (highest = most desirable)
func (*Pack) UpdateIndexHash ¶
UpdateIndexHash recalculates the hash of the index file of this modpack
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 Updater ¶
type Updater interface { // 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 Mod'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