net

package
v0.0.0-...-b9cfb1f Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2019 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const McpeFlag = 0xFE

Variables

This section is empty.

Functions

This section is empty.

Types

type MinecraftPacketBatch

type MinecraftPacketBatch struct {
	*binutils.Stream
	// contains filtered or unexported fields
}

func NewMinecraftPacketBatch

func NewMinecraftPacketBatch(session *MinecraftSession) *MinecraftPacketBatch

NewMinecraftPacketBatch returns a new Minecraft Packet Batch used to decode/encode batches from Encapsulated Packets.

func (*MinecraftPacketBatch) AddPacket

func (batch *MinecraftPacketBatch) AddPacket(packet packets.IPacket)

AddPacket adds a packet to the batch when encoding.

func (*MinecraftPacketBatch) Decode

func (batch *MinecraftPacketBatch) Decode()

Decode decodes the batch and separates packets. This does not decode the packets.

func (*MinecraftPacketBatch) Encode

func (batch *MinecraftPacketBatch) Encode()

Encode encodes all packets in the batch and zlib encodes them.

func (*MinecraftPacketBatch) GetPackets

func (batch *MinecraftPacketBatch) GetPackets() []packets.IPacket

GetPackets returns all packets inside of the batch. This only returns correctly when done after decoding, or before encoding.

type MinecraftSession

type MinecraftSession struct {
	Connected bool
	// contains filtered or unexported fields
}

func NewMinecraftSession

func NewMinecraftSession(adapter *NetworkAdapter, session *server.Session) *MinecraftSession

NewMinecraftSession returns a new Minecraft session with the given RakNet session.

func (*MinecraftSession) AddPermission

func (session *MinecraftSession) AddPermission(permission *permissions.Permission) bool

AddPermission adds a permission to the session. Returns true if a permission with the same name was overwritten.

func (*MinecraftSession) Close

func (session *MinecraftSession) Close(reason string, hideDisconnectionScreen bool)

func (*MinecraftSession) EnableEncryption

func (session *MinecraftSession) EnableEncryption()

EnableEncryption enables encryption for this session and computes secret key bytes.

func (*MinecraftSession) GetChunkLoader

func (session *MinecraftSession) GetChunkLoader() *worlds.Loader

GetChunkLoader returns the chunk loader of the session.

func (*MinecraftSession) GetClientId

func (session *MinecraftSession) GetClientId() int

GetClientId returns the client ID of this session.

func (*MinecraftSession) GetDisplayName

func (session *MinecraftSession) GetDisplayName() string

GetDisplayName returns the display name of the player under the session.

func (*MinecraftSession) GetEncryptionHandler

func (session *MinecraftSession) GetEncryptionHandler() *utils.EncryptionHandler

GetEncryptionHandler returns the handler used for encryption.

func (*MinecraftSession) GetGameVersion

func (session *MinecraftSession) GetGameVersion() string

GetGameVersion returns the Minecraft version the player used to join the server.

func (*MinecraftSession) GetLanguage

func (session *MinecraftSession) GetLanguage() string

GetLanguage returns the language (locale) of this session.

func (*MinecraftSession) GetName

func (session *MinecraftSession) GetName() string

GetName returns the name of the player under the session.

func (*MinecraftSession) GetPermissionGroup

func (session *MinecraftSession) GetPermissionGroup() *permissions.Group

GetPermissionGroup returns the permission group this session is in.

func (*MinecraftSession) GetPing

func (session *MinecraftSession) GetPing() int64

GetPing returns the ping of the session in milliseconds.

func (*MinecraftSession) GetPlatform

func (session *MinecraftSession) GetPlatform() int32

GetPlatform returns the platform the client uses to player the game.

func (*MinecraftSession) GetPlayer

func (session *MinecraftSession) GetPlayer() *players.Player

GetPlayer returns the player associated with the Minecraft session. This player may not yet exist during the login sequence, and this function may return nil.

func (*MinecraftSession) GetProtocolNumber

func (session *MinecraftSession) GetProtocolNumber() int32

GetProtocolNumber returns the bedrock number the client used to join the server.

func (*MinecraftSession) GetSession

func (session *MinecraftSession) GetSession() *server.Session

