Documentation
¶
Index ¶
- type Base
- func (pack *Base) GetChunk(offset int, length int) []byte
- func (pack *Base) GetContent() []byte
- func (pack *Base) GetFileSize() int64
- func (pack *Base) GetManifest() *Manifest
- func (pack *Base) GetPath() string
- func (pack *Base) GetSha256() string
- func (pack *Base) GetUUID() string
- func (pack *Base) GetVersion() string
- func (pack *Base) Load() error
- func (pack *Base) ValidateManifest() error
- func (pack *Base) ValidateModules() error
- type BehaviorPack
- type Manager
- func (manager *Manager) GetBehaviorPack(uuid string) *BehaviorPack
- func (manager *Manager) GetBehaviorPacks() map[string]*BehaviorPack
- func (manager *Manager) GetBehaviorStack() *Stack
- func (manager *Manager) GetPack(uuid string) Pack
- func (manager *Manager) GetResourcePack(uuid string) *ResourcePack
- func (manager *Manager) GetResourcePacks() map[string]*ResourcePack
- func (manager *Manager) GetResourceStack() *Stack
- func (manager *Manager) IsBehaviorPackLoaded(uuid string) bool
- func (manager *Manager) IsPackLoaded(uuid string) bool
- func (manager *Manager) IsResourcePackLoaded(uuid string) bool
- func (manager *Manager) LoadBehaviorPacks() []error
- func (manager *Manager) LoadResourcePacks() []error
- type Manifest
- type Pack
- type PackType
- type ResourcePack
- type Stack
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 ¶
GetChunk returns a chunk of the pack at the given offset with the given length.
func (*Base) GetContent ¶
GetContent returns the full byte array of the data of the pack.
func (*Base) GetFileSize ¶
GetFileSize returns the file size of the pack.
func (*Base) GetManifest ¶
GetManifest returns the manifest of the pack.
func (*Base) GetVersion ¶
GetVersion returns the version string of the pack.
func (*Base) ValidateManifest ¶
ValidateManifest validates the manifest, and returns an error if any.
func (*Base) ValidateModules ¶
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 ¶
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 ¶
GetBehaviorStack returns the behavior pack stack.
func (*Manager) GetPack ¶
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 ¶
GetResourceStack returns the resource pack stack.
func (*Manager) IsBehaviorPackLoaded ¶
IsBehaviorPackLoaded checks if a behavior pack with the given UUID is loaded.
func (*Manager) IsPackLoaded ¶
IsPackLoaded checks if any pack with the given UUID is loaded.
func (*Manager) IsResourcePackLoaded ¶
IsResourcePackLoaded checks if a resource pack with the given UUID is loaded.
func (*Manager) LoadBehaviorPacks ¶
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 ¶
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 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.