typhoon

package module
v0.0.0-...-18414ba Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2022 License: GPL-2.0 Imports: 24 Imported by: 0

README

TyphoonCore

Lightweight minecraft server engine

Build Status stability-wip

Minecraft protocol support
Minecraft Version Protocol Version Supported
1.7.2 to 1.7.5 4 true
1.7.6 to 1.7.10 5 true
1.8 to 1.8.9 47 true
1.9 107 true
1.9.1 108 true
1.9.2 109 true
1.9.3 to 1.9.4 110 true
1.10 to 1.10.2 210 true
1.11 315 true
1.11.1 to 1.11.2 316 true
1.12 335 true
1.12.1 338 true
1.12.2 340 true
1.13 393 true
1.13.1 401 true
1.13.2 404 true
1.14 477 true
1.14.1 480 true
1.14.2 485 true
1.14.3 490 true
1.14.4 498 true
1.15 573 true
1.15.1 575 true
1.15.2 578 true
Snapshot support

TyphoonCore is able to load TyphoonDep protocol-map modules to add a partial snapshots support.

All json files are loaded from the "modules" folder in the same directory as the TyphoonLimbo binary.

You can generate a protocol-map module with the fetcher. Just pick the "page" link of your wanted version on wiki.vg as argument of the fecther and the magic will happen.

How to use
go get github.com/TyphoonMC/TyphoonCore
Example
package main

import (
	"fmt"
	t "github.com/TyphoonMC/TyphoonCore"
)

func main() {
	core := t.Init()
	core.SetBrand("exampleserver")

	core.On(func(e *t.PlayerJoinEvent) {
		msg := t.ChatMessage("Welcome ")
		msg.SetExtra([]t.IChatComponent{
			t.ChatMessage(e.Player.GetName()),
			t.ChatMessage(" !"),
		})
		e.Player.SendMessage(msg)
	})

	core.Start()
}

Other examples :

Roadmap
  • User friendly API
  • World loading
  • Multiworld
  • Entities
  • Physics
  • Biomes
  • Redstone
  • Pistons

Documentation

Index

Constants

View Source
const (
	CommandNodeTypeLiteral
	CommandNodeTypeArgument
)

Variables

View Source
var (
	ChatColorBlack         = ChatColor{0, "black"}
	ChatColorDarkBlue      = ChatColor{1, "dark_blue"}
	ChatColorDarkGreen     = ChatColor{2, "dark_green"}
	ChatColorDarkAqua      = ChatColor{3, "dark_aqua"}
	ChatColorDarkRed       = ChatColor{4, "dark_red"}
	ChatColorDarkPurple    = ChatColor{5, "dark_purple"}
	ChatColorGold          = ChatColor{6, "gold"}
	ChatColorGray          = ChatColor{7, "gray"}
	ChatColorDarkGray      = ChatColor{8, "dark_gray"}
	ChatColorIndigo        = ChatColor{9, "blue"}
	ChatColorGreen         = ChatColor{10, "green"}
	ChatColorAqua          = ChatColor{11, "aqua"}
	ChatColorRed           = ChatColor{12, "red"}
	ChatColorPink          = ChatColor{13, "light_purple"}
	ChatColorYellow        = ChatColor{14, "yellow"}
	ChatColorWhite         = ChatColor{15, "white"}
	ChatStyleObfuscated    = ChatStyle{&ChatColor{'k', "obfuscated"}}
	ChatStyleBold          = ChatStyle{&ChatColor{'l', "bold"}}
	ChatStyleStrikeThrough = ChatStyle{&ChatColor{'m', "strikethrough"}}
	ChatStyleUnderlined    = ChatStyle{&ChatColor{'n', "underlined"}}
	ChatStyleItalic        = ChatStyle{&ChatColor{'o', "italic"}}
)
View Source
var (
	NETHER = Dimension{
		"minecraft:the_nether",
		0xFF,
		0,
		uint64Ptr(18000),
		0.1,
		1,
		1,
		1,
		0,
		"",
		256,
		0,
		1,
		0,
		0,
	}
	OVERWORLD = Dimension{
		"minecraft:overworld",
		0x00,
		1,
		nil,
		0,
		0,
		0,
		0,
		1,
		"",
		256,
		0,
		0,
		1,
		1,
	}
	END = Dimension{
		"minecraft:the_end",
		0x01,
		0,
		uint64Ptr(6000),
		0,
		0,
		0,
		0,
		0,
		"",
		0,
		1,
		0,
		0,
		1,
	}
)
View Source
var (
	BLOCK_REGISTRY = generateRegistry()
)

Functions

func IsCompatible

func IsCompatible(proto Protocol) bool

func JsonEscape

func JsonEscape(s string) string

func JsonMessage

func JsonMessage(s string) json.RawMessage

func PacketTypeHash

func PacketTypeHash(state State, id int) int64

Types

type BlockPalette

type BlockPalette interface {
	GetId(name string) int
	RecoverName(id int) string
	GetSize() int
	GetContent() []string
}

type BlockRegistry

type BlockRegistry struct {
	NameToGuid map[string]uint16
	GuidToName map[uint16]string
	// contains filtered or unexported fields
}

func (*BlockRegistry) GetBlockId

func (registry *BlockRegistry) GetBlockId(name string, proto Protocol) int

func (*BlockRegistry) GetGuid

func (registry *BlockRegistry) GetGuid(name string) uint16

func (*BlockRegistry) GetLegacyBlockTypeData

func (registry *BlockRegistry) GetLegacyBlockTypeData(name string, proto Protocol) (int, int)

func (*BlockRegistry) GetName