GetSession returns the GoRakLib session of this session.

func (*MinecraftSession) GetUUID

func (session *MinecraftSession) GetUUID() uuid.UUID

GetUUID returns the UUID of this session.

func (*MinecraftSession) GetViewDistance

func (session *MinecraftSession) GetViewDistance() int32

GetViewDistance returns the view distance of this player.

func (*MinecraftSession) GetXUID

func (session *MinecraftSession) GetXUID() string

GetXUID returns the XUID of this session.

func (*MinecraftSession) HandlePacket

func (session *MinecraftSession) HandlePacket(packet packets.IPacket)

HandlePacket handles packets of this session.

func (*MinecraftSession) HasPermission

func (session *MinecraftSession) HasPermission(permission string) bool

HasPermission checks if this session has a permission.

func (*MinecraftSession) HasSpawned

func (session *MinecraftSession) HasSpawned() bool

HasSpawned checks if the player of the session has spawned.

func (*MinecraftSession) IsXBOXLiveAuthenticated

func (session *MinecraftSession) IsXBOXLiveAuthenticated() bool

IsXBOXLiveAuthenticated checks if the session logged in while being logged into XBOX Live.

func (*MinecraftSession) Kick

func (session *MinecraftSession) Kick(reason string, hideDisconnectionScreen bool, isAdmin bool)

func (*MinecraftSession) RemovePermission

func (session *MinecraftSession) RemovePermission(permission string) bool

RemovePermission deletes a permission from the session. This does not delete the permission from the group the session is in.

func (*MinecraftSession) SendAddEntity

func (session *MinecraftSession) SendAddEntity(entity protocol.AddEntityEntry)

func (*MinecraftSession) SendAddPlayer

func (session *MinecraftSession) SendAddPlayer(uuid uuid.UUID, player protocol.AddPlayerEntry)

func (*MinecraftSession) SendAnimate

func (session *MinecraftSession) SendAnimate(action int32, runtimeId uint64, float float32)

func (*MinecraftSession) SendBatch

func (session *MinecraftSession) SendBatch(batch *MinecraftPacketBatch)

SendBatch sends a batch to this session.

func (*MinecraftSession) SendChunkRadiusUpdated

func (session *MinecraftSession) SendChunkRadiusUpdated(radius int32)

func (*MinecraftSession) SendCraftingData

func (session *MinecraftSession) SendCraftingData()

func (*MinecraftSession) SendDisconnect

func (session *MinecraftSession) SendDisconnect(message string, hideDisconnect bool)

func (*MinecraftSession) SendFullChunkData

func (session *MinecraftSession) SendFullChunkData(chunk *chunks.Chunk)

func (*MinecraftSession) SendMessage

func (session *MinecraftSession) SendMessage(message ...interface{})

SendMessage sends a text message to the Minecraft session.

func (*MinecraftSession) SendMoveEntity

func (session *MinecraftSession) SendMoveEntity(runtimeId uint64, position r3.Vector, rot data.Rotation, flags byte, teleport bool)

func (*MinecraftSession) SendMovePlayer

func (session *MinecraftSession) SendMovePlayer(runtimeId uint64, position r3.Vector, rotation data.Rotation, mode byte, onGround bool, ridingRuntimeId uint64)

func (*MinecraftSession) SendNetworkChunkPublisherUpdate

func (session *MinecraftSession) SendNetworkChunkPublisherUpdate(position blocks.Position, radius uint32)

func (*MinecraftSession) SendPacket

func (session *MinecraftSession) SendPacket(packet packets.IPacket)

SendPacket sends a packet to this session.

func (*MinecraftSession) SendPlayStatus

func (session *MinecraftSession) SendPlayStatus(status int32)

func (*MinecraftSession) SendPlayerAction

func (session *MinecraftSession) SendPlayerAction(runtimeId uint64, action int32, position blocks.Position, face int32)

func (*MinecraftSession) SendPlayerList

func (session *MinecraftSession) SendPlayerList(listType byte, players map[string]protocol.PlayerListEntry)

func (*MinecraftSession) SendPlayerSkin

func (session *MinecraftSession) SendPlayerSkin(uuid2 uuid.UUID, skinId, geometryName, geometryData string, skinData, capeData []byte)

