Documentation ¶
Index ¶
- Constants
- func Within(pos, min, max cube.Pos) bool
- type DB
- func (db *DB) Close() error
- func (db *DB) PlayerPlots(id uuid.UUID) ([]Position, error)
- func (db *DB) Plot(pos Position) (*Plot, error)
- func (db *DB) RemovePlot(pos Position) error
- func (db *DB) StorePlayerPlots(id uuid.UUID, positions []Position) error
- func (db *DB) StorePlot(pos Position, p *Plot) error
- type Generator
- type PlayerHandler
- func (h *PlayerHandler) DB() *DB
- func (h *PlayerHandler) HandleBlockBreak(ctx *player.Context, pos cube.Pos, _ *[]item.Stack, _ *int)
- func (h *PlayerHandler) HandleBlockPlace(ctx *player.Context, pos cube.Pos, _ world.Block)
- func (h *PlayerHandler) HandleItemUseOnBlock(ctx *player.Context, pos cube.Pos, face cube.Face, _ mgl64.Vec3)
- func (h *PlayerHandler) HandleMove(ctx *player.Context, pos mgl64.Vec3, _ cube.Rotation)
- func (h *PlayerHandler) HandleQuit()
- func (h *PlayerHandler) PlotPositions() []Position
- func (h *PlayerHandler) Plots() []*Plot
- func (h *PlayerHandler) SetPlotPositions(positions []Position) error
- func (h *PlayerHandler) Settings() Settings
- type Plot
- type Position
- func (pos Position) Absolute(settings Settings) cube.Pos
- func (pos Position) Add(p Position) Position
- func (pos Position) Bounds(settings Settings) (min, max cube.Pos)
- func (pos Position) Hash() []byte
- func (pos Position) Reset(tx *world.Tx, settings Settings)
- func (pos Position) TeleportPosition(settings Settings) mgl64.Vec3
- type Settings
- type WorldHandler
Constants ¶
const (
// RoadHeight is a rough Y position of the height of the road where a player can be safely teleported.
RoadHeight = 24
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB handles access to the plots leveldb database. It provides abstraction over the database layer so that plots may be directly read from it.
func OpenDB ¶
OpenDB opens the directory passed as a leveldb database for plots. If the directory does not yet exist, it is created. If successful, a new DB is returned which may be used to read and write plots.
func (*DB) PlayerPlots ¶
PlayerPlots attempts to read a list of Positions from the DB for the player.Player passed.
func (*DB) RemovePlot ¶
RemovePlot attempts to remove a Plot at a specific Position in the DB.
func (*DB) StorePlayerPlots ¶
StorePlayerPlots attempts to store the Positions of the plots it owns into the DB.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator implements a generator for a plot world. The settings of the generator are configurable, allowing for different results depending on the fields set.
func NewGenerator ¶
NewGenerator returns a new plot Generator with the Settings passed.
type PlayerHandler ¶
type PlayerHandler struct { player.NopHandler // contains filtered or unexported fields }
PlayerHandler handles events of a player.Player. It handles things such as preventing players from placing in plots that they do not own.
func LookupHandler ¶
func LookupHandler(p *player.Player) (*PlayerHandler, bool)
LookupHandler looks up the PlayerHandler of a player.Player passed.
func NewPlayerHandler ¶
func NewPlayerHandler(id uuid.UUID, settings Settings, db *DB) *PlayerHandler
NewPlayerHandler creates a new PlayerHandler for the player.Player passed. The Settings and DB are used to track which plots the player.Player can build in.
func (*PlayerHandler) DB ¶
func (h *PlayerHandler) DB() *DB
DB returns the plot DB of the PlayerHandler.
func (*PlayerHandler) HandleBlockBreak ¶
func (h *PlayerHandler) HandleBlockBreak(ctx *player.Context, pos cube.Pos, _ *[]item.Stack, _ *int)
HandleBlockBreak prevents block breaking outside of the player's plots.
func (*PlayerHandler) HandleBlockPlace ¶
HandleBlockPlace prevents block placing outside of the player's plots.
func (*PlayerHandler) HandleItemUseOnBlock ¶
func (h *PlayerHandler) HandleItemUseOnBlock(ctx *player.Context, pos cube.Pos, face cube.Face, _ mgl64.Vec3)
HandleItemUseOnBlock prevents using items on blocks outside of the player's plots.
func (*PlayerHandler) HandleMove ¶
HandleMove shows information on the plot that the player enters.
func (*PlayerHandler) HandleQuit ¶
func (h *PlayerHandler) HandleQuit()
HandleQuit removes the PlayerHandler from the Handlers map.
func (*PlayerHandler) PlotPositions ¶
func (h *PlayerHandler) PlotPositions() []Position
PlotPositions returns positions of all plots that the PlayerHandler holds.
func (*PlayerHandler) Plots ¶
func (h *PlayerHandler) Plots() []*Plot
Plots returns a list of all Plots that the PlayerHandler owns.
func (*PlayerHandler) SetPlotPositions ¶
func (h *PlayerHandler) SetPlotPositions(positions []Position) error
SetPlotPositions sets the positions of all plots that the PlayerHandler holds.
func (*PlayerHandler) Settings ¶
func (h *PlayerHandler) Settings() Settings
Settings returns the Settings of the PlayerHandler.
type Plot ¶
type Plot struct { // Owner is the UUID of the owner of the plot. The owner has administrative permissions over the plot such // as being able to add helpers to the plot. Owner uuid.UUID // OwnerName is the name last recorded for the owner. OwnerName string // Helpers is a list of helpers added to the plot. These helpers may edit the plot, but are unable to, for // example, add other helpers. Helpers []uuid.UUID // Colour is the colour of the plot. The border of the plot will have this colour and the colour will be // used to refer to different chunks owned by the player. Colour string MergedDirections []cube.Direction }
Plot represents a plot in the world. Each plot has an owner
func (*Plot) ColourToFormat ¶
ColourToFormat converts the colour of the plot to a text.FormatFunc and returns it.
func (*Plot) ColourToString ¶
ColourToString converts the colour of the plot to a readable representation.
type Position ¶
type Position [2]int
Position represents the position of a plot. These positions are similar to chunk positions, in that they do not represent absolute coordinates, but, instead, a coordinate based on the size of plots.
func PosFromBlockPos ¶
PosFromBlockPos returns a Position that reflects the position of the plot present at that position.
func (Position) Add ¶
Add adds a Position to the current Position and returns a new resulting Position.
func (Position) Bounds ¶
Bounds returns the bounds of the Plot present at this position. Blocks may only be edited within these block positions.
func (Position) Hash ¶
Hash creates a hash of the position and returns it. This hash is unique per Position and may be used to do lookups in databases.
type Settings ¶
type Settings struct { // FloorBlock is the block on the floor of each plot. The floor may be changed later, but plots will have // this floor by default. FloorBlock world.Block // BoundaryBlock is the block used to surround plots with. These blocks cannot be changed by an individual // player. BoundaryBlock world.Block // RoadBlock is the outer block of the pattern on the road. These blocks cannot be changed by any player. RoadBlock world.Block // PlotWidth is the width in blocks that each plot generated will be. PlotWidth int // MaximumPlots is the maximum amount of plots that a player is allowed to claim. Trying to claim more // than this will result in an error. MaximumPlots int }
Settings holds the settings for a plot Generator. These settings may be changed in order to change the appearance of the plots generated.
type WorldHandler ¶
type WorldHandler struct { world.NopHandler // contains filtered or unexported fields }
WorldHandler handles events of the world.World, making sure liquids don't spread out of plots.
func NewWorldHandler ¶
func NewWorldHandler(settings Settings) *WorldHandler
NewWorldHandler returns a new WorldHandler instance using the world.World and Settings passed.