func (registry *BlockRegistry) GetName(guid uint16) string

type BossBarAction

type BossBarAction int
const (
	BOSSBAR_ADD BossBarAction = iota
	BOSSBAR_REMOVE
	BOSSBAR_UPDATE_HEALTH
	BOSSBAR_UPDATE_TITLE
	BOSSBAR_UPDATE_STYLE
	BOSSBAR_UPDATE_FLAGS
)

type BossBarColor

type BossBarColor int
const (
	BOSSBAR_COLOR_PINK BossBarColor = iota
	BOSSBAR_COLOR_BLUE
	BOSSBAR_COLOR_RED
	BOSSBAR_COLOR_GREEN
	BOSSBAR_COLOR_YELLOW
	BOSSBAR_COLOR_PURPLE
	BOSSBAR_COLOR_WHITE
)

type BossBarDivision

type BossBarDivision int
const (
	BOSSBAR_NODIVISION BossBarDivision = iota
	BOSSBAR_6NOTCHES
	BOSSBAR_10NOTCHES
	BOSSBAR_12NOTCHES
	BOSSBAR_20NOTCHES
)

type BufferConfig

type BufferConfig struct {
	HandshakeAddress int `json:"handshake_address"`
	PlayerName       int `json:"player_name"`
	ChatMessage      int `json:"chat_message"`
}

type ChatAction

type ChatAction struct {
	Action string      `json:"action"`
	Value  interface{} `json:"value"`
}

func ChatClickRunCommand

func ChatClickRunCommand(command string) *ChatAction

func ChatHoverMessage

func ChatHoverMessage(components []IChatComponent) *ChatAction

func ChatHoverText

func ChatHoverText(component string) *ChatAction

type ChatColor

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

func (*ChatColor) ChatFormat

func (color *ChatColor) ChatFormat() string

func (*ChatColor) GetId

func (color *ChatColor) GetId() byte

func (*ChatColor) GetName

func (color *ChatColor) GetName() string

type ChatComponent

type ChatComponent struct {
	Bold          bool             `json:"bold"`
	Italic        bool             `json:"italic"`
	Underlined    bool             `json:"underlined"`
	StrikeThrough bool             `json:"strikethrough"`
	Obfuscated    bool             `json:"obfuscated"`
	Color         *string          `json:"color,omitempty"`
	Insertion     *string          `json:"insertion,omitempty"`
	ClickEvent    *ChatAction      `json:"clickEvent,omitempty"`
	HoverEvent    *ChatAction      `json:"hoverEvent,omitempty"`
	Extra         []IChatComponent `json:"extra,omitempty"`
}

func (*ChatComponent) AddExtra

func (component *ChatComponent) AddExtra(extra IChatComponent)

func (*ChatComponent) JSON

func (component *ChatComponent) JSON() (string, error)

func (*ChatComponent) SetBold

func (component *ChatComponent) SetBold(bold bool)

func (*ChatComponent) SetClickEvent

func (component *ChatComponent) SetClickEvent(action *ChatAction)

func (*ChatComponent) SetColor

func (component *ChatComponent) SetColor(color *ChatColor)

func (*ChatComponent) SetExtra

func (component *ChatComponent) SetExtra(extra []IChatComponent)

func (*ChatComponent) SetHoverEvent

func (component *ChatComponent) SetHoverEvent(action *ChatAction)

func (*ChatComponent) SetInsertion

func (component *ChatComponent) SetInsertion(insertion string)

func (*ChatComponent) SetItalic

func (component *ChatComponent) SetItalic(italic bool)

func (*ChatComponent) SetObfuscated

func (component *ChatComponent) SetObfuscated(obfuscated bool)

func (*ChatComponent) SetStrikeThrough

func (component *ChatComponent) SetStrikeThrough(strikeThrough bool)

func (*ChatComponent) SetUnderlined

func (component *ChatComponent) SetUnderlined(underlined bool)

type ChatPosition

type ChatPosition uint8
const (
	CHAT_BOX ChatPosition = iota
	SYSTEM
	ACTION_BAR
)

type ChatStyle

type ChatStyle struct {
	*ChatColor
}

func (*ChatStyle) ChatFormat

func (color *ChatStyle) ChatFormat() string

type Chunk

type Chunk struct {
	ChunkX   int32
	ChunkZ   int32
	Sections [16]*ChunkSection
}

func (*Chunk) GetSection

func (chunk *Chunk) GetSection(y int) *ChunkSection

type ChunkBlockPalette

type ChunkBlockPalette struct {
	Map []string
}

func (*ChunkBlockPalette) GetContent

func (palette *ChunkBlockPalette) GetContent() []string

func (*ChunkBlockPalette) GetId

func (palette *ChunkBlockPalette) GetId(name string) int

func (*ChunkBlockPalette) GetSize

func (palette *ChunkBlockPalette) GetSize() int

func (*ChunkBlockPalette) RecoverName

func (palette *ChunkBlockPalette) RecoverName(id int) string

type ChunkSection

type ChunkSection struct {
	Palette BlockPalette
	Blocks  [16 * 16 * 16]int
}

func (*ChunkSection) SetBlock

func (section *ChunkSection) SetBlock(x, y, z int, typ string)

type ClientStatusAction

type ClientStatusAction uint8
const (
	PERFORM_RESPAWN ClientStatusAction = iota
	REQUEST_STATS
	OPEN_INVENTORY
)

type CommandNode

type CommandNode struct {
	Type         CommandNodeType
	Execute      func(player *Player, args []string)
	Children     []*CommandNode
	RedirectNode *CommandNode
	Name         string
	Parser       CommandParser
}