func (*MinecraftSession) SendRemoveEntity

func (session *MinecraftSession) SendRemoveEntity(uniqueId int64)

func (*MinecraftSession) SendResourcePackChunkData

func (session *MinecraftSession) SendResourcePackChunkData(packUUID string, chunkIndex int32, progress int64, data []byte)

func (*MinecraftSession) SendResourcePackDataInfo

func (session *MinecraftSession) SendResourcePackDataInfo(pack packs.Pack)

func (*MinecraftSession) SendResourcePackInfo

func (session *MinecraftSession) SendResourcePackInfo(mustAccept bool, resourcePacks *packs.Stack, behaviorPacks *packs.Stack)

func (*MinecraftSession) SendResourcePackStack

func (session *MinecraftSession) SendResourcePackStack(mustAccept bool, resourcePacks *packs.Stack, behaviorPacks *packs.Stack)

func (*MinecraftSession) SendServerHandshake

func (session *MinecraftSession) SendServerHandshake(encryptionJwt string)

func (*MinecraftSession) SendSetEntityData

func (session *MinecraftSession) SendSetEntityData(runtimeId uint64, data map[uint32][]interface{})

func (*MinecraftSession) SendSkin

func (session *MinecraftSession) SendSkin(target *MinecraftSession)

func (*MinecraftSession) SendStartGame

func (session *MinecraftSession) SendStartGame(player protocol.StartGameEntry, runtimeIdsTable []byte)

func (*MinecraftSession) SendText

func (session *MinecraftSession) SendText(text types.Text)

func (*MinecraftSession) SendUpdateAttributes

func (session *MinecraftSession) SendUpdateAttributes(runtimeId uint64, attributes data.AttributeMap)

func (*MinecraftSession) SendUpdateBlock

func (session *MinecraftSession) SendUpdateBlock(position blocks.Position, blockRuntimeId, dataLayerId uint32)

func (*MinecraftSession) SetData

func (session *MinecraftSession) SetData(permissionManager *permissions.Manager, data types.SessionData)

SetData sets the basic session data of the Minecraft Session

func (*MinecraftSession) SetLanguage

func (session *MinecraftSession) SetLanguage(language string)

SetLanguage sets the language (locale) of this session.

func (*MinecraftSession) SetPermissionGroup

func (session *MinecraftSession) SetPermissionGroup(group *permissions.Group)

SetPermissionGroup sets the permission group of this session.

func (*MinecraftSession) SetPlayer

func (session *MinecraftSession) SetPlayer(player *players.Player)

SetPlayer sets the player associated with the Minecraft session. Network actions will be executed on this player.

func (*MinecraftSession) SetViewDistance

func (session *MinecraftSession) SetViewDistance(distance int32)

SetViewDistance sets the view distance of this player.

func (*MinecraftSession) SetXBOXLiveAuthenticated

func (session *MinecraftSession) SetXBOXLiveAuthenticated(value bool)

SetXBOXLiveAuthenticated sets the session XBOX Live authenticated.

func (*MinecraftSession) SyncMove

func (session *MinecraftSession) SyncMove(x, y, z float64, pitch, yaw, headYaw float64, onGround bool)

SyncMove synchronizes the server's player movement with the client movement.

func (*MinecraftSession) Tick

func (session *MinecraftSession) Tick()

func (*MinecraftSession) Transfer

func (session *MinecraftSession) Transfer(address string, port uint16)

func (*MinecraftSession) UsesEncryption

func (session *MinecraftSession) UsesEncryption() bool

UsesEncryption checks if the session uses encryption or not.

type NetworkAdapter

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

func NewNetworkAdapter

func NewNetworkAdapter(packetManager protocol2.IPacketManager, sessionManager *SessionManager) *NetworkAdapter

NewNetworkAdapter returns a new Network adapter to adapt to the RakNet server.

func (*NetworkAdapter) GetRakLibManager

func (adapter *NetworkAdapter) GetRakLibManager() *server.Manager

GetRakLibManager returns the GoRakLib manager of the network adapter.

func (*NetworkAdapter) GetSession

func (adapter *NetworkAdapter) GetSession(address string, port uint16) *server.Session

GetSession returns a GoRakLib session by an address and port.

