core

package
v1.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2024 License: MIT-0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Side_Client = Side("client")
	Side_Server = Side("server")
	Side_Both   = Side("both")

	DL_Url        = DLType("url")
	DL_Curseforge = DLType("curseforge")
)

Variables

View Source
var (
	DefaultCurseClient = NewCurseClient(getApiKey())
)
View Source
var PreferredHashList = []string{
	"murmur2",
	"md5",
	"sha1",
	"sha256",
	"sha512",
}

Functions

func MatchHash

func MatchHash(data []byte, hashFormat string, hash string) (bool, error)

Types

type CurseClient

type CurseClient struct {
	// contains filtered or unexported fields
}

func NewCurseClient

func NewCurseClient(apiKey string) *CurseClient

func (*CurseClient) GetDownloadUrl

func (c *CurseClient) GetDownloadUrl(ctx context.Context, d *CurseforgeData) (string, error)

type CurseforgeData added in v1.1.0

type CurseforgeData struct {
	ProjectID int `json:"projectId"`
	FileID    int `json:"fileId"`
}

func ParseCfData added in v1.1.0

func ParseCfData(s string) (*CurseforgeData, error)

func (*CurseforgeData) String added in v1.1.0

func (d *CurseforgeData) String() string

type DLType added in v1.1.0

type DLType string

type Download added in v1.1.0

type Download struct {
	Type DLType `json:"type"`
	Data string `json:"data"`
}

type IndexToml

type IndexToml struct {
	HashFormat string            `toml:"hash-format"`
	Files      []IndexedfileToml `toml:"files,omitempty"`
}

type IndexedfileToml

type IndexedfileToml struct {
	File       string `toml:"file"`
	Hash       string `toml:"hash"`
	Alias      string `toml:"alias,omitempty"`
	HashFormat string `toml:"hash-format,omitempty"`
	Metafile   bool   `toml:"metafile,omitempty"`
	Preserve   bool   `toml:"preserve,omitempty"`
}

type Installer added in v1.1.0

type Installer interface {
	Install() error
	GetUpdates() error
	InstallMod(m *Mod) (bool, error)
}

type LocalInstaller added in v1.1.0

type LocalInstaller struct {
	BaseDir string
	Pack    *Pack
	// contains filtered or unexported fields
}

func NewLocalInstaller added in v1.1.0

func NewLocalInstaller(p *Pack, dir string) (*LocalInstaller, error)

func (*LocalInstaller) GetUpdates added in v1.1.0

func (i *LocalInstaller) GetUpdates() (*Updates, error)

func (*LocalInstaller) Install added in v1.1.0

func (i *LocalInstaller) Install(ctx context.Context) (*Updates, error)

Install execute install and update modpack

func (*LocalInstaller) InstallMod added in v1.1.0

func (i *LocalInstaller) InstallMod(ctx context.Context, m *Mod) error

type MetafileDownload added in v1.1.0

type MetafileDownload struct {
	HashFormat string `toml:"hash-format"`
	Hash       string `toml:"hash"`
	Url        string `toml:"url,omitempty"`
	Mode       string `toml:"mode,omitempty"`
}

type MetafileOption added in v1.1.0

type MetafileOption struct {
	Optional    bool   `toml:"optional"`
	Default     bool   `toml:"default,omitempty"`
	Description string `toml:"description,omitempty"`
}

type MetafileToml

type MetafileToml struct {
	Filename  string            `toml:"filename"`
	Name      string            `toml:"name"`
	Side      string            `toml:"side,omitempty"`
	Download  *MetafileDownload `toml:"download"`
	Update    *MetafileUpdate   `toml:"update,omitempty"`
	Option    *MetafileOption   `toml:"option,omitempty"`
	IndexName string
}

type MetafileUpdate added in v1.1.0

type MetafileUpdate struct {
	Modrinth   *UpdateModrinth   `toml:"modrinth,omitempty,nullable"`
	CurseForge *UpdateCurseForge `toml:"curseforge,omitempty,nullable"`
}

type Mod

type Mod struct {
	Path       string    `json:"path"`
	Hash       string    `json:"hash"`
	HashFormat string    `json:"hashFormat"`
	Side       Side      `json:"side,omitempty"`
	Downloads  *Download `json:"download"`
}

type Pack added in v1.1.0

type Pack struct {
	Name    string `json:"name"`
	Author  string `json:"author,omitempty"`
	Version string `json:"version,omitempty"`
	Mods    []*Mod `json:"files,omitempty"`
}

func NewPack added in v1.1.0

func NewPack(r *Repository) (*Pack, error)

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       struct {
		File       string `toml:"file"`
		HashFormat string `toml:"hash-format"`
		Hash       string `toml:"hash"`
	} `toml:"index"`
	Versions map[string]string `toml:"versions"`
}

type RepoOptFn

type RepoOptFn func(r *Repository)

type Repository

type Repository struct {
	Url            *url.URL
	Pack           *PackToml
	Index          *IndexToml
	Metafiles      []*MetafileToml
	PackHashFormat string
	PackHash       string
	// contains filtered or unexported fields
}

func NewRepository

func NewRepository(url *url.URL, hashFormat, hash string) *Repository

func (*Repository) BaseUrl

func (r *Repository) BaseUrl() *url.URL

func (*Repository) IndexUrl

func (r *Repository) IndexUrl() *url.URL

func (*Repository) Load added in v1.1.0

func (r *Repository) Load(ctx context.Context) error

type Side added in v1.1.0

type Side string

type UpdateCurseForge added in v1.0.2

type UpdateCurseForge struct {
	FileId    int `toml:"file-id,omitempty"`
	ProjectId int `toml:"project-id,omitempty"`
}

type UpdateModrinth added in v1.0.2

type UpdateModrinth struct {
	ModId   string `toml:"mod-id,omitempty"`
	Version string `toml:"version,omitempty"`
}

type Updates added in v1.1.0

type Updates struct {
	Added     []*Mod
	Removed   []*Mod
	Unchanged []*Mod
}

func (*Updates) String added in v1.1.0

func (u *Updates) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL