UNPKG

@jsprismarine/prismarine

Version:

Dedicated Minecraft Bedrock Edition server written in TypeScript

123 lines 4.7 kB
import { Gametype } from '../../../minecraft/src/index.ts'; import { default as Player } from '../Player'; import { default as Server } from '../Server'; import { Attributes } from '../entity/Attribute'; import { Metadata } from '../entity/Metadata'; import { Item } from '../item/Item'; import { default as Chunk } from '../world/chunk/Chunk'; import { default as ClientConnection } from './ClientConnection'; import { DataPacket } from './Packets'; import { ChunkCoord } from './packet/NetworkChunkPublisherUpdatePacket'; import { default as MovementType } from './type/MovementType'; import { default as TextType } from './type/TextType'; export default class PlayerSession { private connection; private readonly server; private player; private readonly chunkSendQueue; private readonly loadedChunks; private readonly loadingChunks; constructor(server: Server, connection: ClientConnection, player: Player); update(_tick: number): Promise<void>; send(packet: DataPacket): Promise<void>; /** * Notify a client about change(s) to the adventure settings. * * @param player - The client-controlled entity */ sendSettings(player?: Player): Promise<void>; sendAbilities(player?: Player): Promise<void>; needNewChunks(forceResend?: boolean, dist?: number): Promise<void>; requestChunk(x: number, z: number): Promise<void>; /** * Clear the currently loaded and loading chunks. * * @remarks * Usually used for changing dimension, world, etc. */ clearChunks(): Promise<void>; /** * @TODO: Implement this. */ sendInventory(): Promise<void>; sendCreativeContents(empty?: boolean): Promise<void>; /** * Sets the item in the player hand. * @param {Item} item - The entity. */ sendHandItem(item: Item): Promise<void>; /** * Send the current tick to a client. * @param {number} tick - The tick */ sendTime(tick: number): Promise<void>; /** * Send gamemode to a client. * @param {Gametype} gamemode - the numeric gamemode ID. */ sendGamemode(gamemode?: Gametype): Promise<void>; sendNetworkChunkPublisher(distance: number, savedChunks: ChunkCoord[]): Promise<void>; sendAvailableCommands(): Promise<void>; /** * Set the client's maximum view distance. * * @param distance - The view distance */ setViewDistance(distance: number): Promise<void>; sendAttributes(attributes?: Attributes): Promise<void>; sendMetadata(metadata?: Metadata): Promise<void>; /** * Send a chat message to the client. * @param {object} options - The options for the message. * @param {string} options.message - The message to send. * @param {string} [options.sourceName=''] - The source of the message. * @param {string} [options.xuid=''] - The XUID of the player. * @param {string} [options.platformChatId=''] - The platform chat ID. * @param {string[]} [options.parameters=[]] - The parameters for the message. * @param {boolean} [options.needsTranslation=false] - Whether the message needs translation. * @param {TextType} [options.type=TextType.Raw] - The type of the message. * @returns {Promise<void>} A promise that resolves when the message is sent. */ sendMessage({ message, sourceName, xuid, platformChatId, parameters, needsTranslation, type }: { message: string; sourceName?: string; xuid?: string; platformChatId?: string; parameters?: string[]; needsTranslation?: boolean; type?: TextType; }): Promise<void>; sendChunk(chunk: Chunk): Promise<void>; /** * Broadcast the movement to a defined player */ broadcastMove(player: Player, mode?: MovementType): Promise<void>; /** * Adds the client to the player list of every player inside * the server and also to the player itself. */ addToPlayerList(): Promise<void>; /** * Removes a player from other players list */ removeFromPlayerList(): Promise<void>; /** * Sends the full player list to the player. */ sendPlayerList(): Promise<void>; /** * Spawn the player for another player * * @param player - the player to send the AddPlayerPacket to */ sendSpawn(player: Player): Promise<void>; /** * Despawn the player entity from another player */ sendDespawn(player: Player): Promise<void>; sendPlayStatus(status: number): Promise<void>; kick(reason?: string): Promise<void>; getConnection(): ClientConnection; getPlayer(): Player; } //# sourceMappingURL=PlayerSession.d.ts.map