tablist

package
v0.21.5 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BufferClearTabListEntries

func BufferClearTabListEntries(list TabList, bufferPacket func(proto.Packet) error) error

BufferClearTabListEntries clears all entries from the tab list. The packet entries are written with bufferPacket, so make sure to do an explicit flush.

Types

type Entry

type Entry interface {
	TabList() TabList // The TabList this entry is in.
	// Profile returns the profile of the entry, which uniquely identifies the entry with its
	// containing uuid, as well as deciding what is shown as the player head in the tab list.
	Profile() profile.GameProfile
	// DisplayName returns the optional text displayed for this entry in the TabList,
	// otherwise if returns nil Profile().Name is shown (but not returned here).
	DisplayName() component.Component
	// SetDisplayName the text to be displayed for the entry.
	// If nil Profile().Name will be shown.
	SetDisplayName(component.Component) error
	// GameMode returns the game mode the entry has been set to.
	//  0 - Survival
	//  1 - Creative
	//  2 - Adventure
	//  3 - Spectator
	GameMode() int
	// SetGameMode sets the gamemode for the entry.
	// See GameMode() for more details.
	SetGameMode(int) error
	// Latency returns the latency/ping for the entry.
	//
	// The icon shown in the tab list is calculated
	// by the millisecond latency as follows:
	//
	//  A negative latency will display the no connection icon
	//  0-150 will display 5 bars
	//  150-300 will display 4 bars
	//  300-600 will display 3 bars
	//  600-1000 will display 2 bars
	//  A latency move than 1 second will display 1 bar
	Latency() time.Duration
	// SetLatency sets the latency/ping for the entry.
	// See Latency() for how it is displayed.
	SetLatency(time.Duration) error
	crypto.KeyIdentifiable
}

Entry is a single entry/player in a TabList.

type PlayerKeyProvider added in v0.19.1

type PlayerKeyProvider interface {
	PlayerKey(playerID uuid.UUID) crypto.IdentifiedKey // May return nil if player not found
}

type TabList

type TabList interface {
	SetHeaderFooter(header, footer component.Component) error // Sets the tab list header and footer for the player.
	ClearHeaderFooter() error                                 // Clears the tab list header and footer for the player.
	AddEntry(Entry) error                                     // Adds an entry to the tab list.
	RemoveEntry(id uuid.UUID) error                           // Removes an entry from the tab list.
	HasEntry(id uuid.UUID) bool                               // Determines if the specified entry exists in the tab list.
	Entries() map[uuid.UUID]Entry                             // Returns the entries in the tab list.
	ProcessBackendPacket(*packet.PlayerListItem) error        // Processes a packet.PlayerListItem sent from the backend to the client.
}

TabList is the tab list of a player.

func New

func New(w proto.PacketWriter, protocol proto.Protocol, keyProvider PlayerKeyProvider) TabList

New creates a new TabList for versions >= 1.8.

func NewLegacy

func NewLegacy(w proto.PacketWriter, p proto.Protocol) TabList

NewLegacy returns a new legacy TabList for version <= 1.7.

Jump to

Keyboard shortcuts

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