func CommandNodeArgument

func CommandNodeArgument(
	name string,
	children []*CommandNode,
	parser CommandParser,
	execute func(player *Player, args []string)) *CommandNode

func CommandNodeLiteral

func CommandNodeLiteral(
	name string,
	children []*CommandNode,
	execute func(player *Player, args []string)) *CommandNode

type CommandNodeType

type CommandNodeType uint8

type CommandParser

type CommandParser interface {
	GetId() string
	IsMultiple() bool
	IsValid(string) bool
	IsArrayValid([]string) bool
	GetSuggestion() CommandSuggestionType
	Complete(string) []string
	// contains filtered or unexported methods
}

type CommandParserBool

type CommandParserBool struct{}

func (*CommandParserBool) Complete

func (c *CommandParserBool) Complete(arg string) []string

func (*CommandParserBool) GetId

func (c *CommandParserBool) GetId() string

func (*CommandParserBool) GetSuggestion

func (c *CommandParserBool) GetSuggestion() CommandSuggestionType

func (*CommandParserBool) IsArrayValid

func (c *CommandParserBool) IsArrayValid(arg []string) bool

func (*CommandParserBool) IsMultiple

func (c *CommandParserBool) IsMultiple() bool

func (*CommandParserBool) IsValid

func (c *CommandParserBool) IsValid(arg string) bool

type CommandParserDouble

type CommandParserDouble struct {
	Min OptDouble
	Max OptDouble
}

func (*CommandParserDouble) Complete

func (c *CommandParserDouble) Complete(arg string) []string

func (*CommandParserDouble) GetId

func (c *CommandParserDouble) GetId() string

func (*CommandParserDouble) GetSuggestion

func (c *CommandParserDouble) GetSuggestion() CommandSuggestionType

func (*CommandParserDouble) IsArrayValid

func (c *CommandParserDouble) IsArrayValid(arg []string) bool

func (*CommandParserDouble) IsMultiple

func (c *CommandParserDouble) IsMultiple() bool

func (*CommandParserDouble) IsValid

func (c *CommandParserDouble) IsValid(arg string) bool

type CommandParserFloat

type CommandParserFloat struct {
	Min OptFloat
	Max OptFloat
}

func (*CommandParserFloat) Complete

func (c *CommandParserFloat) Complete(arg string) []string

func (*CommandParserFloat) GetId

func (c *CommandParserFloat) GetId() string

func (*CommandParserFloat) GetSuggestion

func (c *CommandParserFloat) GetSuggestion() CommandSuggestionType

func (*CommandParserFloat) IsArrayValid

func (c *CommandParserFloat) IsArrayValid(arg []string) bool

func (*CommandParserFloat) IsMultiple

func (c *CommandParserFloat) IsMultiple() bool

func (*CommandParserFloat) IsValid

func (c *CommandParserFloat) IsValid(arg string) bool

type CommandParserInteger

type CommandParserInteger struct {
	Min OptInteger
	Max OptInteger
}

func (*CommandParserInteger) Complete

func (c *CommandParserInteger) Complete(arg string) []string

func (*CommandParserInteger) GetId

func (c *CommandParserInteger) GetId() string

func (*CommandParserInteger) GetSuggestion

func (c *CommandParserInteger) GetSuggestion() CommandSuggestionType

func (*CommandParserInteger) IsArrayValid

func (c *CommandParserInteger) IsArrayValid(arg []string) bool

func (*CommandParserInteger) IsMultiple

func (c *CommandParserInteger) IsMultiple() bool

func (*CommandParserInteger) IsValid

func (c *CommandParserInteger) IsValid(arg string) bool

type CommandParserString

type CommandParserString struct {
	Format CommandParserStringFormat
}

func (*CommandParserString) Complete

func (c *CommandParserString) Complete(arg string) []string

func (*CommandParserString) GetId

func (c *CommandParserString) GetId() string

func (*CommandParserString) GetSuggestion

func (c *CommandParserString) GetSuggestion() CommandSuggestionType

func (*CommandParserString) IsArrayValid

func (c *CommandParserString) IsArrayValid(arg []string) bool

func (*CommandParserString) IsMultiple

func (c *CommandParserString) IsMultiple() bool

func (*CommandParserString) IsValid

func (c *CommandParserString) IsValid(arg string) bool

type CommandParserStringFormat

type CommandParserStringFormat int
const (
	CommandParserStringFormatSingleWord CommandParserStringFormat = iota

	CommandParserStringFormatGreedyPhrase
)

type CommandSuggestionType

type CommandSuggestionType string
const (
	CommandSuggestionNone               CommandSuggestionType = ""
	CommandSuggestionAskServer          CommandSuggestionType = "minecraft:ask_server"
	CommandSuggestionAllRecipes         CommandSuggestionType = "minecraft:all_recipes"
	CommandSuggestionAvailableSounds    CommandSuggestionType = "minecraft:available_sounds"
	CommandSuggestionSummonableEntities CommandSuggestionType = "minecraft:summonable_entities"
)

type Config

type Config struct {
	ListenAddress string       `json:"listen_address"`
	MaxPlayers    int          `json:"max_players"`
	Motd          string       `json:"motd"`
	Restricted    bool         `json:"restricted"`
	Logs          bool         `json:"logs"`
	Compression   bool         `json:"enable_compression"`
	Threshold     int          `json:"compression_threshold"`
	BufferConfig  BufferConfig `json:"buffer_config"`
}

type ConnReadWrite

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

func (ConnReadWrite) ReadByte

func (rdrwtr ConnReadWrite) ReadByte() (b byte, err error)

type Core

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

func Init

func Init() *Core

