llgutils

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: BSD-3-Clause Imports: 14 Imported by: 1

README

llgutils

Pretty much a library for creating a launcher for Lunar Client in Go.

Installation

run

go get github.com/KotonBads/llgutils@latest

then

go mod tidy

Example

package main

import (
	utils "github.com/KotonBads/llgutils"
)

func main() {
	launchbody := utils.LaunchBody{
		OS:      "linux",
		Arch:    "x64",
		Version: "1.8.9",
		Module:  "forge",
	}
	launchmeta, _ := utils.FetchLaunchMeta(launchbody)
	launchmeta.DownloadArtifacts("temp")
	launchmeta.DownloadCosmetics("temp/textures")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckHash

func CheckHash(path string, hash string) bool

func DownloadFile

func DownloadFile(path string, url string) (err error)

func IfExists

func IfExists(path string) bool

func Unzip

func Unzip(src string, dest string) error

Types

type Artifacts

type Artifacts struct {
	Name string `json:"name"`
	Sha1 string `json:"sha1"`
	Url  string `json:"url"`
	Type string `json:"type"`
}

type LaunchBody

type LaunchBody struct {
	OS      string
	Version string
	Module  string
	Arch    string
}

func (LaunchBody) FetchLaunchMeta added in v1.4.0

func (launchdata LaunchBody) FetchLaunchMeta() (response LaunchMeta, err error)

Fetches Lunar's API.

Takes in a `LaunchBody` type.

Returns a `LaunchMeta` type.

type LaunchMeta

type LaunchMeta struct {
	Success        bool `json:"success"`
	LaunchTypeData struct {
		Artifacts []Artifacts `json:"artifacts"`
		MainClass string      `json:"mainClass"`
	} `json:"launchTypeData"`
	Licenses []struct {
		File string `json:"file"`
		URL  string `json:"url"`
		Sha1 string `json:"sha1"`
	} `json:"licenses"`
	Textures struct {
		IndexURL  string `json:"indexUrl"`
		IndexSha1 string `json:"indexSha1"`
		BaseURL   string `json:"baseUrl"`
	} `json:"textures"`
	Jre struct {
		Download struct {
			URL       string `json:"url"`
			Extension string `json:"extension"`
		} `json:"download"`
		ExecutablePathInArchive []string    `json:"executablePathInArchive"`
		CheckFiles              [][]string  `json:"checkFiles"`
		ExtraArguments          []string    `json:"extraArguments"`
		JavawDownload           interface{} `json:"javawDownload"`
		JavawExeChecksum        interface{} `json:"javawExeChecksum"`
		JavaExeChecksum         string      `json:"javaExeChecksum"`
	} `json:"jre"`
	Error struct {
		Issues []struct {
			Code     string   `json:"error"`
			Expected string   `json:"expected"`
			Received string   `json:"received"`
			Path     []string `json:"path"`
			Message  string   `json:"message"`
		} `json:"issues"`
	} `json:"error"`
}

func (LaunchMeta) DownloadArtifacts

func (data LaunchMeta) DownloadArtifacts(path string) (err error)

Downloads Lunar's artifacts from API.

Specify where to download artifacts with `path`.

func (LaunchMeta) DownloadCosmetics

func (data LaunchMeta) DownloadCosmetics(path string) (err error)

Downloads Lunar's cosmetics and various textures from API concurrently.

Specify where to download artifacts with `path`.

func (LaunchMeta) SortFiles

func (data LaunchMeta) SortFiles(path string) (classpath []string, ichorClassPath []string, external []string, natives []string)

Sorts Lunar's artifacts by TYPE.

Specify the path to Lunar's artifacts with `path`.

Returns []string: classpath, ichorClassPath, external, natives.

Jump to

Keyboard shortcuts

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