save

package
v0.0.0-...-285b3f1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STATS_DIR        = "/stats"
	PLAYER_DIR       = "/playerdata"
	ADVANCEMENTS_DIR = "/advancements"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Advancement

type Advancement struct {
	Done bool `json:"done"`
}

type CustomStats

type CustomStats struct {
	Jump        int
	Deaths      int
	DamageTaken int
	DamageDealt int
	Playtime    int
	Walk        int
	Swim        int
	Sprint      int
	Dive        int
	Fall        int
	Fly         int
	Boat        int
	Horse       int
	Climb       int
	Sleep       int
	Crafted     int
	Custom      map[string]int
}

func (*CustomStats) UnmarshalJSON

func (s *CustomStats) UnmarshalJSON(data []byte) error

Implements Unmarshal, allows unknown stats to be saved in map

type ErrFailedToParseStat

type ErrFailedToParseStat struct {
	Name  string
	Value int
}

func NewErrFailedToParseStat

func NewErrFailedToParseStat(name string, value int) *ErrFailedToParseStat

func (*ErrFailedToParseStat) Error

func (e *ErrFailedToParseStat) Error() string

type ErrNoWorldDirectory

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

func NewErrNoWorldDirectory

func NewErrNoWorldDirectory(details string) *ErrNoWorldDirectory

func (*ErrNoWorldDirectory) Error

func (e *ErrNoWorldDirectory) Error() string

type MinecraftAdvancements

type MinecraftAdvancements struct {
	Advancements map[string]Advancement
}

func (*MinecraftAdvancements) UnmarshalJSON

func (a *MinecraftAdvancements) UnmarshalJSON(data []byte) error

Implements Unmarshal, allows to drop "DataVersion"

type MinecraftLevelDat

type MinecraftLevelDat struct {
	Data struct {
		Version        MinecraftVersion `nbt:"Version"`
		StorageVersion int              `nbt:"version"`
	} `nbt:"Data"`
}

type MinecraftPlayerData

type MinecraftPlayerData struct {
	XPTotal   int     `nbt:"XpTotal"`
	XPLevel   int     `nbt:"XpLevel"`
	Score     int     `nbt:"Score"`
	Health    float64 `nbt:"Health"`
	FoodLevel int     `nbt:"foodLevel"`
}

type MinecraftStats

type MinecraftStats struct {
	Stats Stats `json:"stats"`
}

type MinecraftVersion

type MinecraftVersion struct {
	Id       int    `nbt:"Id"`
	Name     string `nbt:"Name"`
	Snapshot bool   `nbt:"Snapshot"`
}

type PlayerData

type PlayerData struct {
	Advancements map[string]Advancement
	Stats        Stats
	PlayerData   MinecraftPlayerData
}

type Save

type Save struct {
	Version MinecraftVersion
	// contains filtered or unexported fields
}

func NewSave

func NewSave(path string) (*Save, error)

Create a new save from the given path

func (*Save) GetPlayers

func (s *Save) GetPlayers() ([]string, error)

Return all players from the save

func (*Save) GetVersion

func (s *Save) GetVersion() error

Return the Minecraft Version of the save

func (*Save) LoadPlayerData

func (s *Save) LoadPlayerData(player string) (PlayerData, error)

Load all relevant data for the given player

type SaveCollector

type SaveCollector struct {
	ReduceMetrics bool
	// contains filtered or unexported fields
}

func NewSaveCollector

func NewSaveCollector(path string, reduceMetrics bool) (*SaveCollector, error)

Create new instance of collector, returns error if an world directory is not provided Arguments:

	path: The path of the minecraft world directory
 reduceMetrics: Indicate if the amount of metrics should be reduced

func (*SaveCollector) Collect

func (c *SaveCollector) Collect(ch chan<- prometheus.Metric)

Implements the Collect function for prometheus.Collector

func (*SaveCollector) Describe

func (c *SaveCollector) Describe(ch chan<- *prometheus.Desc)

Implements the Describe function for prometheus.Collector

type Stats

type Stats struct {
	CraftedItems map[string]int `json:"minecraft:crafted"`
	Mined        map[string]int `json:"minecraft:mined"`
	PickedUp     map[string]int `json:"minecraft:picked_up"`
	Killed       map[string]int `json:"minecraft:killed"`
	KilledBy     map[string]int `json:"minecraft:killed_by"`
	Custom       CustomStats    `json:"minecraft:custom"`
}

func NewStats

func NewStats() Stats

Jump to

Keyboard shortcuts

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