func (*Core) CallEvent

func (c *Core) CallEvent(event Event)

func (*Core) DeclareCommand

func (c *Core) DeclareCommand(graph *CommandNode)

func (*Core) GetConfig

func (c *Core) GetConfig(config interface{})

func (*Core) GetPlayerRegistry

func (c *Core) GetPlayerRegistry() *PlayerRegistry

func (*Core) On

func (c *Core) On(handler interface{})

func (*Core) OnPluginMessage

func (c *Core) OnPluginMessage(channel string, handler interface{})

func (*Core) SetBrand

func (c *Core) SetBrand(brand string)

func (*Core) SetGamemode

func (c *Core) SetGamemode(gamemode Gamemode)

func (*Core) SetMap

func (c *Core) SetMap(world *Map)

func (*Core) Start

func (c *Core) Start()

type Difficulty

type Difficulty uint8
const (
	PEACEFUL Difficulty = iota
	EASY
	NORMAL
	HARD
)

type Dimension

type Dimension struct {
	Name               string
	Id                 uint8
	Natural            uint8
	FixedTime          *uint64
	AmbientLight       float32
	Shrunk             uint8
	Ultrawarm          uint8
	HasCeiling         uint8
	HasSkylight        uint8
	Infiniburn         string
	LogicalHeight      uint32
	HasRaids           uint8
	RespawnAnchorWorks uint8
	BedWorks           uint8
	PiglinSafe         uint8
}

func (Dimension) Entry

func (dimension Dimension) Entry() *nbt.Compound

func (Dimension) String

func (dimension Dimension) String() string

type Event

type Event interface{}

type EventCallback

type EventCallback struct {
	Callback interface{}
	MetaData map[string]string
}

type Gamemode

type Gamemode uint8
const (
	SURVIVAL Gamemode = iota
	CREATIVE
	ADVENTURE
	SPECTATOR
)

type HackContent

type HackContent struct {
	Name     string   `json:"name"`
	Protocol Protocol `json:"protocol"`
	Base     Protocol `json:"base"`
	Map      HackMap  `json:"map"`
}

type HackMap

type HackMap struct {
	Clientbound map[string]string `json:"clientbound"`
	Serverbound map[string]string `json:"serverbound"`
}

type HackModule

type HackModule struct {
	Type    HackType    `json:"type"`
	Content HackContent `json:"content"`
}

type HackType

type HackType struct {
	Name    string `json:"name"`
	Version int    `json:"version"`
}

type IChatComponent

type IChatComponent interface {
	JSON() (string, error)
}

func BukkitMessageConvert

func BukkitMessageConvert(message string) IChatComponent

type InAddr

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

type LevelType

type LevelType string
const (
	DEFAULT      LevelType = "default"
	FLAT         LevelType = "flat"
	LARGE_BIOMES LevelType = "largeBiomes"
	AMPLIFIED    LevelType = "amplified"
	DEFAULT_1_1  LevelType = "default_1_1"
)

type Location

type Location struct {
	X float64 `json:"x"`
	Y float64 `json:"y"`
	Z float64 `json:"z"`
}

func (*Location) ToPosition

func (loc *Location) ToPosition() *Position

type Map

type Map struct {
	Spawn     Location
	Dimension Dimension
	Chunks    []*Chunk
}

func LoadSchematic

func LoadSchematic(file string) (*Map, error)

func (*Map) GetChunk

func (m *Map) GetChunk(x int32, z int32) *Chunk

func (*Map) SendSpawnChunks

func (m *Map) SendSpawnChunks(p *Player)

func (*Map) SetBlock

func (m *Map) SetBlock(x, y, z int, typ string)

type OptDouble

type OptDouble struct {
	Used  bool
	Value float64
}

type OptFloat

type OptFloat struct {
	Used  bool
	Value float32
}

type OptInteger

type OptInteger struct {
	Used  bool
	Value int32
}

type Packet

type Packet interface {
	Write(*Player) error
	Read(*Player, int) error
	Handle(*Player)
	Id() (int, Protocol)
}

type PacketBossBar

type PacketBossBar struct {
	UUID     uuid.UUID
	Action   BossBarAction
	Title    string
	Health   float32
	Color    BossBarColor
	Division BossBarDivision
	Flags    uint8
}

func (*PacketBossBar) Handle

func (packet *PacketBossBar) Handle(player *Player)

func (*PacketBossBar) Id

func (packet *PacketBossBar) Id() (int, Protocol)

func (*PacketBossBar) Read

func (packet *PacketBossBar) Read(player *Player, length int) (err error)

func (*PacketBossBar) Write

func (packet *PacketBossBar) Write(player *Player) (err error)

type PacketHandshake

type PacketHandshake struct {
	Protocol Protocol
	Address  string
	Port     uint16
	State    State
}

func (*PacketHandshake) Handle

func (packet *PacketHandshake) Handle(player *Player)

func (*PacketHandshake) Id

func (packet *PacketHandshake) Id() (int, Protocol)

func (*PacketHandshake) Read

func (packet *PacketHandshake) Read(player *Player, length int) (err error)

func (*PacketHandshake) Write

func (packet *PacketHandshake) Write(player *Player) (err error)

type PacketLoginDisconnect

type PacketLoginDisconnect struct {
	Component string
}

func (*PacketLoginDisconnect) Handle

func (packet *PacketLoginDisconnect) Handle(player *Player)

func (*PacketLoginDisconnect) Id

func (packet *PacketLoginDisconnect) Id() (int, Protocol)

func (*PacketLoginDisconnect) Read

func (packet *PacketLoginDisconnect) Read(player *Player, length int) (err error)

