codec

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: Apache-2.0 Imports: 11 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec interface {
	Marshaler
	Unmarshaler
}

Codec can marshal and unmarshal to/from components to/from a different format.

type Json

type Json struct {
	// Since Minecraft 1.16+ there can be hex colors (e.g. "#ff5555" instead of the named color "red").
	// This setting decides whether to use the nearest legacy named color of the hex color instead.
	//
	// This setting is false by default to support older client versions.
	NoDownsampleColor bool
	// Since Minecraft 1.16+ hoverEvent "value" is deprecated in favour of "contents".
	// This setting decides whether the "value" key in a hoverEvent object shall be included
	// next to "contents" or not.
	//
	// It is false by default to support older client versions.
	NoLegacyHover bool
	// Whether to use Go's standard json library for marshalling.
	// It can be set to true if features such as key sorting in objects is needed
	// (e.g. when testing to compare output).
	//
	// It is false by default to use a MUCH MORE efficient (faster, less B/op & allocs/op needed)
	// third-party json marshaller instead.
	StdJson bool
}

Json is a json serializer for Minecraft text components.

func (*Json) Marshal

func (j *Json) Marshal(wr io.Writer, c Component) (err error)

Marshal writes the json encoded Component to the Writer.

func (*Json) Unmarshal

func (j *Json) Unmarshal(data []byte) (Component, error)

type Marshaler

type Marshaler interface {
	// Marshal writes the encoding of c into wr.
	Marshal(wr io.Writer, c Component) error
}

type Plain

type Plain struct{}

Plain is a plain text component serializer. Plain does not support more complex features such as, but not limited to, colours, decorations, ClickEvent and HoverEvent.

func (Plain) Marshal

func (p Plain) Marshal(wr io.Writer, c component.Component) error

func (Plain) Unmarshal

func (Plain) Unmarshal(str []byte) (component.Component, error)

type Unmarshaler

type Unmarshaler interface {
	// Unmarshal decodes a Component from data.
	Unmarshal(data []byte) (Component, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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