packs

package
v0.0.0-...-b9cfb1f Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2019 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

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

PacketManagerBase is a struct that forms the base of every pack. It has functions for loading, validating and pack data.

func (*Base) GetChunk

func (pack *Base) GetChunk(offset int, length int) []byte

GetChunk returns a chunk of the pack at the given offset with the given length.

func (*Base) GetContent

func (pack *Base) GetContent() []byte

GetContent returns the full byte array of the data of the pack.

func (*Base) GetFileSize

func (pack *Base) GetFileSize() int64

GetFileSize returns the file size of the pack.

func (*Base) GetManifest

func (pack *Base) GetManifest() *Manifest

GetManifest returns the manifest of the pack.

func (*Base) GetPath

func (pack *Base) GetPath() string

GetPath returns the path of the pack.

func (*Base) GetSha256

func (pack *Base) GetSha256() string

GetSha256 returns the Sha256 checksum of the pack.

func (*Base) GetUUID

func (pack *Base) GetUUID() string

GetUUID returns the UUID of the pack.

func (*Base) GetVersion

func (pack *Base) GetVersion() string

GetVersion returns the version string of the pack.

func (*Base) Load

func (pack *Base) Load() error

Load loads the pack, and returns an error if any.

func (*Base) ValidateManifest

func (pack *Base) ValidateManifest() error

ValidateManifest validates the manifest, and returns an error if any.

func (*Base) ValidateModules

func (pack *Base) ValidateModules() error

ValidateModules validates the modules of the pack, and returns an error if any.

type BehaviorPack

type BehaviorPack struct {
	*Base
}

BehaviorPack is a pack used to modify the behavior of entities.

func NewBehaviorPack

func NewBehaviorPack(path string) *BehaviorPack

NewBehaviorPack returns a new behavior pack at the given path.

func (*BehaviorPack) ValidateDependencies

func (pack *BehaviorPack) ValidateDependencies(manager *Manager) error

ValidateDependencies validates all dependencies of the behavior pack, and returns an error if any.

type Manager

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

Manager manages the loading of packs. It provides helper functions for both types of packs.

func NewManager

func NewManager(serverPath string) *Manager

NewManager returns a new pack manager with the given path.

func (*Manager) GetBehaviorPack

func (manager *Manager) GetBehaviorPack(uuid string) *BehaviorPack

GetBehaviorPack returns a behavior pack by its UUID, or nil if none was found.

func (*Manager) GetBehaviorPacks

func (manager *Manager) GetBehaviorPacks() map[string]*BehaviorPack

GetBehaviorPacks returns all behavior packs in a UUID => pack map.

func (*Manager) GetBehaviorStack

func (manager *Manager) GetBehaviorStack() *Stack

GetBehaviorStack returns the behavior pack stack.

func (*Manager) GetPack

func (manager *Manager) GetPack(uuid string) Pack

GetPack returns any pack that has the given UUID, or nil if none was found.

func (*Manager) GetResourcePack

func (manager *Manager) GetResourcePack(uuid string) *ResourcePack

GetResourcePack returns a resource pack by its UUID, or nil of none was found.

func (*Manager) GetResourcePacks

func (manager *Manager) GetResourcePacks() map[string]*ResourcePack

GetResourcePacks returns all resource maps in a UUID => pack map.

func (*Manager) GetResourceStack

func (manager *Manager) GetResourceStack() *Stack

GetResourceStack returns the resource pack stack.

func (*Manager) IsBehaviorPackLoaded

func (manager *Manager) IsBehaviorPackLoaded(uuid string) bool

IsBehaviorPackLoaded checks if a behavior pack with the given UUID is loaded.

func (*Manager) IsPackLoaded

func (manager *Manager) IsPackLoaded(uuid string) bool

IsPackLoaded checks if any pack with the given UUID is loaded.

func (*Manager) IsResourcePackLoaded

func (manager *Manager) IsResourcePackLoaded(uuid string) bool

IsResourcePackLoaded checks if a resource pack with the given UUID is loaded.

func (*Manager) LoadBehaviorPacks

func (manager *Manager) LoadBehaviorPacks() []error

LoadBehaviorPacks loads all behavior packs in the `serverPath/extensions/behavior_packs/` folder. It returns an array of errors that occurred during the loading of all behavior packs.

func (*Manager) LoadResourcePacks

func (manager *Manager) LoadResourcePacks() []error

LoadResourcePacks loads all resource packs in the `serverPath/extensions/resource_packs/` folder. It returns an array of errors that occurred during the loading of all resource packs.

type Manifest

type Manifest struct {
	Header struct {
		Description   string    `json:"description"`
		Name          string    `json:"name"`
		UUID          string    `json:"uuid"`
		Version       []float64 `json:"version"`
		VersionString string
	} `json:"header"`
	Modules []struct {
		Description string    `json:"description"`
		Type        string    `json:"type"`
		UUID        string    `json:"uuid"`
		Version     []float64 `json:"version"`
	} `json:"modules"`
	Dependencies []struct {
		Description string    `json:"description"`
		Type        string    `json:"type"`
		UUID        string    `json:"uuid"`
		Version     []float64 `json:"version"`
	} `json:"dependencies"`
}

Manifest is a struct that contains all information of a pack.

type Pack

type Pack interface {
	GetUUID() string
	GetVersion() string
	GetFileSize() int64
	GetSha256() string
	GetChunk(offset int, length int) []byte
	GetPath() string
}

Pack is the main interface which both Resource- and BehaviorPack satisfy.

type PackType

type PackType string

PackType is a name of a pack type.

const (
	Behavior PackType = "data"
	Resource PackType = "resources"
)

type ResourcePack

type ResourcePack struct {
	*Base
}

ResourcePack is a pack that modifies the visual side of game play.

func NewResourcePack

func NewResourcePack(path string) *ResourcePack

NewResourcePack returns a new resource pack with the given path.

type Stack

type Stack []Pack

Stack is a struct that allows ordering the stack of packs.

func NewStack

func NewStack() *Stack

NewStack returns a new pack stack.

func (*Stack) GetPackAtOffset

func (stack *Stack) GetPackAtOffset(offset int) Pack

GetPackAtOffset returns the pack at the given offset on the stack.

func (*Stack) Len

func (stack *Stack) Len() int

Len returns the length of the stack.

func (*Stack) Peek

func (stack *Stack) Peek() Pack

Peek returns the top pack of the stack.

func (*Stack) Pop

func (stack *Stack) Pop()

Pop removes the pack on top of the stack.

func (*Stack) Push

func (stack *Stack) Push(pack Pack)

Push adds the given pack on top of the stack.

func (*Stack) Swap

func (stack *Stack) Swap(offset1, offset2 int)

Swap swaps the packs at the given offsets with each other.

Jump to

Keyboard shortcuts

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