func (*PacketLoginDisconnect) Write

func (packet *PacketLoginDisconnect) Write(player *Player) (err error)

type PacketLoginStart

type PacketLoginStart struct {
	Username string
}

func (*PacketLoginStart) Handle

func (packet *PacketLoginStart) Handle(player *Player)

func (*PacketLoginStart) Id

func (packet *PacketLoginStart) Id() (int, Protocol)

func (*PacketLoginStart) Read

func (packet *PacketLoginStart) Read(player *Player, length int) (err error)

func (*PacketLoginStart) Write

func (packet *PacketLoginStart) Write(player *Player) (err error)

type PacketLoginSuccess

type PacketLoginSuccess struct {
	UUID     uuid.UUID
	Username string
}

func (*PacketLoginSuccess) Handle

func (packet *PacketLoginSuccess) Handle(player *Player)

func (*PacketLoginSuccess) Id

func (packet *PacketLoginSuccess) Id() (int, Protocol)

func (*PacketLoginSuccess) Read

func (packet *PacketLoginSuccess) Read(player *Player, length int) (err error)

func (*PacketLoginSuccess) Write

func (packet *PacketLoginSuccess) Write(player *Player) (err error)

type PacketPlayChat

type PacketPlayChat struct {
	Message string
}

func (*PacketPlayChat) Handle

func (packet *PacketPlayChat) Handle(player *Player)

func (*PacketPlayChat) Id

func (packet *PacketPlayChat) Id() (int, Protocol)

func (*PacketPlayChat) Read

func (packet *PacketPlayChat) Read(player *Player, length int) (err error)

func (*PacketPlayChat) Write

func (packet *PacketPlayChat) Write(player *Player) (err error)

type PacketPlayChunkData

type PacketPlayChunkData struct {
	X               int32
	Z               int32
	GroundUp        bool
	ServerLightning bool
	Sections        []*ChunkSection
	Biomes          *[]byte
	BlockEntities   []nbt.Compound
}

func (*PacketPlayChunkData) Handle

func (packet *PacketPlayChunkData) Handle(player *Player)

func (*PacketPlayChunkData) Id

func (packet *PacketPlayChunkData) Id() (int, Protocol)

func (*PacketPlayChunkData) Read

func (packet *PacketPlayChunkData) Read(player *Player, length int) (err error)

func (*PacketPlayChunkData) Write

func (packet *PacketPlayChunkData) Write(player *Player) (err error)

func (*PacketPlayChunkData) WriteV1_13

func (packet *PacketPlayChunkData) WriteV1_13(player *Player) (err error)

func (*PacketPlayChunkData) WriteV1_7

func (packet *PacketPlayChunkData) WriteV1_7(player *Player) (err error)

func (*PacketPlayChunkData) WriteV1_8

func (packet *PacketPlayChunkData) WriteV1_8(player *Player) (err error)

func (*PacketPlayChunkData) WriteV1_9

func (packet *PacketPlayChunkData) WriteV1_9(player *Player) (err error)

type PacketPlayClientStatus

type PacketPlayClientStatus struct {
	Action ClientStatusAction
}

func (*PacketPlayClientStatus) Handle

func (packet *PacketPlayClientStatus) Handle(player *Player)

func (*PacketPlayClientStatus) Id

func (packet *PacketPlayClientStatus) Id() (int, Protocol)

func (*PacketPlayClientStatus) Read

func (packet *PacketPlayClientStatus) Read(player *Player, length int) (err error)

func (*PacketPlayClientStatus) Write

func (packet *PacketPlayClientStatus) Write(player *Player) (err error)

type PacketPlayDisconnect

type PacketPlayDisconnect struct {
	Component string
}

func (*PacketPlayDisconnect) Handle

func (packet *PacketPlayDisconnect) Handle(player *Player)

func (*PacketPlayDisconnect) Id

func (packet *PacketPlayDisconnect) Id() (int, Protocol)

func (*PacketPlayDisconnect) Read

func (packet *PacketPlayDisconnect) Read(player *Player, length int) (err error)

func (*PacketPlayDisconnect) Write

func (packet *PacketPlayDisconnect) Write(player *Player) (err error)

type PacketPlayJoinGame

type PacketPlayJoinGame struct {
	EntityId            uint32
	Gamemode            Gamemode
	Dimension           Dimension
	HashedSeed          uint64
	Difficulty          Difficulty
	MaxPlayers          uint8
	LevelType           LevelType
	ReducedDebug        bool
	EnableRespawnScreen bool
	IsDebug             bool
	IsFlat              bool
}

func (*PacketPlayJoinGame) Handle

func (packet *PacketPlayJoinGame) Handle(player *Player)

func (*PacketPlayJoinGame) Id

func (packet *PacketPlayJoinGame) Id() (int, Protocol)

func (*PacketPlayJoinGame) Read

func (packet *PacketPlayJoinGame) Read(player *Player, length int) (err error)

func (*PacketPlayJoinGame) Write

func (packet *PacketPlayJoinGame) Write(player *Player) (err error)

type PacketPlayKeepAlive

type PacketPlayKeepAlive struct {
	Identifier int
}

func (*PacketPlayKeepAlive) Handle

func (packet *PacketPlayKeepAlive) Handle(player *Player)

func (*PacketPlayKeepAlive) Id

func (packet *PacketPlayKeepAlive) Id() (int, Protocol)

func (*PacketPlayKeepAlive) Read

func (packet *PacketPlayKeepAlive) Read(player *Player, length int) (err error)

func (*PacketPlayKeepAlive) Write

func (packet *PacketPlayKeepAlive) Write(player *Player) (err error)