func (*NetworkAdapter) HandlePacket

func (adapter *NetworkAdapter) HandlePacket(session *MinecraftSession, buffer []byte)

HandlePackets handles all packets of the given session + player.

func (*NetworkAdapter) SendBatch

func (adapter *NetworkAdapter) SendBatch(batch *MinecraftPacketBatch, session *server.Session, priority server.Priority)

SendBatch sends a Minecraft packet batch to the given GoRakLib session with the given priority.

func (*NetworkAdapter) SendPacket

func (adapter *NetworkAdapter) SendPacket(pk packets.IPacket, session *MinecraftSession, priority server.Priority)

SendPacket sends a packet to the given Minecraft session with the given priority.

type PacketHandler

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

Packet handlers can be registered to listen on certain packet IDs. Handlers can be registered on unhandled packets in order to handle them from a plugin. Every packet handler has a handling function that handles the incoming packet.

func NewPacketHandler

func NewPacketHandler(function func(packet packets.IPacket, session *MinecraftSession) bool) *PacketHandler

NewPacketHandler returns a new packet handler with the given ID. NewPacketHandler will by default use a priority of 5.

func (*PacketHandler) GetPriority

func (handler *PacketHandler) GetPriority() int

GetPriority returns the priority of this handler in an integer 0 - 10.

func (*PacketHandler) SetPriority

func (handler *PacketHandler) SetPriority(priority int) bool

SetPriority sets the priority of this handler in an integer 0 - 10. 0 is executed first, 10 is executed last.

type SessionManager

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

SessionManager is a struct managing Minecraft sessions. A session manager holds multiple maps used to find sessions by given keys.

func NewSessionManager

func NewSessionManager() *SessionManager

NewSessionManager returns a new session manager.

func (*SessionManager) AddMinecraftSession

func (manager *SessionManager) AddMinecraftSession(session *MinecraftSession)

AddMinecraftSession adds the given Minecraft session to the manager.

func (*SessionManager) GetSession

func (manager *SessionManager) GetSession(name string) (*MinecraftSession, bool)

GetSession attempts to retrieve a session by its name. A bool is returned indicating success.

func (*SessionManager) GetSessionByRakNetSession

func (manager *SessionManager) GetSessionByRakNetSession(rakNetSession *server.Session) (*MinecraftSession, bool)

GetSessionByRakNetSession attempts to retrieve a session by its RakNet session. A bool is returned indicating success.

func (*SessionManager) GetSessionByUUID

func (manager *SessionManager) GetSessionByUUID(uuid uuid.UUID) (*MinecraftSession, bool)

GetSessionByUUID attempts to retrieve a session by its UUID. A bool is returned indicating success.

func (*SessionManager) GetSessionByXUID

func (manager *SessionManager) GetSessionByXUID(xuid string) (*MinecraftSession, bool)

GetSessionByXUID attempts to retrieve a session by its XUID. A bool is returned indicating success.

func (*SessionManager) GetSessionCount

func (manager *SessionManager) GetSessionCount() int

GetSessionCount returns the session count of the manager.

func (*SessionManager) GetSessions

func (manager *SessionManager) GetSessions() map[string]*MinecraftSession

GetSessions returns the name => session map of the manager.

func (*SessionManager) HasSession

func (manager *SessionManager) HasSession(name string) bool

HasSession checks if the session manager has a session with the given name.

func (*SessionManager) HasSessionWithRakNetSession

func (manager *SessionManager) HasSessionWithRakNetSession(rakNetSession *server.Session) bool

HasSessionWithRakNetSession checks if the session manager has a session with the given RakNet session.

func (*SessionManager) HasSessionWithUUID

func (manager *SessionManager) HasSessionWithUUID(uuid uuid.UUID) bool

HasSessionWithUUID checks if the session manager has a session with the given UUID.

func (*SessionManager) HasSessionWithXUID

func (manager *SessionManager) HasSessionWithXUID(xuid string) bool

HasSessionWithXUID checks if the session manager has a session with the given XUID.

func (*SessionManager) RemoveMinecraftSession

func (manager *SessionManager) RemoveMinecraftSession(session *MinecraftSession)

RemoveMinecraftSession removes a Minecraft session from the manager.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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