func (db *DB) PlayerPlots(p *player.Player) ([]Position, error) {
	uuid := p.UUID()
	val, err := db.ldb.Get(uuid[:], nil)
	if err != nil {
		return nil, fmt.Errorf("player plots: %w", err)
	}
	var positions []Position
	if err := json.Unmarshal(val, &positions); err != nil {
		return nil, fmt.Errorf("player plots: %w", err)
	}
	return positions, nil
}
PlayerPlots attempts to read a list of Positions from the DB for the player.Player passed.
package plot
import (
	"encoding/json"
	"fmt"
	"github.com/df-mc/dragonfly/server/player"
	"github.com/df-mc/goleveldb/leveldb"
	"os"
)
type DB struct {
	ldb      *leveldb.DB
	settings Settings
	cache    map[Position]*Plot
}
func OpenDB(dir string, settings Settings) (*DB, error) {
	_ = os.MkdirAll(dir, 0777)
	ldb, err := leveldb.OpenFile(dir, nil)
	if err != nil {
		return nil, fmt.Errorf("error opening leveldb database: %w", err)
	}
	return &DB{ldb: ldb, settings: settings, cache: map[Position]*Plot{}}, nil
}
func (db *DB) Plot(pos Position) (*Plot, error) {
	if p, ok := db.cache[pos]; ok {
		return p, nil
	}
	val, err := db.ldb.Get(pos.Hash(), nil)
	if err != nil {
		return nil, fmt.Errorf("plot: %w", err)
	}
	var p Plot
	if err := json.Unmarshal(val, &p); err != nil {
		return nil, fmt.Errorf("plot: %w", err)
	}
	db.cache[pos] = &p
	return &p, nil
}
func (db *DB) StorePlot(pos Position, p *Plot) error {
	b, err := json.Marshal(p)
	if err != nil {
		return fmt.Errorf("store plot: %w", err)
	}
	if err := db.ldb.Put(pos.Hash(), b, nil); err != nil {
		return fmt.Errorf("store plot: %w", err)
	}
	db.cache[pos] = p
	return nil
}
func (db *DB) RemovePlot(pos Position) error {
	if err := db.ldb.Delete(pos.Hash(), nil); err != nil {
		return fmt.Errorf("remove plot: %w", err)
	}
	delete(db.cache, pos)
	return nil
}