type PacketPlayMessage

type PacketPlayMessage struct {
	Component string
	Position  ChatPosition
	Sender    uuid.UUID
}

func (*PacketPlayMessage) Handle

func (packet *PacketPlayMessage) Handle(player *Player)

func (*PacketPlayMessage) Id

func (packet *PacketPlayMessage) Id() (int, Protocol)

func (*PacketPlayMessage) Read

func (packet *PacketPlayMessage) Read(player *Player, length int) (err error)

func (*PacketPlayMessage) Write

func (packet *PacketPlayMessage) Write(player *Player) (err error)

type PacketPlayParticle

type PacketPlayParticle struct {
	Type         int
	LongDistance bool
	X            float32
	Y            float32
	Z            float32
	OffsetX      float32
	OffsetY      float32
	OffsetZ      float32
	ParticleData float32
	Count        int
	Data         []int
}

func (*PacketPlayParticle) Handle

func (packet *PacketPlayParticle) Handle(player *Player)

func (*PacketPlayParticle) Id

func (packet *PacketPlayParticle) Id() (int, Protocol)

func (*PacketPlayParticle) Read

func (packet *PacketPlayParticle) Read(player *Player, length int) (err error)

func (*PacketPlayParticle) Write

func (packet *PacketPlayParticle) Write(player *Player) (err error)

type PacketPlayPlayerAbilities

type PacketPlayPlayerAbilities struct {
	Invulnerable bool
	Fly          bool
	CanFly       bool
	Creative     bool
	FlyingSpeed  float32
	FieldOfView  float32
}

func (*PacketPlayPlayerAbilities) Handle

func (packet *PacketPlayPlayerAbilities) Handle(player *Player)

func (*PacketPlayPlayerAbilities) Id

func (packet *PacketPlayPlayerAbilities) Id() (int, Protocol)

func (*PacketPlayPlayerAbilities) Read

func (packet *PacketPlayPlayerAbilities) Read(player *Player, length int) (err error)

func (*PacketPlayPlayerAbilities) Write

func (packet *PacketPlayPlayerAbilities) Write(player *Player) (err error)

type PacketPlayServerDifficulty

type PacketPlayServerDifficulty struct {
	Difficulty Difficulty
}

func (*PacketPlayServerDifficulty) Handle

func (packet *PacketPlayServerDifficulty) Handle(player *Player)

func (*PacketPlayServerDifficulty) Id

func (packet *PacketPlayServerDifficulty) Id() (int, Protocol)

func (*PacketPlayServerDifficulty) Read

func (packet *PacketPlayServerDifficulty) Read(player *Player, length int) (err error)

func (*PacketPlayServerDifficulty) Write

func (packet *PacketPlayServerDifficulty) Write(player *Player) (err error)

type PacketPlaySpawnPosition

type PacketPlaySpawnPosition struct {
	Position Position
}

func (*PacketPlaySpawnPosition) Handle

func (packet *PacketPlaySpawnPosition) Handle(player *Player)

func (*PacketPlaySpawnPosition) Id

func (packet *PacketPlaySpawnPosition) Id() (int, Protocol)

func (*PacketPlaySpawnPosition) Read

func (packet *PacketPlaySpawnPosition) Read(player *Player, length int) (err error)

func (*PacketPlaySpawnPosition) Write

func (packet *PacketPlaySpawnPosition) Write(player *Player) (err error)

type PacketPlayTabComplete

type PacketPlayTabComplete struct {
	Matches []string
}

func (*PacketPlayTabComplete) Handle

func (packet *PacketPlayTabComplete) Handle(player *Player)

func (*PacketPlayTabComplete) Id

func (packet *PacketPlayTabComplete) Id() (int, Protocol)

func (*PacketPlayTabComplete) Read

func (packet *PacketPlayTabComplete) Read(player *Player, length int) (err error)

func (*PacketPlayTabComplete) Write

func (packet *PacketPlayTabComplete) Write(player *Player) (err error)

type PacketPlayTabCompleteServerbound

type PacketPlayTabCompleteServerbound struct {
	Text          string
	AssumeCommand bool
	Position      Position
}

func (*PacketPlayTabCompleteServerbound) Handle

func (packet *PacketPlayTabCompleteServerbound) Handle(player *Player)

func (*PacketPlayTabCompleteServerbound) Id

func (*PacketPlayTabCompleteServerbound) Read

func (packet *PacketPlayTabCompleteServerbound) Read(player *Player, length int) (err error)

func (*PacketPlayTabCompleteServerbound) Write

func (packet *PacketPlayTabCompleteServerbound) Write(player *Player) (err error)

type PacketPlayerListHeaderFooter

type PacketPlayerListHeaderFooter struct {
	Header *string
	Footer *string
}

func (*PacketPlayerListHeaderFooter) Handle

func (packet *PacketPlayerListHeaderFooter) Handle(player *Player)

func (*PacketPlayerListHeaderFooter) Id

func (packet *PacketPlayerListHeaderFooter) Id() (int, Protocol)

func (*PacketPlayerListHeaderFooter) Read

func (packet *PacketPlayerListHeaderFooter) Read(player *Player, length int) (err error)

func (*PacketPlayerListHeaderFooter) Write

func (packet *PacketPlayerListHeaderFooter) Write(player *Player) (err error)

type PacketPlayerPositionLook

type PacketPlayerPositionLook struct {
	X          float64
	Y          float64
	Z          float64
	Yaw        float32
	Pitch      float32
	Flags      uint8
	TeleportId int
}

func (*PacketPlayerPositionLook) Handle

