chunkStorage

package
v0.0.0-...-8203687 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotImplemented = errors.New("not implemented")
	ErrAlreadyExists  = errors.New("already exists")
	ErrReadOnly       = errors.New("storage is read-only")
	ErrNoWorld        = errors.New("world not found")
	ErrNoDim          = errors.New("dimension not found")
)

Functions

func CloseStorages

func CloseStorages(storages map[string]Storage)

func ConvFlexibleNBTtoSave

func ConvFlexibleNBTtoSave(d []byte) (ret *save.Chunk, err error)

func CreateDefaultLevelData

func CreateDefaultLevelData(LevelName string) save.LevelData

func GetWorldStorage

func GetWorldStorage(storages map[string]Storage, wname string) (*SWorld, ChunkStorage, error)

func GuessDimTypeFromName

func GuessDimTypeFromName(dname string) save.DimensionType

Types

type ChunkData

type ChunkData struct {
	X, Z int
	Data interface{}
}

type ChunkStorage

type ChunkStorage interface {
	GetAbilities() StorageAbilities
	GetStatus() (string, error)
	GetChunksCount() (uint64, error)
	GetChunksSize() (uint64, error)

	ListWorlds() ([]SWorld, error)
	ListWorldNames() ([]string, error)
	GetWorld(wname string) (*SWorld, error)
	AddWorld(world SWorld) error
	SetWorldAlias(wname, newalias string) error
	SetWorldIP(wname, newip string) error
	SetWorldData(wname string, data save.LevelData) error

	ListWorldDimensions(wname string) ([]SDim, error)
	ListDimensions() ([]SDim, error)
	AddDimension(wname string, dim SDim) error
	GetDimension(wname, dname string) (*SDim, error)
	SetDimensionData(wname, dname string, data save.DimensionType) error
	GetDimensionChunksCount(wname, dname string) (uint64, error)
	GetDimensionChunksSize(wname, dname string) (uint64, error)

	AddChunk(wname, dname string, cx, cz int, col save.Chunk) error
	AddChunkRaw(wname, dname string, cx, cz int, dat []byte) error
	GetChunk(wname, dname string, cx, cz int) (*save.Chunk, error)
	GetChunkRaw(wname, dname string, cx, cz int) ([]byte, error)
	// Warning, chunk data array may be real big!
	GetChunksRegion(wname, dname string, cx0, cz0, cx1, cz1 int) ([]ChunkData, error)
	// Warning, chunk data array may be real big!
	GetChunksRegionRaw(wname, dname string, cx0, cz0, cx1, cz1 int) ([]ChunkData, error)
	// Warning, chunk data array may be real big!
	GetChunksCountRegion(wname, dname string, cx0, cz0, cx1, cz1 int) ([]ChunkData, error)

	GetChunkModDate(wname, dname string, cx, cz int) (*time.Time, error)

	Close() error
}

Everything returns empty slice/nil if specified object is not found, error only in case of abnormal things.

type SDim

type SDim struct {
	Name       string // unique per world
	World      string // name of the world
	CreatedAt  time.Time
	ModifiedAt time.Time
	Data       save.DimensionType
}

func ListDimensions

func ListDimensions(storages map[string]Storage, wname string) ([]SDim, error)

type SWorld

type SWorld struct {
	Name       string // unique
	Alias      string
	IP         string
	CreatedAt  time.Time
	ModifiedAt time.Time
	Data       save.LevelData
}

func ListWorlds

func ListWorlds(storages map[string]Storage) []SWorld

type Storage

type Storage struct {
	Type    string       `json:"type"`
	Address string       `json:"address"`
	Driver  ChunkStorage `json:"-"`
}

type StorageAbilities

type StorageAbilities struct {
	CanCreateWorldsDimensions   bool
	CanAddChunks                bool
	CanPreserveOldChunks        bool
	CanStoreUnlimitedDimensions bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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