minecraft

package module
v0.0.0-...-05b57c5 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2018 License: Unlicense Imports: 7 Imported by: 0

README

Minecraft Go Package

Just some helpers for reading and interacting with minecraft.

Supported

  • Reading ./usercache.json username cache.
  • Reading ./<world>/stats/<uuid>.json player stats.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Statistics

type Statistics struct {
	Groups  StatsGroups `json:"stats"`
	Version int         `json:"DataVersion"`
}

Statistics represents a collection of versioned stats

func OpenStatistics

func OpenStatistics(path string) (Statistics, error)

OpenStatistics will open and read the Statitics from the specified path (e.g /opt/minecraft/world/stats/playerid.json)

func ReadStatistics

func ReadStatistics(r io.Reader) (Statistics, error)

ReadStatistics will decode the statistics from the provided io.Reader

type Stats

type Stats map[string]int

Stats represents a collection of stats

type StatsGroups

type StatsGroups map[string]Stats

StatsGroups represents the stats collection

type Time

type Time struct {
	time.Time
}

Time specific to how minecraft reads/writes it (Java)

func (*Time) IsZero

func (t *Time) IsZero() bool

IsZero returns if the value is zero

func (*Time) MarshalJSON

func (t *Time) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON implements json.Unmarshaler

type User

type User struct {
	Name    string `json:"name"`
	ID      string `json:"uuid"`
	Expires Time   `json:"expiresOn"`
}

User represents a user in the usercache.json

type UserCache

type UserCache []User

UserCache represents users found in the cache

func OpenCache

func OpenCache(path string) (UserCache, error)

OpenCache will open and read the UserCache from the specified path (e.g /opt/minecraft/usercache.json)

func ReadCache

func ReadCache(r io.Reader) (UserCache, error)

ReadCache will decode the user cache from the provided io.Reader

func (UserCache) Get

func (uc UserCache) Get(name string) (User, bool)

Get will return a cached user with the specified name and if found

func (UserCache) GetByID

func (uc UserCache) GetByID(id string) (User, bool)

GetByID will return a cached user with the specified id and if found

type UserStatistics

type UserStatistics struct {
	Statistics
	User
}

UserStatistics includes the user and the statistics

Jump to

Keyboard shortcuts

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