func (packet *PacketPlayerPositionLook) Handle(player *Player)

func (*PacketPlayerPositionLook) Id

func (packet *PacketPlayerPositionLook) Id() (int, Protocol)

func (*PacketPlayerPositionLook) Read

func (packet *PacketPlayerPositionLook) Read(player *Player, length int) (err error)

func (*PacketPlayerPositionLook) Write

func (packet *PacketPlayerPositionLook) Write(player *Player) (err error)

type PacketSetCompression

type PacketSetCompression struct {
	Threshold int
}

func (*PacketSetCompression) Handle

func (packet *PacketSetCompression) Handle(player *Player)

func (*PacketSetCompression) Id

func (packet *PacketSetCompression) Id() (int, Protocol)

func (*PacketSetCompression) Read

func (packet *PacketSetCompression) Read(player *Player, length int) (err error)

func (*PacketSetCompression) Write

func (packet *PacketSetCompression) Write(player *Player) (err error)

type PacketStatusPing

type PacketStatusPing struct {
	Time uint64
}

func (*PacketStatusPing) Handle

func (packet *PacketStatusPing) Handle(player *Player)

func (*PacketStatusPing) Id

func (packet *PacketStatusPing) Id() (int, Protocol)

func (*PacketStatusPing) Read

func (packet *PacketStatusPing) Read(player *Player, length int) (err error)

func (*PacketStatusPing) Write

func (packet *PacketStatusPing) Write(player *Player) (err error)

type PacketStatusRequest

type PacketStatusRequest struct{}

func (*PacketStatusRequest) Handle

func (packet *PacketStatusRequest) Handle(player *Player)

func (*PacketStatusRequest) Id

func (packet *PacketStatusRequest) Id() (int, Protocol)

func (*PacketStatusRequest) Read

func (packet *PacketStatusRequest) Read(player *Player, length int) (err error)

func (*PacketStatusRequest) Write

func (packet *PacketStatusRequest) Write(player *Player) (err error)

type PacketStatusResponse

type PacketStatusResponse struct {
	Response string
}

func (*PacketStatusResponse) Handle

func (packet *PacketStatusResponse) Handle(player *Player)

func (*PacketStatusResponse) Id

func (packet *PacketStatusResponse) Id() (int, Protocol)

func (*PacketStatusResponse) Read

func (packet *PacketStatusResponse) Read(player *Player, length int) (err error)

func (*PacketStatusResponse) Write

func (packet *PacketStatusResponse) Write(player *Player) (err error)

type PacketUpdateHealth

type PacketUpdateHealth struct {
	Health         float32
	Food           int
	FoodSaturation float32
}

func (*PacketUpdateHealth) Handle

func (packet *PacketUpdateHealth) Handle(player *Player)

func (*PacketUpdateHealth) Id

func (packet *PacketUpdateHealth) Id() (int, Protocol)

func (*PacketUpdateHealth) Read

func (packet *PacketUpdateHealth) Read(player *Player, length int) (err error)

func (*PacketUpdateHealth) Write

func (packet *PacketUpdateHealth) Write(player *Player) (err error)

type Player

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

func (*Player) GetName

func (player *Player) GetName() string

func (*Player) GetUUID

func (player *Player) GetUUID() uuid2.UUID

func (*Player) HackClientbound

func (player *Player) HackClientbound(id int, protocol Protocol) int

func (*Player) HackServerbound

func (player *Player) HackServerbound(id int) int

func (*Player) HandlePacket

func (player *Player) HandlePacket(id int, length int) (packet Packet, err error)

func (*Player) Kick

func (player *Player) Kick(s string)

func (*Player) ReadBool

func (player *Player) ReadBool() (b bool, err error)

func (*Player) ReadByte

func (player *Player) ReadByte() (b byte, err error)

func (*Player) ReadByteArray

func (player *Player) ReadByteArray(length int) (data []byte, err error)

func (*Player) ReadFloat32

func (player *Player) ReadFloat32() (i float32, err error)

func (*Player) ReadFloat64

func (player *Player) ReadFloat64() (i float64, err error)

func (*Player) ReadNStringLimited

func (player *Player) ReadNStringLimited(max int) (s string, read int, err error)

func (*Player) ReadPacket

func (player *Player) ReadPacket() (packet Packet, err error)

func (*Player) ReadPacketWithCompression

func (player *Player) ReadPacketWithCompression() (packet Packet, err error)

func (*Player) ReadPacketWithoutCompression

func (player *Player) ReadPacketWithoutCompression() (packet Packet, err error)

func (*Player) ReadPosition

func (player *Player) ReadPosition() (i Position, err error)

func (*Player) ReadString

func (player *Player) ReadString() (s string, err error)

func (*Player) ReadStringLimited

func (player *Player) ReadStringLimited(max int) (s string, err error)

func (*Player) ReadUInt16

func (player *Player) ReadUInt16() (i uint16, err error)

func (*Player) ReadUInt32

func (player *Player) ReadUInt32() (i uint32, err error)

func (*Player) ReadUInt64

func (player *Player) ReadUInt64() (i uint64, err error)

func (*Player) ReadUInt8

func (player *Player) ReadUInt8() (i uint8, err error)

func (*Player) ReadVarInt

func (player *Player) ReadVarInt() (i int, err error)

func (*Player) SendActionBar

func (p *Player) SendActionBar(message IChatComponent)

func (*Player) SendBukkitMessage

func (p *Player) SendBukkitMessage(message string)

func (*Player) SendMessage

func (p *Player) SendMessage(message IChatComponent)

func (*Player) SendRawActionBar

func (p *Player) SendRawActionBar(message string)

func (*Player) SendRawMessage

func (p *Player) SendRawMessage(message string)

func (*Player) WriteBool

func (player *Player) WriteBool(b bool) (err error)

func (*Player) WriteByteArray

func (player *Player) WriteByteArray(data []byte) (err error)

func (*Player) WriteFloat32

func (player *Player) WriteFloat32(i float32) (err error)

func (*Player) WriteFloat64

func (player *Player) WriteFloat64(i float64) (err error)

func (*Player) WriteLittleEndianUInt16

func (player *Player) WriteLittleEndianUInt16(i uint16) (err error)

func (*Player) WriteNBTCompound

func (player *Player) WriteNBTCompound(tag nbt.Compound) (err error)

func (*Player) WritePacket

func (player *Player) WritePacket(packet Packet) (err error)

func (*Player) WritePacketWithCompression

func (player *Player) WritePacketWithCompression(packet Packet) (err error)

func (*Player) WritePacketWithoutCompression

func (player *Player) WritePacketWithoutCompression(packet Packet) (err error)

func (*Player) WritePosition

func (player *Player) WritePosition(i Position) (err error)

func (*Player) WriteString

func (player *Player) WriteString(s string) (err error)

func (*Player) WriteStringRestricted

func (player *Player) WriteStringRestricted(s string, max int) (err error)

func (*Player) WriteUInt16

func (player *Player) WriteUInt16(i uint16) (err error)

func (*Player) WriteUInt32

func (player *Player) WriteUInt32(i uint32) (err error)

func (*Player) WriteUInt64

func (player *Player) WriteUInt64(i uint64) (err error)

func (*Player) WriteUInt8

func (player *Player) WriteUInt8(i uint8) (err error)

func (*Player) WriteUUID

func (player *Player) WriteUUID(uid uuid.UUID) (err error)

func (*Player) WriteVarInt

func (player *Player) WriteVarInt(i int) (err error)

type PlayerChatEvent

type PlayerChatEvent struct {
	Player  *Player
	Message string
}

type PlayerClickType

type PlayerClickType byte
const (
	PlayerRightClick PlayerClickType = iota
	PlayerLeftClick
)

type PlayerInteractEvent

type PlayerInteractEvent struct {
	Player    *Player
	ClickType PlayerClickType
}

type PlayerJoinEvent

type PlayerJoinEvent struct {
	Player *Player
}

type PlayerKickEvent

type PlayerKickEvent struct {
	Player *Player
	Reason string
}

type PlayerPreJoinEvent

type PlayerPreJoinEvent struct {
	Player *Player
}

type PlayerQuitEvent

type PlayerQuitEvent struct {
	Player *Player
}

type PlayerRegistry

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

func (*PlayerRegistry) ForEachPlayer

func (registry *PlayerRegistry) ForEachPlayer(fn func(player *Player))

func (*PlayerRegistry) ForEachPlayerAsync

func (registry *PlayerRegistry) ForEachPlayerAsync(fn func(player *Player))

func (*PlayerRegistry) GetPlayerCount

func (registry *PlayerRegistry) GetPlayerCount() int

func (*PlayerRegistry) GetPlayers

func (registry *PlayerRegistry) GetPlayers() []*Player

type PluginMessageEvent

type PluginMessageEvent struct {
	Channel string
	Data    []byte
}

type Position

type Position struct {
	X int `json:"x"`
	Y int `json:"y"`
	Z int `json:"z"`
}

type Protocol

type Protocol uint16
const (
	V1_7_2  Protocol = 4
	V1_7_6  Protocol = 5
	V1_8    Protocol = 47
	V1_9    Protocol = 107
	V1_9_1  Protocol = 108
	V1_9_2  Protocol = 109
	V1_9_3  Protocol = 110
	V1_10   Protocol = 210
	V1_11   Protocol = 315
	V1_11_1 Protocol = 316
	V1_12   Protocol = 335
	V1_12_1 Protocol = 338
	V1_12_2 Protocol = 340
	V1_13   Protocol = 393
	V1_13_1 Protocol = 401
	V1_13_2 Protocol = 404
	V1_14   Protocol = 477
	V1_14_1 Protocol = 480
	V1_14_2 Protocol = 485
	V1_14_3 Protocol = 490
	V1_14_4 Protocol = 498
	V1_15   Protocol = 573
	V1_15_1 Protocol = 575
	V1_15_2 Protocol = 578
	V1_16   Protocol = 735
	V1_16_1 Protocol = 736
	V1_16_2 Protocol = 751
	V1_16_3 Protocol = 753
	V1_16_4 Protocol = 754
)

type ScoreboardPosition

type ScoreboardPosition uint8
const (
	LIST ScoreboardPosition = iota
	SIDEBAR
	BELOW_NAME
)

type State

type State int8
const (
	HANDSHAKING State = iota
	STATUS
	LOGIN
	PLAY
)

type StringChatComponent

type StringChatComponent struct {
	Text string `json:"text"`
	*ChatComponent
}

func ChatMessage

func ChatMessage(text string) *StringChatComponent

func (*StringChatComponent) JSON

func (component *StringChatComponent) JSON() (string, error)

func (*StringChatComponent) SetText

func (component *StringChatComponent) SetText(text string)

type VarBuffer

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

func (*VarBuffer) Bytes

func (buff *VarBuffer) Bytes() []byte

func (*VarBuffer) Len

func (buff *VarBuffer) Len() int

func (*VarBuffer) Read

func (buff *VarBuffer) Read(p []byte) (n int, err error)

func (*VarBuffer) Write

func (buff *VarBuffer) Write(p []byte) (n int, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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